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 @@
-void f() throws Exception, Exception {
-}
-
-
-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.
+
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:
java.lang.Record,
- so instanceof Record returns false.class no longer extends java.lang.Record,
+ so instanceof Record returns false.Class.isRecord() and
Class.getRecordComponents() produce different results.hashCode() implementation may produce a different result
- because the formula to calculate record hashCode is deliberately not specified.record hashCode is deliberately not specified.record serialization mechanism differs from that of an ordinary class.
Refer to Java Object Serialization Specification for details.
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 staticInteger.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
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 -#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. +Reportsreturn 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