mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
DevKit: skip annotating when current project is not plugin
This commit is contained in:
@@ -16,7 +16,6 @@
|
||||
package org.jetbrains.idea.devkit.navigation;
|
||||
|
||||
import com.intellij.codeInsight.daemon.RelatedItemLineMarkerInfo;
|
||||
import com.intellij.codeInsight.daemon.RelatedItemLineMarkerProvider;
|
||||
import com.intellij.codeInsight.navigation.NavigationGutterIconBuilder;
|
||||
import com.intellij.icons.AllIcons;
|
||||
import com.intellij.navigation.GotoRelatedItem;
|
||||
@@ -24,8 +23,10 @@ import com.intellij.openapi.editor.markup.GutterIconRenderer;
|
||||
import com.intellij.openapi.module.Module;
|
||||
import com.intellij.openapi.module.ModuleUtilCore;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.search.GlobalSearchScope;
|
||||
import com.intellij.psi.PsiClass;
|
||||
import com.intellij.psi.PsiDirectory;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.PsiFile;
|
||||
import com.intellij.psi.util.InheritanceUtil;
|
||||
import com.intellij.util.NotNullFunction;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
@@ -41,7 +42,7 @@ import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
|
||||
public class DescriptionTypeRelatedItemLineMarkerProvider extends RelatedItemLineMarkerProvider {
|
||||
public class DescriptionTypeRelatedItemLineMarkerProvider extends DevkitRelatedLineMarkerProviderBase {
|
||||
|
||||
private static final NotNullFunction<PsiFile, Collection<? extends PsiElement>> CONVERTER =
|
||||
new NotNullFunction<PsiFile, Collection<? extends PsiElement>>() {
|
||||
@@ -74,11 +75,6 @@ public class DescriptionTypeRelatedItemLineMarkerProvider extends RelatedItemLin
|
||||
Module module = ModuleUtilCore.findModuleForPsiElement(psiClass);
|
||||
if (module == null) return;
|
||||
|
||||
final GlobalSearchScope scope = GlobalSearchScope.moduleRuntimeScope(module, false);
|
||||
final PsiClass actionClass = JavaPsiFacade.getInstance(psiClass.getProject())
|
||||
.findClass(DescriptionType.INSPECTION.getClassName(), scope);
|
||||
if (actionClass == null) return;
|
||||
|
||||
PsiElement highlightingElement = psiClass.getNameIdentifier();
|
||||
if (highlightingElement == null) return;
|
||||
|
||||
|
||||
@@ -0,0 +1,52 @@
|
||||
/*
|
||||
* Copyright 2000-2014 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.jetbrains.idea.devkit.navigation;
|
||||
|
||||
import com.intellij.codeInsight.daemon.RelatedItemLineMarkerInfo;
|
||||
import com.intellij.codeInsight.daemon.RelatedItemLineMarkerProvider;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.psi.JavaPsiFacade;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.search.GlobalSearchScope;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import org.jetbrains.idea.devkit.inspections.DescriptionType;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Do not process when current project is not a Plugin project.
|
||||
*/
|
||||
public abstract class DevkitRelatedLineMarkerProviderBase extends RelatedItemLineMarkerProvider {
|
||||
|
||||
@Override
|
||||
public void collectNavigationMarkers(List<PsiElement> elements,
|
||||
Collection<? super RelatedItemLineMarkerInfo> result,
|
||||
boolean forNavigation) {
|
||||
final PsiElement psiElement = ContainerUtil.getFirstItem(elements);
|
||||
if (psiElement == null ||
|
||||
!isPluginProject(psiElement.getProject())) {
|
||||
return;
|
||||
}
|
||||
|
||||
super.collectNavigationMarkers(elements, result, forNavigation);
|
||||
}
|
||||
|
||||
private static boolean isPluginProject(Project project) {
|
||||
return JavaPsiFacade.getInstance(project).findClass(DescriptionType.INSPECTION.getClassName(),
|
||||
GlobalSearchScope.allScope(project)) != null;
|
||||
}
|
||||
}
|
||||
+1
-2
@@ -16,7 +16,6 @@
|
||||
package org.jetbrains.idea.devkit.navigation;
|
||||
|
||||
import com.intellij.codeInsight.daemon.RelatedItemLineMarkerInfo;
|
||||
import com.intellij.codeInsight.daemon.RelatedItemLineMarkerProvider;
|
||||
import com.intellij.codeInsight.navigation.NavigationGutterIconBuilder;
|
||||
import com.intellij.icons.AllIcons;
|
||||
import com.intellij.navigation.GotoRelatedItem;
|
||||
@@ -37,7 +36,7 @@ import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
public class ExtensionPointDeclarationRelatedItemLineMarkerProvider extends RelatedItemLineMarkerProvider {
|
||||
public class ExtensionPointDeclarationRelatedItemLineMarkerProvider extends DevkitRelatedLineMarkerProviderBase {
|
||||
|
||||
private static final NotNullFunction<ExtensionPointCandidate, Collection<? extends PsiElement>> CONVERTER =
|
||||
new NotNullFunction<ExtensionPointCandidate, Collection<? extends PsiElement>>() {
|
||||
|
||||
+5
-2
@@ -16,6 +16,7 @@
|
||||
package org.jetbrains.idea.devkit.navigation;
|
||||
|
||||
import com.intellij.codeInsight.daemon.GutterMark;
|
||||
import com.intellij.codeInspection.LocalInspectionEP;
|
||||
import com.intellij.icons.AllIcons;
|
||||
import com.intellij.openapi.application.PluginPathManager;
|
||||
import com.intellij.openapi.extensions.ExtensionPointName;
|
||||
@@ -34,8 +35,10 @@ public class ExtensionPointDeclarationRelatedItemLineMarkerProviderTest extends
|
||||
|
||||
@Override
|
||||
protected void tuneFixture(JavaModuleFixtureBuilder moduleBuilder) throws Exception {
|
||||
String pathForClass = PathUtil.getJarPathForClass(ExtensionPointName.class);
|
||||
moduleBuilder.addLibrary("extensions", pathForClass);
|
||||
String extensionsJar = PathUtil.getJarPathForClass(ExtensionPointName.class);
|
||||
moduleBuilder.addLibrary("extensions", extensionsJar);
|
||||
String langApiJar = PathUtil.getJarPathForClass(LocalInspectionEP.class);
|
||||
moduleBuilder.addLibrary("lang-api", langApiJar);
|
||||
}
|
||||
|
||||
public void testMyStringEP() {
|
||||
|
||||
Reference in New Issue
Block a user