This commit is contained in:
Alexey Kudravtsev
2014-02-10 12:32:38 +04:00
parent 261824e613
commit 42f69a2a2f
7 changed files with 25 additions and 23 deletions
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2013 JetBrains s.r.o.
* 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.
@@ -435,7 +435,7 @@ public class UnusedDeclarationInspection extends GlobalInspectionTool {
myPhase = 1;
}
public boolean isEntryPoint(final RefElement owner) {
public boolean isEntryPoint(@NotNull RefElement owner) {
final PsiElement element = owner.getElement();
if (RefUtil.isImplicitUsage(element)) return true;
if (element instanceof PsiModifierListOwner) {
@@ -444,9 +444,11 @@ public class UnusedDeclarationInspection extends GlobalInspectionTool {
return true;
}
}
for (EntryPoint extension : myExtensions) {
if (extension.isEntryPoint(owner, element)) {
return true;
if (element != null) {
for (EntryPoint extension : myExtensions) {
if (extension.isEntryPoint(owner, element)) {
return true;
}
}
}
return false;
@@ -482,7 +484,7 @@ public class UnusedDeclarationInspection extends GlobalInspectionTool {
}
if (element instanceof PsiModifierListOwner) {
final EntryPointsManager entryPointsManager = EntryPointsManager.getInstance(project);
if (entryPointsManager.isEntryPoint((PsiModifierListOwner)element)) return true;
if (entryPointsManager.isEntryPoint(element)) return true;
//if (AnnotationUtil
// .checkAnnotatedUsingPatterns((PsiModifierListOwner)element, entryPointsManager.ADDITIONAL_ANNOTATIONS) ||
// AnnotationUtil
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2013 JetBrains s.r.o.
* 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.
@@ -109,8 +109,8 @@ public class LightAdvHighlightingJdk7Test extends LightDaemonAnalyzerTestCase {
ExtensionPoint<EntryPoint> point = Extensions.getRootArea().getExtensionPoint(ToolExtensionPoints.DEAD_CODE_TOOL);
EntryPoint extension = new EntryPoint() {
@NotNull @Override public String getDisplayName() { return "duh"; }
@Override public boolean isEntryPoint(RefElement refElement, PsiElement psiElement) { return false; }
@Override public boolean isEntryPoint(PsiElement psiElement) { return false; }
@Override public boolean isEntryPoint(@NotNull RefElement refElement, @NotNull PsiElement psiElement) { return false; }
@Override public boolean isEntryPoint(@NotNull PsiElement psiElement) { return false; }
@Override public boolean isSelected() { return false; }
@Override public void setSelected(boolean selected) { }
@Override public void readExternal(Element element) { }
@@ -234,12 +234,12 @@ public class LightAdvHighlightingTest extends LightDaemonAnalyzerTestCase {
}
@Override
public boolean isEntryPoint(RefElement refElement, PsiElement psiElement) {
public boolean isEntryPoint(@NotNull RefElement refElement, @NotNull PsiElement psiElement) {
return false;
}
@Override
public boolean isEntryPoint(PsiElement psiElement) {
public boolean isEntryPoint(@NotNull PsiElement psiElement) {
return psiElement instanceof PsiMethod && ((PsiMethod)psiElement).getName().equals("myTestMethod");
}
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2012 JetBrains s.r.o.
* 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.
@@ -188,12 +188,12 @@ public abstract class InspectionTestCase extends PsiTestCase {
}
@Override
public boolean isEntryPoint(RefElement refElement, PsiElement psiElement) {
public boolean isEntryPoint(@NotNull RefElement refElement, @NotNull PsiElement psiElement) {
return isEntryPoint(psiElement);
}
@Override
public boolean isEntryPoint(PsiElement psiElement) {
public boolean isEntryPoint(@NotNull PsiElement psiElement) {
return ext_src != null && VfsUtilCore.isAncestor(ext_src, PsiUtilCore.getVirtualFile(psiElement), false);
}
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2009 JetBrains s.r.o.
* 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.
@@ -28,8 +28,8 @@ public abstract class EntryPoint implements JDOMExternalizable , Cloneable {
@NotNull
public abstract String getDisplayName();
public abstract boolean isEntryPoint(RefElement refElement, PsiElement psiElement);
public abstract boolean isEntryPoint(PsiElement psiElement);
public abstract boolean isEntryPoint(@NotNull RefElement refElement, @NotNull PsiElement psiElement);
public abstract boolean isEntryPoint(@NotNull PsiElement psiElement);
public abstract boolean isSelected();
public abstract void setSelected(boolean selected);
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2009 JetBrains s.r.o.
* 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.
@@ -45,12 +45,12 @@ public class JUnitEntryPoint extends EntryPoint {
return InspectionsBundle.message("inspection.dead.code.option2");
}
public boolean isEntryPoint(RefElement refElement, PsiElement psiElement) {
public boolean isEntryPoint(@NotNull RefElement refElement, @NotNull PsiElement psiElement) {
return isEntryPoint(psiElement);
}
@Override
public boolean isEntryPoint(PsiElement psiElement) {
public boolean isEntryPoint(@NotNull PsiElement psiElement) {
if (ADD_JUNIT_TO_ENTRIES) {
if (psiElement instanceof PsiClass) {
final PsiClass aClass = (PsiClass)psiElement;
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2009 JetBrains s.r.o.
* 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.
@@ -48,12 +48,12 @@ public class TestNGEntryPoint extends EntryPoint {
return "Automatically add all TestNG classes/methods/etc. to entry points";
}
public boolean isEntryPoint(RefElement refElement, PsiElement psiElement) {
public boolean isEntryPoint(@NotNull RefElement refElement, @NotNull PsiElement psiElement) {
return isEntryPoint(psiElement);
}
@Override
public boolean isEntryPoint(PsiElement psiElement) {
public boolean isEntryPoint(@NotNull PsiElement psiElement) {
if (ADD_TESTNG_TO_ENTRIES) {
if (psiElement instanceof PsiModifierListOwner) {
if (TestNGUtil.hasTest((PsiModifierListOwner)psiElement, false, false, TestNGUtil.hasDocTagsSupport)) return true;