more accurate error messages for field refs (IDEA-164919)

This commit is contained in:
Anna.Kozlova
2016-12-02 17:52:28 +01:00
parent 373ec23f11
commit 955ed1e8b2
4 changed files with 9 additions and 7 deletions
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2015 JetBrains s.r.o.
* Copyright 2000-2016 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.
@@ -171,7 +171,8 @@ public class TestOnlyInspection extends BaseJavaBatchLocalInspectionTool {
private static void reportProblem(PsiElement e, PsiMember target, ProblemsHolder h) {
String message = InspectionsBundle.message(target instanceof PsiClass
? "inspection.test.only.problems.test.only.class.reference"
: "inspection.test.only.problems.test.only.method.call");
: target instanceof PsiField ? "inspection.test.only.problems.test.only.field.reference"
: "inspection.test.only.problems.test.only.method.call");
h.registerProblem(e, message, ProblemHighlightType.GENERIC_ERROR_OR_WARNING);
}
}
@@ -16,7 +16,7 @@
<file>B.java</file>
<line>11</line>
<package>&lt;default&gt;</package>
<description>Test-only method is called in production code</description>
<description>Test-only field is referenced in production code</description>
</problem>
<problem>
@@ -55,19 +55,19 @@
<file>B.java</file>
<line>18</line>
<package>&lt;default&gt;</package>
<description>Test-only method is called in production code</description>
<description>Test-only field is referenced in production code</description>
</problem>
<problem>
<file>B.java</file>
<line>19</line>
<package>&lt;default&gt;</package>
<description>Test-only method is called in production code</description>
<description>Test-only field is referenced in production code</description>
</problem>
<problem>
<file>B.java</file>
<line>20</line>
<package>&lt;default&gt;</package>
<description>Test-only method is called in production code</description>
<description>Test-only field is referenced in production code</description>
</problem>
<problem>
@@ -6,7 +6,7 @@
<module>testInsideField</module>
<package>&lt;default&gt;</package>
<entry_point TYPE="method" FQNAME="A$2 void run()"/>
<description>Test-only method is called in production code</description>
<description>Test-only field is referenced in production code</description>
</problem>
</problems>
@@ -163,6 +163,7 @@ inspection.nullable.problems.NotNull.parameter.receives.null.literal=Parameter a
inspection.test.only.problems.display.name=Test-only class or method call in production code
inspection.test.only.problems.test.only.method.call=Test-only method is called in production code
inspection.test.only.problems.test.only.class.reference=Test-only class is referenced in production code
inspection.test.only.problems.test.only.field.reference=Test-only field is referenced in production code
inspection.visibility.display.name=Declaration access can be weaker
inspection.visibility.option=Suggest package-private visibility level for class members