diff --git a/java/java-analysis-api/resources/messages/JavaAnalysisBundle.properties b/java/java-analysis-api/resources/messages/JavaAnalysisBundle.properties index 30a99892e57a..b2b71172c3aa 100644 --- a/java/java-analysis-api/resources/messages/JavaAnalysisBundle.properties +++ b/java/java-analysis-api/resources/messages/JavaAnalysisBundle.properties @@ -222,7 +222,7 @@ inspection.common.if.parts.disable.highlight.tail.call=Do not highlight common p inspection.common.if.parts.family.else.if.description='else if' can be merged inspection.common.if.parts.family.else.if=Merge 'else if' statement inspection.common.if.parts.family=Extract common parts of 'if' statement -inspection.common.if.parts.settings.highlight.when.tail.call=Highlight when last common statement is call +inspection.common.if.parts.settings.highlight.when.tail.call=Highlight when the last common statement is a call inspection.compiler.javac.quirks.anno.array.comma.fix=Remove trailing comma inspection.compiler.javac.quirks.anno.array.comma.problem=Trailing comma in annotation array initializer may cause compilation error in some Javac versions (e.g. JDK 5 and JDK 6). inspection.compiler.javac.quirks.name=Javac quirks @@ -236,12 +236,13 @@ inspection.data.flow.simplify.to.assignment.quickfix.name=Simplify to normal ass inspection.data.flow.turn.off.constant.references.quickfix=Don't report values which are guaranteed to be constant inspection.data.flow.turn.off.nullable.returning.notnull.quickfix=Don't report nullable methods which always return not-null value inspection.data.flow.turn.off.true.asserts.quickfix=Don't report always true assertions -inspection.duplicate.throws.display.name=Duplicate throws +inspection.duplicate.throws.display.name=Duplicate 'throws' inspection.duplicate.throws.ignore.subclassing.option=Ignore exceptions subclassing others -inspection.duplicate.throws.more.general.problem=There is a more general exception, ''{0}'', in the throws list already. -inspection.duplicate.throws.problem=Duplicate throws +inspection.duplicate.throws.more.general.problem=There is a more general exception, ''{0}'', in the throws list already. +inspection.duplicate.throws.problem=Duplicate throws inspection.equals.hashcode.only.one.defined.problem.descriptor=Class has {0} defined but does not define {1} inspection.export.results.can.be.final.description=Declaration can have final modifier +inspection.expression.can.be.replaced.with.message=Expression can be replaced with ''{0}'' inspection.field.not.used.in.to.string.description2=Field ''{0}'' is not used in ''toString()'' method inspection.field.not.used.in.to.string.description=Method ''{0}'' is not used in ''toString()'' method inspection.implicit.subclass.display.forClass=Class ''{0}'' could be implicitly subclassed and must not be final diff --git a/java/java-analysis-impl/src/com/intellij/codeInspection/UseCompareMethodInspection.java b/java/java-analysis-impl/src/com/intellij/codeInspection/UseCompareMethodInspection.java index 00af99b37f81..7587eb7ebb73 100644 --- a/java/java-analysis-impl/src/com/intellij/codeInspection/UseCompareMethodInspection.java +++ b/java/java-analysis-impl/src/com/intellij/codeInspection/UseCompareMethodInspection.java @@ -63,7 +63,7 @@ public class UseCompareMethodInspection extends AbstractBaseJavaLocalInspectionT } private void register(CompareInfo info, PsiElement nameElement) { - holder.registerProblem(nameElement, JavaAnalysisBundle.message("inspection.can.be.replaced.with.message", info.myClass.getClassName() + ".compare"), + holder.registerProblem(nameElement, JavaAnalysisBundle.message("inspection.expression.can.be.replaced.with.message", info.myClass.getClassName() + ".compare"), new ReplaceWithPrimitiveCompareFix(info.getReplacementText())); } }; diff --git a/java/java-analysis-impl/src/messages/QuickFixBundle.properties b/java/java-analysis-impl/src/messages/QuickFixBundle.properties index 0b4f73fd723c..fff91e525273 100644 --- a/java/java-analysis-impl/src/messages/QuickFixBundle.properties +++ b/java/java-analysis-impl/src/messages/QuickFixBundle.properties @@ -140,9 +140,9 @@ fix.parameter.type.text=Make ''{0}'' take parameter of type ''{1}'' here fix.return.type.family=Fix return type fix.return.type.or.predecessor.text=Make ''{0}'' return ''{1}'' or predecessor fix.return.type.text=Make ''{0}'' return ''{1}'' -fix.throws.list.family=Fix throws list -fix.throws.list.add.exception=Add ''{0}'' to ''{1}'' throws list -fix.throws.list.remove.exception=Remove ''{0}'' from ''{1}'' throws list +fix.throws.list.family=Fix 'throws' list +fix.throws.list.add.exception=Add ''{0}'' to ''{1}'' 'throws' list +fix.throws.list.remove.exception=Remove ''{0}'' from ''{1}'' 'throws' list fix.modifiers.family=Fix modifiers anonymous.class.presentation=Anonymous class derived from {0} diff --git a/java/java-impl/src/inspectionDescriptions/DuplicateThrows.html b/java/java-impl/src/inspectionDescriptions/DuplicateThrows.html index f79fe866f172..1e34c4152512 100644 --- a/java/java-impl/src/inspectionDescriptions/DuplicateThrows.html +++ b/java/java-impl/src/inspectionDescriptions/DuplicateThrows.html @@ -1,21 +1,17 @@ -Reports duplicate exceptions in a method throws list. -For example: -
-void f() throws Exception, Exception {
-}
-
-
-The inspection also warns if one exception subclasses another. - For example: -
-void f() throws IOException, Exception {
-}
-
+Reports duplicate exceptions in a method throws list. +

Example:

+
+  void f() throws Exception, Exception {}
+
+

After the quick-fix is applied, the result looks like this:

+
+  void f() throws Exception {}
+

-Use the checkbox below to ignore exceptions subclassing others. + Use the checkbox below to ignore exceptions subclassing others.

diff --git a/java/java-impl/src/inspectionDescriptions/Java9RedundantRequiresStatement.html b/java/java-impl/src/inspectionDescriptions/Java9RedundantRequiresStatement.html index 22d09bb47e16..086c5b1e0865 100644 --- a/java/java-impl/src/inspectionDescriptions/Java9RedundantRequiresStatement.html +++ b/java/java-impl/src/inspectionDescriptions/Java9RedundantRequiresStatement.html @@ -1,11 +1,13 @@ -The inspection detects a situation where Java 9 module A requires Java 9 module B, but A doesn't use any package from B. -Also, requiring the module 'java.base' is redundant. -

- The fix deletes the 'requires' directive for such redundant dependencies. - If the deleted dependency re-exported modules that are actually used, the fix adds 'requires' directive for these modules. +Reports situations where a Java 9 module A requires a Java 9 module B, +but A doesn't use any package from B. +Also, requiring the module java.base is redundant. +

+ The fix deletes the requires directive for such redundant dependencies. + If the deleted dependency re-exported modules that are actually used, the fix adds a requires directive for these modules. +

New in 2017.1 \ No newline at end of file diff --git a/java/java-impl/src/inspectionDescriptions/RecordCanBeClass.html b/java/java-impl/src/inspectionDescriptions/RecordCanBeClass.html index 62e4b960453d..728663f25c9f 100644 --- a/java/java-impl/src/inspectionDescriptions/RecordCanBeClass.html +++ b/java/java-impl/src/inspectionDescriptions/RecordCanBeClass.html @@ -1,19 +1,18 @@ -Suggests to replace records with ordinary classes. -The inspection could be useful if you need to move a Java record -to codebases that use earlier Java versions. +Suggests to replace a record by an ordinary class. +This inspection makes it possible to move a Java record to a codebase using an earlier Java version.

- Note that the resulting class is not completely equivalent to the original record: + Note that the resulting class is not completely equivalent to the original record:

@@ -21,7 +20,7 @@ to codebases that use earlier Java versions.
   record Point(int x, int y) {}
 
-This record will be converted to +

This record will be converted to:

   final class Point {
     private final int x;
@@ -32,21 +31,17 @@ This record will be converted to
       this.y = y;
     }
 
-    public int x() {
-      return x;
-    }
+    public int x() { return x; }
 
-    public int y() {
-      return y;
-    }
+    public int y() { return y; }
 
     @Override
     public boolean equals(Object obj) {
       if (obj == this) return true;
       if (obj == null || obj.getClass() != this.getClass()) return false;
-      var that = (Point) obj;
+      var that = (Point)obj;
       return this.x == that.x &&
-              this.y == that.y;
+             this.y == that.y;
     }
 
     @Override
@@ -57,12 +52,12 @@ This record will be converted to
     @Override
     public String toString() {
       return "Point[" +
-              "x=" + x + ", " +
-              "y=" + y + ']';
+             "x=" + x + ", " +
+             "y=" + y + ']';
     }
   }
 
-

This inspection only applies to language level 14 preview and 15 preview.

+

This inspection only applies from language level 15 preview.

New in 2020.3

\ No newline at end of file diff --git a/java/java-impl/src/inspectionDescriptions/UseCompareMethod.html b/java/java-impl/src/inspectionDescriptions/UseCompareMethod.html index 693217070ead..15f04225196d 100644 --- a/java/java-impl/src/inspectionDescriptions/UseCompareMethod.html +++ b/java/java-impl/src/inspectionDescriptions/UseCompareMethod.html @@ -1,13 +1,21 @@ -Suggests to use the static Integer.compare() method and similar methods where more verbose or less efficient constructs are -used. For example, x > y ? 1 : x < y ? -1 : 0 or Integer.valueOf(x).compareTo(y) could be -replaced with Integer.compare(x, y). If x and y are already boxed integers, then -x.compareTo(y) is suggested. - -

Double.compare and Float.compare methods appeared in Java 1.4, methods for other primitive types - are available since Java 1.7

+Reports cases where the static Integer.compare() method or similar methods can be used +instead of more verbose or less efficient constructs. +If x and y are already boxed integers, then x.compareTo(y) is suggested. +

Example:

+
+  int z = x > y ? 1 : x < y ? -1 : 0;
+
+

After the quick-fix is applied, the result looks like this:

+
+  int z = Integer.compare(x, y);
+
+

+ Double.compare and Float.compare methods appeared in Java 1.4, methods for other primitive types + are available since Java 1.7. +

New in 2017.2

\ No newline at end of file diff --git a/java/java-tests/testData/inspection/duplicateThrows/DuplicateThrows.java b/java/java-tests/testData/inspection/duplicateThrows/DuplicateThrows.java index 88174d08dcbf..71b31f6d7b34 100644 --- a/java/java-tests/testData/inspection/duplicateThrows/DuplicateThrows.java +++ b/java/java-tests/testData/inspection/duplicateThrows/DuplicateThrows.java @@ -2,12 +2,12 @@ import java.io.*; class X { void f() throws - Exception, + Exception, Exception { } void f2() throws Exception, - IllegalArgumentException { + IllegalArgumentException { } void f3() throws FileNotFoundException, @@ -15,8 +15,8 @@ class X { } public void TTT() throws - FileNotFoundException, - EOFException, + FileNotFoundException, + EOFException, FileNotFoundException, EOFException { } diff --git a/java/java-tests/testData/inspection/recordCanBeClass/afterAmbiguousAnnotations.java b/java/java-tests/testData/inspection/recordCanBeClass/afterAmbiguousAnnotations.java index 98dd79fb3c64..cc11fad5e246 100644 --- a/java/java-tests/testData/inspection/recordCanBeClass/afterAmbiguousAnnotations.java +++ b/java/java-tests/testData/inspection/recordCanBeClass/afterAmbiguousAnnotations.java @@ -1,4 +1,4 @@ -// "Convert record to class" "true" +// "Convert 'record' to 'class'" "true" import java.lang.annotation.*; import java.util.Objects; diff --git a/java/java-tests/testData/inspection/recordCanBeClass/afterAnnotations.java b/java/java-tests/testData/inspection/recordCanBeClass/afterAnnotations.java index 5551d4fa8241..0a8b837564a1 100644 --- a/java/java-tests/testData/inspection/recordCanBeClass/afterAnnotations.java +++ b/java/java-tests/testData/inspection/recordCanBeClass/afterAnnotations.java @@ -1,4 +1,4 @@ -// "Convert record to class" "true" +// "Convert 'record' to 'class'" "true" import java.lang.annotation.*; import java.util.Objects; diff --git a/java/java-tests/testData/inspection/recordCanBeClass/afterCanonicalConstructor.java b/java/java-tests/testData/inspection/recordCanBeClass/afterCanonicalConstructor.java index 2841c010f701..b92ea1d6104c 100644 --- a/java/java-tests/testData/inspection/recordCanBeClass/afterCanonicalConstructor.java +++ b/java/java-tests/testData/inspection/recordCanBeClass/afterCanonicalConstructor.java @@ -1,6 +1,6 @@ import java.util.Objects; -// "Convert record to class" "true" +// "Convert 'record' to 'class'" "true" final class Range implements Cloneable { private final int x; private final int y; diff --git a/java/java-tests/testData/inspection/recordCanBeClass/afterCompactConstructor.java b/java/java-tests/testData/inspection/recordCanBeClass/afterCompactConstructor.java index da6f96842d76..86f4dd930b46 100644 --- a/java/java-tests/testData/inspection/recordCanBeClass/afterCompactConstructor.java +++ b/java/java-tests/testData/inspection/recordCanBeClass/afterCompactConstructor.java @@ -1,6 +1,6 @@ import java.util.Objects; -// "Convert record to class" "true" +// "Convert 'record' to 'class'" "true" final class Range { private final int x; private final int y; diff --git a/java/java-tests/testData/inspection/recordCanBeClass/afterCustomConstructor.java b/java/java-tests/testData/inspection/recordCanBeClass/afterCustomConstructor.java index 9d18b73fa00f..b43bd28b12fc 100644 --- a/java/java-tests/testData/inspection/recordCanBeClass/afterCustomConstructor.java +++ b/java/java-tests/testData/inspection/recordCanBeClass/afterCustomConstructor.java @@ -1,6 +1,6 @@ import java.util.Objects; -// "Convert record to class" "true" +// "Convert 'record' to 'class'" "true" final class Range { static final Range ZERO = new Range(0); private final int x; diff --git a/java/java-tests/testData/inspection/recordCanBeClass/afterGeneric.java b/java/java-tests/testData/inspection/recordCanBeClass/afterGeneric.java index ca0282271697..9337b47cf132 100644 --- a/java/java-tests/testData/inspection/recordCanBeClass/afterGeneric.java +++ b/java/java-tests/testData/inspection/recordCanBeClass/afterGeneric.java @@ -1,6 +1,6 @@ import java.util.Objects; -// "Convert record to class" "true" +// "Convert 'record' to 'class'" "true" final class R { private final T t; diff --git a/java/java-tests/testData/inspection/recordCanBeClass/afterIncomplete.java b/java/java-tests/testData/inspection/recordCanBeClass/afterIncomplete.java index 997f81f6c033..3e17e8a6a093 100644 --- a/java/java-tests/testData/inspection/recordCanBeClass/afterIncomplete.java +++ b/java/java-tests/testData/inspection/recordCanBeClass/afterIncomplete.java @@ -1,6 +1,6 @@ import java.util.Objects; -// "Convert record to class" "true" +// "Convert 'record' to 'class'" "true" final class Rec { private final int x; private final int y; diff --git a/java/java-tests/testData/inspection/recordCanBeClass/afterInner.java b/java/java-tests/testData/inspection/recordCanBeClass/afterInner.java index d74767205db3..81d3871c53c5 100644 --- a/java/java-tests/testData/inspection/recordCanBeClass/afterInner.java +++ b/java/java-tests/testData/inspection/recordCanBeClass/afterInner.java @@ -1,4 +1,4 @@ -// "Convert record to class" "true" +// "Convert 'record' to 'class'" "true" class X { private static final class R { private R() { diff --git a/java/java-tests/testData/inspection/recordCanBeClass/afterNoArg.java b/java/java-tests/testData/inspection/recordCanBeClass/afterNoArg.java index cab507206cb9..af2e24aabecf 100644 --- a/java/java-tests/testData/inspection/recordCanBeClass/afterNoArg.java +++ b/java/java-tests/testData/inspection/recordCanBeClass/afterNoArg.java @@ -1,4 +1,4 @@ -// "Convert record to class" "true" +// "Convert 'record' to 'class'" "true" final class R { R() { } diff --git a/java/java-tests/testData/inspection/recordCanBeClass/afterNormal.java b/java/java-tests/testData/inspection/recordCanBeClass/afterNormal.java index f0e88388ed67..f38b0b15e8df 100644 --- a/java/java-tests/testData/inspection/recordCanBeClass/afterNormal.java +++ b/java/java-tests/testData/inspection/recordCanBeClass/afterNormal.java @@ -1,4 +1,4 @@ -// "Convert record to class" "true" +// "Convert 'record' to 'class'" "true" import java.util.Objects; diff --git a/java/java-tests/testData/inspection/recordCanBeClass/beforeAmbiguousAnnotations.java b/java/java-tests/testData/inspection/recordCanBeClass/beforeAmbiguousAnnotations.java index 9b9307c2c313..464882d7de27 100644 --- a/java/java-tests/testData/inspection/recordCanBeClass/beforeAmbiguousAnnotations.java +++ b/java/java-tests/testData/inspection/recordCanBeClass/beforeAmbiguousAnnotations.java @@ -1,4 +1,4 @@ -// "Convert record to class" "true" +// "Convert 'record' to 'class'" "true" import java.lang.annotation.*; @Target({ElementType.PARAMETER, ElementType.METHOD, ElementType.FIELD, ElementType.TYPE_USE}) diff --git a/java/java-tests/testData/inspection/recordCanBeClass/beforeAnnotations.java b/java/java-tests/testData/inspection/recordCanBeClass/beforeAnnotations.java index 5f24b1837da2..056ad2d6a023 100644 --- a/java/java-tests/testData/inspection/recordCanBeClass/beforeAnnotations.java +++ b/java/java-tests/testData/inspection/recordCanBeClass/beforeAnnotations.java @@ -1,4 +1,4 @@ -// "Convert record to class" "true" +// "Convert 'record' to 'class'" "true" import java.lang.annotation.*; @Target(ElementType.FIELD) diff --git a/java/java-tests/testData/inspection/recordCanBeClass/beforeCanonicalConstructor.java b/java/java-tests/testData/inspection/recordCanBeClass/beforeCanonicalConstructor.java index 45b70968febc..542702869fb0 100644 --- a/java/java-tests/testData/inspection/recordCanBeClass/beforeCanonicalConstructor.java +++ b/java/java-tests/testData/inspection/recordCanBeClass/beforeCanonicalConstructor.java @@ -1,4 +1,4 @@ -// "Convert record to class" "true" +// "Convert 'record' to 'class'" "true" record Range(int x, int y) implements Cloneable { Range(int x, int y) { if (x > y) { diff --git a/java/java-tests/testData/inspection/recordCanBeClass/beforeCompactConstructor.java b/java/java-tests/testData/inspection/recordCanBeClass/beforeCompactConstructor.java index 544234bbee7a..b43953fcf91f 100644 --- a/java/java-tests/testData/inspection/recordCanBeClass/beforeCompactConstructor.java +++ b/java/java-tests/testData/inspection/recordCanBeClass/beforeCompactConstructor.java @@ -1,4 +1,4 @@ -// "Convert record to class" "true" +// "Convert 'record' to 'class'" "true" record Range(int x, int y) { /** * Checks invariant diff --git a/java/java-tests/testData/inspection/recordCanBeClass/beforeCustomConstructor.java b/java/java-tests/testData/inspection/recordCanBeClass/beforeCustomConstructor.java index af3bb0a74a8e..55100c4425ce 100644 --- a/java/java-tests/testData/inspection/recordCanBeClass/beforeCustomConstructor.java +++ b/java/java-tests/testData/inspection/recordCanBeClass/beforeCustomConstructor.java @@ -1,4 +1,4 @@ -// "Convert record to class" "true" +// "Convert 'record' to 'class'" "true" record Range(int x, int y) { static final Range ZERO = new Range(0); diff --git a/java/java-tests/testData/inspection/recordCanBeClass/beforeGeneric.java b/java/java-tests/testData/inspection/recordCanBeClass/beforeGeneric.java index 3a9fd6409709..f32b268be9f1 100644 --- a/java/java-tests/testData/inspection/recordCanBeClass/beforeGeneric.java +++ b/java/java-tests/testData/inspection/recordCanBeClass/beforeGeneric.java @@ -1,2 +1,2 @@ -// "Convert record to class" "true" +// "Convert 'record' to 'class'" "true" final record R(T t) {} \ No newline at end of file diff --git a/java/java-tests/testData/inspection/recordCanBeClass/beforeIncomplete.java b/java/java-tests/testData/inspection/recordCanBeClass/beforeIncomplete.java index b39f82b54640..1541ddc28fa9 100644 --- a/java/java-tests/testData/inspection/recordCanBeClass/beforeIncomplete.java +++ b/java/java-tests/testData/inspection/recordCanBeClass/beforeIncomplete.java @@ -1,2 +1,2 @@ -// "Convert record to class" "true" +// "Convert 'record' to 'class'" "true" record Rec(int x, int y \ No newline at end of file diff --git a/java/java-tests/testData/inspection/recordCanBeClass/beforeInner.java b/java/java-tests/testData/inspection/recordCanBeClass/beforeInner.java index 0643692d0130..eea5dc131944 100644 --- a/java/java-tests/testData/inspection/recordCanBeClass/beforeInner.java +++ b/java/java-tests/testData/inspection/recordCanBeClass/beforeInner.java @@ -1,4 +1,4 @@ -// "Convert record to class" "true" +// "Convert 'record' to 'class'" "true" class X { private record R() {} } \ No newline at end of file diff --git a/java/java-tests/testData/inspection/recordCanBeClass/beforeNoArg.java b/java/java-tests/testData/inspection/recordCanBeClass/beforeNoArg.java index f45dfbc140aa..6f4a024216af 100644 --- a/java/java-tests/testData/inspection/recordCanBeClass/beforeNoArg.java +++ b/java/java-tests/testData/inspection/recordCanBeClass/beforeNoArg.java @@ -1,2 +1,2 @@ -// "Convert record to class" "true" +// "Convert 'record' to 'class'" "true" record R() {} \ No newline at end of file diff --git a/java/java-tests/testData/inspection/recordCanBeClass/beforeNormal.java b/java/java-tests/testData/inspection/recordCanBeClass/beforeNormal.java index 42b92ae7f533..06f3dd619b60 100644 --- a/java/java-tests/testData/inspection/recordCanBeClass/beforeNormal.java +++ b/java/java-tests/testData/inspection/recordCanBeClass/beforeNormal.java @@ -1,4 +1,4 @@ -// "Convert record to class" "true" +// "Convert 'record' to 'class'" "true" /** * Cool record. diff --git a/java/java-tests/testData/inspection/recordCanBeClass8/afterNonPublic.java b/java/java-tests/testData/inspection/recordCanBeClass8/afterNonPublic.java index f6389202fe56..dbf17f1f98f7 100644 --- a/java/java-tests/testData/inspection/recordCanBeClass8/afterNonPublic.java +++ b/java/java-tests/testData/inspection/recordCanBeClass8/afterNonPublic.java @@ -1,6 +1,6 @@ import java.util.Objects; -// "Convert record to class" "true" +// "Convert 'record' to 'class'" "true" final class Point { private final double x; private final double y; diff --git a/java/java-tests/testData/inspection/recordCanBeClass8/afterSimple.java b/java/java-tests/testData/inspection/recordCanBeClass8/afterSimple.java index 1a0cc10216d7..8bcda7ce6633 100644 --- a/java/java-tests/testData/inspection/recordCanBeClass8/afterSimple.java +++ b/java/java-tests/testData/inspection/recordCanBeClass8/afterSimple.java @@ -1,6 +1,6 @@ import java.util.Objects; -// "Convert record to class" "true" +// "Convert 'record' to 'class'" "true" public final class Point { private final int x; private final int y; diff --git a/java/java-tests/testData/inspection/recordCanBeClass8/beforeNonPublic.java b/java/java-tests/testData/inspection/recordCanBeClass8/beforeNonPublic.java index f10e766fd572..5215ba43b908 100644 --- a/java/java-tests/testData/inspection/recordCanBeClass8/beforeNonPublic.java +++ b/java/java-tests/testData/inspection/recordCanBeClass8/beforeNonPublic.java @@ -1,4 +1,4 @@ -// "Convert record to class" "true" +// "Convert 'record' to 'class'" "true" record Point(double x, double y) { void foo() {} } \ No newline at end of file diff --git a/java/java-tests/testData/inspection/recordCanBeClass8/beforeSimple.java b/java/java-tests/testData/inspection/recordCanBeClass8/beforeSimple.java index ab7c1fc8c138..926e3f20fd74 100644 --- a/java/java-tests/testData/inspection/recordCanBeClass8/beforeSimple.java +++ b/java/java-tests/testData/inspection/recordCanBeClass8/beforeSimple.java @@ -1,2 +1,2 @@ -// "Convert record to class" "true" +// "Convert 'record' to 'class'" "true" public record Point(int x, int y) {} \ No newline at end of file diff --git a/java/java-tests/testSrc/com/intellij/java/codeInspection/SerializableRecordCanBeClassInspectionTest.java b/java/java-tests/testSrc/com/intellij/java/codeInspection/SerializableRecordCanBeClassInspectionTest.java index feb06594964b..a4c53dba9009 100644 --- a/java/java-tests/testSrc/com/intellij/java/codeInspection/SerializableRecordCanBeClassInspectionTest.java +++ b/java/java-tests/testSrc/com/intellij/java/codeInspection/SerializableRecordCanBeClassInspectionTest.java @@ -12,12 +12,12 @@ public class SerializableRecordCanBeClassInspectionTest extends LightJavaInspect public void testSerializableVersionUIDWithoutSerial() { doTest("import java.io.Serializable;\n" + - "record R() implements Serializable {\n" + + "record R() implements Serializable {\n" + " @MyAnn\n" + " private static final long serialVersionUID = 1;\n" + " static long number = 10;\n" + "}"); - checkQuickFix("Convert record to class", "import java.io.Serial;\n" + + checkQuickFix("Convert 'record' to 'class'", "import java.io.Serial;\n" + "import java.io.Serializable;\n" + "\n" + "final class R implements Serializable {\n" + @@ -50,13 +50,13 @@ public class SerializableRecordCanBeClassInspectionTest extends LightJavaInspect public void testSerializableVersionUIDWithSerial() { doTest("import java.io.Serial;\n" + "import java.io.Serializable;\n" + - "record R() implements Serializable {\n" + + "record R() implements Serializable {\n" + " @Serial" + " @MyAnn\n" + " private static final long serialVersionUID = 1;\n" + " static long number = 10;\n" + "}"); - checkQuickFix("Convert record to class", "import java.io.Serial;\n" + + checkQuickFix("Convert 'record' to 'class'", "import java.io.Serial;\n" + "import java.io.Serializable;\n" + "\n" + "final class R implements Serializable {\n" + @@ -88,10 +88,10 @@ public class SerializableRecordCanBeClassInspectionTest extends LightJavaInspect public void testWithoutSerialVersionUID() { doTest("import java.io.Serializable;\n" + - "record R() implements Serializable {\n" + + "record R() implements Serializable {\n" + " static long number = 10;\n" + "}"); - checkQuickFix("Convert record to class", "import java.io.Serial;\n" + + checkQuickFix("Convert 'record' to 'class'", "import java.io.Serial;\n" + "import java.io.Serializable;\n" + "\n" + "final class R implements Serializable {\n" + @@ -122,12 +122,12 @@ public class SerializableRecordCanBeClassInspectionTest extends LightJavaInspect public void testSerialVersionUIDWithWrongModifier() { doTest("import java.io.Serializable;\n" + - "record R() implements Serializable {\n" + + "record R() implements Serializable {\n" + " static long number = 10;\n" + " @MyAnn\n" + " private static long serialVersionUID = 10;\n" + // not final "}"); - checkQuickFix("Convert record to class", "import java.io.Serializable;\n" + + checkQuickFix("Convert 'record' to 'class'", "import java.io.Serializable;\n" + "\n" + "final class R implements Serializable {\n" + " static long number = 10;\n" + diff --git a/java/openapi/resources/messages/JavaBundle.properties b/java/openapi/resources/messages/JavaBundle.properties index 7d0cf1617f28..8ea8a9aa0fcd 100644 --- a/java/openapi/resources/messages/JavaBundle.properties +++ b/java/openapi/resources/messages/JavaBundle.properties @@ -40,8 +40,8 @@ assignment.to.declared.variable.problem.descriptor=Variable ''{0}'' is initializ assignment.to.itself.problem.descriptor=Variable ''{0}'' is assigned to itself assignment.to.itself.quickfix.name=Remove self assignment bean.property=Bean Property -boolean.method.is.always.inverted.display.name=Boolean method is always inverted -boolean.method.is.always.inverted.problem.descriptor=Boolean method #ref is always inverted +boolean.method.is.always.inverted.display.name='boolean' method is always inverted +boolean.method.is.always.inverted.problem.descriptor=boolean method #ref is always inverted button.add.blank=Add Blank button.add.class=Add Class... button.add=Add... @@ -1305,8 +1305,8 @@ update.external.annotations=Update External Annotations intention.create.switch.statement=Create switch statement sort.threads.by.type=Sort Threads by Type sort.threads.by.name=Sort Threads by Name -inspection.message.record.can.be.converted.to.class=Record can be converted to a class -intention.family.name.convert.record.to.class=Convert record to class +inspection.message.record.can.be.converted.to.class='record' can be converted to 'class' +intention.family.name.convert.record.to.class=Convert 'record' to 'class' class.can.be.record.display.name=Class can be a record class.can.be.record.quick.fix=Convert to a record class.can.be.record.suggest.renaming.accessors=Suggest renaming get/is-accessors diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/BooleanMethodIsAlwaysInverted.html b/plugins/InspectionGadgets/src/inspectionDescriptions/BooleanMethodIsAlwaysInverted.html index 30c4147c0eaa..920b35772d4b 100644 --- a/plugins/InspectionGadgets/src/inspectionDescriptions/BooleanMethodIsAlwaysInverted.html +++ b/plugins/InspectionGadgets/src/inspectionDescriptions/BooleanMethodIsAlwaysInverted.html @@ -1,25 +1,38 @@ -Reports methods with a boolean return type, which are only used in a negated context. +Reports methods with a boolean return type, which are only used in a negated context. Due to performance reasons some methods might not be reported during in-editor highlighting. -

-For example: -

-class C {
-  boolean inverted() {
-    return true;
-  }
-
-  void f() {
-    if (!inverted()) {
-      return;
-    }
-  }
-  boolean member = !inverted();
-}  
-
-

+

Example:

+
+  class C {
+    boolean alwaysInverted() {
+      return true;
+    }
+
+    void f() {
+      if (!alwaysInverted()) {
+        return;
+      }
+    }
+    boolean member = !alwaysInverted();
+  }
+
+

After the quick-fix is applied (the function name can be changed), the result looks like this:

+
+  class C {
+    boolean notInvertedAnymore() {
+      return false;
+    }
+
+    void f() {
+      if (notInvertedAnymore()) {
+        return;
+      }
+    }
+    boolean member = notInvertedAnymore();
+  }
+
diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/IfStatementWithIdenticalBranches.html b/plugins/InspectionGadgets/src/inspectionDescriptions/IfStatementWithIdenticalBranches.html index 093a54cfb3d7..8b488911592f 100644 --- a/plugins/InspectionGadgets/src/inspectionDescriptions/IfStatementWithIdenticalBranches.html +++ b/plugins/InspectionGadgets/src/inspectionDescriptions/IfStatementWithIdenticalBranches.html @@ -1,9 +1,10 @@ -Inspection that can extract common parts from branches of if statement. +Reports if statements where common parts can be extracted from the branches. +These common parts are independent from the condition and make if statements harder to understand. -

Before:

-

+

Example:

+
   if (x > 12) {
     doSomethingBefore();
     doSomethingDifferent1();
@@ -13,9 +14,9 @@ Inspection that can extract common parts from branches of if statement.
     doSomethingDifferent2();
     doSomethingAfter();
   }
-
-

After:

-

+
+

After the quick-fix is applied, the result looks like this:

+
   doSomethingBefore();
   if (x > 12) {
     doSomethingDifferent1();
@@ -23,7 +24,7 @@ Inspection that can extract common parts from branches of if statement.
     doSomethingDifferent2();
   }
   doSomethingAfter();
-
+

Updated in 2018.1

diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/ReturnFromFinallyBlock.html b/plugins/InspectionGadgets/src/inspectionDescriptions/ReturnFromFinallyBlock.html index 48c1caf170bd..257ea73149af 100644 --- a/plugins/InspectionGadgets/src/inspectionDescriptions/ReturnFromFinallyBlock.html +++ b/plugins/InspectionGadgets/src/inspectionDescriptions/ReturnFromFinallyBlock.html @@ -1,10 +1,16 @@ -Reports return statements inside of finally -blocks. While occasionally intended, such return statements may mask exceptions thrown, and -tremendously complicate debugging. +Reports return statements inside of finally blocks. +While occasionally intended, such return statements may mask thrown exceptions, +and tremendously complicate debugging. -

- +

Example:

+
+  try {
+    foo();
+  } finally {
+    if (bar()) return;
+  }
+
\ No newline at end of file diff --git a/plugins/InspectionGadgets/src/inspectionDescriptions/UnnecessaryLocalVariable.html b/plugins/InspectionGadgets/src/inspectionDescriptions/UnnecessaryLocalVariable.html index 47edad81408d..7581d84060cc 100644 --- a/plugins/InspectionGadgets/src/inspectionDescriptions/UnnecessaryLocalVariable.html +++ b/plugins/InspectionGadgets/src/inspectionDescriptions/UnnecessaryLocalVariable.html @@ -1,18 +1,30 @@ -Reports unnecessary local variables, which add -nothing to the comprehensibility of a method. Variables caught include local variables -which are immediately returned, local variables that are immediately assigned to another -variable and then not used, and local variables which always have the same value as another -local variable or parameter. +Reports unnecessary local variables, which add nothing to the comprehensibility of a method. +Variables caught include local variables which are immediately returned, +local variables that are immediately assigned to another variable and then not used, +and local variables which always have the same value as another local variable or parameter. +

Example:

+
+  boolean yes() {
+    boolean b = true;
+    return b;
+  }
+
+

After the quick-fix is applied, the result looks like this:

+
+  boolean yes() {
+    return true;
+  }
+

-Use the first checkbox below to have this inspection ignore variables which are immediately -returned or thrown. Some coding styles suggest using such variables for clarity and -ease of debugging. -

-Use the second checkbox below to have this inspection ignore variable which are annotated. + Use the first checkbox below to have this inspection ignore immediately returned or thrown variables. + Some coding styles suggest using such variables for clarity and ease of debugging. +

+ Use the second checkbox below to have this inspection ignore annotated variables. +

\ No newline at end of file