@Override public void navigate(MouseEvent mouseEvent, PsiElement element) { PsiElement parent = element.getParent(); if (!(parent instanceof DotNetVirtualImplementOwner) || !OverrideUtil.isAllowForOverride(parent)) { return; } Collection<DotNetVirtualImplementOwner> members = OverrideUtil.collectOverridenMembers(((DotNetVirtualImplementOwner) parent)); if (members.isEmpty()) { return; } if (members.size() == 1) { DotNetVirtualImplementOwner firstItem = ContainerUtil.getFirstItem(members); if (firstItem instanceof Navigatable) { ((Navigatable) firstItem).navigate(true); } } else { PsiElement[] elements = members.toArray(new PsiElement[members.size()]); JBPopup popup = NavigationUtil.getPsiElementPopup( elements, new ElementGutterRender(), "Open elements (" + elements.length + " " + "items)" + ""); popup.show(new RelativePoint(mouseEvent)); } }
@Override public void collect(PsiElement psiElement, @NotNull Collection<LineMarkerInfo> lineMarkerInfos) { PsiElement parent = psiElement.getParent(); IElementType elementType = psiElement.getNode().getElementType(); if ((elementType == CSharpTokens.IDENTIFIER || elementType == CSharpTokens.THIS_KEYWORD) && OverrideUtil.isAllowForOverride(parent)) { DotNetVirtualImplementOwner virtualImplementOwner = (DotNetVirtualImplementOwner) parent; Collection<DotNetVirtualImplementOwner> overrideElements = OverrideUtil.collectOverridenMembers(virtualImplementOwner); if (overrideElements.isEmpty()) { return; } Icon icon = CSharpIcons.Gutter.HidedMethod; for (DotNetVirtualImplementOwner overrideElement : overrideElements) { if (overrideElement.getTypeForImplement() == null) { icon = null; break; } } if (icon == null) { boolean allAbstract = true; for (DotNetVirtualImplementOwner overrideElement : overrideElements) { if (!(overrideElement instanceof DotNetModifierListOwner && ((DotNetModifierListOwner) overrideElement) .hasModifier(DotNetModifier.ABSTRACT))) { allAbstract = false; break; } } boolean abstractMe = virtualImplementOwner instanceof DotNetModifierListOwner && ((DotNetModifierListOwner) virtualImplementOwner) .hasModifier(DotNetModifier.ABSTRACT); if (allAbstract && abstractMe) { icon = AllIcons.Gutter.OverridenMethod; } else if (abstractMe) { icon = AllIcons.Gutter.ImplementedMethod; } else { icon = AllIcons.Gutter.OverridenMethod; } } val lineMarkerInfo = new LineMarkerInfo<PsiElement>( psiElement, psiElement.getTextRange(), icon, Pass.UPDATE_OVERRIDEN_MARKERS, new ConstantFunction<PsiElement, String>("Searching for overrided"), OurHandler.INSTANCE, GutterIconRenderer.Alignment.LEFT); lineMarkerInfos.add(lineMarkerInfo); } }
@Override public boolean execute(@NotNull PsiElement element, ResolveState state) { DotNetGenericExtractor extractor = state.get(CSharpResolveUtil.EXTRACTOR); assert extractor != null; for (PsiElement psiElement : OverrideUtil.getAllMembers(element, myScope, extractor, true)) { if (!ExecuteTargetUtil.isMyElement(this, psiElement)) { continue; } addElement(psiElement); } return true; }