From 42f69a2a2ff92a1f3e5191d3f3cf07b895b3f53c Mon Sep 17 00:00:00 2001 From: Alexey Kudravtsev Date: Fri, 7 Feb 2014 15:05:25 +0400 Subject: [PATCH] notnull --- .../deadCode/UnusedDeclarationInspection.java | 14 ++++++++------ .../daemon/LightAdvHighlightingJdk7Test.java | 6 +++--- .../daemon/LightAdvHighlightingTest.java | 4 ++-- .../intellij/testFramework/InspectionTestCase.java | 6 +++--- .../codeInspection/reference/EntryPoint.java | 6 +++--- .../junit2/inspection/JUnitEntryPoint.java | 6 +++--- .../testng/inspection/TestNGEntryPoint.java | 6 +++--- 7 files changed, 25 insertions(+), 23 deletions(-) diff --git a/java/java-analysis-impl/src/com/intellij/codeInspection/deadCode/UnusedDeclarationInspection.java b/java/java-analysis-impl/src/com/intellij/codeInspection/deadCode/UnusedDeclarationInspection.java index 51a311194080..bbeb09e06f92 100644 --- a/java/java-analysis-impl/src/com/intellij/codeInspection/deadCode/UnusedDeclarationInspection.java +++ b/java/java-analysis-impl/src/com/intellij/codeInspection/deadCode/UnusedDeclarationInspection.java @@ -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 diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/LightAdvHighlightingJdk7Test.java b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/LightAdvHighlightingJdk7Test.java index 03e81dd85c5a..ec160610ed7a 100644 --- a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/LightAdvHighlightingJdk7Test.java +++ b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/LightAdvHighlightingJdk7Test.java @@ -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 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) { } diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/LightAdvHighlightingTest.java b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/LightAdvHighlightingTest.java index 2ae666ffe803..974a3222f119 100644 --- a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/LightAdvHighlightingTest.java +++ b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/LightAdvHighlightingTest.java @@ -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"); } diff --git a/java/testFramework/src/com/intellij/testFramework/InspectionTestCase.java b/java/testFramework/src/com/intellij/testFramework/InspectionTestCase.java index c9d5c6742a68..5962675dcbb0 100644 --- a/java/testFramework/src/com/intellij/testFramework/InspectionTestCase.java +++ b/java/testFramework/src/com/intellij/testFramework/InspectionTestCase.java @@ -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); } diff --git a/platform/analysis-api/src/com/intellij/codeInspection/reference/EntryPoint.java b/platform/analysis-api/src/com/intellij/codeInspection/reference/EntryPoint.java index 464ab9add995..e24167444c0c 100644 --- a/platform/analysis-api/src/com/intellij/codeInspection/reference/EntryPoint.java +++ b/platform/analysis-api/src/com/intellij/codeInspection/reference/EntryPoint.java @@ -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); diff --git a/plugins/junit/src/com/intellij/execution/junit2/inspection/JUnitEntryPoint.java b/plugins/junit/src/com/intellij/execution/junit2/inspection/JUnitEntryPoint.java index 54f0bc6e1ba9..b59854e320e6 100644 --- a/plugins/junit/src/com/intellij/execution/junit2/inspection/JUnitEntryPoint.java +++ b/plugins/junit/src/com/intellij/execution/junit2/inspection/JUnitEntryPoint.java @@ -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; diff --git a/plugins/testng/src/com/theoryinpractice/testng/inspection/TestNGEntryPoint.java b/plugins/testng/src/com/theoryinpractice/testng/inspection/TestNGEntryPoint.java index 36395bcb510c..784da489907d 100644 --- a/plugins/testng/src/com/theoryinpractice/testng/inspection/TestNGEntryPoint.java +++ b/plugins/testng/src/com/theoryinpractice/testng/inspection/TestNGEntryPoint.java @@ -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;