diff --git a/RegExpSupport/src/org/intellij/lang/regexp/validation/RegExpAnnotator.java b/RegExpSupport/src/org/intellij/lang/regexp/validation/RegExpAnnotator.java index 9f6f7c3a1dd3..921aa6b55507 100644 --- a/RegExpSupport/src/org/intellij/lang/regexp/validation/RegExpAnnotator.java +++ b/RegExpSupport/src/org/intellij/lang/regexp/validation/RegExpAnnotator.java @@ -576,7 +576,7 @@ public final class RegExpAnnotator extends RegExpElementVisitor implements Annot myLength++; } - public void stopAndReportError(RegExpElement element, String message) { + public void stopAndReportError(RegExpElement element, @NotNull String message) { myHolder.createErrorAnnotation(element, message); myStop = true; } diff --git a/java/java-psi-impl/src/com/intellij/codeInsight/daemon/JavaErrorMessages.java b/java/java-psi-impl/src/com/intellij/codeInsight/daemon/JavaErrorMessages.java index 74d06d2fd568..755346cde7f0 100644 --- a/java/java-psi-impl/src/com/intellij/codeInsight/daemon/JavaErrorMessages.java +++ b/java/java-psi-impl/src/com/intellij/codeInsight/daemon/JavaErrorMessages.java @@ -25,6 +25,7 @@ import org.jetbrains.annotations.PropertyKey; */ public class JavaErrorMessages extends AbstractBundle { + @NotNull public static String message(@NotNull @PropertyKey(resourceBundle = BUNDLE) String key, @NotNull Object... params) { return INSTANCE.getMessage(key, params); } diff --git a/json/src/com/intellij/json/JsonBundle.java b/json/src/com/intellij/json/JsonBundle.java index 9ccab90f24f9..9f006b8ea4fe 100644 --- a/json/src/com/intellij/json/JsonBundle.java +++ b/json/src/com/intellij/json/JsonBundle.java @@ -21,6 +21,7 @@ public class JsonBundle { // empty } + @NotNull public static String message(@NotNull @PropertyKey(resourceBundle = BUNDLE) String key, @NotNull Object... params) { return CommonBundle.message(getBundle(), key, params); } diff --git a/platform/core-api/src/com/intellij/psi/PsiBundle.java b/platform/core-api/src/com/intellij/psi/PsiBundle.java index 145185b5c10f..011a1003d2f8 100644 --- a/platform/core-api/src/com/intellij/psi/PsiBundle.java +++ b/platform/core-api/src/com/intellij/psi/PsiBundle.java @@ -29,6 +29,7 @@ import java.util.ResourceBundle; */ public class PsiBundle { + @NotNull public static String message(@NotNull @PropertyKey(resourceBundle = BUNDLE) String key, @NotNull Object... params) { return CommonBundle.message(getBundle(), key, params); } diff --git a/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/GroovyBundle.java b/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/GroovyBundle.java index 68531cadf3ac..0875e7658c65 100644 --- a/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/GroovyBundle.java +++ b/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/GroovyBundle.java @@ -30,6 +30,7 @@ import java.util.ResourceBundle; */ public class GroovyBundle { + @NotNull public static String message(@NotNull @PropertyKey(resourceBundle = BUNDLE) String key, @NotNull Object... params) { return CommonBundle.message(getBundle(), key, params); } diff --git a/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/annotator/GroovyAnnotator.java b/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/annotator/GroovyAnnotator.java index a9064fe956f9..5eecd2ba3956 100644 --- a/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/annotator/GroovyAnnotator.java +++ b/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/annotator/GroovyAnnotator.java @@ -1121,7 +1121,7 @@ public class GroovyAnnotator extends GroovyElementVisitor { } - private void checkTypeArgForPrimitive(@Nullable GrTypeElement element, String message) { + private void checkTypeArgForPrimitive(@Nullable GrTypeElement element, @NotNull String message) { if (element == null || !(element.getType() instanceof PsiPrimitiveType)) return; final Annotation annotation = myHolder.createErrorAnnotation(element, message); @@ -1390,7 +1390,7 @@ public class GroovyAnnotator extends GroovyElementVisitor { public void visitAnnotationArgumentList(@NotNull GrAnnotationArgumentList annotationArgumentList) { GrAnnotation parent = (GrAnnotation)annotationArgumentList.getParent(); Pair r = AnnotationChecker.checkAnnotationArgumentList(parent, myHolder, parent.getClassReference()); - if (r != null && r.getFirst() != null) { + if (r != null && r.getFirst() != null && r.getSecond() != null) { myHolder.createErrorAnnotation(r.getFirst(), r.getSecond()); } } @@ -1409,7 +1409,7 @@ public class GroovyAnnotator extends GroovyElementVisitor { final PsiType type = annotationMethod.getReturnType(); - Pair result = CustomAnnotationChecker.checkAnnotationValueByType(value, type, false); + Pair.NonNull result = CustomAnnotationChecker.checkAnnotationValueByType(value, type, false); if (result != null) { myHolder.createErrorAnnotation(result.getFirst(), result.getSecond()); } @@ -1646,7 +1646,7 @@ public class GroovyAnnotator extends GroovyElementVisitor { } } - private static void checkAnnotationList(AnnotationHolder holder, @NotNull GrModifierList modifierList, String message) { + private static void checkAnnotationList(AnnotationHolder holder, @NotNull GrModifierList modifierList, @NotNull String message) { final PsiElement[] modifiers = modifierList.getModifiers(); for (PsiElement modifier : modifiers) { if (!(modifier instanceof PsiAnnotation)) { diff --git a/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/annotator/checkers/AnnotationCollectorChecker.java b/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/annotator/checkers/AnnotationCollectorChecker.java index 3e6dd12cf4d1..2f71611019eb 100644 --- a/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/annotator/checkers/AnnotationCollectorChecker.java +++ b/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/annotator/checkers/AnnotationCollectorChecker.java @@ -43,7 +43,7 @@ public class AnnotationCollectorChecker extends CustomAnnotationChecker { final PsiClass clazz = (PsiClass)annotation.getClassReference().resolve(); if (clazz == null) return true; final GrAnnotationNameValuePair[] attributes = annotation.getParameterList().getAttributes(); - Pair r = + Pair.NonNull r = CustomAnnotationChecker.checkAnnotationArguments(clazz, annotation.getClassReference(), attributes, false); if (r != null && r.getFirst() != null) { holder.createErrorAnnotation(r.getFirst(), r.getSecond()); diff --git a/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/annotator/checkers/CustomAnnotationChecker.java b/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/annotator/checkers/CustomAnnotationChecker.java index 1c860b79f506..ce119554566a 100644 --- a/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/annotator/checkers/CustomAnnotationChecker.java +++ b/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/annotator/checkers/CustomAnnotationChecker.java @@ -51,7 +51,7 @@ public abstract class CustomAnnotationChecker { return null; } - public static Pair checkAnnotationArguments(@NotNull PsiClass annotation, + public static Pair.NonNull checkAnnotationArguments(@NotNull PsiClass annotation, @NotNull PsiElement refToHighlight, @NotNull GrAnnotationNameValuePair[] attributes, boolean checkMissedAttributes) { @@ -60,7 +60,7 @@ public abstract class CustomAnnotationChecker { if (attributes.length > 0) { final PsiElement identifier = attributes[0].getNameIdentifierGroovy(); if (attributes.length == 1 && identifier == null) { - Pair r = + Pair.NonNull r = checkAnnotationValue(annotation, attributes[0], "value", usedAttrs, attributes[0].getValue()); if (r != null) return r; } @@ -70,7 +70,7 @@ public abstract class CustomAnnotationChecker { if (name != null) { final PsiElement toHighlight = attribute.getNameIdentifierGroovy(); assert toHighlight != null; - Pair r = checkAnnotationValue(annotation, toHighlight, name, usedAttrs, attribute.getValue()); + Pair.NonNull r = checkAnnotationValue(annotation, toHighlight, name, usedAttrs, attribute.getValue()); if (r != null) return r; } } @@ -89,23 +89,23 @@ public abstract class CustomAnnotationChecker { } if (checkMissedAttributes && !missedAttrs.isEmpty()) { - return Pair.create(refToHighlight, GroovyBundle.message("missed.attributes", StringUtil.join(missedAttrs, ", "))); + return Pair.createNonNull(refToHighlight, GroovyBundle.message("missed.attributes", StringUtil.join(missedAttrs, ", "))); } return null; } - private static Pair checkAnnotationValue(@NotNull PsiClass annotation, + private static Pair.NonNull checkAnnotationValue(@NotNull PsiClass annotation, @NotNull PsiElement identifierToHighlight, @NotNull String name, @NotNull Set usedAttrs, @Nullable GrAnnotationMemberValue value) { if (!usedAttrs.add(name)) { - return Pair.create(identifierToHighlight, GroovyBundle.message("duplicate.attribute")); + return Pair.createNonNull(identifierToHighlight, GroovyBundle.message("duplicate.attribute")); } final PsiMethod[] methods = annotation.findMethodsByName(name, false); if (methods.length == 0) { - return Pair.create(identifierToHighlight, + return Pair.createNonNull(identifierToHighlight, GroovyBundle.message("at.interface.0.does.not.contain.attribute", annotation.getQualifiedName(), name)); } final PsiMethod method = methods[0]; @@ -116,7 +116,7 @@ public abstract class CustomAnnotationChecker { return null; } - public static Pair checkAnnotationValueByType(@NotNull GrAnnotationMemberValue value, + public static Pair.NonNull checkAnnotationValueByType(@NotNull GrAnnotationMemberValue value, @Nullable PsiType ltype, boolean skipArrays) { final GlobalSearchScope resolveScope = value.getResolveScope(); @@ -132,7 +132,7 @@ public abstract class CustomAnnotationChecker { } if (rtype != null && !isAnnoTypeAssignable(ltype, rtype, value, skipArrays)) { - return Pair.create(value, GroovyBundle.message("cannot.assign", rtype.getPresentableText(), ltype.getPresentableText())); + return Pair.createNonNull(value, GroovyBundle.message("cannot.assign", rtype.getPresentableText(), ltype.getPresentableText())); } } @@ -141,7 +141,7 @@ public abstract class CustomAnnotationChecker { if (resolved instanceof PsiClass) { final PsiClassType rtype = JavaPsiFacade.getElementFactory(value.getProject()).createType((PsiClass)resolved, PsiSubstitutor.EMPTY); if (!isAnnoTypeAssignable(ltype, rtype, value, skipArrays)) { - return Pair.create(value, GroovyBundle.message("cannot.assign", rtype.getPresentableText(), ltype.getPresentableText())); + return Pair.createNonNull(value, GroovyBundle.message("cannot.assign", rtype.getPresentableText(), ltype.getPresentableText())); } } } @@ -151,14 +151,14 @@ public abstract class CustomAnnotationChecker { final PsiType componentType = ((PsiArrayType)ltype).getComponentType(); final GrAnnotationMemberValue[] initializers = ((GrAnnotationArrayInitializer)value).getInitializers(); for (GrAnnotationMemberValue initializer : initializers) { - Pair r = checkAnnotationValueByType(initializer, componentType, false); + Pair.NonNull r = checkAnnotationValueByType(initializer, componentType, false); if (r!=null) return r; } } else { final PsiType rtype = TypesUtil.getTupleByAnnotationArrayInitializer((GrAnnotationArrayInitializer)value); if (!isAnnoTypeAssignable(ltype, rtype, value, skipArrays)) { - return Pair.create(value, GroovyBundle.message("cannot.assign", rtype.getPresentableText(), ltype.getPresentableText())); + return Pair.createNonNull(value, GroovyBundle.message("cannot.assign", rtype.getPresentableText(), ltype.getPresentableText())); } } } diff --git a/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/annotator/checkers/TypeCheckedAnnotationChecker.java b/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/annotator/checkers/TypeCheckedAnnotationChecker.java index 38f1012f4f72..08256767d2ec 100644 --- a/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/annotator/checkers/TypeCheckedAnnotationChecker.java +++ b/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/annotator/checkers/TypeCheckedAnnotationChecker.java @@ -44,7 +44,7 @@ public class TypeCheckedAnnotationChecker extends CustomAnnotationChecker { "2.1.0".equals(sdkVersion))) return false; GrAnnotationNameValuePair[] attributes = annotation.getParameterList().getAttributes(); - Pair r = checkAnnotationArguments((PsiClass)resolved, classReference, attributes, false); + Pair.NonNull r = checkAnnotationArguments((PsiClass)resolved, classReference, attributes, false); if (r != null && r.getFirst() != null) { holder.createErrorAnnotation(r.getFirst(), r.getSecond()); } diff --git a/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/annotator/util.kt b/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/annotator/util.kt index 8f7274fd0839..4188c3461ac5 100644 --- a/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/annotator/util.kt +++ b/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/annotator/util.kt @@ -33,7 +33,7 @@ internal fun checkModifierIsNotAllowed(modifierList: GrModifierList, internal fun checkModifierIsNotAllowed(modifierList: GrModifierList, @GrModifierConstant modifier: String, - message: String?, + message: String, holder: AnnotationHolder) { val modifierElement = modifierList.getModifier(modifier) ?: return val annotation = holder.createErrorAnnotation(modifierElement, message) diff --git a/plugins/yaml/src/org/jetbrains/yaml/YAMLBundle.java b/plugins/yaml/src/org/jetbrains/yaml/YAMLBundle.java index 21cd64caa6b3..6d89d0c5714e 100644 --- a/plugins/yaml/src/org/jetbrains/yaml/YAMLBundle.java +++ b/plugins/yaml/src/org/jetbrains/yaml/YAMLBundle.java @@ -13,6 +13,7 @@ import java.util.ResourceBundle; * @author oleg */ public class YAMLBundle { + @NotNull public static String message(@NotNull @PropertyKey(resourceBundle = BUNDLE) String key, @NotNull Object... params) { return CommonBundle.message(getBundle(), key, params); } @@ -27,6 +28,7 @@ public class YAMLBundle { /* * This method added for jruby access */ + @NotNull public static String message(@PropertyKey(resourceBundle = BUNDLE) String key) { return CommonBundle.message(getBundle(), key); } diff --git a/python/rest/src/com/jetbrains/rest/validation/RestAnnotator.java b/python/rest/src/com/jetbrains/rest/validation/RestAnnotator.java index b45708327ba6..55e2f7b75344 100644 --- a/python/rest/src/com/jetbrains/rest/validation/RestAnnotator.java +++ b/python/rest/src/com/jetbrains/rest/validation/RestAnnotator.java @@ -42,7 +42,4 @@ public abstract class RestAnnotator extends RestElementVisitor { } } - protected void markError(PsiElement element, String message) { - getHolder().createErrorAnnotation(element, message); - } } diff --git a/python/src/com/jetbrains/python/PyBundle.java b/python/src/com/jetbrains/python/PyBundle.java index 42a153637b75..e506fd3c8afd 100644 --- a/python/src/com/jetbrains/python/PyBundle.java +++ b/python/src/com/jetbrains/python/PyBundle.java @@ -33,6 +33,7 @@ import java.util.ResourceBundle; */ public class PyBundle { + @NotNull public static String message(@NotNull @PropertyKey(resourceBundle = BUNDLE) String key, @NotNull Object... params) { return CommonBundle.message(getBundle(), key, params); } diff --git a/python/src/com/jetbrains/python/validation/BreakContinueAnnotator.java b/python/src/com/jetbrains/python/validation/BreakContinueAnnotator.java index b1724d5cb767..45505e03c7a1 100644 --- a/python/src/com/jetbrains/python/validation/BreakContinueAnnotator.java +++ b/python/src/com/jetbrains/python/validation/BreakContinueAnnotator.java @@ -15,11 +15,10 @@ */ package com.jetbrains.python.validation; +import com.jetbrains.python.PyPsiBundle; import com.jetbrains.python.psi.PyBreakStatement; import com.jetbrains.python.psi.PyContinueStatement; -import static com.jetbrains.python.PyPsiBundle.message; - /** * Annotates misplaced 'break' and 'continue'. */ @@ -27,14 +26,14 @@ public class BreakContinueAnnotator extends PyAnnotator { @Override public void visitPyBreakStatement(final PyBreakStatement node) { if (node.getLoopStatement() == null) { - getHolder().createErrorAnnotation(node, message("ANN.break.outside.loop")); + getHolder().createErrorAnnotation(node, PyPsiBundle.message("ANN.break.outside.loop")); } } @Override public void visitPyContinueStatement(final PyContinueStatement node) { if (node.getLoopStatement() == null) { - getHolder().createErrorAnnotation(node, message("ANN.continue.outside.loop")); + getHolder().createErrorAnnotation(node, PyPsiBundle.message("ANN.continue.outside.loop")); } } }