diff --git a/java/java-analysis-impl/src/com/intellij/codeInspection/dataFlow/ControlFlowAnalyzer.java b/java/java-analysis-impl/src/com/intellij/codeInspection/dataFlow/ControlFlowAnalyzer.java
index 3799ba8a40fe..8f2bc4db3ceb 100644
--- a/java/java-analysis-impl/src/com/intellij/codeInspection/dataFlow/ControlFlowAnalyzer.java
+++ b/java/java-analysis-impl/src/com/intellij/codeInspection/dataFlow/ControlFlowAnalyzer.java
@@ -1512,8 +1512,8 @@ class ControlFlowAnalyzer extends JavaElementVisitor {
if ("false".equals(name)) return ValueConstraint.FALSE_VALUE;
if ("exit".equals(name)) return ValueConstraint.SYSTEM_EXIT;
if ("fail".equals(name)) return ValueConstraint.THROW_EXCEPTION;
- if ("any".equals(name)) return ValueConstraint.ANY_VALUE;
- throw new ParseException("Constraint should be one of: null, !null, true, false, exit, fail, any. Found: " + name);
+ if ("_".equals(name)) return ValueConstraint.ANY_VALUE;
+ throw new ParseException("Constraint should be one of: null, !null, true, false, exit, fail, _. Found: " + name);
}
private static class ParseException extends Exception {
diff --git a/platform/annotations/src/org/jetbrains/annotations/Contract.java b/platform/annotations/src/org/jetbrains/annotations/Contract.java
index 29d70dadfbbb..672b5cf9f9b7 100644
--- a/platform/annotations/src/org/jetbrains/annotations/Contract.java
+++ b/platform/annotations/src/org/jetbrains/annotations/Contract.java
@@ -30,7 +30,7 @@ import java.lang.annotation.*;
*
* The constraints denote the following:
*
- * - any - any value
+ *
- _ - any value
*
- null - null value
*
- !null - a value statically proved to be not-null
*
- true - true boolean value
@@ -39,8 +39,8 @@ import java.lang.annotation.*;
*
- exit - the method terminates the current process, if the arguments satisfy argument constraints
*
* Examples:
- * @Contract("any, null -> null") - method returns null if its second argument is null
- * @Contract("any, null -> null; any, !null -> !null") - method returns null if its second argument is null and not-null otherwise
+ * @Contract("_, null -> null") - method returns null if its second argument is null
+ * @Contract("_, null -> null; _, !null -> !null") - method returns null if its second argument is null and not-null otherwise
* @Contract("true -> fail") - a typical assertFalse method which throws an exception if true is passed to it
*
* @author peter
diff --git a/platform/core-api/src/com/intellij/psi/util/PsiTreeUtil.java b/platform/core-api/src/com/intellij/psi/util/PsiTreeUtil.java
index fb1e404bd91d..b342e2b8bde9 100644
--- a/platform/core-api/src/com/intellij/psi/util/PsiTreeUtil.java
+++ b/platform/core-api/src/com/intellij/psi/util/PsiTreeUtil.java
@@ -51,7 +51,7 @@ public class PsiTreeUtil {
* @param strict whether return true if ancestor and parent are the same.
* @return true if element has ancestor as its parent somewhere in the hierarchy and false otherwise.
*/
- @Contract("null, any, any -> false")
+ @Contract("null, _, _ -> false")
public static boolean isAncestor(@Nullable PsiElement ancestor, @NotNull PsiElement element, boolean strict) {
if (ancestor == null) return false;
// fast path to avoid loading tree
@@ -79,7 +79,7 @@ public class PsiTreeUtil {
* @param strict whether return true if ancestor and parent are the same.
* @return true if element has ancestor as its parent somewhere in the hierarchy and false otherwise.
*/
- @Contract("null, any, any -> false")
+ @Contract("null, _, _ -> false")
public static boolean isContextAncestor(@Nullable PsiElement ancestor, @NotNull PsiElement element, boolean strict) {
if (ancestor == null) return false;
boolean stopAtFileLevel = !(ancestor instanceof PsiFile || ancestor instanceof PsiDirectory);
@@ -223,7 +223,7 @@ public class PsiTreeUtil {
* @return first found element, or null if nothing found.
*/
@Nullable
- @Contract("null, any, any -> null")
+ @Contract("null, _, _ -> null")
public static T findChildOfAnyType(@Nullable final PsiElement element, @NotNull final Class extends T>... classes) {
return findChildOfAnyType(element, true, classes);
}
@@ -238,7 +238,7 @@ public class PsiTreeUtil {
* @return first found element, or null if nothing found.
*/
@Nullable
- @Contract("null, any, any -> null")
+ @Contract("null, _, _ -> null")
public static T findChildOfAnyType(@Nullable final PsiElement element,
final boolean strict,
@NotNull final Class extends T>... classes) {
@@ -378,7 +378,7 @@ public class PsiTreeUtil {
* @since 5.1
*/
@Nullable
- @Contract("null, any -> null")
+ @Contract("null, _ -> null")
public static T getChildOfAnyType(@Nullable PsiElement element, @NotNull Class extends T>... classes) {
if (element == null) return null;
for (PsiElement child = element.getFirstChild(); child != null; child = child.getNextSibling()) {
@@ -393,7 +393,7 @@ public class PsiTreeUtil {
}
@Nullable
- @Contract("null, any -> null")
+ @Contract("null, _ -> null")
public static T getNextSiblingOfType(@Nullable PsiElement sibling, @NotNull Class aClass) {
if (sibling == null) return null;
for (PsiElement child = sibling.getNextSibling(); child != null; child = child.getNextSibling()) {
@@ -406,7 +406,7 @@ public class PsiTreeUtil {
}
@Nullable
- @Contract("null, any -> null")
+ @Contract("null, _ -> null")
public static T getPrevSiblingOfType(@Nullable PsiElement sibling, @NotNull Class aClass) {
if (sibling == null) return null;
for (PsiElement child = sibling.getPrevSibling(); child != null; child = child.getPrevSibling()) {
@@ -419,7 +419,7 @@ public class PsiTreeUtil {
}
@Nullable
- @Contract("null, any -> null")
+ @Contract("null, _ -> null")
public static T getTopmostParentOfType(@Nullable PsiElement element, @NotNull Class aClass) {
T answer = getParentOfType(element, aClass);
@@ -434,7 +434,7 @@ public class PsiTreeUtil {
}
@Nullable
- @Contract("null, any -> null")
+ @Contract("null, _ -> null")
public static T getParentOfType(@Nullable PsiElement element, @NotNull Class aClass) {
return getParentOfType(element, aClass, true);
}
@@ -454,7 +454,7 @@ public class PsiTreeUtil {
}
@Nullable
- @Contract("null, any -> null")
+ @Contract("null, _ -> null")
public static E getStubOrPsiParentOfType(@Nullable PsiElement element, @NotNull Class parentClass) {
if (element instanceof StubBasedPsiElement) {
StubBase stub = (StubBase)((StubBasedPsiElement)element).getStub();
@@ -467,7 +467,7 @@ public class PsiTreeUtil {
}
@Nullable
- @Contract("null, any, any, any -> null")
+ @Contract("null, _, _, _ -> null")
public static T getContextOfType(@Nullable PsiElement element,
@NotNull Class aClass,
boolean strict,
@@ -487,7 +487,7 @@ public class PsiTreeUtil {
}
@Nullable
- @Contract("null, any, any -> null")
+ @Contract("null, _, _ -> null")
public static T getContextOfType(@Nullable PsiElement element,
@NotNull Class extends T> aClass,
boolean strict) {
@@ -500,7 +500,7 @@ public class PsiTreeUtil {
}
@Nullable
- @Contract("null, any, any -> null")
+ @Contract("null, _, _ -> null")
public static T getContextOfType(@Nullable PsiElement element,
boolean strict,
@NotNull Class extends T>... classes) {
@@ -518,7 +518,7 @@ public class PsiTreeUtil {
}
@Nullable
- @Contract("null, any, any -> null")
+ @Contract("null, _, _ -> null")
public static T getParentOfType(@Nullable PsiElement element, @NotNull Class aClass, boolean strict) {
if (element == null) return null;
if (strict) {
@@ -538,7 +538,7 @@ public class PsiTreeUtil {
}
@Nullable
- @Contract("null, any, any, any -> null")
+ @Contract("null, _, _, _ -> null")
public static T getParentOfType(@Nullable PsiElement element,
@NotNull Class aClass,
boolean strict,
@@ -559,7 +559,7 @@ public class PsiTreeUtil {
}
@Nullable
- @Contract("null, any -> null")
+ @Contract("null, _ -> null")
public static PsiElement skipSiblingsForward(@Nullable PsiElement element, @NotNull Class... elementClasses) {
if (element == null) return null;
NextSibling:
@@ -571,7 +571,7 @@ public class PsiTreeUtil {
}
@Nullable
- @Contract("null, any -> null")
+ @Contract("null, _ -> null")
public static PsiElement skipSiblingsBackward(@Nullable PsiElement element, @NotNull Class... elementClasses) {
if (element == null) return null;
NextSibling:
@@ -583,7 +583,7 @@ public class PsiTreeUtil {
}
@Nullable
- @Contract("null, any -> null")
+ @Contract("null, _ -> null")
public static PsiElement skipParentsOfType(@Nullable PsiElement element, @NotNull Class... parentClasses) {
if (element == null) return null;
NextSibling:
@@ -595,7 +595,7 @@ public class PsiTreeUtil {
}
@Nullable
- @Contract("null, any -> null")
+ @Contract("null, _ -> null")
public static T getParentOfType(@Nullable final PsiElement element,
@NotNull final Class extends T>... classes) {
if (element == null) return null;
@@ -605,7 +605,7 @@ public class PsiTreeUtil {
}
@Nullable
- @Contract("null, any -> null")
+ @Contract("null, _ -> null")
public static T getNonStrictParentOfType(@Nullable final PsiElement element,
@NotNull final Class extends T>... classes) {
PsiElement run = element;
@@ -648,7 +648,7 @@ public class PsiTreeUtil {
return processor.getCollection();
}
- @Contract("null, any -> true")
+ @Contract("null, _ -> true")
public static boolean processElements(@Nullable PsiElement element, @NotNull final PsiElementProcessor processor) {
if (element == null) return true;
if (element instanceof PsiCompiledElement || !element.isPhysical()) { // DummyHolders cannot be visited by walking visitors because children/parent relationship is broken there