diff --git a/java/java-analysis-impl/src/com/intellij/codeInspection/dataFlow/MutationSignature.java b/java/java-analysis-impl/src/com/intellij/codeInspection/dataFlow/MutationSignature.java index 4334fda67110..d4412ad7f5d2 100644 --- a/java/java-analysis-impl/src/com/intellij/codeInspection/dataFlow/MutationSignature.java +++ b/java/java-analysis-impl/src/com/intellij/codeInspection/dataFlow/MutationSignature.java @@ -14,13 +14,13 @@ public class MutationSignature { private static final String CONTRACT_ANNOTATION = "org.jetbrains.annotations.Contract"; private static final MutationSignature UNKNOWN = new MutationSignature(false, new boolean[0]); private static final MutationSignature PURE = new MutationSignature(false, new boolean[0]); - public static final String INVALID_TOKEN_MESSAGE = "Invalid token: %s; supported are 'this', 'arg1', 'arg2', etc."; + public static final String INVALID_TOKEN_MESSAGE = "Invalid token: %s; supported are 'this', 'param1', 'param2', etc."; private final boolean myThis; - private final boolean[] myArgs; + private final boolean[] myParameters; - private MutationSignature(boolean mutatesThis, boolean[] args) { + private MutationSignature(boolean mutatesThis, boolean[] params) { myThis = mutatesThis; - myArgs = args; + myParameters = params; } public boolean mutatesThis() { @@ -28,7 +28,7 @@ public class MutationSignature { } public boolean mutatesArg(int n) { - return n < myArgs.length && myArgs[n]; + return n < myParameters.length && myParameters[n]; } public boolean preservesThis() { @@ -55,15 +55,15 @@ public class MutationSignature { if (part.equals("this")) { mutatesThis = true; } - else if (part.equals("arg")) { + else if (part.equals("param")) { if (args.length == 0) { args = new boolean[] {true}; } else { args[0] = true; } } - else if (part.startsWith("arg")) { - int argNum = Integer.parseInt(part.substring("arg".length())); + else if (part.startsWith("param")) { + int argNum = Integer.parseInt(part.substring("param".length())); if (argNum < 0 || argNum > 255) { throw new IllegalArgumentException(String.format(INVALID_TOKEN_MESSAGE, part)); } @@ -93,11 +93,11 @@ public class MutationSignature { return "Static method cannot mutate 'this'"; } PsiParameter[] parameters = method.getParameterList().getParameters(); - if (ms.myArgs.length > parameters.length) { - return "Reference to parameter #" + ms.myArgs.length + " is invalid"; + if (ms.myParameters.length > parameters.length) { + return "Reference to parameter #" + ms.myParameters.length + " is invalid"; } - for (int i = 0; i < ms.myArgs.length; i++) { - if (ms.myArgs[i]) { + for (int i = 0; i < ms.myParameters.length; i++) { + if (ms.myParameters[i]) { PsiType type = parameters[i].getType(); if (ClassUtils.isImmutable(type)) { return "Parameter #" + (i + 1) + " has immutable type '" + type.getPresentableText() + "'"; diff --git a/java/java-tests/testData/inspection/dataFlow/contractCheck/MutationSignatureProblems.java b/java/java-tests/testData/inspection/dataFlow/contractCheck/MutationSignatureProblems.java index 684ef30edf4d..4fda13fb9a8b 100644 --- a/java/java-tests/testData/inspection/dataFlow/contractCheck/MutationSignatureProblems.java +++ b/java/java-tests/testData/inspection/dataFlow/contractCheck/MutationSignatureProblems.java @@ -14,30 +14,30 @@ class Test { @Contract(mutates = "this") public static void test1(List list) {} - @Contract(mutates = "arg3") + @Contract(mutates = "param3") public static void test2(List list) {} - @Contract(mutates = "blahblahblah") + @Contract(mutates = "blahblahblah") public static void test3(List list) {} - @Contract(mutates = "arg") + @Contract(mutates = "param") public static void test4(List list) {} - @Contract(mutates = "arg", pure = true) + @Contract(mutates = "param", pure = true) public static void test5(List list) {} - @Contract(mutates = "arg", pure = false) + @Contract(mutates = "param", pure = false) public static void test6(List list) {} @Contract(mutates = "", pure = true) public static void test7(List list) {} - @Contract(mutates = "arg1") + @Contract(mutates = "param1") public static void test8(String s, int i, List list) {} - @Contract(mutates = "arg2") + @Contract(mutates = "param2") public static void test9(String s, int i, List list) {} - @Contract(mutates = "arg3") + @Contract(mutates = "param3") public static void test10(String s, int i, List list) {} } \ No newline at end of file diff --git a/java/java-tests/testData/inspection/dataFlow/fixture/MutabilityBasics.java b/java/java-tests/testData/inspection/dataFlow/fixture/MutabilityBasics.java index c0b802f4bb70..62900d029f06 100644 --- a/java/java-tests/testData/inspection/dataFlow/fixture/MutabilityBasics.java +++ b/java/java-tests/testData/inspection/dataFlow/fixture/MutabilityBasics.java @@ -12,12 +12,12 @@ public class MutabilityBasics { return Collections.emptyList(); } - @Contract(mutates = "arg") + @Contract(mutates = "param") static > void sort(List collection) { Collections.sort(collection); } - @Contract(mutates = "arg1") + @Contract(mutates = "param1") static > void addAll(Collection collection, List other) { sort(other); collection.addAll(other); diff --git a/java/jdkAnnotations/java/lang/annotations.xml b/java/jdkAnnotations/java/lang/annotations.xml index d9e8555ee959..b26cbe05be68 100644 --- a/java/jdkAnnotations/java/lang/annotations.xml +++ b/java/jdkAnnotations/java/lang/annotations.xml @@ -721,7 +721,7 @@ - + diff --git a/java/jdkAnnotations/java/util/annotations.xml b/java/jdkAnnotations/java/util/annotations.xml index 456b1d98ffa8..a3e6b560cb94 100644 --- a/java/jdkAnnotations/java/util/annotations.xml +++ b/java/jdkAnnotations/java/util/annotations.xml @@ -368,7 +368,7 @@ - + @@ -376,7 +376,7 @@ - + @@ -384,7 +384,7 @@ - + @@ -392,7 +392,7 @@ - + @@ -400,7 +400,7 @@ - + @@ -408,7 +408,7 @@ - + @@ -416,7 +416,7 @@ - + @@ -424,7 +424,7 @@ - + @@ -432,7 +432,7 @@ - + @@ -440,7 +440,7 @@ - + @@ -448,7 +448,7 @@ - + @@ -456,7 +456,7 @@ - + @@ -464,7 +464,7 @@ - + @@ -472,7 +472,7 @@ - + @@ -480,7 +480,7 @@ - + @@ -488,7 +488,7 @@ - + @@ -496,7 +496,7 @@ - + @@ -504,7 +504,7 @@ - + @@ -512,177 +512,177 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -693,7 +693,7 @@ - + @@ -704,7 +704,7 @@ - + @@ -712,7 +712,7 @@ - + @@ -720,7 +720,7 @@ - + @@ -728,7 +728,7 @@ - + @@ -736,7 +736,7 @@ - + @@ -744,7 +744,7 @@ - + @@ -752,7 +752,7 @@ - + @@ -760,7 +760,7 @@ - + @@ -768,7 +768,7 @@ - + @@ -776,7 +776,7 @@ - + @@ -784,7 +784,7 @@ - + @@ -792,7 +792,7 @@ - + @@ -800,7 +800,7 @@ - + @@ -808,7 +808,7 @@ - + @@ -816,7 +816,7 @@ - + @@ -824,7 +824,7 @@ - + @@ -1056,7 +1056,7 @@ - + @@ -1073,7 +1073,7 @@ - + @@ -1297,7 +1297,7 @@ - + @@ -1308,7 +1308,7 @@ - + @@ -1316,7 +1316,7 @@ - + @@ -1324,7 +1324,7 @@ - + @@ -1332,7 +1332,7 @@ - + @@ -1340,7 +1340,7 @@ - + @@ -1351,7 +1351,7 @@ - + @@ -1359,7 +1359,7 @@ - + @@ -1370,7 +1370,7 @@ - + diff --git a/platform/annotations/common/src/org/jetbrains/annotations/Contract.java b/platform/annotations/common/src/org/jetbrains/annotations/Contract.java index 38d44b90d7b0..3bbaadaaf4c7 100644 --- a/platform/annotations/common/src/org/jetbrains/annotations/Contract.java +++ b/platform/annotations/common/src/org/jetbrains/annotations/Contract.java @@ -81,9 +81,9 @@ public @interface Contract { * The following values are possible: * * - * - * - * + * + * + * *
"this"Method mutates the receiver object, and doesn't mutates any objects passed as arguments (cannot be applied for static method or constructor)
"arg"Method mutates the sole argument and doesn't mutate the receiver object (if applicable)
"arg1", "arg2", ...Method mutates the N-th argument
"this,arg1"Method mutates the receiver and first argument and doesn't mutate any other arguments
"param"Method mutates the sole argument and doesn't mutate the receiver object (if applicable)
"param1", "param2", ...Method mutates the N-th argument
"this,param1"Method mutates the receiver and first argument and doesn't mutate any other arguments
* * Warning: This annotation parameter is experimental and may be changed or removed without further notice!