GitOrigin-RevId: ae13da6bcf5f32d76be8afde9557bdc1edb9de09
This commit is contained in:
Alexey Kudravtsev
2019-11-20 14:36:40 +00:00
committed by intellij-monorepo-bot
parent be3050c28f
commit 4c18366fd7
14 changed files with 30 additions and 27 deletions
@@ -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;
}
@@ -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);
}
@@ -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);
}
@@ -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);
}
@@ -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);
}
@@ -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<PsiElement, String> 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<PsiElement, String> result = CustomAnnotationChecker.checkAnnotationValueByType(value, type, false);
Pair.NonNull<PsiElement, String> 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)) {
@@ -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<PsiElement, String> r =
Pair.NonNull<PsiElement, String> r =
CustomAnnotationChecker.checkAnnotationArguments(clazz, annotation.getClassReference(), attributes, false);
if (r != null && r.getFirst() != null) {
holder.createErrorAnnotation(r.getFirst(), r.getSecond());
@@ -51,7 +51,7 @@ public abstract class CustomAnnotationChecker {
return null;
}
public static Pair<PsiElement, String> checkAnnotationArguments(@NotNull PsiClass annotation,
public static Pair.NonNull<PsiElement, String> 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<PsiElement, String> r =
Pair.NonNull<PsiElement, String> 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<PsiElement, String> r = checkAnnotationValue(annotation, toHighlight, name, usedAttrs, attribute.getValue());
Pair.NonNull<PsiElement, String> 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<PsiElement, String> checkAnnotationValue(@NotNull PsiClass annotation,
private static Pair.NonNull<PsiElement, String> checkAnnotationValue(@NotNull PsiClass annotation,
@NotNull PsiElement identifierToHighlight,
@NotNull String name,
@NotNull Set<? super String> 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<PsiElement,String> checkAnnotationValueByType(@NotNull GrAnnotationMemberValue value,
public static Pair.NonNull<PsiElement,String> 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<PsiElement, String> r = checkAnnotationValueByType(initializer, componentType, false);
Pair.NonNull<PsiElement, String> 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()));
}
}
}
@@ -44,7 +44,7 @@ public class TypeCheckedAnnotationChecker extends CustomAnnotationChecker {
"2.1.0".equals(sdkVersion))) return false;
GrAnnotationNameValuePair[] attributes = annotation.getParameterList().getAttributes();
Pair<PsiElement, String> r = checkAnnotationArguments((PsiClass)resolved, classReference, attributes, false);
Pair.NonNull<PsiElement, String> r = checkAnnotationArguments((PsiClass)resolved, classReference, attributes, false);
if (r != null && r.getFirst() != null) {
holder.createErrorAnnotation(r.getFirst(), r.getSecond());
}
@@ -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)
@@ -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);
}
@@ -42,7 +42,4 @@ public abstract class RestAnnotator extends RestElementVisitor {
}
}
protected void markError(PsiElement element, String message) {
getHolder().createErrorAnnotation(element, message);
}
}
@@ -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);
}
@@ -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"));
}
}
}