Search in sources :

Example 1 with ExtensionPointCandidate

use of org.jetbrains.idea.devkit.util.ExtensionPointCandidate in project intellij-community by JetBrains.

the class RegisterExtensionFixProvider method getQuickFixes.

@NotNull
@Override
public IntentionAction[] getQuickFixes(@NotNull PsiElement element) {
    if (!(element instanceof PsiIdentifier))
        return IntentionAction.EMPTY_ARRAY;
    PsiElement parent = element.getParent();
    if (!(parent instanceof PsiClass))
        return IntentionAction.EMPTY_ARRAY;
    PsiClass psiClass = (PsiClass) parent;
    if (InheritanceUtil.isInheritor(psiClass, LocalInspectionTool.class.getName())) {
        return new IntentionAction[] { new RegisterInspectionFix(psiClass, LocalInspectionEP.LOCAL_INSPECTION) };
    }
    if (InheritanceUtil.isInheritor(psiClass, GlobalInspectionTool.class.getName())) {
        return new IntentionAction[] { new RegisterInspectionFix(psiClass, InspectionEP.GLOBAL_INSPECTION) };
    }
    ExtensionPointLocator extensionPointLocator = new ExtensionPointLocator(psiClass);
    List<ExtensionPointCandidate> candidateList = extensionPointLocator.findSuperCandidates();
    if (!candidateList.isEmpty()) {
        return new IntentionAction[] { new RegisterExtensionFix(psiClass, candidateList) };
    }
    return IntentionAction.EMPTY_ARRAY;
}
Also used : GlobalInspectionTool(com.intellij.codeInspection.GlobalInspectionTool) ExtensionPointLocator(org.jetbrains.idea.devkit.util.ExtensionPointLocator) ExtensionPointCandidate(org.jetbrains.idea.devkit.util.ExtensionPointCandidate) IntentionAction(com.intellij.codeInsight.intention.IntentionAction) PsiIdentifier(com.intellij.psi.PsiIdentifier) PsiClass(com.intellij.psi.PsiClass) LocalInspectionTool(com.intellij.codeInspection.LocalInspectionTool) PsiElement(com.intellij.psi.PsiElement) NotNull(org.jetbrains.annotations.NotNull)

Example 2 with ExtensionPointCandidate

use of org.jetbrains.idea.devkit.util.ExtensionPointCandidate in project intellij-community by JetBrains.

the class ExtensionPointDeclarationRelatedItemLineMarkerProvider method process.

private static void process(PsiField psiField, Collection<? super RelatedItemLineMarkerInfo> result) {
    if (!isExtensionPointNameDeclarationField(psiField))
        return;
    final PsiClass epClass = resolveExtensionPointClass(psiField);
    if (epClass == null)
        return;
    final String epName = resolveEpName(psiField);
    if (epName == null)
        return;
    ExtensionPointLocator locator = new ExtensionPointLocator(epClass);
    List<ExtensionPointCandidate> targets = ContainerUtil.filter(locator.findDirectCandidates(), candidate -> epName.equals(candidate.epName));
    final RelatedItemLineMarkerInfo<PsiElement> info = NavigationGutterIconBuilder.create(AllIcons.Nodes.Plugin, CONVERTER, RELATED_ITEM_PROVIDER).setTargets(targets).setPopupTitle("Choose Extension Point").setTooltipText("Extension Point Declaration").setAlignment(GutterIconRenderer.Alignment.RIGHT).createLineMarkerInfo(psiField.getNameIdentifier());
    result.add(info);
}
Also used : ExtensionPointLocator(org.jetbrains.idea.devkit.util.ExtensionPointLocator) ExtensionPointCandidate(org.jetbrains.idea.devkit.util.ExtensionPointCandidate)

Aggregations

ExtensionPointCandidate (org.jetbrains.idea.devkit.util.ExtensionPointCandidate)2 ExtensionPointLocator (org.jetbrains.idea.devkit.util.ExtensionPointLocator)2 IntentionAction (com.intellij.codeInsight.intention.IntentionAction)1 GlobalInspectionTool (com.intellij.codeInspection.GlobalInspectionTool)1 LocalInspectionTool (com.intellij.codeInspection.LocalInspectionTool)1 PsiClass (com.intellij.psi.PsiClass)1 PsiElement (com.intellij.psi.PsiElement)1 PsiIdentifier (com.intellij.psi.PsiIdentifier)1 NotNull (org.jetbrains.annotations.NotNull)1