From 4591f890b21345cf84c965828e99ef0771df4b90 Mon Sep 17 00:00:00 2001 From: Sergey Ignatov Date: Mon, 6 Jan 2020 16:55:35 +0300 Subject: [PATCH] unify bundle names: rename java error bundle GitOrigin-RevId: 4da165583299a5a856b369700dc6ee3c21df4d3a --- .../expression/EvaluatorBuilderImpl.java | 5 +- .../analysis/AnnotationsHighlightUtil.java | 88 +++--- .../impl/analysis/ErrorFixExtensionPoint.java | 2 +- .../impl/analysis/GenericsHighlightUtil.java | 107 ++++---- .../impl/analysis/HighlightClassUtil.java | 77 +++--- .../analysis/HighlightControlFlowUtil.java | 23 +- .../impl/analysis/HighlightMethodUtil.java | 147 +++++----- .../daemon/impl/analysis/HighlightUtil.java | 252 +++++++++--------- .../impl/analysis/HighlightVisitorImpl.java | 22 +- .../impl/analysis/ModuleHighlightUtil.java | 63 ++--- .../analysis/PostHighlightingVisitor.java | 24 +- .../NumericOverflowInspection.java | 4 +- .../AccessStaticViaInstanceBase.java | 13 +- .../JavacQuirksInspectionVisitor.java | 8 +- .../DeprecatedApiUsageProcessor.java | 10 +- .../DeprecationInspectionBase.java | 6 +- ...ndantThrowsDeclarationLocalInspection.java | 4 +- .../analysis/JavaErrorQuickFixProvider.java | 6 +- .../impl/quickfix/CreateFromUsageUtils.java | 4 +- .../RecordConstructorChooserDialog.java | 6 +- ...vaLangInvokeHandleSignatureInspection.java | 8 +- .../SuspiciousNameCombinationInspection.java | 4 +- .../UncheckedWarningLocalInspection.java | 35 +-- .../WrongPackageStatementInspection.java | 10 +- .../psi/impl/JavaPlatformModuleSystem.kt | 21 +- .../impl/providers/JavaClassReferenceSet.java | 6 +- .../impl/providers/PsiPackageReference.java | 4 +- .../codeInsight/daemon/JavaErrorBundle.java | 38 +++ .../codeInsight/daemon/JavaErrorMessages.java | 39 +-- .../lang/java/parser/DeclarationParser.java | 74 ++--- .../lang/java/parser/ExpressionParser.java | 56 ++-- .../intellij/lang/java/parser/FileParser.java | 8 +- .../lang/java/parser/JShellParser.java | 4 +- .../lang/java/parser/JavaParserUtil.java | 12 +- .../lang/java/parser/ModuleParser.java | 40 +-- .../lang/java/parser/ReferenceParser.java | 34 +-- .../lang/java/parser/StatementParser.java | 72 ++--- .../psi/controlFlow/ControlFlowAnalyzer.java | 4 +- .../PsiImportStaticReferenceElementImpl.java | 5 +- .../source/javadoc/ClassReferenceTagInfo.java | 6 +- .../impl/source/javadoc/ExceptionTagInfo.java | 6 +- .../impl/source/javadoc/ParamDocTagInfo.java | 8 +- .../impl/source/javadoc/ValueDocTagInfo.java | 10 +- ....properties => JavaErrorBundle.properties} | 0 .../header/impl/ClassReferenceParser.java | 4 +- .../ChangeClassParametersIntention.java | 8 +- .../jdk/ForwardCompatibilityInspection.java | 16 +- .../checkers/CustomAnnotationChecker.java | 6 +- .../checkers/FieldAnnotationChecker.java | 6 +- 49 files changed, 725 insertions(+), 690 deletions(-) create mode 100644 java/java-psi-impl/src/com/intellij/codeInsight/daemon/JavaErrorBundle.java rename java/java-psi-impl/src/messages/{JavaErrorMessages.properties => JavaErrorBundle.properties} (100%) diff --git a/java/debugger/impl/src/com/intellij/debugger/engine/evaluation/expression/EvaluatorBuilderImpl.java b/java/debugger/impl/src/com/intellij/debugger/engine/evaluation/expression/EvaluatorBuilderImpl.java index 70f9881cc289..27e8ee9330c7 100644 --- a/java/debugger/impl/src/com/intellij/debugger/engine/evaluation/expression/EvaluatorBuilderImpl.java +++ b/java/debugger/impl/src/com/intellij/debugger/engine/evaluation/expression/EvaluatorBuilderImpl.java @@ -6,7 +6,7 @@ */ package com.intellij.debugger.engine.evaluation.expression; -import com.intellij.codeInsight.daemon.JavaErrorMessages; +import com.intellij.codeInsight.daemon.JavaErrorBundle; import com.intellij.codeInsight.daemon.impl.HighlightInfo; import com.intellij.codeInsight.daemon.impl.analysis.HighlightUtil; import com.intellij.codeInsight.daemon.impl.analysis.JavaHighlightUtil; @@ -1208,7 +1208,8 @@ public class EvaluatorBuilderImpl implements EvaluatorBuilder { !TypeConversionUtil.areTypesConvertible(operandType, castType) && PsiUtil.resolveClassInType(operandType) != null) { throw new EvaluateRuntimeException( - new EvaluateException(JavaErrorMessages.message("inconvertible.type.cast", JavaHighlightUtil.formatType(operandType), JavaHighlightUtil + new EvaluateException( + JavaErrorBundle.message("inconvertible.type.cast", JavaHighlightUtil.formatType(operandType), JavaHighlightUtil .formatType(castType))) ); } diff --git a/java/java-analysis-impl/src/com/intellij/codeInsight/daemon/impl/analysis/AnnotationsHighlightUtil.java b/java/java-analysis-impl/src/com/intellij/codeInsight/daemon/impl/analysis/AnnotationsHighlightUtil.java index a4ddde1b57aa..4216d6a24da0 100644 --- a/java/java-analysis-impl/src/com/intellij/codeInsight/daemon/impl/analysis/AnnotationsHighlightUtil.java +++ b/java/java-analysis-impl/src/com/intellij/codeInsight/daemon/impl/analysis/AnnotationsHighlightUtil.java @@ -2,7 +2,7 @@ package com.intellij.codeInsight.daemon.impl.analysis; import com.intellij.codeInsight.AnnotationTargetUtil; -import com.intellij.codeInsight.daemon.JavaErrorMessages; +import com.intellij.codeInsight.daemon.JavaErrorBundle; import com.intellij.codeInsight.daemon.impl.HighlightInfo; import com.intellij.codeInsight.daemon.impl.HighlightInfoType; import com.intellij.codeInsight.daemon.impl.quickfix.QuickFixAction; @@ -60,7 +60,7 @@ public class AnnotationsHighlightUtil { } if (method == null) { if (pair.getName() != null) { - final String description = JavaErrorMessages.message("annotation.unknown.method", ref.getCanonicalText()); + final String description = JavaErrorBundle.message("annotation.unknown.method", ref.getCanonicalText()); final HighlightInfo highlightInfo = HighlightInfo.newHighlightInfo(HighlightInfoType.WRONG_REF) .range(ref.getElement(), ref.getRangeInElement()) .descriptionAndTooltip(description) @@ -69,7 +69,7 @@ public class AnnotationsHighlightUtil { return highlightInfo; } else { - String description = JavaErrorMessages.message("annotation.missing.method", ref.getCanonicalText()); + String description = JavaErrorBundle.message("annotation.missing.method", ref.getCanonicalText()); PsiElement element = ref.getElement(); final HighlightInfo highlightInfo = HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(element).descriptionAndTooltip(description).create(); @@ -99,7 +99,7 @@ public class AnnotationsHighlightUtil { if (attribute == pair) break; String name = pair.getName(); if (Comparing.equal(attribute.getName(), name)) { - String description = JavaErrorMessages.message("annotation.duplicate.attribute", + String description = JavaErrorBundle.message("annotation.duplicate.attribute", name == null ? PsiAnnotation.DEFAULT_REFERENCED_METHOD_NAME : name); return HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(pair).descriptionAndTooltip(description).create(); } @@ -111,7 +111,7 @@ public class AnnotationsHighlightUtil { static HighlightInfo checkMemberValueType(@NotNull PsiAnnotationMemberValue value, @NotNull PsiType expectedType) { if (expectedType instanceof PsiClassType && expectedType.equalsToText(CommonClassNames.JAVA_LANG_CLASS)) { if (!(value instanceof PsiClassObjectAccessExpression)) { - String description = JavaErrorMessages.message("annotation.non.class.literal.attribute.value"); + String description = JavaErrorBundle.message("annotation.non.class.literal.attribute.value"); return HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(value).descriptionAndTooltip(description).create(); } } @@ -133,14 +133,14 @@ public class AnnotationsHighlightUtil { } } - String description = JavaErrorMessages.message("incompatible.types", JavaHighlightUtil.formatType(expectedType), - nameRef.getCanonicalText()); + String description = JavaErrorBundle.message("incompatible.types", JavaHighlightUtil.formatType(expectedType), + nameRef.getCanonicalText()); return HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(value).descriptionAndTooltip(description).create(); } if (value instanceof PsiArrayInitializerMemberValue) { if (expectedType instanceof PsiArrayType) return null; - String description = JavaErrorMessages.message("annotation.illegal.array.initializer", JavaHighlightUtil.formatType(expectedType)); + String description = JavaErrorBundle.message("annotation.illegal.array.initializer", JavaHighlightUtil.formatType(expectedType)); return HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(value).descriptionAndTooltip(description).create(); } @@ -150,7 +150,7 @@ public class AnnotationsHighlightUtil { final PsiClass psiClass = PsiUtil.resolveClassInType(type); if (psiClass != null && psiClass.isEnum() && !(expr instanceof PsiReferenceExpression && ((PsiReferenceExpression)expr).resolve() instanceof PsiEnumConstant)) { - String description = JavaErrorMessages.message("annotation.non.enum.constant.attribute.value"); + String description = JavaErrorBundle.message("annotation.non.enum.constant.attribute.value"); return HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(value).descriptionAndTooltip(description).create(); } @@ -160,7 +160,8 @@ public class AnnotationsHighlightUtil { return null; } - String description = JavaErrorMessages.message("incompatible.types", JavaHighlightUtil.formatType(expectedType), JavaHighlightUtil.formatType(type)); + String description = JavaErrorBundle + .message("incompatible.types", JavaHighlightUtil.formatType(expectedType), JavaHighlightUtil.formatType(type)); HighlightInfo info = HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(value).descriptionAndTooltip(description).create(); QuickFixAction.registerQuickFixAction(info, QuickFixFactory.getInstance().createSurroundWithQuotesAnnotationParameterValueFix(value, expectedType)); return info; @@ -187,20 +188,20 @@ public class AnnotationsHighlightUtil { if (containedElementFQN != null) { String containerName = annotationType.getQualifiedName(); if (isAnnotationRepeatedTwice(owner, containedElementFQN)) { - String description = JavaErrorMessages.message("annotation.container.wrong.place", containerName); + String description = JavaErrorBundle.message("annotation.container.wrong.place", containerName); return annotationError(annotationToCheck, description); } } else if (isAnnotationRepeatedTwice(owner, annotationType.getQualifiedName())) { if (!languageLevel.isAtLeast(LanguageLevel.JDK_1_8)) { - String description = JavaErrorMessages.message("annotation.duplicate.annotation"); + String description = JavaErrorBundle.message("annotation.duplicate.annotation"); return HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(element).descriptionAndTooltip(description).create(); } PsiAnnotation metaAnno = PsiImplUtil.findAnnotation(annotationType.getModifierList(), CommonClassNames.JAVA_LANG_ANNOTATION_REPEATABLE); if (metaAnno == null) { - String explanation = JavaErrorMessages.message("annotation.non.repeatable", annotationType.getQualifiedName()); - String description = JavaErrorMessages.message("annotation.duplicate.explained", explanation); + String explanation = JavaErrorBundle.message("annotation.non.repeatable", annotationType.getQualifiedName()); + String description = JavaErrorBundle.message("annotation.duplicate.explained", explanation); HighlightInfo info = HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(element).descriptionAndTooltip(description).create(); QuickFixAction.registerQuickFixAction(info, QuickFixFactory.getInstance().createCollapseAnnotationsFix(annotationToCheck)); @@ -209,7 +210,7 @@ public class AnnotationsHighlightUtil { String explanation = doCheckRepeatableAnnotation(metaAnno); if (explanation != null) { - String description = JavaErrorMessages.message("annotation.duplicate.explained", explanation); + String description = JavaErrorBundle.message("annotation.duplicate.explained", explanation); return HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(element).descriptionAndTooltip(description).create(); } @@ -218,8 +219,8 @@ public class AnnotationsHighlightUtil { PsiAnnotation.TargetType[] targets = AnnotationTargetUtil.getTargetsForLocation(owner); PsiAnnotation.TargetType applicable = AnnotationTargetUtil.findAnnotationTarget(container, targets); if (applicable == null) { - String target = JavaErrorMessages.message("annotation.target." + targets[0]); - String message = JavaErrorMessages.message("annotation.container.not.applicable", container.getName(), target); + String target = JavaErrorBundle.message("annotation.target." + targets[0]); + String message = JavaErrorBundle.message("annotation.container.not.applicable", container.getName(), target); return annotationError(annotationToCheck, message); } } @@ -294,7 +295,7 @@ public class AnnotationsHighlightUtil { buff.append("'").append(missed.get(i)).append("'"); } - String description = JavaErrorMessages.message("annotation.missing.attribute", buff); + String description = JavaErrorBundle.message("annotation.missing.attribute", buff); HighlightInfo info = HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(nameRef).descriptionAndTooltip(description).create(); IntentionAction fix = QuickFixFactory.getInstance().createAddMissingRequiredAnnotationParametersFix( @@ -311,7 +312,7 @@ public class AnnotationsHighlightUtil { final PsiElement parent = expression.getParent(); if (PsiUtil.isAnnotationMethod(parent) || parent instanceof PsiNameValuePair || parent instanceof PsiArrayInitializerMemberValue) { if (!PsiUtil.isConstantExpression(expression)) { - String description = JavaErrorMessages.message("annotation.non.constant.attribute.value"); + String description = JavaErrorBundle.message("annotation.non.constant.attribute.value"); return HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(expression).descriptionAndTooltip(description).create(); } } @@ -323,7 +324,8 @@ public class AnnotationsHighlightUtil { if (type != null && type.accept(AnnotationReturnTypeVisitor.INSTANCE).booleanValue()) { return null; } - String description = JavaErrorMessages.message("annotation.invalid.annotation.member.type", type != null ? type.getPresentableText() : null); + String description = JavaErrorBundle + .message("annotation.invalid.annotation.member.type", type != null ? type.getPresentableText() : null); return HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(typeElement).descriptionAndTooltip(description).create(); } @@ -345,7 +347,7 @@ public class AnnotationsHighlightUtil { PsiAnnotationOwner owner = annotation.getOwner(); PsiAnnotation.TargetType[] targets = AnnotationTargetUtil.getTargetsForLocation(owner); if (owner == null || targets.length == 0) { - String message = JavaErrorMessages.message("annotation.not.allowed.here"); + String message = JavaErrorBundle.message("annotation.not.allowed.here"); return annotationError(annotation, message); } @@ -358,8 +360,8 @@ public class AnnotationsHighlightUtil { if (applicable == PsiAnnotation.TargetType.UNKNOWN) return null; if (applicable == null) { - String target = JavaErrorMessages.message("annotation.target." + targets[0]); - String message = JavaErrorMessages.message("annotation.not.applicable", nameRef.getText(), target); + String target = JavaErrorBundle.message("annotation.target." + targets[0]); + String message = JavaErrorBundle.message("annotation.not.applicable", nameRef.getText(), target); return annotationError(annotation, message); } @@ -377,7 +379,7 @@ public class AnnotationsHighlightUtil { PsiTypeElement typeElement = (PsiTypeElement)nextElement; PsiType type = typeElement.getType(); if (PsiType.VOID.equals(type)) { - String message = JavaErrorMessages.message("annotation.not.allowed.void"); + String message = JavaErrorBundle.message("annotation.not.allowed.void"); return annotationError(annotation, message); } if (!(type instanceof PsiPrimitiveType || type instanceof PsiArrayType)) { @@ -387,7 +389,7 @@ public class AnnotationsHighlightUtil { } PsiElement context = PsiTreeUtil.skipParentsOfType(typeElement, PsiTypeElement.class); if (context instanceof PsiClassObjectAccessExpression) { - String message = JavaErrorMessages.message("annotation.not.allowed.class"); + String message = JavaErrorBundle.message("annotation.not.allowed.class"); return annotationError(annotation, message); } } @@ -410,14 +412,14 @@ public class AnnotationsHighlightUtil { String message = null; if (!(refTarget instanceof PsiClass)) { - message = JavaErrorMessages.message("annotation.not.allowed.ref"); + message = JavaErrorBundle.message("annotation.not.allowed.ref"); } else { PsiElement parent = ref.getParent(); if (parent instanceof PsiJavaCodeReferenceElement) { PsiElement qualified = ((PsiJavaCodeReferenceElement)parent).resolve(); if (qualified instanceof PsiMember && ((PsiMember)qualified).hasModifierProperty(PsiModifier.STATIC)) { - message = JavaErrorMessages.message("annotation.not.allowed.static"); + message = JavaErrorBundle.message("annotation.not.allowed.static"); } } } @@ -441,7 +443,7 @@ public class AnnotationsHighlightUtil { if (nameReferenceElement != null) { PsiElement resolved = nameReferenceElement.resolve(); if (!(resolved instanceof PsiClass) || !((PsiClass)resolved).isAnnotationType()) { - String description = JavaErrorMessages.message("annotation.annotation.type.expected"); + String description = JavaErrorBundle.message("annotation.annotation.type.expected"); return HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(nameReferenceElement).descriptionAndTooltip(description).create(); } } @@ -452,7 +454,7 @@ public class AnnotationsHighlightUtil { PsiType type = typeElement.getType(); Set checked = new HashSet<>(); if (cyclicDependencies(aClass, type, checked, aClass.getManager())) { - String description = JavaErrorMessages.message("annotation.cyclic.element.type"); + String description = JavaErrorBundle.message("annotation.cyclic.element.type"); return HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(typeElement).descriptionAndTooltip(description).create(); } return null; @@ -498,13 +500,13 @@ public class AnnotationsHighlightUtil { if (PsiUtil.isAnnotationMethod(parent)) { PsiAnnotationMethod method = (PsiAnnotationMethod)parent; if (list == method.getThrowsList()) { - String description = JavaErrorMessages.message("annotation.members.may.not.have.throws.list"); + String description = JavaErrorBundle.message("annotation.members.may.not.have.throws.list"); return HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(list).descriptionAndTooltip(description).create(); } } else if (parent instanceof PsiClass && ((PsiClass)parent).isAnnotationType()) { if (PsiKeyword.EXTENDS.equals(list.getFirstChild().getText())) { - String description = JavaErrorMessages.message("annotation.may.not.have.extends.list"); + String description = JavaErrorBundle.message("annotation.may.not.have.extends.list"); return HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(list).descriptionAndTooltip(description).create(); } } @@ -514,7 +516,7 @@ public class AnnotationsHighlightUtil { static HighlightInfo checkPackageAnnotationContainingFile(@NotNull PsiPackageStatement statement, @NotNull PsiFile file) { PsiModifierList annotationList = statement.getAnnotationList(); if (annotationList != null && !PsiPackage.PACKAGE_INFO_FILE.equals(file.getName())) { - String message = JavaErrorMessages.message("invalid.package.annotation.containing.file"); + String message = JavaErrorBundle.message("invalid.package.annotation.containing.file"); return HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(annotationList).descriptionAndTooltip(message).create(); } return null; @@ -540,7 +542,7 @@ public class AnnotationsHighlightUtil { PsiElement target = ((PsiReferenceExpression) initializer).resolve(); if (target != null) { if (targets.contains(target)) { - String description = JavaErrorMessages.message("repeated.annotation.target"); + String description = JavaErrorBundle.message("repeated.annotation.target"); return HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(initializer).descriptionAndTooltip(description).create(); } targets.add(target); @@ -591,13 +593,13 @@ public class AnnotationsHighlightUtil { PsiMethod[] methods = container.findMethodsByName("value", false); if (methods.length == 0) { - return JavaErrorMessages.message("annotation.container.no.value", container.getQualifiedName()); + return JavaErrorBundle.message("annotation.container.no.value", container.getQualifiedName()); } if (methods.length == 1) { PsiType expected = new PsiImmediateClassType((PsiClass)target, PsiSubstitutor.EMPTY).createArrayType(); if (!expected.equals(methods[0].getReturnType())) { - return JavaErrorMessages.message("annotation.container.bad.type", container.getQualifiedName(), JavaHighlightUtil.formatType(expected)); + return JavaErrorBundle.message("annotation.container.bad.type", container.getQualifiedName(), JavaHighlightUtil.formatType(expected)); } } @@ -605,7 +607,7 @@ public class AnnotationsHighlightUtil { if (targetPolicy != null) { RetentionPolicy containerPolicy = getRetentionPolicy(container); if (containerPolicy != null && targetPolicy.compareTo(containerPolicy) > 0) { - return JavaErrorMessages.message("annotation.container.low.retention", container.getQualifiedName(), containerPolicy); + return JavaErrorBundle.message("annotation.container.low.retention", container.getQualifiedName(), containerPolicy); } } @@ -613,13 +615,13 @@ public class AnnotationsHighlightUtil { if (repeatableTargets != null) { Set containerTargets = AnnotationTargetUtil.getAnnotationTargets(container); if (containerTargets != null && !repeatableTargets.containsAll(containerTargets)) { - return JavaErrorMessages.message("annotation.container.wide.target", container.getQualifiedName()); + return JavaErrorBundle.message("annotation.container.wide.target", container.getQualifiedName()); } } for (PsiMethod method : container.getMethods()) { if (method instanceof PsiAnnotationMethod && !"value".equals(method.getName()) && ((PsiAnnotationMethod)method).getDefaultValue() == null) { - return JavaErrorMessages.message("annotation.container.abstract", container.getQualifiedName(), method.getName()); + return JavaErrorBundle.message("annotation.container.abstract", container.getQualifiedName(), method.getName()); } } @@ -642,19 +644,19 @@ public class AnnotationsHighlightUtil { if (owner == null) return null; if (!(owner instanceof PsiMethod)) { - String text = JavaErrorMessages.message("receiver.wrong.context"); + String text = JavaErrorBundle.message("receiver.wrong.context"); return HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(parameter.getIdentifier()).descriptionAndTooltip(text).create(); } PsiMethod method = (PsiMethod)owner; if (isStatic(method) || method.isConstructor() && isStatic(method.getContainingClass())) { - String text = JavaErrorMessages.message("receiver.static.context"); + String text = JavaErrorBundle.message("receiver.static.context"); return HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(parameter.getIdentifier()).descriptionAndTooltip(text).create(); } PsiElement leftNeighbour = PsiTreeUtil.skipWhitespacesBackward(parameter); if (leftNeighbour != null && !PsiUtil.isJavaToken(leftNeighbour, JavaTokenType.LPARENTH)) { - String text = JavaErrorMessages.message("receiver.wrong.position"); + String text = JavaErrorBundle.message("receiver.wrong.position"); return HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(parameter.getIdentifier()).descriptionAndTooltip(text).create(); } @@ -675,13 +677,13 @@ public class AnnotationsHighlightUtil { PsiClassType type = PsiElementFactory.getInstance(parameter.getProject()).createType(enclosingClass, PsiSubstitutor.EMPTY); if (!type.equals(parameter.getType())) { PsiElement range = ObjectUtils.notNull(parameter.getTypeElement(), parameter); - String text = JavaErrorMessages.message("receiver.type.mismatch"); + String text = JavaErrorBundle.message("receiver.type.mismatch"); return HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(range).descriptionAndTooltip(text).create(); } PsiThisExpression identifier = parameter.getIdentifier(); if (!enclosingClass.equals(PsiUtil.resolveClassInType(identifier.getType()))) { - String text = JavaErrorMessages.message("receiver.name.mismatch"); + String text = JavaErrorBundle.message("receiver.name.mismatch"); return HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(identifier).descriptionAndTooltip(text).create(); } } diff --git a/java/java-analysis-impl/src/com/intellij/codeInsight/daemon/impl/analysis/ErrorFixExtensionPoint.java b/java/java-analysis-impl/src/com/intellij/codeInsight/daemon/impl/analysis/ErrorFixExtensionPoint.java index f221f42a8798..d6b94c0c7d0b 100644 --- a/java/java-analysis-impl/src/com/intellij/codeInsight/daemon/impl/analysis/ErrorFixExtensionPoint.java +++ b/java/java-analysis-impl/src/com/intellij/codeInsight/daemon/impl/analysis/ErrorFixExtensionPoint.java @@ -34,7 +34,7 @@ import java.lang.reflect.InvocationTargetException; import java.util.List; import java.util.Map; -import static com.intellij.codeInsight.daemon.JavaErrorMessages.BUNDLE; +import static com.intellij.codeInsight.daemon.JavaErrorBundle.BUNDLE; public class ErrorFixExtensionPoint extends AbstractExtensionPointBean { public static final ExtensionPointName ERROR_FIX_EXTENSION_POINT = diff --git a/java/java-analysis-impl/src/com/intellij/codeInsight/daemon/impl/analysis/GenericsHighlightUtil.java b/java/java-analysis-impl/src/com/intellij/codeInsight/daemon/impl/analysis/GenericsHighlightUtil.java index ca8e461928e6..e8d1ddbfd099 100644 --- a/java/java-analysis-impl/src/com/intellij/codeInsight/daemon/impl/analysis/GenericsHighlightUtil.java +++ b/java/java-analysis-impl/src/com/intellij/codeInsight/daemon/impl/analysis/GenericsHighlightUtil.java @@ -1,7 +1,7 @@ // Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. package com.intellij.codeInsight.daemon.impl.analysis; -import com.intellij.codeInsight.daemon.JavaErrorMessages; +import com.intellij.codeInsight.daemon.JavaErrorBundle; import com.intellij.codeInsight.daemon.impl.HighlightInfo; import com.intellij.codeInsight.daemon.impl.HighlightInfoType; import com.intellij.codeInsight.daemon.impl.quickfix.QuickFixAction; @@ -63,7 +63,7 @@ public class GenericsHighlightUtil { ? "generics.inferred.type.for.type.parameter.is.not.within.its.bound.extend" : "generics.inferred.type.for.type.parameter.is.not.within.its.bound.implement"; - String description = JavaErrorMessages.message( + String description = JavaErrorBundle.message( messageKey, HighlightUtil.formatClass(typeParameter), JavaHighlightUtil.formatType(extendsType), @@ -95,7 +95,7 @@ public class GenericsHighlightUtil { referenceElements = referenceParameterList.getTypeParameterElements(); if (referenceElements.length == 1 && referenceElements[0].getType() instanceof PsiDiamondType) { if (!typeParameterListOwner.hasTypeParameters()) { - final String description = JavaErrorMessages.message("generics.diamond.not.applicable"); + final String description = JavaErrorBundle.message("generics.diamond.not.applicable"); return HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(referenceParameterList).descriptionAndTooltip(description).create(); } inferenceResult = ((PsiDiamondType)referenceElements[0].getType()).resolveInferredTypes(); @@ -127,7 +127,7 @@ public class GenericsHighlightUtil { description = null; } else { - description = JavaErrorMessages.message( + description = JavaErrorBundle.message( "generics.type.or.method.does.not.have.type.parameters", typeParameterListOwnerCategoryDescription(typeParameterListOwner), typeParameterListOwnerDescription(typeParameterListOwner) @@ -135,7 +135,7 @@ public class GenericsHighlightUtil { } } else { - description = JavaErrorMessages.message("generics.wrong.number.of.type.arguments", refParametersNum, targetParametersNum); + description = JavaErrorBundle.message("generics.wrong.number.of.type.arguments", refParametersNum, targetParametersNum); } if (description != null) { @@ -253,9 +253,9 @@ public class GenericsHighlightUtil { ? "generics.type.parameter.is.not.within.its.bound.extend" : "generics.type.parameter.is.not.within.its.bound.implement"; - String description = JavaErrorMessages.message(messageKey, + String description = JavaErrorBundle.message(messageKey, referenceClass != null ? HighlightUtil.formatClass(referenceClass) : type.getPresentableText(), - JavaHighlightUtil.formatType(bound)); + JavaHighlightUtil.formatType(bound)); final HighlightInfo info = HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(typeElement2Highlight).descriptionAndTooltip(description).create(); @@ -287,10 +287,10 @@ public class GenericsHighlightUtil { @NotNull private static String typeParameterListOwnerCategoryDescription(@NotNull PsiTypeParameterListOwner typeParameterListOwner) { if (typeParameterListOwner instanceof PsiClass) { - return JavaErrorMessages.message("generics.holder.type"); + return JavaErrorBundle.message("generics.holder.type"); } else if (typeParameterListOwner instanceof PsiMethod) { - return JavaErrorMessages.message("generics.holder.method"); + return JavaErrorBundle.message("generics.holder.method"); } else { LOG.error("Unknown " + typeParameterListOwner); @@ -307,14 +307,14 @@ public class GenericsHighlightUtil { if (extendFrom == null) return null; HighlightInfo errorResult = null; if (!extendFrom.isInterface() && referenceElements.length != 0 && element != referenceElements[0]) { - String description = JavaErrorMessages.message("interface.expected"); + String description = JavaErrorBundle.message("interface.expected"); errorResult = HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(element).descriptionAndTooltip(description).create(); PsiClassType type = JavaPsiFacade.getElementFactory(aClass.getProject()).createType(extendFrom, resolveResult.getSubstitutor()); QuickFixAction.registerQuickFixAction(errorResult, QUICK_FIX_FACTORY.createMoveBoundClassToFrontFix(aClass, type), null); } else if (referenceElements.length != 0 && element != referenceElements[0] && referenceElements[0].resolve() instanceof PsiTypeParameter) { - final String description = JavaErrorMessages.message("type.parameter.cannot.be.followed.by.other.bounds"); + final String description = JavaErrorBundle.message("type.parameter.cannot.be.followed.by.other.bounds"); errorResult = HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(element).descriptionAndTooltip(description).create(); PsiClassType type = JavaPsiFacade.getElementFactory(aClass.getProject()).createType(extendFrom, resolveResult.getSubstitutor()); @@ -356,10 +356,10 @@ public class GenericsHighlightUtil { PsiType type2 = superTypeSubstitutor.substitute(typeParameter); if (!Comparing.equal(type1, type2)) { - String description = JavaErrorMessages.message("generics.cannot.be.inherited.with.different.type.arguments", - HighlightUtil.formatClass(superClass), - JavaHighlightUtil.formatType(type1), - JavaHighlightUtil.formatType(type2)); + String description = JavaErrorBundle.message("generics.cannot.be.inherited.with.different.type.arguments", + HighlightUtil.formatClass(superClass), + JavaHighlightUtil.formatType(type1), + JavaHighlightUtil.formatType(type2)); return HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(textRange).descriptionAndTooltip(description).create(); } } @@ -469,8 +469,9 @@ public class GenericsHighlightUtil { } final String key = aClass instanceof PsiEnumConstantInitializer || aClass.isRecord() ? "class.must.implement.method" : "class.must.be.abstract"; - final String message = JavaErrorMessages.message(key, HighlightUtil.formatClass(aClass, false), JavaHighlightUtil.formatMethod(abstracts.get(0)), - HighlightUtil.formatClass(unrelatedMethodContainingClass, false)); + final String message = JavaErrorBundle + .message(key, HighlightUtil.formatClass(aClass, false), JavaHighlightUtil.formatMethod(abstracts.get(0)), + HighlightUtil.formatClass(unrelatedMethodContainingClass, false)); final HighlightInfo info = HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(classIdentifier).descriptionAndTooltip(message).create(); QuickFixAction.registerQuickFixAction(info, QUICK_FIX_FACTORY.createImplementMethodsFix(aClass)); return info; @@ -683,7 +684,7 @@ public class GenericsHighlightUtil { method.hasModifierProperty(PsiModifier.STATIC) ? "generics.methods.have.same.erasure.hide" : "generics.methods.have.same.erasure.override"; - String description = JavaErrorMessages.message(key, HighlightMethodUtil.createClashMethodMessage(method, superMethod, !sameClass)); + String description = JavaErrorBundle.message(key, HighlightMethodUtil.createClashMethodMessage(method, superMethod, !sameClass)); HighlightInfo info = HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(textRange).descriptionAndTooltip(description).create(); QuickFixAction.registerQuickFixAction(info, QUICK_FIX_FACTORY.createSameErasureButDifferentMethodsFix(method, superMethod)); @@ -697,8 +698,8 @@ public class GenericsHighlightUtil { final JavaResolveResult result = classReference.advancedResolve(false); final PsiElement element = result.getElement(); if (element instanceof PsiTypeParameter) { - String description = JavaErrorMessages.message("generics.type.parameter.cannot.be.instantiated", - HighlightUtil.formatClass((PsiTypeParameter)element)); + String description = JavaErrorBundle.message("generics.type.parameter.cannot.be.instantiated", + HighlightUtil.formatClass((PsiTypeParameter)element)); return HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(classReference).descriptionAndTooltip(description).create(); } return null; @@ -715,20 +716,20 @@ public class GenericsHighlightUtil { if (refParent instanceof PsiNewExpression) { PsiNewExpression newExpression = (PsiNewExpression)refParent; if (!(newExpression.getType() instanceof PsiArrayType)) { - String description = JavaErrorMessages.message("wildcard.type.cannot.be.instantiated", JavaHighlightUtil.formatType(type)); + String description = JavaErrorBundle.message("wildcard.type.cannot.be.instantiated", JavaHighlightUtil.formatType(type)); return HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(typeElement).descriptionAndTooltip(description).create(); } } else if (refParent instanceof PsiReferenceList) { PsiElement refPParent = refParent.getParent(); if (!(refPParent instanceof PsiTypeParameter) || refParent != ((PsiTypeParameter)refPParent).getExtendsList()) { - String description = JavaErrorMessages.message("generics.wildcard.not.expected"); + String description = JavaErrorBundle.message("generics.wildcard.not.expected"); return HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(typeElement).descriptionAndTooltip(description).create(); } } } else { - String description = JavaErrorMessages.message("generics.wildcards.may.be.used.only.as.reference.parameters"); + String description = JavaErrorBundle.message("generics.wildcards.may.be.used.only.as.reference.parameters"); return HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(typeElement).descriptionAndTooltip(description).create(); } } @@ -748,7 +749,7 @@ public class GenericsHighlightUtil { if (level.isAtLeast(LanguageLevel.JDK_X)) return null; - String text = JavaErrorMessages.message("generics.type.argument.cannot.be.of.primitive.type"); + String text = JavaErrorBundle.message("generics.type.argument.cannot.be.of.primitive.type"); HighlightInfo highlightInfo = HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(typeElement).descriptionAndTooltip(text).create(); PsiType toConvert = type; @@ -772,8 +773,8 @@ public class GenericsHighlightUtil { if (expression.getType() == null) return null; final PsiType itemType = JavaGenericsUtil.getCollectionItemType(expression); if (itemType == null) { - String description = JavaErrorMessages.message("foreach.not.applicable", - JavaHighlightUtil.formatType(expression.getType())); + String description = JavaErrorBundle.message("foreach.not.applicable", + JavaHighlightUtil.formatType(expression.getType())); final HighlightInfo highlightInfo = HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(expression).descriptionAndTooltip(description).create(); QuickFixAction.registerQuickFixAction(highlightInfo, QUICK_FIX_FACTORY.createNotIterableForEachLoopFix(expression)); return highlightInfo; @@ -821,7 +822,7 @@ public class GenericsHighlightUtil { if (PsiUtil.isCompileTimeConstant((PsiVariable)field)) return null; - String description = JavaErrorMessages.message( + String description = JavaErrorBundle.message( "illegal.to.access.static.member.from.enum.constructor.or.instance.initializer", HighlightMessageUtil.getSymbolName(resolved, result.getSubstitutor()) ); @@ -832,7 +833,7 @@ public class GenericsHighlightUtil { static HighlightInfo checkEnumInstantiation(@NotNull PsiElement expression, @Nullable PsiClass aClass) { if (aClass != null && aClass.isEnum() && !(expression instanceof PsiNewExpression && ((PsiNewExpression)expression).isArrayCreation())) { - String description = JavaErrorMessages.message("enum.types.cannot.be.instantiated"); + String description = JavaErrorBundle.message("enum.types.cannot.be.instantiated"); return HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(expression).descriptionAndTooltip(description).create(); } return null; @@ -841,12 +842,12 @@ public class GenericsHighlightUtil { static HighlightInfo checkGenericArrayCreation(@NotNull PsiElement element, @Nullable PsiType type) { if (type instanceof PsiArrayType) { if (!JavaGenericsUtil.isReifiableType(((PsiArrayType)type).getComponentType())) { - String description = JavaErrorMessages.message("generic.array.creation"); + String description = JavaErrorBundle.message("generic.array.creation"); return HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(element).descriptionAndTooltip(description).create(); } if (element instanceof PsiNewExpression && ((PsiNewExpression)element).getTypeArguments().length > 0) { - String description = JavaErrorMessages.message("array.creation.with.type.arguments"); + String description = JavaErrorBundle.message("array.creation.with.type.arguments"); return HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(element).descriptionAndTooltip(description).create(); } } @@ -870,15 +871,15 @@ public class GenericsHighlightUtil { static HighlightInfo checkTypeParametersList(@NotNull PsiTypeParameterList list, @NotNull PsiTypeParameter[] parameters, @NotNull LanguageLevel level) { final PsiElement parent = list.getParent(); if (parent instanceof PsiClass && ((PsiClass)parent).isEnum()) { - String description = JavaErrorMessages.message("generics.enum.may.not.have.type.parameters"); + String description = JavaErrorBundle.message("generics.enum.may.not.have.type.parameters"); return HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(list).descriptionAndTooltip(description).create(); } if (PsiUtil.isAnnotationMethod(parent)) { - String description = JavaErrorMessages.message("generics.annotation.members.may.not.have.type.parameters"); + String description = JavaErrorBundle.message("generics.annotation.members.may.not.have.type.parameters"); return HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(list).descriptionAndTooltip(description).create(); } if (parent instanceof PsiClass && ((PsiClass)parent).isAnnotationType()) { - String description = JavaErrorMessages.message("annotation.may.not.have.type.parameters"); + String description = JavaErrorBundle.message("annotation.may.not.have.type.parameters"); return HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(list).descriptionAndTooltip(description).create(); } @@ -891,7 +892,7 @@ public class GenericsHighlightUtil { final PsiTypeParameter typeParameter2 = parameters[j]; String name2 = typeParameter2.getName(); if (Comparing.strEqual(name1, name2)) { - String message = JavaErrorMessages.message("generics.duplicate.type.parameter", name1); + String message = JavaErrorBundle.message("generics.duplicate.type.parameter", name1); return HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(typeParameter2).descriptionAndTooltip(message).create(); } } @@ -916,7 +917,7 @@ public class GenericsHighlightUtil { for (PsiTypeElement typeElement : typeElements) { final PsiClass aClass = PsiUtil.resolveClassInClassTypeOnly(typeElement.getType()); if (aClass instanceof PsiTypeParameter) { - final String message = JavaErrorMessages.message("generics.cannot.catch.type.parameters"); + final String message = JavaErrorBundle.message("generics.cannot.catch.type.parameters"); result.add(HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(typeElement).descriptionAndTooltip(message).create()); } } @@ -937,12 +938,12 @@ public class GenericsHighlightUtil { private static HighlightInfo isIllegalForInstanceOf(@Nullable PsiType type, @NotNull PsiTypeElement typeElement) { final PsiClass resolved = PsiUtil.resolveClassInClassTypeOnly(type); if (resolved instanceof PsiTypeParameter) { - String description = JavaErrorMessages.message("generics.cannot.instanceof.type.parameters"); + String description = JavaErrorBundle.message("generics.cannot.instanceof.type.parameters"); return HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(typeElement).descriptionAndTooltip(description).create(); } if (!JavaGenericsUtil.isReifiableType(type)) { - String description = JavaErrorMessages.message("illegal.generic.type.for.instanceof"); + String description = JavaErrorBundle.message("illegal.generic.type.for.instanceof"); return HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(typeElement).descriptionAndTooltip(description).create(); } @@ -967,7 +968,7 @@ public class GenericsHighlightUtil { private static HighlightInfo canSelectFrom(@NotNull PsiClassType type, @NotNull PsiTypeElement operand) { PsiClass aClass = type.resolve(); if (aClass instanceof PsiTypeParameter) { - String description = JavaErrorMessages.message("cannot.select.dot.class.from.type.variable"); + String description = JavaErrorBundle.message("cannot.select.dot.class.from.type.variable"); return HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(operand).descriptionAndTooltip(description).create(); } if (type.getParameters().length > 0) { @@ -992,7 +993,7 @@ public class GenericsHighlightUtil { } } if (superMethod == null) { - String description = JavaErrorMessages.message("method.does.not.override.super"); + String description = JavaErrorBundle.message("method.does.not.override.super"); HighlightInfo highlightInfo = HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(overrideAnnotation).descriptionAndTooltip(description).create(); QUICK_FIX_FACTORY.registerPullAsAbstractUpFixes(method, new QuickFixActionRegistrarImpl(highlightInfo)); @@ -1002,7 +1003,7 @@ public class GenericsHighlightUtil { if (languageLevel == LanguageLevel.JDK_1_5 && superClass != null && superClass.isInterface()) { - String description = JavaErrorMessages.message("override.not.allowed.in.interfaces"); + String description = JavaErrorBundle.message("override.not.allowed.in.interfaces"); HighlightInfo info = HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(overrideAnnotation).descriptionAndTooltip(description).create(); QuickFixAction.registerQuickFixAction(info, QUICK_FIX_FACTORY.createIncreaseLanguageLevelFix(LanguageLevel.JDK_1_6)); @@ -1097,7 +1098,7 @@ public class GenericsHighlightUtil { if (constructor instanceof PsiMethod) { final PsiClass aClass = constructor.getContainingClass(); if (aClass != null && aClass.isEnum()) { - final String message = JavaErrorMessages.message("call.to.super.is.not.allowed.in.enum.constructor"); + final String message = JavaErrorBundle.message("call.to.super.is.not.allowed.in.enum.constructor"); return HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(expr).descriptionAndTooltip(message).create(); } } @@ -1110,7 +1111,7 @@ public class GenericsHighlightUtil { if (declarationScope instanceof PsiMethod) { PsiParameter[] params = ((PsiMethod)declarationScope).getParameterList().getParameters(); if (params[params.length - 1] != parameter) { - String description = JavaErrorMessages.message("vararg.not.last.parameter"); + String description = JavaErrorBundle.message("vararg.not.last.parameter"); HighlightInfo info = HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(parameter).descriptionAndTooltip(description).create(); QuickFixAction.registerQuickFixAction(info, QUICK_FIX_FACTORY.createMakeVarargParameterLastFix(parameter)); return info; @@ -1128,7 +1129,7 @@ public class GenericsHighlightUtil { if (list == null) { list = new ArrayList<>(); } - String description = JavaErrorMessages.message("modifiers.for.enum.constants"); + String description = JavaErrorBundle.message("modifiers.for.enum.constants"); list.add(HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(child).descriptionAndTooltip(description).create()); } } @@ -1140,7 +1141,7 @@ public class GenericsHighlightUtil { if (parent instanceof PsiReferenceExpression) { final PsiElement grandParent = parent.getParent(); if (!(grandParent instanceof PsiMethodCallExpression) && !(parent instanceof PsiMethodReferenceExpression)) { - final String message = JavaErrorMessages.message("generics.reference.parameters.not.allowed"); + final String message = JavaErrorBundle.message("generics.reference.parameters.not.allowed"); return HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(refParamList).descriptionAndTooltip(message).create(); } } @@ -1198,8 +1199,8 @@ public class GenericsHighlightUtil { } } final String message = element instanceof PsiClass - ? JavaErrorMessages.message("generics.type.arguments.on.raw.type") - : JavaErrorMessages.message("generics.type.arguments.on.raw.method"); + ? JavaErrorBundle.message("generics.type.arguments.on.raw.type") + : JavaErrorBundle.message("generics.type.arguments.on.raw.method"); return HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(refParamList).descriptionAndTooltip(message).create(); } @@ -1221,7 +1222,7 @@ public class GenericsHighlightUtil { JavaPsiFacade.getInstance(klass.getProject()).findClass(CommonClassNames.JAVA_LANG_THROWABLE, klass.getResolveScope()); } if (InheritanceUtil.isInheritorOrSelf((PsiClass)resolved, throwableClass, true)) { - String message = JavaErrorMessages.message("generic.extend.exception"); + String message = JavaErrorBundle.message("generic.extend.exception"); HighlightInfo info = HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(refElement).descriptionAndTooltip(message).create(); PsiClassType classType = JavaPsiFacade.getElementFactory(klass.getProject()).createType((PsiClass)resolved); QuickFixAction.registerQuickFixAction(info, QUICK_FIX_FACTORY.createExtendsListFix(klass, classType, false)); @@ -1236,7 +1237,7 @@ public class GenericsHighlightUtil { for (PsiJavaCodeReferenceElement refElement : list.getReferenceElements()) { PsiReferenceParameterList parameterList = refElement.getParameterList(); if (parameterList != null && parameterList.getTypeParameterElements().length != 0) { - String message = JavaErrorMessages.message("generic.extend.exception"); + String message = JavaErrorBundle.message("generic.extend.exception"); return HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(refElement).descriptionAndTooltip(message).create(); } } @@ -1249,7 +1250,7 @@ public class GenericsHighlightUtil { static HighlightInfo checkGenericCannotExtendException(@NotNull PsiAnonymousClass anonymousClass) { if (hasGenericSignature(anonymousClass) && InheritanceUtil.isInheritor(anonymousClass, true, CommonClassNames.JAVA_LANG_THROWABLE)) { - String message = JavaErrorMessages.message("generic.extend.exception"); + String message = JavaErrorBundle.message("generic.extend.exception"); return HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(anonymousClass.getBaseClassReference()).descriptionAndTooltip(message).create(); } return null; @@ -1268,7 +1269,7 @@ public class GenericsHighlightUtil { if (!aClass.isEnum()) return null; PsiElement parent = aClass.getParent(); if (!(parent instanceof PsiClass || parent instanceof PsiFile || parent instanceof PsiClassLevelDeclarationStatement)) { - String description = JavaErrorMessages.message("local.enum"); + String description = JavaErrorBundle.message("local.enum"); TextRange textRange = HighlightNamesUtil.getClassDeclarationTextRange(aClass); return HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(textRange).descriptionAndTooltip(description).create(); } @@ -1281,8 +1282,8 @@ public class GenericsHighlightUtil { if (qualifier instanceof PsiJavaCodeReferenceElement) { final PsiReferenceParameterList parameterList = ((PsiJavaCodeReferenceElement)qualifier).getParameterList(); if (parameterList != null && parameterList.getTypeArguments().length > 0) { - final String message = JavaErrorMessages.message("generics.select.static.class.from.parameterized.type", - HighlightUtil.formatClass((PsiClass)resolved)); + final String message = JavaErrorBundle.message("generics.select.static.class.from.parameterized.type", + HighlightUtil.formatClass((PsiClass)resolved)); return HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(parameterList).descriptionAndTooltip(message).create(); } } @@ -1292,7 +1293,7 @@ public class GenericsHighlightUtil { static HighlightInfo checkCannotInheritFromTypeParameter(@Nullable PsiClass superClass, @NotNull PsiJavaCodeReferenceElement toHighlight) { if (superClass instanceof PsiTypeParameter) { - String description = JavaErrorMessages.message("class.cannot.inherit.from.its.type.parameter"); + String description = JavaErrorBundle.message("class.cannot.inherit.from.its.type.parameter"); return HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(toHighlight).descriptionAndTooltip(description).create(); } return null; diff --git a/java/java-analysis-impl/src/com/intellij/codeInsight/daemon/impl/analysis/HighlightClassUtil.java b/java/java-analysis-impl/src/com/intellij/codeInsight/daemon/impl/analysis/HighlightClassUtil.java index 19cfde5ec5d6..7d4c9dc9a7a1 100644 --- a/java/java-analysis-impl/src/com/intellij/codeInsight/daemon/impl/analysis/HighlightClassUtil.java +++ b/java/java-analysis-impl/src/com/intellij/codeInsight/daemon/impl/analysis/HighlightClassUtil.java @@ -8,7 +8,7 @@ package com.intellij.codeInsight.daemon.impl.analysis; import com.intellij.codeInsight.ClassUtil; import com.intellij.codeInsight.ExceptionUtil; -import com.intellij.codeInsight.daemon.JavaErrorMessages; +import com.intellij.codeInsight.daemon.JavaErrorBundle; import com.intellij.codeInsight.daemon.QuickFixBundle; import com.intellij.codeInsight.daemon.impl.HighlightInfo; import com.intellij.codeInsight.daemon.impl.HighlightInfoType; @@ -76,7 +76,7 @@ public class HighlightClassUtil { String methodName = JavaHighlightUtil.formatMethod(abstractMethod); String messageKey = aClass instanceof PsiEnumConstantInitializer || aClass.isRecord() || implementsFixElement instanceof PsiEnumConstant ? "class.must.implement.method" : "class.must.be.abstract"; - String message = JavaErrorMessages.message(messageKey, baseClassName, methodName, HighlightUtil.formatClass(superClass, false)); + String message = JavaErrorBundle.message(messageKey, baseClassName, methodName, HighlightUtil.formatClass(superClass, false)); HighlightInfo errorResult = HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(range).descriptionAndTooltip(message).create(); final PsiMethod anyMethodToImplement = ClassUtil.getAnyMethodToImplement(aClass); @@ -115,7 +115,7 @@ public class HighlightClassUtil { if (aClass.hasModifierProperty(PsiModifier.ABSTRACT) && (!(highlightElement instanceof PsiNewExpression) || !(((PsiNewExpression)highlightElement).getType() instanceof PsiArrayType))) { String baseClassName = aClass.getName(); - String message = JavaErrorMessages.message("abstract.cannot.be.instantiated", baseClassName); + String message = JavaErrorBundle.message("abstract.cannot.be.instantiated", baseClassName); errorResult = HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(highlightElement).descriptionAndTooltip(message).create(); final PsiMethod anyAbstractMethod = ClassUtil.getAnyAbstractMethod(aClass); if (!aClass.isInterface() && anyAbstractMethod == null) { @@ -173,7 +173,7 @@ public class HighlightClassUtil { } } if (dupFileName == null) return null; - String message = JavaErrorMessages.message("duplicate.class.in.other.file", dupFileName); + String message = JavaErrorBundle.message("duplicate.class.in.other.file", dupFileName); TextRange textRange = HighlightNamesUtil.getClassDeclarationTextRange(aClass); return HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(textRange).descriptionAndTooltip(message).create(); @@ -214,7 +214,7 @@ public class HighlightClassUtil { } if (duplicateFound) { - String message = JavaErrorMessages.message("duplicate.class", name); + String message = JavaErrorBundle.message("duplicate.class", name); TextRange textRange = HighlightNamesUtil.getClassDeclarationTextRange(aClass); return HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(textRange).descriptionAndTooltip(message).create(); } @@ -229,7 +229,7 @@ public class HighlightClassUtil { if (virtualFile == null || virtualFile.getNameWithoutExtension().equals(aClass.getName())) { return null; } - String message = JavaErrorMessages.message("public.class.should.be.named.after.file", aClass.getName()); + String message = JavaErrorBundle.message("public.class.should.be.named.after.file", aClass.getName()); TextRange range = HighlightNamesUtil.getClassDeclarationTextRange(aClass); HighlightInfo errorResult = HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR). range(aClass, range.getStartOffset(), range.getEndOffset()). @@ -266,7 +266,7 @@ public class HighlightClassUtil { String name = aClass.getQualifiedName(); if (CommonClassNames.DEFAULT_PACKAGE.equals(name)) { - String message = JavaErrorMessages.message("class.clashes.with.package", name); + String message = JavaErrorBundle.message("class.clashes.with.package", name); TextRange range = HighlightNamesUtil.getClassDeclarationTextRange(aClass); return HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(range).descriptionAndTooltip(message).create(); } @@ -278,7 +278,7 @@ public class HighlightClassUtil { String simpleName = aClass.getName(); PsiDirectory subDirectory = ((PsiDirectory)directory).findSubdirectory(simpleName); if (subDirectory != null && simpleName.equals(subDirectory.getName()) && PsiTreeUtil.findChildOfType(subDirectory, PsiJavaFile.class) != null) { - String message = JavaErrorMessages.message("class.clashes.with.package", name); + String message = JavaErrorBundle.message("class.clashes.with.package", name); TextRange range = HighlightNamesUtil.getClassDeclarationTextRange(aClass); return HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(range).descriptionAndTooltip(message).create(); } @@ -298,7 +298,7 @@ public class HighlightClassUtil { return null; } - String message = JavaErrorMessages.message("static.declaration.in.inner.class"); + String message = JavaErrorBundle.message("static.declaration.in.inner.class"); HighlightInfo result = HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(keyword).descriptionAndTooltip(message).create(); QuickFixAction.registerQuickFixAction(result, QUICK_FIX_FACTORY.createModifierListFix(field, PsiModifier.STATIC, false, false)); @@ -319,7 +319,7 @@ public class HighlightClassUtil { } PsiMethod method = (PsiMethod)keyword.getParent().getParent(); if (PsiUtilCore.hasErrorElementChild(method)) return null; - String message = JavaErrorMessages.message("static.declaration.in.inner.class"); + String message = JavaErrorBundle.message("static.declaration.in.inner.class"); HighlightInfo result = HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(keyword).descriptionAndTooltip(message).create(); QuickFixAction.registerQuickFixAction(result, QUICK_FIX_FACTORY.createModifierListFix(method, PsiModifier.STATIC, false, false)); registerMakeInnerClassStatic((PsiClass)keyword.getParent().getParent().getParent(), result); @@ -332,7 +332,7 @@ public class HighlightClassUtil { } PsiClassInitializer initializer = (PsiClassInitializer)keyword.getParent().getParent(); if (PsiUtilCore.hasErrorElementChild(initializer)) return null; - String message = JavaErrorMessages.message("static.declaration.in.inner.class"); + String message = JavaErrorBundle.message("static.declaration.in.inner.class"); HighlightInfo result = HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(keyword).descriptionAndTooltip(message).create(); QuickFixAction.registerQuickFixAction(result, QUICK_FIX_FACTORY.createModifierListFix(initializer, PsiModifier.STATIC, false, false)); registerMakeInnerClassStatic((PsiClass)keyword.getParent().getParent().getParent(), result); @@ -379,7 +379,7 @@ public class HighlightClassUtil { } } TextRange range = context != null ? context.getTextRange() : HighlightNamesUtil.getClassDeclarationTextRange(aClass); - String message = JavaErrorMessages.message("static.declaration.in.inner.class"); + String message = JavaErrorBundle.message("static.declaration.in.inner.class"); HighlightInfo info = HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(range).descriptionAndTooltip(message).create(); if (context != keyword) { QuickFixAction.registerQuickFixActions(info, null, JvmElementActionFactories.createModifierActions(aClass, MemberRequestsKt.modifierRequest(JvmModifier.STATIC, false))); @@ -406,7 +406,7 @@ public class HighlightClassUtil { if (aClass.isEnum() || aClass.isRecord()) { boolean isExtends = list.equals(aClass.getExtendsList()); if (isExtends) { - String description = JavaErrorMessages.message(aClass.isRecord() ? "record.extends" : "extends.after.enum"); + String description = JavaErrorBundle.message(aClass.isRecord() ? "record.extends" : "extends.after.enum"); HighlightInfo info = HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(list).descriptionAndTooltip(description).create(); QuickFixAction.registerQuickFixAction(info, QUICK_FIX_FACTORY.createDeleteFix(list)); @@ -423,7 +423,7 @@ public class HighlightClassUtil { if (aClass.isInterface()) { boolean isImplements = list.equals(aClass.getImplementsList()); if (isImplements) { - String description = JavaErrorMessages.message("implements.after.interface"); + String description = JavaErrorBundle.message("implements.after.interface"); HighlightInfo result = HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(list).descriptionAndTooltip(description).create(); final PsiClassType[] referencedTypes = list.getReferencedTypes(); @@ -448,7 +448,7 @@ public class HighlightClassUtil { HighlightInfo errorResult = null; PsiClass extendFrom = (PsiClass)resolveResult.getElement(); if (extendFrom.isInterface() != mustBeInterface) { - String message = JavaErrorMessages.message(mustBeInterface ? "interface.expected" : "no.interface.expected"); + String message = JavaErrorBundle.message(mustBeInterface ? "interface.expected" : "no.interface.expected"); errorResult = HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(ref).descriptionAndTooltip(message).create(); PsiClassType type = JavaPsiFacade.getElementFactory(aClass.getProject()).createType(ref); @@ -460,7 +460,8 @@ public class HighlightClassUtil { static HighlightInfo checkCannotInheritFromFinal(@NotNull PsiClass superClass, @NotNull PsiElement elementToHighlight) { HighlightInfo errorResult = null; if (superClass.hasModifierProperty(PsiModifier.FINAL) || superClass.isEnum()) { - String message = JavaErrorMessages.message("inheritance.from.final.class", superClass.getQualifiedName(), superClass.isEnum() ? PsiKeyword.ENUM : PsiKeyword.FINAL); + String message = JavaErrorBundle + .message("inheritance.from.final.class", superClass.getQualifiedName(), superClass.isEnum() ? PsiKeyword.ENUM : PsiKeyword.FINAL); errorResult = HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(elementToHighlight).descriptionAndTooltip(message).create(); QuickFixAction.registerQuickFixActions(errorResult, null, JvmElementActionFactories.createModifierActions(superClass, MemberRequestsKt.modifierRequest(JvmModifier.FINAL, false))); @@ -537,7 +538,7 @@ public class HighlightClassUtil { PsiFormatUtilBase.SHOW_TYPE); return HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR) .range(range) - .descriptionAndTooltip(JavaErrorMessages.message("ambiguous.method.call", m1, m2)) + .descriptionAndTooltip(JavaErrorBundle.message("ambiguous.method.call", m1, m2)) .create(); } @@ -555,7 +556,7 @@ public class HighlightClassUtil { return null; } - String description = JavaErrorMessages.message("no.default.constructor.available", HighlightUtil.formatClass(baseClass)); + String description = JavaErrorBundle.message("no.default.constructor.available", HighlightUtil.formatClass(baseClass)); HighlightInfo info = HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(range).descriptionAndTooltip(description).create(); QuickFixAction.registerQuickFixAction(info, QUICK_FIX_FACTORY.createCreateConstructorMatchingSuperFix(aClass)); @@ -566,7 +567,7 @@ public class HighlightClassUtil { static HighlightInfo checkInterfaceCannotBeLocal(@NotNull PsiClass aClass) { if (PsiUtil.isLocalClass(aClass)) { TextRange range = HighlightNamesUtil.getClassDeclarationTextRange(aClass); - String description = JavaErrorMessages.message("interface.cannot.be.local"); + String description = JavaErrorBundle.message("interface.cannot.be.local"); return HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(range).descriptionAndTooltip(description).create(); } return null; @@ -575,7 +576,7 @@ public class HighlightClassUtil { static HighlightInfo checkCyclicInheritance(@NotNull PsiClass aClass) { PsiClass circularClass = InheritanceUtil.getCircularClass(aClass); if (circularClass != null) { - String description = JavaErrorMessages.message("cyclic.inheritance", HighlightUtil.formatClass(circularClass)); + String description = JavaErrorBundle.message("cyclic.inheritance", HighlightUtil.formatClass(circularClass)); TextRange range = HighlightNamesUtil.getClassDeclarationTextRange(aClass); return HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(range).descriptionAndTooltip(description).create(); } @@ -598,7 +599,7 @@ public class HighlightClassUtil { } } if (dupCount > 1) { - String description = JavaErrorMessages.message("duplicate.class", HighlightUtil.formatClass(aClass)); + String description = JavaErrorBundle.message("duplicate.class", HighlightUtil.formatClass(aClass)); return HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(element).descriptionAndTooltip(description).create(); } return null; @@ -617,7 +618,7 @@ public class HighlightClassUtil { if (importStatement.isOnDemand()) continue; PsiElement resolved = importStatement.resolve(); if (resolved instanceof PsiClass && !resolved.equals(aClass) && Comparing.equal(aClass.getName(), ((PsiClass)resolved).getName(), true)) { - String description = JavaErrorMessages.message("class.already.imported", HighlightUtil.formatClass(aClass, false)); + String description = JavaErrorBundle.message("class.already.imported", HighlightUtil.formatClass(aClass, false)); return HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(elementToHighlight).descriptionAndTooltip(description).create(); } } @@ -633,7 +634,7 @@ public class HighlightClassUtil { if (!aClass.isInterface() && referencedTypes.length > 1 && aClass.getExtendsList() == list) { - String description = JavaErrorMessages.message("class.cannot.extend.multiple.classes"); + String description = JavaErrorBundle.message("class.cannot.extend.multiple.classes"); return HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(list).descriptionAndTooltip(description).create(); } @@ -642,7 +643,7 @@ public class HighlightClassUtil { static HighlightInfo checkThingNotAllowedInInterface(@NotNull PsiElement element, @Nullable PsiClass aClass) { if (aClass == null || !aClass.isInterface()) return null; - String description = JavaErrorMessages.message("not.allowed.in.interface"); + String description = JavaErrorBundle.message("not.allowed.in.interface"); return HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(element).descriptionAndTooltip(description).create(); } @@ -650,7 +651,7 @@ public class HighlightClassUtil { PsiExpression qualifier = expression.getQualifier(); if (qualifier == null) return null; if (type instanceof PsiArrayType) { - String description = JavaErrorMessages.message("invalid.qualified.new"); + String description = JavaErrorBundle.message("invalid.qualified.new"); HighlightInfo info = HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(expression).descriptionAndTooltip(description).create(); QuickFixAction.registerQuickFixAction(info, QUICK_FIX_FACTORY.createRemoveNewQualifierFix(expression, null)); @@ -659,7 +660,7 @@ public class HighlightClassUtil { HighlightInfo info = null; if (aClass != null) { if (aClass.hasModifierProperty(PsiModifier.STATIC)) { - String description = JavaErrorMessages.message("qualified.new.of.static.class"); + String description = JavaErrorBundle.message("qualified.new.of.static.class"); info = HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(expression).descriptionAndTooltip(description).create(); if (!aClass.isEnum()) { QuickFixAction.registerQuickFixActions(info, null, JvmElementActionFactories.createModifierActions(aClass, MemberRequestsKt.modifierRequest(JvmModifier.STATIC, false))); @@ -717,7 +718,7 @@ public class HighlightClassUtil { return null; } if (!(resolved instanceof PsiClass)) { - String description = JavaErrorMessages.message("class.name.expected"); + String description = JavaErrorBundle.message("class.name.expected"); return HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(extendRef).descriptionAndTooltip(description).create(); } final HighlightInfo[] infos = new HighlightInfo[1]; @@ -736,9 +737,9 @@ public class HighlightClassUtil { final PsiClass base = (PsiClass)resolve; final PsiClass baseClass = base.getContainingClass(); if (baseClass != null && base.hasModifierProperty(PsiModifier.PRIVATE) && baseClass == containerClass && baseClass.getContainingClass() == null) { - String description = JavaErrorMessages.message("private.symbol", - HighlightUtil.formatClass(base), - HighlightUtil.formatClass(baseClass)); + String description = JavaErrorBundle.message("private.symbol", + HighlightUtil.formatClass(base), + HighlightUtil.formatClass(baseClass)); infos[0] = HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(extendRef).descriptionAndTooltip(description).create(); return; } @@ -749,7 +750,7 @@ public class HighlightClassUtil { if (resolve == resolved && baseClass != null && (!PsiTreeUtil.isAncestor(baseClass, extendRef, true) || aClass.hasModifierProperty(PsiModifier.STATIC)) && !InheritanceUtil.hasEnclosingInstanceInScope(baseClass, extendRef, psiClass -> psiClass != aClass, true) && !qualifiedNewCalledInConstructors(aClass)) { - String description = JavaErrorMessages.message("no.enclosing.instance.in.scope", HighlightUtil.formatClass(baseClass)); + String description = JavaErrorBundle.message("no.enclosing.instance.in.scope", HighlightUtil.formatClass(baseClass)); infos[0] = HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(extendRef).descriptionAndTooltip(description).create(); } } @@ -847,7 +848,7 @@ public class HighlightClassUtil { @Nullable PsiClass outerClass, @NotNull PsiElement elementToHighlight) { if (outerClass != null && !PsiTreeUtil.isContextAncestor(outerClass, place, false)) { - String description = JavaErrorMessages.message("is.not.an.enclosing.class", HighlightUtil.formatClass(outerClass)); + String description = JavaErrorBundle.message("is.not.an.enclosing.class", HighlightUtil.formatClass(outerClass)); HighlightInfo highlightInfo = HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(elementToHighlight).descriptionAndTooltip(description).create(); registerMakeInnerClassStatic(aClass, highlightInfo); @@ -857,7 +858,7 @@ public class HighlightClassUtil { if (staticParent != null) { String element = outerClass == null ? "" : HighlightUtil.formatClass(outerClass) + "." + (place instanceof PsiSuperExpression ? PsiKeyword.SUPER : PsiKeyword.THIS); - String description = JavaErrorMessages.message("cannot.be.referenced.from.static.context", element); + String description = JavaErrorBundle.message("cannot.be.referenced.from.static.context", element); HighlightInfo highlightInfo = HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(elementToHighlight).descriptionAndTooltip(description).create(); // make context not static or referenced class static @@ -881,7 +882,7 @@ public class HighlightClassUtil { if (!psiClass.isRecord()) { if (header != null) { HighlightInfo info = HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(header) - .descriptionAndTooltip(JavaErrorMessages.message("record.header.regular.class")).create(); + .descriptionAndTooltip(JavaErrorBundle.message("record.header.regular.class")).create(); QuickFixAction.registerQuickFixAction(info, QUICK_FIX_FACTORY.createDeleteFix(header)); return info; } @@ -891,7 +892,7 @@ public class HighlightClassUtil { if (identifier == null) return null; if (header == null) { HighlightInfo info = HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(identifier) - .descriptionAndTooltip(JavaErrorMessages.message("record.no.header")).create(); + .descriptionAndTooltip(JavaErrorBundle.message("record.no.header")).create(); QuickFixAction.registerQuickFixAction(info, QUICK_FIX_FACTORY.createAddEmptyRecordHeaderFix(psiClass)); return info; } @@ -903,8 +904,8 @@ public class HighlightClassUtil { PsiClass aClass = member.getContainingClass(); if (aClass != null && aClass.isRecord()) { HighlightInfo info = HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(member) - .descriptionAndTooltip(JavaErrorMessages.message(member instanceof PsiClassInitializer ? - "record.instance.initializer" : "record.instance.field")).create(); + .descriptionAndTooltip(JavaErrorBundle.message(member instanceof PsiClassInitializer ? + "record.instance.initializer" : "record.instance.field")).create(); QuickFixAction.registerQuickFixAction(info, QUICK_FIX_FACTORY.createModifierListFix(member, PsiModifier.STATIC, true, false)); return info; } @@ -915,7 +916,7 @@ public class HighlightClassUtil { static HighlightInfo checkExtendsProhibitedClass(@NotNull PsiClass superClass, @NotNull PsiElement elementToHighlight) { String qualifiedName = superClass.getQualifiedName(); if (CommonClassNames.JAVA_LANG_ENUM.equals(qualifiedName) || CommonClassNames.JAVA_LANG_RECORD.equals(qualifiedName)) { - String message = JavaErrorMessages.message("classes.extends.prohibited.super", qualifiedName); + String message = JavaErrorBundle.message("classes.extends.prohibited.super", qualifiedName); return HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(elementToHighlight).descriptionAndTooltip(message).create(); } return null; diff --git a/java/java-analysis-impl/src/com/intellij/codeInsight/daemon/impl/analysis/HighlightControlFlowUtil.java b/java/java-analysis-impl/src/com/intellij/codeInsight/daemon/impl/analysis/HighlightControlFlowUtil.java index 79be9e2b21d1..b555f6600a22 100644 --- a/java/java-analysis-impl/src/com/intellij/codeInsight/daemon/impl/analysis/HighlightControlFlowUtil.java +++ b/java/java-analysis-impl/src/com/intellij/codeInsight/daemon/impl/analysis/HighlightControlFlowUtil.java @@ -1,7 +1,7 @@ // Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. package com.intellij.codeInsight.daemon.impl.analysis; -import com.intellij.codeInsight.daemon.JavaErrorMessages; +import com.intellij.codeInsight.daemon.JavaErrorBundle; import com.intellij.codeInsight.daemon.QuickFixBundle; import com.intellij.codeInsight.daemon.impl.HighlightInfo; import com.intellij.codeInsight.daemon.impl.HighlightInfoType; @@ -54,7 +54,7 @@ public class HighlightControlFlowUtil { if (!ControlFlowUtil.returnPresent(controlFlow)) { PsiJavaToken rBrace = body.getRBrace(); PsiElement context = rBrace == null ? body.getLastChild() : rBrace; - String message = JavaErrorMessages.message("missing.return.statement"); + String message = JavaErrorBundle.message("missing.return.statement"); HighlightInfo info = HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(context).descriptionAndTooltip(message).create(); PsiElement parent = body.getParent(); if (parent instanceof PsiMethod) { @@ -94,7 +94,7 @@ public class HighlightControlFlowUtil { final ControlFlow controlFlow = ControlFlowFactory.getInstance(codeBlock.getProject()).getControlFlow(codeBlock, policy, false, false); final PsiElement unreachableStatement = ControlFlowUtil.getUnreachableStatement(controlFlow); if (unreachableStatement != null) { - String description = JavaErrorMessages.message("unreachable.statement"); + String description = JavaErrorBundle.message("unreachable.statement"); PsiElement keyword = null; if (unreachableStatement instanceof PsiIfStatement || unreachableStatement instanceof PsiSwitchBlock || @@ -249,7 +249,7 @@ public class HighlightControlFlowUtil { if (field == null) return null; if (variableDefinitelyAssignedIn(field, body)) return null; if (JavaPsiRecordUtil.isCompactConstructor(canonicalConstructor) && variableDefinitelyNotAssignedIn(field, body)) return null; - String description = JavaErrorMessages.message("record.component.not.initialized", field.getName()); + String description = JavaErrorBundle.message("record.component.not.initialized", field.getName()); return HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(identifier).descriptionAndTooltip(description).create(); } @@ -257,7 +257,7 @@ public class HighlightControlFlowUtil { if (!field.hasModifierProperty(PsiModifier.FINAL)) return null; if (isFieldInitializedAfterObjectConstruction(field)) return null; - String description = JavaErrorMessages.message("variable.not.initialized", field.getName()); + String description = JavaErrorBundle.message("variable.not.initialized", field.getName()); TextRange range = HighlightNamesUtil.getFieldDeclarationTextRange(field); HighlightInfo highlightInfo = HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(range).descriptionAndTooltip(description).create(); QuickFixAction.registerQuickFixAction(highlightInfo, HighlightMethodUtil.getFixRange(field), QUICK_FIX_FACTORY.createCreateConstructorParameterFromFieldFix(field)); @@ -417,7 +417,7 @@ public class HighlightControlFlowUtil { } if (codeBlockProblems.contains(expression)) { final String name = expression.getElement().getText(); - String description = JavaErrorMessages.message("variable.not.initialized", name); + String description = JavaErrorBundle.message("variable.not.initialized", name); HighlightInfo highlightInfo = HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(expression).descriptionAndTooltip(description).create(); QuickFixAction.registerQuickFixAction(highlightInfo, QUICK_FIX_FACTORY.createAddVariableInitializerFix(variable)); @@ -555,7 +555,7 @@ public class HighlightControlFlowUtil { if (alreadyAssigned) { String description = - JavaErrorMessages.message(inLoop ? "variable.assigned.in.loop" : "variable.already.assigned", variable.getName()); + JavaErrorBundle.message(inLoop ? "variable.assigned.in.loop" : "variable.already.assigned", variable.getName()); final HighlightInfo highlightInfo = HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(expression).descriptionAndTooltip(description).create(); HighlightFixUtil.registerMakeNotFinalAction(variable, highlightInfo); @@ -630,7 +630,7 @@ public class HighlightControlFlowUtil { if (canWrite) return null; } final String name = variable.getName(); - String description = JavaErrorMessages.message("assignment.to.final.variable", name); + String description = JavaErrorBundle.message("assignment.to.final.variable", name); final HighlightInfo highlightInfo = HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(reference).descriptionAndTooltip(description).create(); if (!(variable instanceof PsiPatternVariable)) { @@ -696,7 +696,8 @@ public class HighlightControlFlowUtil { if (isToBeEffectivelyFinal && isEffectivelyFinal(variable, innerClass, context)) { return null; } - final String description = JavaErrorMessages.message(isToBeEffectivelyFinal ? "variable.must.be.final.or.effectively.final" : "variable.must.be.final", context.getText()); + final String description = JavaErrorBundle + .message(isToBeEffectivelyFinal ? "variable.must.be.final.or.effectively.final" : "variable.must.be.final", context.getText()); final HighlightInfo highlightInfo = HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(context).descriptionAndTooltip(description).create(); @@ -714,7 +715,7 @@ public class HighlightControlFlowUtil { return null; } if (!isEffectivelyFinal(variable, lambdaExpression, context)) { - String text = JavaErrorMessages.message("lambda.variable.must.be.final"); + String text = JavaErrorBundle.message("lambda.variable.must.be.final"); HighlightInfo highlightInfo = HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(context).descriptionAndTooltip(text).create(); QuickFixAction.registerQuickFixAction(highlightInfo, QUICK_FIX_FACTORY.createVariableAccessFromInnerClassFix(variable, lambdaExpression)); return ErrorFixExtensionPoint.registerFixes(highlightInfo, context, "lambda.variable.must.be.final"); @@ -816,7 +817,7 @@ public class HighlightControlFlowUtil { final ControlFlow controlFlow = getControlFlowNoConstantEvaluate(body); final int completionReasons = ControlFlowUtil.getCompletionReasons(controlFlow, 0, controlFlow.getSize()); if (!BitUtil.isSet(completionReasons, ControlFlowUtil.NORMAL_COMPLETION_REASON)) { - String description = JavaErrorMessages.message("initializer.must.be.able.to.complete.normally"); + String description = JavaErrorBundle.message("initializer.must.be.able.to.complete.normally"); return HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(body).descriptionAndTooltip(description).create(); } } diff --git a/java/java-analysis-impl/src/com/intellij/codeInsight/daemon/impl/analysis/HighlightMethodUtil.java b/java/java-analysis-impl/src/com/intellij/codeInsight/daemon/impl/analysis/HighlightMethodUtil.java index d1b75b753cc1..d054898d447c 100644 --- a/java/java-analysis-impl/src/com/intellij/codeInsight/daemon/impl/analysis/HighlightMethodUtil.java +++ b/java/java-analysis-impl/src/com/intellij/codeInsight/daemon/impl/analysis/HighlightMethodUtil.java @@ -2,7 +2,7 @@ package com.intellij.codeInsight.daemon.impl.analysis; import com.intellij.codeInsight.ExceptionUtil; -import com.intellij.codeInsight.daemon.JavaErrorMessages; +import com.intellij.codeInsight.daemon.JavaErrorBundle; import com.intellij.codeInsight.daemon.impl.HighlightInfo; import com.intellij.codeInsight.daemon.impl.HighlightInfoType; import com.intellij.codeInsight.daemon.impl.quickfix.*; @@ -66,17 +66,17 @@ public class HighlightMethodUtil { PsiClass class1 = method1.getContainingClass(); PsiClass class2 = method2.getContainingClass(); if (class1 != null && class2 != null) { - return JavaErrorMessages.message("clash.methods.message.show.classes", - JavaHighlightUtil.formatMethod(method1), - JavaHighlightUtil.formatMethod(method2), - HighlightUtil.formatClass(class1), - HighlightUtil.formatClass(class2)); + return JavaErrorBundle.message("clash.methods.message.show.classes", + JavaHighlightUtil.formatMethod(method1), + JavaHighlightUtil.formatMethod(method2), + HighlightUtil.formatClass(class1), + HighlightUtil.formatClass(class2)); } } - return JavaErrorMessages.message("clash.methods.message", - JavaHighlightUtil.formatMethod(method1), - JavaHighlightUtil.formatMethod(method2)); + return JavaErrorBundle.message("clash.methods.message", + JavaHighlightUtil.formatMethod(method1), + JavaHighlightUtil.formatMethod(method2)); } static HighlightInfo checkMethodWeakerPrivileges(@NotNull MethodSignatureBackedByPsiMethod methodSignature, @@ -107,10 +107,10 @@ public class HighlightMethodUtil { boolean includeRealPositionInfo) { int superAccessLevel = PsiUtil.getAccessLevel(superMethod.getModifierList()); if (accessLevel < superAccessLevel) { - String description = JavaErrorMessages.message("weaker.privileges", - createClashMethodMessage(method, superMethod, true), - VisibilityUtil.toPresentableText(accessModifier), - PsiUtil.getAccessModifier(superAccessLevel)); + String description = JavaErrorBundle.message("weaker.privileges", + createClashMethodMessage(method, superMethod, true), + VisibilityUtil.toPresentableText(accessModifier), + PsiUtil.getAccessModifier(superAccessLevel)); TextRange textRange = TextRange.EMPTY_RANGE; if (includeRealPositionInfo) { PsiElement keyword = PsiUtil.findModifierInList(modifierList, accessModifier); @@ -167,7 +167,7 @@ public class HighlightMethodUtil { } HighlightInfo info = checkSuperMethodSignature( superMethod, superMethodSignature, superReturnType, method, methodSignature, returnType, - JavaErrorMessages.message("incompatible.return.type"), textRange, PsiUtil.getLanguageLevel(aClass)); + JavaErrorBundle.message("incompatible.return.type"), textRange, PsiUtil.getLanguageLevel(aClass)); if (info != null) return info; } @@ -253,9 +253,9 @@ public class HighlightMethodUtil { // strange things happen when super method is from Object and method from interface if (superMethod.hasModifierProperty(PsiModifier.FINAL)) { PsiClass superClass = superMethod.getContainingClass(); - String description = JavaErrorMessages.message("final.method.override", - JavaHighlightUtil.formatMethod(method), - JavaHighlightUtil.formatMethod(superMethod), + String description = JavaErrorBundle.message("final.method.override", + JavaHighlightUtil.formatMethod(method), + JavaHighlightUtil.formatMethod(superMethod), superClass != null ? HighlightUtil.formatClass(superClass) : ""); TextRange textRange = HighlightNamesUtil.getMethodDeclarationTextRange(method); HighlightInfo errorResult = HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(textRange).descriptionAndTooltip(description).create(); @@ -308,9 +308,9 @@ public class HighlightMethodUtil { if (superContainingClass != null && !aClass.isInheritor(superContainingClass, true)) continue; } PsiClassType exception = checkedExceptions.get(index); - String description = JavaErrorMessages.message("overridden.method.does.not.throw", - createClashMethodMessage(method, superMethod, true), - JavaHighlightUtil.formatType(exception)); + String description = JavaErrorBundle.message("overridden.method.does.not.throw", + createClashMethodMessage(method, superMethod, true), + JavaHighlightUtil.formatType(exception)); TextRange textRange; if (includeRealPositionInfo) { PsiElement exceptionContext = exceptionContexts.get(index); @@ -440,7 +440,7 @@ public class HighlightMethodUtil { } } else { - String description = JavaErrorMessages.message("method.call.expected"); + String description = JavaErrorBundle.message("method.call.expected"); highlightInfo = HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(methodCall).descriptionAndTooltip(description).create(); if (resolved instanceof PsiClass) { @@ -480,7 +480,7 @@ public class HighlightMethodUtil { PsiElement parent = resolvedMethod.getParent(); String containerName = parent == null ? "" : HighlightMessageUtil.getSymbolName(parent, substitutor); String argTypes = buildArgTypesList(list); - String description = JavaErrorMessages.message("wrong.method.arguments", methodName, containerName, argTypes); + String description = JavaErrorBundle.message("wrong.method.arguments", methodName, containerName, argTypes); String toolTip = null; List mismatchedExpressions; if (parent instanceof PsiClass) { @@ -536,7 +536,8 @@ public class HighlightMethodUtil { : ""; return HighlightUtil.createIncompatibleTypesTooltip(paramType, argType, (lRawType, lTypeArguments, rRawType, rTypeArguments) -> - JavaErrorMessages.message("incompatible.types.html.tooltip", lRawType, lTypeArguments, rRawType, rTypeArguments, reason, "#" + ColorUtil.toHex(UIUtil.getContextHelpForeground()))); + JavaErrorBundle + .message("incompatible.types.html.tooltip", lRawType, lTypeArguments, rRawType, rTypeArguments, reason, "#" + ColorUtil.toHex(UIUtil.getContextHelpForeground()))); } return null; } @@ -657,7 +658,7 @@ public class HighlightMethodUtil { } } - return JavaErrorMessages.message("static.interface.method.call.qualifier"); + return JavaErrorBundle.message("static.interface.method.call.qualifier"); } private static void registerMethodReturnFixAction(@NotNull HighlightInfo highlightInfo, @@ -754,8 +755,10 @@ public class HighlightMethodUtil { PsiClass qualifierClass = RefactoringChangeUtil.getQualifierClass(referenceToMethod); String qualifier = qualifierClass != null ? qualifierClass.getName() : null; - description = qualifier != null ? JavaErrorMessages.message("ambiguous.method.call.no.match", referenceToMethod.getReferenceName(), qualifier) - : JavaErrorMessages.message("cannot.resolve.method", referenceToMethod.getReferenceName() + buildArgTypesList(list)); + description = qualifier != null ? JavaErrorBundle + .message("ambiguous.method.call.no.match", referenceToMethod.getReferenceName(), qualifier) + : JavaErrorBundle + .message("cannot.resolve.method", referenceToMethod.getReferenceName() + buildArgTypesList(list)); highlightInfoType = HighlightInfoType.WRONG_REF; } else { @@ -818,7 +821,7 @@ public class HighlightMethodUtil { if (virtualFile1 != null) m1 += " (In " + virtualFile1.getPresentableUrl() + ")"; if (virtualFile2 != null) m2 += " (In " + virtualFile2.getPresentableUrl() + ")"; } - description = JavaErrorMessages.message("ambiguous.method.call", m1, m2); + description = JavaErrorBundle.message("ambiguous.method.call", m1, m2); toolTip = createAmbiguousMethodHtmlTooltip(new MethodCandidateInfo[]{methodCandidate1, methodCandidate2}); } else { @@ -829,7 +832,7 @@ public class HighlightMethodUtil { return null; } String methodName = referenceToMethod.getReferenceName() + buildArgTypesList(list); - description = JavaErrorMessages.message("cannot.resolve.method", methodName); + description = JavaErrorBundle.message("cannot.resolve.method", methodName); if (candidates.length == 0) { return null; } @@ -962,12 +965,12 @@ public class HighlightMethodUtil { @NotNull private static String createAmbiguousMethodHtmlTooltip(@NotNull MethodCandidateInfo[] methodCandidates) { - return JavaErrorMessages.message("ambiguous.method.html.tooltip", + return JavaErrorBundle.message("ambiguous.method.html.tooltip", methodCandidates[0].getElement().getParameterList().getParametersCount() + 2, - createAmbiguousMethodHtmlTooltipMethodRow(methodCandidates[0]), - getContainingClassName(methodCandidates[0]), - createAmbiguousMethodHtmlTooltipMethodRow(methodCandidates[1]), - getContainingClassName(methodCandidates[1])); + createAmbiguousMethodHtmlTooltipMethodRow(methodCandidates[0]), + getContainingClassName(methodCandidates[0]), + createAmbiguousMethodHtmlTooltipMethodRow(methodCandidates[1]), + getContainingClassName(methodCandidates[1])); } @NotNull @@ -1129,7 +1132,7 @@ public class HighlightMethodUtil { int start = method.getModifierList().getTextRange().getStartOffset(); int end = method.getTextRange().getEndOffset(); - String description = JavaErrorMessages.message("missing.method.body"); + String description = JavaErrorBundle.message("missing.method.body"); errorResult = HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(start, end).descriptionAndTooltip(description).create(); if (HighlightUtil.getIncompatibleModifier(PsiModifier.ABSTRACT, method.getModifierList()) == null && !(aClass instanceof PsiAnonymousClass)) { QuickFixAction.registerQuickFixActions(errorResult, null, JvmElementActionFactories.createModifierActions(method, MemberRequestsKt.modifierRequest(JvmModifier.ABSTRACT, true))); @@ -1148,7 +1151,7 @@ public class HighlightMethodUtil { && !aClass.hasModifierProperty(PsiModifier.ABSTRACT) && !aClass.isEnum() && !PsiUtilCore.hasErrorElementChild(method)) { - String description = JavaErrorMessages.message("abstract.method.in.non.abstract.class"); + String description = JavaErrorBundle.message("abstract.method.in.non.abstract.class"); errorResult = HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(elementToHighlight).descriptionAndTooltip(description).create(); if (method.getBody() != null) { @@ -1167,7 +1170,7 @@ public class HighlightMethodUtil { String className = aClass instanceof PsiAnonymousClass ? null : aClass.getName(); if (className == null || !Comparing.strEqual(method.getName(), className)) { PsiElement element = ObjectUtils.notNull(method.getNameIdentifier(), method); - String description = JavaErrorMessages.message("missing.return.type"); + String description = JavaErrorBundle.message("missing.return.type"); HighlightInfo info = HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(element).descriptionAndTooltip(description).create(); if (className != null) { QuickFixAction.registerQuickFixAction(info, QUICK_FIX_FACTORY.createRenameElementFix(method, className)); @@ -1195,9 +1198,9 @@ public class HighlightMethodUtil { methodCount++; } if (methodCount > 1) { - String description = JavaErrorMessages.message("duplicate.method", - JavaHighlightUtil.formatMethod(method), - HighlightUtil.formatClass(aClass)); + String description = JavaErrorBundle.message("duplicate.method", + JavaHighlightUtil.formatMethod(method), + HighlightUtil.formatClass(aClass)); TextRange textRange = HighlightNamesUtil.getMethodDeclarationTextRange(method); return HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR). range(method, textRange.getStartOffset(), textRange.getEndOffset()). @@ -1218,7 +1221,7 @@ public class HighlightMethodUtil { String description = null; if (hasNoBody) { if (isExtension) { - description = JavaErrorMessages.message("extension.method.should.have.a.body"); + description = JavaErrorBundle.message("extension.method.should.have.a.body"); } else if (isInterface) { if (isStatic && languageLevel.isAtLeast(LanguageLevel.JDK_1_8)) { @@ -1234,7 +1237,7 @@ public class HighlightMethodUtil { } else if (isInterface) { if (!isExtension && !isStatic && !isPrivate) { - description = JavaErrorMessages.message("interface.methods.cannot.have.body"); + description = JavaErrorBundle.message("interface.methods.cannot.have.body"); if (languageLevel.isAtLeast(LanguageLevel.JDK_1_8)) { if (Stream.of(method.findDeepestSuperMethods()).map(PsiMethod::getContainingClass) .filter(Objects::nonNull).map(PsiClass::getQualifiedName).noneMatch(CommonClassNames.JAVA_LANG_OBJECT::equals)) { @@ -1245,14 +1248,14 @@ public class HighlightMethodUtil { } } else if (isExtension) { - description = JavaErrorMessages.message("extension.method.in.class"); + description = JavaErrorBundle.message("extension.method.in.class"); additionalFixes.add(QUICK_FIX_FACTORY.createModifierListFix(method, PsiModifier.DEFAULT, false, false)); } else if (method.hasModifierProperty(PsiModifier.ABSTRACT)) { - description = JavaErrorMessages.message("abstract.methods.cannot.have.a.body"); + description = JavaErrorBundle.message("abstract.methods.cannot.have.a.body"); } else if (method.hasModifierProperty(PsiModifier.NATIVE)) { - description = JavaErrorMessages.message("native.methods.cannot.have.a.body"); + description = JavaErrorBundle.message("native.methods.cannot.have.a.body"); } if (description == null) return null; @@ -1281,7 +1284,7 @@ public class HighlightMethodUtil { if (ctor != null && ctor.isConstructor()) { if (JavaPsiRecordUtil.isCompactConstructor(ctor) || JavaPsiRecordUtil.isExplicitCanonicalConstructor(ctor)) { - String message = JavaErrorMessages.message("record.constructor.call.in.canonical"); + String message = JavaErrorBundle.message("record.constructor.call.in.canonical"); return HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(methodCall).descriptionAndTooltip(message).create(); } PsiElement prevSibling = methodCall.getParent().getPrevSibling(); @@ -1293,7 +1296,7 @@ public class HighlightMethodUtil { } } PsiReferenceExpression expression = methodCall.getMethodExpression(); - String message = JavaErrorMessages.message("constructor.call.must.be.first.statement", expression.getText() + "()"); + String message = JavaErrorBundle.message("constructor.call.must.be.first.statement", expression.getText() + "()"); return HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(methodCall).descriptionAndTooltip(message).create(); } @@ -1303,7 +1306,7 @@ public class HighlightMethodUtil { if (!(expression.getQualifierExpression() instanceof PsiSuperExpression)) return null; PsiMethod method = methodCallExpression.resolveMethod(); if (method != null && method.hasModifierProperty(PsiModifier.ABSTRACT)) { - String message = JavaErrorMessages.message("direct.abstract.method.access", JavaHighlightUtil.formatMethod(method)); + String message = JavaErrorBundle.message("direct.abstract.method.access", JavaHighlightUtil.formatMethod(method)); return HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(methodCallExpression).descriptionAndTooltip(message).create(); } return null; @@ -1389,11 +1392,11 @@ public class HighlightMethodUtil { ? "static.method.cannot.override.instance.method" : "instance.method.cannot.override.static.method"; - String description = JavaErrorMessages.message(messageKey, - JavaHighlightUtil.formatMethod(method), - HighlightUtil.formatClass(aClass), - JavaHighlightUtil.formatMethod(superMethod), - HighlightUtil.formatClass(superClass)); + String description = JavaErrorBundle.message(messageKey, + JavaHighlightUtil.formatMethod(method), + HighlightUtil.formatClass(aClass), + JavaHighlightUtil.formatMethod(superMethod), + HighlightUtil.formatClass(superClass)); HighlightInfo info = HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(textRange).descriptionAndTooltip(description).create(); if (!isSuperMethodStatic || HighlightUtil.getIncompatibleModifier(PsiModifier.STATIC, modifierList) == null) { @@ -1455,7 +1458,7 @@ public class HighlightMethodUtil { if (otherSuperMethod.getTypeParameters().length > 0 && JavaGenericsUtil.isRawToGeneric(otherReturnType, curType)) return null; } return createIncompatibleReturnTypeMessage(otherSuperMethod, currentMethod, curType, otherReturnType, - JavaErrorMessages.message("unrelated.overriding.methods.return.types"), TextRange.EMPTY_RANGE); + JavaErrorBundle.message("unrelated.overriding.methods.return.types"), TextRange.EMPTY_RANGE); }); if (info != null) return info; } @@ -1497,10 +1500,10 @@ public class HighlightMethodUtil { PsiMethod superMethod = superSignature.getMethod(); if (!superMethod.hasModifierProperty(PsiModifier.STATIC)) { PsiClass superClass = superMethod.getContainingClass(); - description = JavaErrorMessages.message("static.method.cannot.override.instance.method", - JavaHighlightUtil.formatMethod(method), - HighlightUtil.formatClass(containingClass), - JavaHighlightUtil.formatMethod(superMethod), + description = JavaErrorBundle.message("static.method.cannot.override.instance.method", + JavaHighlightUtil.formatMethod(method), + HighlightUtil.formatClass(containingClass), + JavaHighlightUtil.formatMethod(superMethod), superClass != null ? HighlightUtil.formatClass(superClass) : ""); appendImplementMethodFix = false; break Ultimate; @@ -1561,7 +1564,7 @@ public class HighlightMethodUtil { static HighlightInfo checkRecursiveConstructorInvocation(@NotNull PsiMethod method) { if (HighlightControlFlowUtil.isRecursivelyCalledConstructor(method)) { TextRange textRange = HighlightNamesUtil.getMethodDeclarationTextRange(method); - String description = JavaErrorMessages.message("recursive.constructor.invocation"); + String description = JavaErrorBundle.message("recursive.constructor.invocation"); return HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(textRange).descriptionAndTooltip(description).create(); } return null; @@ -1633,7 +1636,7 @@ public class HighlightMethodUtil { if (!list.isEmpty()) { String constructorName = aClass.getName(); String argTypes = buildArgTypesList(list); - String description = JavaErrorMessages.message("wrong.constructor.arguments", constructorName+"()", argTypes); + String description = JavaErrorBundle.message("wrong.constructor.arguments", constructorName + "()", argTypes); String tooltip = createMismatchedArgumentsHtmlTooltip(list, null, PsiParameter.EMPTY_ARRAY, PsiSubstitutor.EMPTY); HighlightInfo info = HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(list).description(description).escapedToolTip(tooltip).navigationShift(+1).create(); QuickFixAction.registerQuickFixActions( @@ -1694,7 +1697,7 @@ public class HighlightMethodUtil { if (constructor == null) { String name = aClass.getName(); name += buildArgTypesList(list); - String description = JavaErrorMessages.message("cannot.resolve.constructor", name); + String description = JavaErrorBundle.message("cannot.resolve.constructor", name); HighlightInfo info = HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(list).descriptionAndTooltip(description).navigationShift(+1).create(); if (info != null) { WrapExpressionFix.registerWrapAction(results, list.getExpressions(), info, getFixRange(list)); @@ -1928,13 +1931,13 @@ public class HighlightMethodUtil { if (methodType == null) return null; // Either constructor or incorrect method, will be reported in another way if (!componentType.equals(methodType)) { String message = - JavaErrorMessages.message("record.accessor.wrong.return.type", componentType.getPresentableText(), methodType.getPresentableText()); + JavaErrorBundle.message("record.accessor.wrong.return.type", componentType.getPresentableText(), methodType.getPresentableText()); HighlightInfo info = HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range( Objects.requireNonNull(method.getReturnTypeElement())).descriptionAndTooltip(message).create(); QuickFixAction.registerQuickFixAction(info, QUICK_FIX_FACTORY.createMethodReturnFix(method, componentType, false)); return info; } - return checkRecordSpecialMethodDeclaration(method, JavaErrorMessages.message("record.accessor")); + return checkRecordSpecialMethodDeclaration(method, JavaErrorBundle.message("record.accessor")); } @NotNull @@ -1947,7 +1950,7 @@ public class HighlightMethodUtil { if (!aClass.isRecord()) { if (JavaPsiRecordUtil.isCompactConstructor(method)) { HighlightInfo info = HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range( - identifier).descriptionAndTooltip(JavaErrorMessages.message("compact.constructor.in.regular.class")).create(); + identifier).descriptionAndTooltip(JavaErrorBundle.message("compact.constructor.in.regular.class")).create(); QuickFixAction.registerQuickFixAction(info, QUICK_FIX_FACTORY.createAddParameterListFix(method)); return Collections.singletonList(info); } @@ -1965,15 +1968,15 @@ public class HighlightMethodUtil { String parameterName = parameters[i].getName(); if (!parameterType.equals(componentType)) { String message = - JavaErrorMessages.message("record.canonical.constructor.wrong.parameter.type", componentName, - componentType.getPresentableText(), parameterType.getPresentableText()); + JavaErrorBundle.message("record.canonical.constructor.wrong.parameter.type", componentName, + componentType.getPresentableText(), parameterType.getPresentableText()); HighlightInfo info = HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range( Objects.requireNonNull(parameters[i].getTypeElement())).descriptionAndTooltip(message).create(); QuickFixAction.registerQuickFixAction(info, QUICK_FIX_FACTORY.createMethodParameterTypeFix(method, i, componentType, false)); problems.add(info); } if (componentName != null && !parameterName.equals(componentName)) { - String message = JavaErrorMessages.message("record.canonical.constructor.wrong.parameter.name", componentName, parameterName); + String message = JavaErrorBundle.message("record.canonical.constructor.wrong.parameter.name", componentName, parameterName); HighlightInfo info = HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range( Objects.requireNonNull(parameters[i].getNameIdentifier())).descriptionAndTooltip(message).create(); if (Arrays.stream(parameters).map(PsiParameter::getName).noneMatch(Predicate.isEqual(componentName))) { @@ -1983,17 +1986,17 @@ public class HighlightMethodUtil { } } ContainerUtil - .addIfNotNull(problems, checkRecordSpecialMethodDeclaration(method, JavaErrorMessages.message("record.canonical.constructor"))); + .addIfNotNull(problems, checkRecordSpecialMethodDeclaration(method, JavaErrorBundle.message("record.canonical.constructor"))); return problems; } else if (JavaPsiRecordUtil.isCompactConstructor(method)) { return Collections - .singletonList(checkRecordSpecialMethodDeclaration(method, JavaErrorMessages.message("record.compact.constructor"))); + .singletonList(checkRecordSpecialMethodDeclaration(method, JavaErrorBundle.message("record.compact.constructor"))); } else { // Non-canonical constructor PsiMethodCallExpression call = JavaPsiConstructorUtil.findThisOrSuperCallInConstructor(method); if (call == null || JavaPsiConstructorUtil.isSuperConstructorCall(call)) { - String message = JavaErrorMessages.message("record.no.constructor.call.in.non.canonical"); + String message = JavaErrorBundle.message("record.no.constructor.call.in.non.canonical"); return Collections.singletonList(HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(identifier) .descriptionAndTooltip(message).create()); } @@ -2008,14 +2011,14 @@ public class HighlightMethodUtil { PsiTypeParameterList typeParameterList = method.getTypeParameterList(); if (typeParameterList != null && typeParameterList.getTypeParameters().length > 0) { HighlightInfo info = HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(typeParameterList) - .descriptionAndTooltip(JavaErrorMessages.message("record.special.method.type.parameters", methodTitle)) + .descriptionAndTooltip(JavaErrorBundle.message("record.special.method.type.parameters", methodTitle)) .create(); QuickFixAction.registerQuickFixAction(info, QUICK_FIX_FACTORY.createDeleteFix(typeParameterList)); return info; } if (!method.hasModifierProperty(PsiModifier.PUBLIC)) { HighlightInfo info = HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(identifier) - .descriptionAndTooltip(JavaErrorMessages.message("record.special.method.non.public", methodTitle)) + .descriptionAndTooltip(JavaErrorBundle.message("record.special.method.non.public", methodTitle)) .create(); QuickFixAction.registerQuickFixAction(info, QUICK_FIX_FACTORY.createModifierListFix(method, PsiModifier.PUBLIC, true, false)); return info; @@ -2023,7 +2026,7 @@ public class HighlightMethodUtil { PsiReferenceList throwsList = method.getThrowsList(); if (throwsList.getReferenceElements().length > 0) { HighlightInfo info = HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(throwsList) - .descriptionAndTooltip(JavaErrorMessages.message("record.special.method.throws", methodTitle)) + .descriptionAndTooltip(JavaErrorBundle.message("record.special.method.throws", methodTitle)) .create(); QuickFixAction.registerQuickFixAction(info, QUICK_FIX_FACTORY.createDeleteFix(throwsList)); return info; diff --git a/java/java-analysis-impl/src/com/intellij/codeInsight/daemon/impl/analysis/HighlightUtil.java b/java/java-analysis-impl/src/com/intellij/codeInsight/daemon/impl/analysis/HighlightUtil.java index 61782b2b621e..90a73516bb47 100644 --- a/java/java-analysis-impl/src/com/intellij/codeInsight/daemon/impl/analysis/HighlightUtil.java +++ b/java/java-analysis-impl/src/com/intellij/codeInsight/daemon/impl/analysis/HighlightUtil.java @@ -6,7 +6,7 @@ import com.intellij.codeInsight.ContainerProvider; import com.intellij.codeInsight.ExceptionUtil; import com.intellij.codeInsight.JavaModuleSystemEx; import com.intellij.codeInsight.JavaModuleSystemEx.ErrorWithFixes; -import com.intellij.codeInsight.daemon.JavaErrorMessages; +import com.intellij.codeInsight.daemon.JavaErrorBundle; import com.intellij.codeInsight.daemon.impl.HighlightInfo; import com.intellij.codeInsight.daemon.impl.HighlightInfoType; import com.intellij.codeInsight.daemon.impl.quickfix.*; @@ -198,7 +198,7 @@ public class HighlightUtil extends HighlightUtilBase { if (TypeConversionUtil.isPrimitiveAndNotNull(operandType) || TypeConversionUtil.isPrimitiveAndNotNull(checkType) || !TypeConversionUtil.areTypesConvertible(operandType, checkType)) { - String message = JavaErrorMessages.message("inconvertible.type.cast", JavaHighlightUtil.formatType(operandType), JavaHighlightUtil + String message = JavaErrorBundle.message("inconvertible.type.cast", JavaHighlightUtil.formatType(operandType), JavaHighlightUtil .formatType(checkType)); return HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(expression).descriptionAndTooltip(message).create(); } @@ -234,7 +234,7 @@ public class HighlightUtil extends HighlightUtilBase { if (aClass != null && !aClass.isInterface()) { final HighlightInfo errorResult = HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR) .range(conjunct) - .descriptionAndTooltip(JavaErrorMessages.message("interface.expected")).create(); + .descriptionAndTooltip(JavaErrorBundle.message("interface.expected")).create(); QuickFixAction.registerQuickFixAction(errorResult, new FlipIntersectionSidesFix(aClass.getName(), conjList, conjunct, castTypeElement), null); return errorResult; } @@ -293,7 +293,7 @@ public class HighlightUtil extends HighlightUtilBase { if (operandType != null && !TypeConversionUtil.areTypesConvertible(operandType, castType, PsiUtil.getLanguageLevel(expression)) && !RedundantCastUtil.isInPolymorphicCall(expression)) { - String message = JavaErrorMessages.message("inconvertible.type.cast", JavaHighlightUtil.formatType(operandType), JavaHighlightUtil + String message = JavaErrorBundle.message("inconvertible.type.cast", JavaHighlightUtil.formatType(operandType), JavaHighlightUtil .formatType(castType)); return HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(expression).descriptionAndTooltip(message).create(); } @@ -316,7 +316,7 @@ public class HighlightUtil extends HighlightUtilBase { } HighlightInfo errorResult = null; if (lValue != null && !TypeConversionUtil.isLValue(lValue)) { - String description = JavaErrorMessages.message("variable.expected"); + String description = JavaErrorBundle.message("variable.expected"); errorResult = HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(lValue).descriptionAndTooltip(description).create(); } @@ -336,9 +336,9 @@ public class HighlightUtil extends HighlightUtilBase { HighlightInfo errorResult = null; if (!TypeConversionUtil.isBinaryOperatorApplicable(opSign, lType, rType, true)) { String operatorText = operationSign.getText().substring(0, operationSign.getText().length() - 1); - String message = JavaErrorMessages.message("binary.operator.not.applicable", operatorText, - JavaHighlightUtil.formatType(lType), - JavaHighlightUtil.formatType(rType)); + String message = JavaErrorBundle.message("binary.operator.not.applicable", operatorText, + JavaHighlightUtil.formatType(lType), + JavaHighlightUtil.formatType(rType)); errorResult = HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(operationSign).descriptionAndTooltip(message).create(); } @@ -414,7 +414,7 @@ public class HighlightUtil extends HighlightUtilBase { static HighlightInfo checkLegalVarReference(@NotNull PsiJavaCodeReferenceElement ref, @NotNull PsiClass resolved) { if (PsiKeyword.VAR.equals(resolved.getName()) && PsiUtil.getLanguageLevel(ref).isAtLeast(LanguageLevel.JDK_10)) { - String message = JavaErrorMessages.message("lvti.illegal"); + String message = JavaErrorBundle.message("lvti.illegal"); PsiElement range = ObjectUtils.notNull(ref.getReferenceNameElement(), ref); return HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).descriptionAndTooltip(message).range(range).create(); } @@ -427,39 +427,39 @@ public class HighlightUtil extends HighlightUtilBase { if (variable instanceof PsiLocalVariable) { PsiExpression initializer = variable.getInitializer(); if (initializer == null) { - String message = JavaErrorMessages.message("lvti.no.initializer"); + String message = JavaErrorBundle.message("lvti.no.initializer"); return HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).descriptionAndTooltip(message).range(typeElement).create(); } if (initializer instanceof PsiFunctionalExpression) { boolean lambda = initializer instanceof PsiLambdaExpression; - String message = JavaErrorMessages.message(lambda ? "lvti.lambda" : "lvti.method.ref"); + String message = JavaErrorBundle.message(lambda ? "lvti.lambda" : "lvti.method.ref"); return HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).descriptionAndTooltip(message).range(typeElement).create(); } PsiElement parent = variable.getParent(); if (parent instanceof PsiDeclarationStatement && ((PsiDeclarationStatement)parent).getDeclaredElements().length > 1) { - String message = JavaErrorMessages.message("lvti.compound"); + String message = JavaErrorBundle.message("lvti.compound"); return HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).descriptionAndTooltip(message).range(variable).create(); } if (isArray(variable)) { - String message = JavaErrorMessages.message("lvti.array"); + String message = JavaErrorBundle.message("lvti.array"); return HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).descriptionAndTooltip(message).range(typeElement).create(); } PsiType lType = variable.getType(); if (PsiType.NULL.equals(lType)) { boolean isSelfReferencing = ReferencesSearch.search(variable, new LocalSearchScope(initializer)).findFirst() != null; - String message = JavaErrorMessages.message(isSelfReferencing ? "lvti.selfReferenced" : "lvti.null"); + String message = JavaErrorBundle.message(isSelfReferencing ? "lvti.selfReferenced" : "lvti.null"); return HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).descriptionAndTooltip(message).range(typeElement).create(); } if (PsiType.VOID.equals(lType)) { - String message = JavaErrorMessages.message("lvti.void"); + String message = JavaErrorBundle.message("lvti.void"); return HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).descriptionAndTooltip(message).range(typeElement).create(); } } else if (variable instanceof PsiParameter && variable.getParent() instanceof PsiParameterList && isArray(variable)) { - String message = JavaErrorMessages.message("lvti.array"); + String message = JavaErrorBundle.message("lvti.array"); return HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).descriptionAndTooltip(message).range(typeElement).create(); } } @@ -516,7 +516,7 @@ public class HighlightUtil extends HighlightUtilBase { static HighlightInfo checkReturnFromSwitchExpr(@NotNull PsiStatement statement) { if (PsiImplUtil.findEnclosingSwitchExpression(statement) != null) { - String message = JavaErrorMessages.message("return.outside.switch.expr"); + String message = JavaErrorBundle.message("return.outside.switch.expr"); return HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(statement).descriptionAndTooltip(message).create(); } @@ -531,7 +531,7 @@ public class HighlightUtil extends HighlightUtilBase { String description; HighlightInfo errorResult = null; if (method == null && !(parent instanceof ServerPageFile)) { - description = JavaErrorMessages.message("return.outside.method"); + description = JavaErrorBundle.message("return.outside.method"); errorResult = HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(statement).descriptionAndTooltip(description).create(); } else { @@ -541,7 +541,7 @@ public class HighlightUtil extends HighlightUtilBase { if (returnValue != null) { PsiType valueType = RefactoringChangeUtil.getTypeByExpression(returnValue); if (isMethodVoid) { - description = JavaErrorMessages.message("return.from.void.method"); + description = JavaErrorBundle.message("return.from.void.method"); errorResult = HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(statement).descriptionAndTooltip(description).create(); if (method != null && valueType != null && method.getBody() != null) { @@ -568,7 +568,7 @@ public class HighlightUtil extends HighlightUtilBase { } } else if (!isMethodVoid) { - description = JavaErrorMessages.message("missing.return.value"); + description = JavaErrorBundle.message("missing.return.value"); errorResult = HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(statement).descriptionAndTooltip(description) .navigationShift(PsiKeyword.RETURN.length()).create(); QuickFixAction.registerQuickFixAction(errorResult, QUICK_FIX_FACTORY.createMethodReturnFix(method, PsiType.VOID, true)); @@ -590,8 +590,8 @@ public class HighlightUtil extends HighlightUtilBase { private static String getUnhandledExceptionsDescriptor(@NotNull final Collection unhandled, @Nullable final String source) { final String exceptions = formatTypes(unhandled); return source == null - ? JavaErrorMessages.message("unhandled.exceptions", exceptions, unhandled.size()) - : JavaErrorMessages.message("unhandled.close.exceptions", exceptions, unhandled.size(), source); + ? JavaErrorBundle.message("unhandled.exceptions", exceptions, unhandled.size()) + : JavaErrorBundle.message("unhandled.close.exceptions", exceptions, unhandled.size(), source); } @NotNull @@ -647,7 +647,7 @@ public class HighlightUtil extends HighlightUtilBase { } if (oldVariable != null) { - String description = JavaErrorMessages.message("variable.already.defined", variable.getName()); + String description = JavaErrorBundle.message("variable.already.defined", variable.getName()); PsiIdentifier identifier = variable.getNameIdentifier(); assert identifier != null : variable; VirtualFile vFile = PsiUtilCore.getVirtualFile(identifier); @@ -656,7 +656,7 @@ public class HighlightUtil extends HighlightUtilBase { final String path = FileUtil.toSystemIndependentName(vFile.getPath()); String linkText = "" + variable.getName() + ""; builder = builder.description(description) - .escapedToolTip("" + JavaErrorMessages.message("variable.already.defined", linkText) + ""); + .escapedToolTip("" + JavaErrorBundle.message("variable.already.defined", linkText) + ""); } else { builder = builder.descriptionAndTooltip(description); @@ -736,13 +736,13 @@ public class HighlightUtil extends HighlightUtilBase { static HighlightInfo checkUnderscore(@NotNull PsiIdentifier identifier, @NotNull LanguageLevel languageLevel) { if ("_".equals(identifier.getText())) { if (languageLevel.isAtLeast(LanguageLevel.JDK_1_9)) { - String text = JavaErrorMessages.message("underscore.identifier.error"); + String text = JavaErrorBundle.message("underscore.identifier.error"); return HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(identifier).descriptionAndTooltip(text).create(); } else if (languageLevel.isAtLeast(LanguageLevel.JDK_1_8)) { PsiElement parent = identifier.getParent(); if (parent instanceof PsiParameter && ((PsiParameter)parent).getDeclarationScope() instanceof PsiLambdaExpression) { - String text = JavaErrorMessages.message("underscore.lambda.identifier"); + String text = JavaErrorBundle.message("underscore.lambda.identifier"); return HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(identifier).descriptionAndTooltip(text).create(); } } @@ -815,7 +815,7 @@ public class HighlightUtil extends HighlightUtilBase { static HighlightInfo checkYieldOutsideSwitchExpression(@NotNull PsiYieldStatement statement) { if (statement.findEnclosingExpression() == null) { - String message = JavaErrorMessages.message("yield.unexpected"); + String message = JavaErrorBundle.message("yield.unexpected"); return HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(statement).descriptionAndTooltip(message).create(); } @@ -825,7 +825,7 @@ public class HighlightUtil extends HighlightUtilBase { static HighlightInfo checkYieldExpressionType(@NotNull PsiYieldStatement statement) { PsiExpression expression = statement.getExpression(); if (expression != null && PsiType.VOID.equals(expression.getType())) { - String message = JavaErrorMessages.message("yield.void"); + String message = JavaErrorBundle.message("yield.void"); return HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(expression).descriptionAndTooltip(message).create(); } @@ -837,7 +837,7 @@ public class HighlightUtil extends HighlightUtilBase { PsiIdentifier label = statement.getLabelIdentifier(); if (label != null && continuedStatement != null && !(continuedStatement instanceof PsiLoopStatement)) { - String message = JavaErrorMessages.message("not.loop.label", label.getText()); + String message = JavaErrorBundle.message("not.loop.label", label.getText()); return HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(statement).descriptionAndTooltip(message).create(); } @@ -850,23 +850,23 @@ public class HighlightUtil extends HighlightUtilBase { @Nullable PsiIdentifier label, @Nullable PsiStatement target, LanguageLevel level, - @PropertyKey(resourceBundle = JavaErrorMessages.BUNDLE) String misplacedKey, - @PropertyKey(resourceBundle = JavaErrorMessages.BUNDLE) String crossingKey) { + @PropertyKey(resourceBundle = JavaErrorBundle.BUNDLE) String misplacedKey, + @PropertyKey(resourceBundle = JavaErrorBundle.BUNDLE) String crossingKey) { if (target == null && label != null) { - String message = JavaErrorMessages.message("unresolved.label", label.getText()); + String message = JavaErrorBundle.message("unresolved.label", label.getText()); return HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(label).descriptionAndTooltip(message).create(); } if (Feature.ENHANCED_SWITCH.isSufficient(level)) { PsiSwitchExpression expression = PsiImplUtil.findEnclosingSwitchExpression(statement); if (expression != null && (target == null || PsiTreeUtil.isAncestor(target, expression, true))) { - String message = JavaErrorMessages.message(crossingKey); + String message = JavaErrorBundle.message(crossingKey); return HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(statement).descriptionAndTooltip(message).create(); } } if (target == null) { - String message = JavaErrorMessages.message(misplacedKey); + String message = JavaErrorBundle.message(misplacedKey); return HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(statement).descriptionAndTooltip(message).create(); } @@ -877,7 +877,7 @@ public class HighlightUtil extends HighlightUtilBase { @PsiModifier.ModifierConstant String modifier = keyword.getText(); String incompatible = getIncompatibleModifier(modifier, modifierList); if (incompatible != null) { - String message = JavaErrorMessages.message("incompatible.modifiers", modifier, incompatible); + String message = JavaErrorBundle.message("incompatible.modifiers", modifier, incompatible); HighlightInfo highlightInfo = HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(keyword).descriptionAndTooltip(message).create(); QuickFixAction.registerQuickFixAction(highlightInfo, QUICK_FIX_FACTORY.createModifierListFix(modifierList, modifier, false, false)); @@ -1033,7 +1033,7 @@ public class HighlightUtil extends HighlightUtilBase { isAllowed &= incompatibles != null; if (!isAllowed) { - String message = JavaErrorMessages.message("modifier.not.allowed", modifier); + String message = JavaErrorBundle.message("modifier.not.allowed", modifier); HighlightInfo highlightInfo = HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(keyword).descriptionAndTooltip(message).create(); QuickFixAction.registerQuickFixAction(highlightInfo, fix != null ? fix : QUICK_FIX_FACTORY.createModifierListFix(modifierList, modifier, false, false)); return highlightInfo; @@ -1088,15 +1088,15 @@ public class HighlightUtil extends HighlightUtilBase { parent instanceof PsiPrefixExpression && ((PsiPrefixExpression)parent).getOperationTokenType() == JavaTokenType.MINUS)) { if (cleanText.equals(PsiLiteralUtil.HEX_PREFIX)) { - String message = JavaErrorMessages.message("hexadecimal.numbers.must.contain.at.least.one.hexadecimal.digit"); + String message = JavaErrorBundle.message("hexadecimal.numbers.must.contain.at.least.one.hexadecimal.digit"); return HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(expression).descriptionAndTooltip(message).create(); } if (cleanText.equals(PsiLiteralUtil.BIN_PREFIX)) { - String message = JavaErrorMessages.message("binary.numbers.must.contain.at.least.one.hexadecimal.digit"); + String message = JavaErrorBundle.message("binary.numbers.must.contain.at.least.one.hexadecimal.digit"); return HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(expression).descriptionAndTooltip(message).create(); } if (value == null || cleanText.equals(PsiLiteralUtil._2_IN_31)) { - String message = JavaErrorMessages.message("integer.number.too.large"); + String message = JavaErrorBundle.message("integer.number.too.large"); return HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(expression).descriptionAndTooltip(message).create(); } } @@ -1108,22 +1108,22 @@ public class HighlightUtil extends HighlightUtilBase { parent instanceof PsiPrefixExpression && ((PsiPrefixExpression)parent).getOperationTokenType() == JavaTokenType.MINUS)) { if (cleanText.equals(PsiLiteralUtil.HEX_PREFIX)) { - String message = JavaErrorMessages.message("hexadecimal.numbers.must.contain.at.least.one.hexadecimal.digit"); + String message = JavaErrorBundle.message("hexadecimal.numbers.must.contain.at.least.one.hexadecimal.digit"); return HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(expression).descriptionAndTooltip(message).create(); } if (cleanText.equals(PsiLiteralUtil.BIN_PREFIX)) { - String message = JavaErrorMessages.message("binary.numbers.must.contain.at.least.one.hexadecimal.digit"); + String message = JavaErrorBundle.message("binary.numbers.must.contain.at.least.one.hexadecimal.digit"); return HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(expression).descriptionAndTooltip(message).create(); } if (value == null || cleanText.equals(PsiLiteralUtil._2_IN_63)) { - String message = JavaErrorMessages.message("long.number.too.large"); + String message = JavaErrorBundle.message("long.number.too.large"); return HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(expression).descriptionAndTooltip(message).create(); } } } else if (isFP) { if (value == null) { - String message = JavaErrorMessages.message("malformed.floating.point.literal"); + String message = JavaErrorBundle.message("malformed.floating.point.literal"); return HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(expression).descriptionAndTooltip(message).create(); } } @@ -1133,7 +1133,7 @@ public class HighlightUtil extends HighlightUtilBase { return null; } if (!StringUtil.endsWithChar(text, '\'') || text.length() == 1) { - String message = JavaErrorMessages.message("unclosed.char.literal"); + String message = JavaErrorBundle.message("unclosed.char.literal"); return HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(expression).descriptionAndTooltip(message).create(); } text = text.substring(1, text.length() - 1); @@ -1141,18 +1141,18 @@ public class HighlightUtil extends HighlightUtilBase { StringBuilder chars = new StringBuilder(); boolean success = PsiLiteralExpressionImpl.parseStringCharacters(text, chars, null); if (!success) { - String message = JavaErrorMessages.message("illegal.escape.character.in.character.literal"); + String message = JavaErrorBundle.message("illegal.escape.character.in.character.literal"); return HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(expression).descriptionAndTooltip(message).create(); } int length = chars.length(); if (length > 1) { - String message = JavaErrorMessages.message("too.many.characters.in.character.literal"); + String message = JavaErrorBundle.message("too.many.characters.in.character.literal"); HighlightInfo info = HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(expression).descriptionAndTooltip(message).create(); QuickFixAction.registerQuickFixAction(info, QUICK_FIX_FACTORY.createConvertToStringLiteralAction()); return info; } else if (length == 0) { - String message = JavaErrorMessages.message("empty.character.literal"); + String message = JavaErrorBundle.message("empty.character.literal"); return HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(expression).descriptionAndTooltip(message).create(); } } @@ -1168,20 +1168,20 @@ public class HighlightUtil extends HighlightUtilBase { if (!StringUtil.startsWithChar(text, '\"')) return null; if (StringUtil.endsWithChar(text, '\"')) { if (text.length() == 1) { - String message = JavaErrorMessages.message("illegal.line.end.in.string.literal"); + String message = JavaErrorBundle.message("illegal.line.end.in.string.literal"); return HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(expression).descriptionAndTooltip(message).create(); } text = text.substring(1, text.length() - 1); } else { - String message = JavaErrorMessages.message("illegal.line.end.in.string.literal"); + String message = JavaErrorBundle.message("illegal.line.end.in.string.literal"); return HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(expression).descriptionAndTooltip(message).create(); } StringBuilder chars = new StringBuilder(); boolean success = PsiLiteralExpressionImpl.parseStringCharacters(text, chars, null); if (!success) { - String message = JavaErrorMessages.message("illegal.escape.character.in.string.literal"); + String message = JavaErrorBundle.message("illegal.escape.character.in.string.literal"); return HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(expression).descriptionAndTooltip(message).create(); } } @@ -1189,7 +1189,7 @@ public class HighlightUtil extends HighlightUtilBase { else if (type == JavaTokenType.TEXT_BLOCK_LITERAL) { if (value == null) { if (!text.endsWith("\"\"\"")) { - String message = JavaErrorMessages.message("text.block.unclosed"); + String message = JavaErrorBundle.message("text.block.unclosed"); int p = expression.getTextRange().getEndOffset(); return HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(p, p).endOfLine().descriptionAndTooltip(message).create(); } @@ -1198,7 +1198,7 @@ public class HighlightUtil extends HighlightUtilBase { int[] offsets = new int[text.length() + 1]; boolean success = CodeInsightUtilCore.parseStringCharacters(text, chars, offsets); if (!success) { - String message = JavaErrorMessages.message("illegal.escape.character.in.string.literal"); + String message = JavaErrorBundle.message("illegal.escape.character.in.string.literal"); TextRange textRange = chars.length() < text.length() - 1 ? new TextRange(offsets[chars.length()], offsets[chars.length() + 1]) : expression.getTextRange(); return HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR) @@ -1206,7 +1206,7 @@ public class HighlightUtil extends HighlightUtilBase { .descriptionAndTooltip(message).create(); } else { - String message = JavaErrorMessages.message("text.block.new.line"); + String message = JavaErrorBundle.message("text.block.new.line"); return HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(expression).descriptionAndTooltip(message).create(); } } @@ -1216,22 +1216,22 @@ public class HighlightUtil extends HighlightUtilBase { if (value instanceof Float) { Float number = (Float)value; if (number.isInfinite()) { - String message = JavaErrorMessages.message("floating.point.number.too.large"); + String message = JavaErrorBundle.message("floating.point.number.too.large"); return HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(expression).descriptionAndTooltip(message).create(); } if (number.floatValue() == 0 && !TypeConversionUtil.isFPZero(text)) { - String message = JavaErrorMessages.message("floating.point.number.too.small"); + String message = JavaErrorBundle.message("floating.point.number.too.small"); return HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(expression).descriptionAndTooltip(message).create(); } } else if (value instanceof Double) { Double number = (Double)value; if (number.isInfinite()) { - String message = JavaErrorMessages.message("floating.point.number.too.large"); + String message = JavaErrorBundle.message("floating.point.number.too.large"); return HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(expression).descriptionAndTooltip(message).create(); } if (number.doubleValue() == 0 && !TypeConversionUtil.isFPZero(text)) { - String message = JavaErrorMessages.message("floating.point.number.too.small"); + String message = JavaErrorBundle.message("floating.point.number.too.small"); return HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(expression).descriptionAndTooltip(message).create(); } } @@ -1268,7 +1268,7 @@ public class HighlightUtil extends HighlightUtilBase { for (String part : parts) { if (part != null && (StringUtil.startsWithChar(part, '_') || StringUtil.endsWithChar(part, '_'))) { - String message = JavaErrorMessages.message("illegal.underscore"); + String message = JavaErrorBundle.message("illegal.underscore"); return HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(expression).descriptionAndTooltip(message).create(); } } @@ -1349,7 +1349,7 @@ public class HighlightUtil extends HighlightUtilBase { if (exceptionType.isAssignableFrom(caughtType) || caughtType.isAssignableFrom(exceptionType)) return null; } - final String description = JavaErrorMessages.message("exception.never.thrown.try", JavaHighlightUtil.formatType(caughtType)); + final String description = JavaErrorBundle.message("exception.never.thrown.try", JavaHighlightUtil.formatType(caughtType)); final HighlightInfo errorResult = HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(parameter).descriptionAndTooltip(description).create(); QuickFixAction.registerQuickFixAction(errorResult, QUICK_FIX_FACTORY.createDeleteCatchFix(parameter)); @@ -1374,7 +1374,7 @@ public class HighlightUtil extends HighlightUtilBase { } } if (!used) { - final String description = JavaErrorMessages.message("exception.never.thrown.try", JavaHighlightUtil.formatType(catchType)); + final String description = JavaErrorBundle.message("exception.never.thrown.try", JavaHighlightUtil.formatType(catchType)); final HighlightInfo highlight = HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(typeElement).descriptionAndTooltip(description).create(); QuickFixAction.registerQuickFixAction(highlight, QUICK_FIX_FACTORY.createDeleteMultiCatchFix(typeElement)); @@ -1430,7 +1430,7 @@ public class HighlightUtil extends HighlightUtilBase { // check & warn if (caught.isEmpty()) { - final String message = JavaErrorMessages.message("exception.already.caught.warn", formatTypes(caughtCopy), caughtCopy.size()); + final String message = JavaErrorBundle.message("exception.already.caught.warn", formatTypes(caughtCopy), caughtCopy.size()); final HighlightInfo highlightInfo = HighlightInfo.newHighlightInfo(HighlightInfoType.WARNING).range(catchSection).descriptionAndTooltip(message).create(); if (isMultiCatch) { @@ -1454,7 +1454,7 @@ public class HighlightUtil extends HighlightUtilBase { PsiElement parent = statement.getParent(); isDeclarationNotAllowed = parent instanceof PsiIfStatement || parent instanceof PsiLoopStatement; } - String description = JavaErrorMessages.message(isDeclarationNotAllowed ? "declaration.not.allowed" : "not.a.statement"); + String description = JavaErrorBundle.message(isDeclarationNotAllowed ? "declaration.not.allowed" : "not.a.statement"); HighlightInfo error = HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(statement).descriptionAndTooltip(description).create(); if (statement instanceof PsiExpressionStatement) { @@ -1481,8 +1481,8 @@ public class HighlightUtil extends HighlightUtilBase { if (kind == null || requiredLevel != null && !level.isAtLeast(requiredLevel)) { boolean is7 = level.isAtLeast(LanguageLevel.JDK_1_7); - String expected = JavaErrorMessages.message(is7 ? "valid.switch.17.selector.types" : "valid.switch.selector.types"); - String message = JavaErrorMessages.message("incompatible.types", expected, JavaHighlightUtil.formatType(type)); + String expected = JavaErrorBundle.message(is7 ? "valid.switch.17.selector.types" : "valid.switch.selector.types"); + String message = JavaErrorBundle.message("incompatible.types", expected, JavaHighlightUtil.formatType(type)); HighlightInfo info = HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(expression).descriptionAndTooltip(message).create(); if (switchBlock instanceof PsiSwitchStatement) { QuickFixAction.registerQuickFixAction(info, QUICK_FIX_FACTORY.createConvertSwitchToIfIntention((PsiSwitchStatement)switchBlock)); @@ -1500,7 +1500,7 @@ public class HighlightUtil extends HighlightUtilBase { PsiClass member = PsiUtil.resolveClassInClassTypeOnly(type); if (member != null && !PsiUtil.isAccessible(member.getProject(), member, expression, null)) { String className = PsiFormatUtil.formatClass(member, PsiFormatUtilBase.SHOW_NAME | PsiFormatUtilBase.SHOW_FQ_NAME); - String message = JavaErrorMessages.message("inaccessible.type", className); + String message = JavaErrorBundle.message("inaccessible.type", className); return HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(expression).descriptionAndTooltip(message).create(); } @@ -1536,7 +1536,7 @@ public class HighlightUtil extends HighlightUtilBase { String name = identifier.getText(); if (RESTRICTED_RECORD_COMPONENT_NAMES.contains(name)) { return HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(identifier) - .descriptionAndTooltip(JavaErrorMessages.message("record.component.restricted.name", name)).create(); + .descriptionAndTooltip(JavaErrorBundle.message("record.component.restricted.name", name)).create(); } } return null; @@ -1545,7 +1545,7 @@ public class HighlightUtil extends HighlightUtilBase { static HighlightInfo checkRecordComponentVarArg(PsiRecordComponent recordComponent) { if (recordComponent.isVarArgs() && PsiTreeUtil.getNextSiblingOfType(recordComponent, PsiRecordComponent.class) != null) { return HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(recordComponent) - .descriptionAndTooltip(JavaErrorMessages.message("record.component.vararg.not.last")).create(); + .descriptionAndTooltip(JavaErrorBundle.message("record.component.vararg.not.last")).create(); } return null; } @@ -1581,9 +1581,9 @@ public class HighlightUtil extends HighlightUtilBase { if (!TypeConversionUtil.isBinaryOperatorApplicable(operationSign, lType, rType, false)) { PsiJavaToken token = expression.getTokenBeforeOperand(operand); assert token != null : expression; - String message = JavaErrorMessages.message("binary.operator.not.applicable", token.getText(), - JavaHighlightUtil.formatType(lType), - JavaHighlightUtil.formatType(rType)); + String message = JavaErrorBundle.message("binary.operator.not.applicable", token.getText(), + JavaHighlightUtil.formatType(lType), + JavaHighlightUtil.formatType(rType)); return HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(expression).descriptionAndTooltip(message).create(); } lType = TypeConversionUtil.calcTypeForBinaryExpression(lType, rType, operationSign, true); @@ -1597,7 +1597,7 @@ public class HighlightUtil extends HighlightUtilBase { if (expression != null && !TypeConversionUtil.isUnaryOperatorApplicable(token, expression)) { PsiType type = expression.getType(); if (type == null) return null; - String message = JavaErrorMessages.message("unary.operator.not.applicable", token.getText(), JavaHighlightUtil.formatType(type)); + String message = JavaErrorBundle.message("unary.operator.not.applicable", token.getText(), JavaHighlightUtil.formatType(type)); PsiElement parentExpr = token.getParent(); HighlightInfo highlightInfo = @@ -1624,7 +1624,7 @@ public class HighlightUtil extends HighlightUtilBase { if (!(parent instanceof PsiReferenceExpression)) { // like in 'Object o = super;' final int o = expr.getTextRange().getEndOffset(); - String description = JavaErrorMessages.message("dot.expected.after.super.or.this"); + String description = JavaErrorBundle.message("dot.expected.after.super.or.this"); return HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(o, o + 1).descriptionAndTooltip(description).create(); } } @@ -1633,7 +1633,7 @@ public class HighlightUtil extends HighlightUtilBase { if (qualifier != null) { PsiElement resolved = qualifier.advancedResolve(true).getElement(); if (resolved != null && !(resolved instanceof PsiClass)) { - String description = JavaErrorMessages.message("class.expected"); + String description = JavaErrorBundle.message("class.expected"); return HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(qualifier).descriptionAndTooltip(description).create(); } aClass = (PsiClass)resolved; @@ -1656,7 +1656,7 @@ public class HighlightUtil extends HighlightUtilBase { //The form T.super.Identifier refers to the field named Identifier of the lexically enclosing instance corresponding to T, //but with that instance viewed as an instance of the superclass of T. if (resolved instanceof PsiField) { - String description = JavaErrorMessages.message("is.not.an.enclosing.class", formatClass(aClass)); + String description = JavaErrorBundle.message("is.not.an.enclosing.class", formatClass(aClass)); return HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(expr).descriptionAndTooltip(description).create(); } } @@ -1688,7 +1688,7 @@ public class HighlightUtil extends HighlightUtilBase { if (cause != null) { return HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR) .range(qualifier) - .descriptionAndTooltip(JavaErrorMessages.message("bad.qualifier.in.super.method.reference", cause + formatClass(superClass))).create(); + .descriptionAndTooltip(JavaErrorBundle.message("bad.qualifier.in.super.method.reference", cause + formatClass(superClass))).create(); } } } @@ -1696,7 +1696,7 @@ public class HighlightUtil extends HighlightUtilBase { if (!classT.isInheritor(aClass, false)) { return HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR) .range(qualifier) - .descriptionAndTooltip(JavaErrorMessages.message("no.enclosing.instance.in.scope", format(aClass))).create(); + .descriptionAndTooltip(JavaErrorBundle.message("no.enclosing.instance.in.scope", format(aClass))).create(); } } } @@ -1725,7 +1725,7 @@ public class HighlightUtil extends HighlightUtilBase { if (languageLevel.isAtLeast(LanguageLevel.JDK_1_8) && qualifier instanceof PsiSuperExpression) { final PsiMethod method = PsiTreeUtil.getParentOfType(expr, PsiMethod.class); if (method != null && method.hasModifierProperty(PsiModifier.DEFAULT) && ((PsiSuperExpression)qualifier).getQualifier() == null) { - String description = JavaErrorMessages.message("unqualified.super.disallowed"); + String description = JavaErrorBundle.message("unqualified.super.disallowed"); HighlightInfo info = HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(expr).descriptionAndTooltip(description).create(); QualifySuperArgumentFix.registerQuickFixAction((PsiSuperExpression)qualifier, info); return info; @@ -1760,7 +1760,7 @@ public class HighlightUtil extends HighlightUtilBase { static String staticContextProblemDescription(@NotNull PsiElement refElement) { String type = LanguageFindUsages.getType(refElement); String name = HighlightMessageUtil.getSymbolName(refElement, PsiSubstitutor.EMPTY); - return JavaErrorMessages.message("non.static.symbol.referenced.from.static.context", type, name); + return JavaErrorBundle.message("non.static.symbol.referenced.from.static.context", type, name); } @NotNull @@ -1778,12 +1778,12 @@ public class HighlightUtil extends HighlightUtilBase { if (refElement.hasModifierProperty(PsiModifier.PRIVATE)) { String containerName = getContainerName(refElement, result.getSubstitutor()); - return Pair.pair(JavaErrorMessages.message("private.symbol", symbolName, containerName), null); + return Pair.pair(JavaErrorBundle.message("private.symbol", symbolName, containerName), null); } if (refElement.hasModifierProperty(PsiModifier.PROTECTED)) { String containerName = getContainerName(refElement, result.getSubstitutor()); - return Pair.pair(JavaErrorMessages.message("protected.symbol", symbolName, containerName), null); + return Pair.pair(JavaErrorBundle.message("protected.symbol", symbolName, containerName), null); } PsiClass packageLocalClass = HighlightFixUtil.getPackageLocalClassInTheMiddle(ref); @@ -1794,13 +1794,13 @@ public class HighlightUtil extends HighlightUtilBase { if (refElement.hasModifierProperty(PsiModifier.PACKAGE_LOCAL) || packageLocalClass != null) { String containerName = getContainerName(refElement, result.getSubstitutor()); - return Pair.pair(JavaErrorMessages.message("package.local.symbol", symbolName, containerName), null); + return Pair.pair(JavaErrorBundle.message("package.local.symbol", symbolName, containerName), null); } String containerName = getContainerName(refElement, result.getSubstitutor()); ErrorWithFixes problem = checkModuleAccess(resolved, ref, symbolName, containerName); if (problem != null) return Pair.pair(problem.message, problem.fixes); - return Pair.pair(JavaErrorMessages.message("visibility.access.problem", symbolName, containerName), null); + return Pair.pair(JavaErrorBundle.message("visibility.access.problem", symbolName, containerName), null); } private static ErrorWithFixes checkModuleAccess(@NotNull PsiElement target, @@ -1813,7 +1813,7 @@ public class HighlightUtil extends HighlightUtilBase { error = checkAccess((JavaModuleSystemEx)moduleSystem, target, place); } else if (!isAccessible(moduleSystem, target, place)) { - String message = JavaErrorMessages.message("visibility.module.access.problem", symbolName, containerName, moduleSystem.getName()); + String message = JavaErrorBundle.message("visibility.module.access.problem", symbolName, containerName, moduleSystem.getName()); error = new ErrorWithFixes(message); } if (error != null) { @@ -1854,7 +1854,7 @@ public class HighlightUtil extends HighlightUtilBase { final PsiType arrayExpressionType = arrayExpression.getType(); if (arrayExpressionType != null && !(arrayExpressionType instanceof PsiArrayType)) { - final String description = JavaErrorMessages.message("array.type.expected", JavaHighlightUtil.formatType(arrayExpressionType)); + final String description = JavaErrorBundle.message("array.type.expected", JavaHighlightUtil.formatType(arrayExpressionType)); final HighlightInfo info = HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(arrayExpression).descriptionAndTooltip(description).create(); QuickFixAction.registerQuickFixAction(info, QUICK_FIX_FACTORY.createReplaceWithListAccessFix(arrayAccessExpression)); @@ -1903,11 +1903,11 @@ public class HighlightUtil extends HighlightUtilBase { if (!(variable instanceof PsiField) && HighlightControlFlowUtil.isEffectivelyFinal(variable, resource, (PsiJavaCodeReferenceElement)expression)) return null; } - String text = JavaErrorMessages.message("resource.variable.must.be.final"); + String text = JavaErrorBundle.message("resource.variable.must.be.final"); return HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(expression).descriptionAndTooltip(text).create(); } - String text = JavaErrorMessages.message("declaration.or.variable.expected"); + String text = JavaErrorBundle.message("declaration.or.variable.expected"); return HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(expression).descriptionAndTooltip(text).create(); } @@ -1945,7 +1945,7 @@ public class HighlightUtil extends HighlightUtilBase { private static HighlightInfo checkArrayInitializerCompatibleTypes(@NotNull PsiExpression initializer, @NotNull PsiType componentType) { PsiType initializerType = initializer.getType(); if (initializerType == null) { - String description = JavaErrorMessages.message("illegal.initializer", JavaHighlightUtil.formatType(componentType)); + String description = JavaErrorBundle.message("illegal.initializer", JavaHighlightUtil.formatType(componentType)); return HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(initializer).descriptionAndTooltip(description).create(); } PsiExpression expression = initializer instanceof PsiArrayInitializerExpression ? null : initializer; @@ -1961,7 +1961,7 @@ public class HighlightUtil extends HighlightUtilBase { PsiElement parent = expression.getParent(); if (parent instanceof PsiReferenceExpression || parent instanceof PsiMethodCallExpression || parent instanceof PsiBreakStatement) return null; - String description = JavaErrorMessages.message("expression.expected"); + String description = JavaErrorBundle.message("expression.expected"); HighlightInfo info = HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(expression).descriptionAndTooltip(description).create(); UnresolvedReferenceQuickFixProvider.registerReferenceFixes(expression, new QuickFixActionRegistrarImpl(info)); return info; @@ -1983,7 +1983,7 @@ public class HighlightUtil extends HighlightUtilBase { return null; } - String description = JavaErrorMessages.message("array.initializer.not.allowed"); + String description = JavaErrorBundle.message("array.initializer.not.allowed"); HighlightInfo info = HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(expression).descriptionAndTooltip(description).create(); QuickFixAction.registerQuickFixAction(info, QUICK_FIX_FACTORY.createAddNewArrayExpressionFix(expression)); return info; @@ -1993,7 +1993,7 @@ public class HighlightUtil extends HighlightUtilBase { static HighlightInfo checkCaseStatement(@NotNull PsiSwitchLabelStatementBase statement) { PsiSwitchBlock switchBlock = statement.getEnclosingSwitchBlock(); if (switchBlock == null) { - String description = JavaErrorMessages.message("case.statement.outside.switch"); + String description = JavaErrorBundle.message("case.statement.outside.switch"); return HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(statement).descriptionAndTooltip(description).create(); } @@ -2039,7 +2039,7 @@ public class HighlightUtil extends HighlightUtilBase { if (element instanceof PsiEnumConstant) { value = ((PsiEnumConstant)element).getName(); if (((PsiReferenceExpression)expr).getQualifier() != null) { - String message = JavaErrorMessages.message("qualified.enum.constant.in.switch"); + String message = JavaErrorBundle.message("qualified.enum.constant.in.switch"); results.add(HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(expr).descriptionAndTooltip(message).create()); continue; } @@ -2049,7 +2049,7 @@ public class HighlightUtil extends HighlightUtilBase { value = ConstantExpressionUtil.computeCastTo(expr, selectorType); } if (value == null) { - String description = JavaErrorMessages.message("constant.expression.required"); + String description = JavaErrorBundle.message("constant.expression.required"); results.add(HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(expr).descriptionAndTooltip(description).create()); continue; } @@ -2063,7 +2063,8 @@ public class HighlightUtil extends HighlightUtilBase { for (Map.Entry> entry : values.entrySet()) { if (entry.getValue().size() > 1) { Object value = entry.getKey(); - String description = value == defaultValue ? JavaErrorMessages.message("duplicate.default.switch.label") : JavaErrorMessages.message("duplicate.switch.label", value); + String description = value == defaultValue ? JavaErrorBundle.message("duplicate.default.switch.label") : JavaErrorBundle + .message("duplicate.switch.label", value); for (PsiElement element : entry.getValue()) { results.add(HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(element).descriptionAndTooltip(description).create()); } @@ -2088,7 +2089,7 @@ public class HighlightUtil extends HighlightUtilBase { } if (!exhaustive) { PsiElement range = ObjectUtils.notNull(selectorExpression, switchBlock); - String message = JavaErrorMessages.message(values.isEmpty() ? "switch.expr.empty" : "switch.expr.incomplete"); + String message = JavaErrorBundle.message(values.isEmpty() ? "switch.expr.empty" : "switch.expr.incomplete"); HighlightInfo info = HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(range).descriptionAndTooltip(message).create(); if (!missingConstants.isEmpty()) { QuickFixAction.registerQuickFixAction(info, QUICK_FIX_FACTORY.createAddMissingEnumBranchesFix(switchBlock, missingConstants)); @@ -2115,7 +2116,7 @@ public class HighlightUtil extends HighlightUtilBase { // the expression and throw statements are fine, only the block statement could be an issue if (ruleBody instanceof PsiBlockStatement && ControlFlowUtils.statementMayCompleteNormally(ruleBody)) { PsiElement target = ObjectUtils.notNull(ObjectUtils.tryCast(rule.getFirstChild(), PsiKeyword.class), rule); - String message = JavaErrorMessages.message("switch.expr.rule.should.produce.result"); + String message = JavaErrorBundle.message("switch.expr.rule.should.produce.result"); results.add(HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(target).descriptionAndTooltip(message).create()); } } @@ -2124,7 +2125,7 @@ public class HighlightUtil extends HighlightUtilBase { // previous statements may have no result as well, but in that case they fall through to the last one, which needs to be checked anyway if (lastStatement != null && ControlFlowUtils.statementMayCompleteNormally(lastStatement)) { PsiElement target = ObjectUtils.notNull(ObjectUtils.tryCast(switchExpression.getFirstChild(), PsiKeyword.class), switchExpression); - String message = JavaErrorMessages.message("switch.expr.should.produce.result"); + String message = JavaErrorBundle.message("switch.expr.should.produce.result"); return Collections.singletonList(HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(target).descriptionAndTooltip(message).create()); } } @@ -2137,7 +2138,7 @@ public class HighlightUtil extends HighlightUtilBase { static HighlightInfo checkIllegalForwardReferenceToField(@NotNull PsiReferenceExpression expression, @NotNull PsiField referencedField) { Boolean isIllegalForwardReference = isIllegalForwardReferenceToField(expression, referencedField, false); if (isIllegalForwardReference == null) return null; - String description = JavaErrorMessages.message(isIllegalForwardReference ? "illegal.forward.reference" : "illegal.self.reference"); + String description = JavaErrorBundle.message(isIllegalForwardReference ? "illegal.forward.reference" : "illegal.self.reference"); return HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(expression).descriptionAndTooltip(description).create(); } @@ -2206,7 +2207,7 @@ public class HighlightUtil extends HighlightUtilBase { PsiClass aClass = PsiUtil.resolveClassInType(componentType); if (aClass == null) { String canonicalText = type.getCanonicalText(); - String description = JavaErrorMessages.message("unknown.class", canonicalText); + String description = JavaErrorBundle.message("unknown.class", canonicalText); HighlightInfo info = HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(typeElement).descriptionAndTooltip(description).create(); PsiJavaCodeReferenceElement referenceElement = typeElement.getInnermostComponentReferenceElement(); @@ -2243,7 +2244,7 @@ public class HighlightUtil extends HighlightUtilBase { } } - String description = JavaErrorMessages.message("illegal.type.void"); + String description = JavaErrorBundle.message("illegal.type.void"); return HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(type).descriptionAndTooltip(description).create(); } @@ -2426,7 +2427,7 @@ public class HighlightUtil extends HighlightUtilBase { } private static HighlightInfo createMemberReferencedError(@NotNull String resolvedName, @NotNull TextRange textRange) { - String description = JavaErrorMessages.message("member.referenced.before.constructor.called", resolvedName); + String description = JavaErrorBundle.message("member.referenced.before.constructor.called", resolvedName); return HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(textRange).descriptionAndTooltip(description).create(); } @@ -2474,7 +2475,7 @@ public class HighlightUtil extends HighlightUtilBase { static HighlightInfo checkLabelWithoutStatement(@NotNull PsiLabeledStatement statement) { if (statement.getStatement() == null) { - String description = JavaErrorMessages.message("label.without.statement"); + String description = JavaErrorBundle.message("label.without.statement"); return HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(statement).descriptionAndTooltip(description).create(); } return null; @@ -2489,7 +2490,7 @@ public class HighlightUtil extends HighlightUtilBase { if (element instanceof PsiMethod || element instanceof PsiClass) break; if (element instanceof PsiLabeledStatement && element != statement && Comparing.equal(((PsiLabeledStatement)element).getLabelIdentifier().getText(), text)) { - String description = JavaErrorMessages.message("duplicate.label", text); + String description = JavaErrorBundle.message("duplicate.label", text); return HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(identifier).descriptionAndTooltip(description).create(); } element = element.getParent(); @@ -2503,7 +2504,7 @@ public class HighlightUtil extends HighlightUtilBase { if (!comment.getText().endsWith("*/")) { int start = comment.getTextRange().getEndOffset() - 1; int end = start + 1; - String description = JavaErrorMessages.message("unclosed.comment"); + String description = JavaErrorBundle.message("unclosed.comment"); return HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(start, end).descriptionAndTooltip(description).create(); } return null; @@ -2527,7 +2528,7 @@ public class HighlightUtil extends HighlightUtilBase { if (sub || sup) { final String name1 = PsiFormatUtil.formatClass(class1, PsiFormatUtilBase.SHOW_NAME | PsiFormatUtilBase.SHOW_FQ_NAME); final String name2 = PsiFormatUtil.formatClass(class2, PsiFormatUtilBase.SHOW_NAME | PsiFormatUtilBase.SHOW_FQ_NAME); - final String message = JavaErrorMessages.message("exception.must.be.disjoint", sub ? name1 : name2, sub ? name2 : name1); + final String message = JavaErrorBundle.message("exception.must.be.disjoint", sub ? name1 : name2, sub ? name2 : name1); final PsiTypeElement element = typeElements.get(sub ? i : j); final HighlightInfo highlight = HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(element).descriptionAndTooltip(message).create(); @@ -2569,7 +2570,7 @@ public class HighlightUtil extends HighlightUtilBase { : checkSingleType(catchClass, upperCatchType); if (highlight) { final String className = PsiFormatUtil.formatClass(catchClass, PsiFormatUtilBase.SHOW_NAME | PsiFormatUtilBase.SHOW_FQ_NAME); - final String description = JavaErrorMessages.message("exception.already.caught", className); + final String description = JavaErrorBundle.message("exception.already.caught", className); final HighlightInfo highlightInfo = HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(typeElement).descriptionAndTooltip(description).create(); result.add(highlightInfo); @@ -2617,7 +2618,7 @@ public class HighlightUtil extends HighlightUtilBase { if (body != null) { PsiElement first = PsiTreeUtil.skipWhitespacesAndCommentsForward(body.getLBrace()); if (first != null && !(first instanceof PsiSwitchLabelStatementBase) && !PsiUtil.isJavaToken(first, JavaTokenType.RBRACE)) { - String description = JavaErrorMessages.message("statement.must.be.prepended.with.case.label"); + String description = JavaErrorBundle.message("statement.must.be.prepended.with.case.label"); return HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(first).descriptionAndTooltip(description).create(); } @@ -2661,7 +2662,7 @@ public class HighlightUtil extends HighlightUtilBase { if (alien != null) { if (enhancedLabels && !(alien instanceof PsiSwitchLabelStatementBase)) { PsiSwitchLabeledRuleStatement previousRule = PsiTreeUtil.getPrevSiblingOfType(alien, PsiSwitchLabeledRuleStatement.class); - String description = JavaErrorMessages.message("statement.must.be.prepended.with.case.label"); + String description = JavaErrorBundle.message("statement.must.be.prepended.with.case.label"); HighlightInfo info = HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(alien).descriptionAndTooltip(description).create(); if (previousRule != null) { @@ -2669,7 +2670,7 @@ public class HighlightUtil extends HighlightUtilBase { } return info; } - String description = JavaErrorMessages.message("different.case.kinds.in.switch"); + String description = JavaErrorBundle.message("different.case.kinds.in.switch"); return HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(alien).descriptionAndTooltip(description).create(); } } @@ -2693,7 +2694,7 @@ public class HighlightUtil extends HighlightUtilBase { return highlightInfo; } if (expression == assertStatement.getAssertDescription() && TypeConversionUtil.isVoidType(type)) { - String description = JavaErrorMessages.message("void.type.is.not.allowed"); + String description = JavaErrorBundle.message("void.type.is.not.allowed"); return HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(expression).descriptionAndTooltip(description).create(); } return null; @@ -2756,8 +2757,9 @@ public class HighlightUtil extends HighlightUtilBase { : String.format("
%s
", reason); String toolTip = createIncompatibleTypesTooltip(lType, rType, (lRawType, lTypeArguments, rRawType, rTypeArguments) -> - JavaErrorMessages.message("incompatible.types.html.tooltip", lRawType, lTypeArguments, rRawType, rTypeArguments, styledReason, "#" + ColorUtil.toHex(UIUtil.getContextHelpForeground()))); - String description = JavaErrorMessages.message( + JavaErrorBundle + .message("incompatible.types.html.tooltip", lRawType, lTypeArguments, rRawType, rTypeArguments, styledReason, "#" + ColorUtil.toHex(UIUtil.getContextHelpForeground()))); + String description = JavaErrorBundle.message( "incompatible.types", JavaHighlightUtil.formatType(lType), JavaHighlightUtil.formatType(rType)); return HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(textRange).description(description).escapedToolTip(toolTip) .navigationShift(navigationShift).create(); @@ -2845,7 +2847,7 @@ public class HighlightUtil extends HighlightUtilBase { String candidate2 = PsiFormatUtil.formatMethod((PsiMethod)element2, PsiSubstitutor.EMPTY, PsiFormatUtilBase.SHOW_CONTAINING_CLASS | PsiFormatUtilBase.SHOW_NAME | PsiFormatUtilBase.SHOW_PARAMETERS, PsiFormatUtilBase.SHOW_TYPE); - return JavaErrorMessages.message("incompatible.types.reason.ambiguous.method.reference", candidate1, candidate2); + return JavaErrorBundle.message("incompatible.types.reason.ambiguous.method.reference", candidate1, candidate2); } } } @@ -2883,7 +2885,7 @@ public class HighlightUtil extends HighlightUtilBase { Pair imported = importedClasses.get(name); PsiClass importedClass = Pair.getSecond(imported); if (importedClass != null && !containingFile.getManager().areElementsEquivalent(importedClass, element)) { - String description = JavaErrorMessages.message("single.import.class.conflict", formatClass(importedClass)); + String description = JavaErrorBundle.message("single.import.class.conflict", formatClass(importedClass)); return HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(statement).descriptionAndTooltip(description).create(); } importedClasses.put(name, Pair.pair(null, (PsiClass)element)); @@ -2932,7 +2934,7 @@ public class HighlightUtil extends HighlightUtilBase { PsiReferenceExpression referenceToMethod = ((PsiMethodCallExpression)granny).getMethodExpression(); PsiExpression qualifierExpression = referenceToMethod.getQualifierExpression(); if (qualifierExpression == ref && resolved != null && !(resolved instanceof PsiClass) && !(resolved instanceof PsiVariable)) { - String message = JavaErrorMessages.message("qualifier.must.be.expression"); + String message = JavaErrorBundle.message("qualifier.must.be.expression"); return HighlightInfo.newHighlightInfo(HighlightInfoType.WRONG_REF).range(qualifierExpression).descriptionAndTooltip(message).create(); } } @@ -2957,10 +2959,10 @@ public class HighlightUtil extends HighlightUtilBase { if (results.length > 1) { String t1 = format(ObjectUtils.notNull(results[0].getElement())); String t2 = format(ObjectUtils.notNull(results[1].getElement())); - description = JavaErrorMessages.message("ambiguous.reference", refName.getText(), t1, t2); + description = JavaErrorBundle.message("ambiguous.reference", refName.getText(), t1, t2); } else { - description = JavaErrorMessages.message("cannot.resolve.symbol", refName.getText()); + description = JavaErrorBundle.message("cannot.resolve.symbol", refName.getText()); } HighlightInfo info = HighlightInfo.newHighlightInfo(HighlightInfoType.WRONG_REF).range(refName).descriptionAndTooltip(description).create(); @@ -3013,7 +3015,7 @@ public class HighlightUtil extends HighlightUtilBase { (PsiTreeUtil.getParentOfType(ref, PsiImportStatementBase.class) != null || PsiUtil.isModuleFile(containingFile) || !PsiUtil.isFromDefaultPackage(containingFile))) { - String description = JavaErrorMessages.message("class.in.default.package", ((PsiClass)resolved).getName()); + String description = JavaErrorBundle.message("class.in.default.package", ((PsiClass)resolved).getName()); return HighlightInfo.newHighlightInfo(HighlightInfoType.WRONG_REF).range(refName).descriptionAndTooltip(description).create(); } @@ -3061,7 +3063,7 @@ public class HighlightUtil extends HighlightUtilBase { GlobalSearchScope scope = module.getModuleWithDependenciesAndLibrariesScope(false); PsiClass aClass = JavaPsiFacade.getInstance(ref.getProject()).findClass(ref.getCanonicalText(), scope); if (aClass != null) { - String message = JavaErrorMessages.message("package.clashes.with.class", ref.getText()); + String message = JavaErrorBundle.message("package.clashes.with.class", ref.getText()); return HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(ref).descriptionAndTooltip(message).create(); } } @@ -3100,7 +3102,7 @@ public class HighlightUtil extends HighlightUtilBase { } } else if (refGrandParent instanceof PsiMethod && referenceList == ((PsiMethod)refGrandParent).getThrowsList()) { - String description = JavaErrorMessages.message("class.name.expected"); + String description = JavaErrorBundle.message("class.name.expected"); highlightInfo = HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(ref).descriptionAndTooltip(description).create(); } return highlightInfo; @@ -3139,7 +3141,7 @@ public class HighlightUtil extends HighlightUtilBase { } } } - String description = JavaErrorMessages.message("expected.class.or.package"); + String description = JavaErrorBundle.message("expected.class.or.package"); HighlightInfo info = HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(qualifier).descriptionAndTooltip(description).create(); QuickFixAction.registerQuickFixAction(info, QUICK_FIX_FACTORY.createRemoveQualifierFix(qualifier, expression, (PsiClass)resolved)); @@ -3149,7 +3151,7 @@ public class HighlightUtil extends HighlightUtilBase { static HighlightInfo checkAnnotationMethodParameters(@NotNull PsiParameterList list) { final PsiElement parent = list.getParent(); if (PsiUtil.isAnnotationMethod(parent) && !list.isEmpty()) { - final String message = JavaErrorMessages.message("annotation.interface.members.may.not.have.parameters"); + final String message = JavaErrorBundle.message("annotation.interface.members.may.not.have.parameters"); final HighlightInfo highlightInfo = HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(list).descriptionAndTooltip(message).create(); QuickFixAction.registerQuickFixAction(highlightInfo, QUICK_FIX_FACTORY.createRemoveParameterListFix((PsiMethod)parent)); @@ -3168,7 +3170,7 @@ public class HighlightUtil extends HighlightUtilBase { return null; } - String message = JavaErrorMessages.message("invalid.statement"); + String message = JavaErrorBundle.message("invalid.statement"); return HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(init).descriptionAndTooltip(message).create(); } @@ -3212,7 +3214,7 @@ public class HighlightUtil extends HighlightUtilBase { private final LanguageLevel level; private final String key; - Feature(LanguageLevel level, @PropertyKey(resourceBundle = JavaErrorMessages.BUNDLE) String key) { + Feature(LanguageLevel level, @PropertyKey(resourceBundle = JavaErrorBundle.BUNDLE) String key) { this.level = level; this.key = key; } @@ -3249,9 +3251,9 @@ public class HighlightUtil extends HighlightUtilBase { @NotNull Feature feature, @NotNull LanguageLevel level, @NotNull PsiFile file) { - String name = JavaErrorMessages.message(feature.key); + String name = JavaErrorBundle.message(feature.key); String version = JavaSdkVersion.fromLanguageLevel(level).getDescription(); - String message = JavaErrorMessages.message("insufficient.language.level", name, version); + String message = JavaErrorBundle.message("insufficient.language.level", name, version); Module module = ModuleUtilCore.findModuleForPsiElement(element); if (module != null) { diff --git a/java/java-analysis-impl/src/com/intellij/codeInsight/daemon/impl/analysis/HighlightVisitorImpl.java b/java/java-analysis-impl/src/com/intellij/codeInsight/daemon/impl/analysis/HighlightVisitorImpl.java index 068847d023aa..c76a6a3cbdd5 100644 --- a/java/java-analysis-impl/src/com/intellij/codeInsight/daemon/impl/analysis/HighlightVisitorImpl.java +++ b/java/java-analysis-impl/src/com/intellij/codeInsight/daemon/impl/analysis/HighlightVisitorImpl.java @@ -2,7 +2,7 @@ package com.intellij.codeInsight.daemon.impl.analysis; import com.intellij.codeHighlighting.Pass; -import com.intellij.codeInsight.daemon.JavaErrorMessages; +import com.intellij.codeInsight.daemon.JavaErrorBundle; import com.intellij.codeInsight.daemon.impl.*; import com.intellij.codeInsight.daemon.impl.analysis.HighlightUtil.Feature; import com.intellij.codeInsight.daemon.impl.quickfix.AdjustFunctionContextFix; @@ -745,7 +745,7 @@ public class HighlightVisitorImpl extends JavaElementVisitor implements Highligh final PsiElement referenceNameElement = ref.getReferenceNameElement(); if (results.length == 0) { - final String description = JavaErrorMessages.message("cannot.resolve.symbol", refName); + final String description = JavaErrorBundle.message("cannot.resolve.symbol", refName); assert referenceNameElement != null : ref; final HighlightInfo info = HighlightInfo.newHighlightInfo(HighlightInfoType.WRONG_REF).range(referenceNameElement).descriptionAndTooltip(description).create(); @@ -762,10 +762,10 @@ public class HighlightVisitorImpl extends JavaElementVisitor implements Highligh final PsiClass aClass = Pair.getSecond(imported); if (aClass != null && !manager.areElementsEquivalent(aClass, element)) { description = imported.first == null - ? JavaErrorMessages.message("single.import.class.conflict", refName) + ? JavaErrorBundle.message("single.import.class.conflict", refName) : imported.first.equals(ref) - ? JavaErrorMessages.message("class.is.ambiguous.in.single.static.import", refName) - : JavaErrorMessages.message("class.is.already.defined.in.single.static.import", refName); + ? JavaErrorBundle.message("class.is.ambiguous.in.single.static.import", refName) + : JavaErrorBundle.message("class.is.already.defined.in.single.static.import", refName); } mySingleImportedClasses.put(refName, Pair.create(ref, (PsiClass)element)); } @@ -774,8 +774,8 @@ public class HighlightVisitorImpl extends JavaElementVisitor implements Highligh final PsiField field = Pair.getSecond(imported); if (field != null && !manager.areElementsEquivalent(field, element)) { description = imported.first.equals(ref) - ? JavaErrorMessages.message("field.is.ambiguous.in.single.static.import", refName) - : JavaErrorMessages.message("field.is.already.defined.in.single.static.import", refName); + ? JavaErrorBundle.message("field.is.ambiguous.in.single.static.import", refName) + : JavaErrorBundle.message("field.is.already.defined.in.single.static.import", refName); } mySingleImportedFields.put(refName, Pair.create(ref, (PsiField)element)); } @@ -1224,7 +1224,7 @@ public class HighlightVisitorImpl extends JavaElementVisitor implements Highligh !(resolved instanceof PsiClass) && resolved instanceof PsiNamedElement && ((PsiNewExpression)parent).getClassOrAnonymousClassReference() == ref) { - String text = JavaErrorMessages.message("cannot.resolve.symbol", ((PsiNamedElement)resolved).getName()); + String text = JavaErrorBundle.message("cannot.resolve.symbol", ((PsiNamedElement)resolved).getName()); myHolder.add(HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(ref).descriptionAndTooltip(text).create()); } @@ -1527,12 +1527,12 @@ public class HighlightVisitorImpl extends JavaElementVisitor implements Highligh !myHolder.add(GenericsHighlightUtil.checkEnumInstantiation(expression, containingClass)) && containingClass.isPhysical() && description == null) { - description = JavaErrorMessages.message("cannot.resolve.constructor", containingClass.getName()); + description = JavaErrorBundle.message("cannot.resolve.constructor", containingClass.getName()); } } } else if (description == null){ - description = JavaErrorMessages.message("cannot.resolve.method", expression.getReferenceName()); + description = JavaErrorBundle.message("cannot.resolve.method", expression.getReferenceName()); } if (description != null) { @@ -1652,7 +1652,7 @@ public class HighlightVisitorImpl extends JavaElementVisitor implements Highligh HighlightInfo info; if (parent instanceof PsiMethod && JavaPsiRecordUtil.isCompactConstructor((PsiMethod)parent)) { info = HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(statement) - .descriptionAndTooltip(JavaErrorMessages.message("record.compact.constructor.return")).create(); + .descriptionAndTooltip(JavaErrorBundle.message("record.compact.constructor.return")).create(); } else { info = parent != null ? HighlightUtil.checkReturnStatementType(statement, parent) : null; if (info != null && parent instanceof PsiMethod) { diff --git a/java/java-analysis-impl/src/com/intellij/codeInsight/daemon/impl/analysis/ModuleHighlightUtil.java b/java/java-analysis-impl/src/com/intellij/codeInsight/daemon/impl/analysis/ModuleHighlightUtil.java index 87ecfd9ec79f..fa3113d64f79 100644 --- a/java/java-analysis-impl/src/com/intellij/codeInsight/daemon/impl/analysis/ModuleHighlightUtil.java +++ b/java/java-analysis-impl/src/com/intellij/codeInsight/daemon/impl/analysis/ModuleHighlightUtil.java @@ -1,7 +1,7 @@ // Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. package com.intellij.codeInsight.daemon.impl.analysis; -import com.intellij.codeInsight.daemon.JavaErrorMessages; +import com.intellij.codeInsight.daemon.JavaErrorBundle; import com.intellij.codeInsight.daemon.QuickFixBundle; import com.intellij.codeInsight.daemon.impl.HighlightInfo; import com.intellij.codeInsight.daemon.impl.HighlightInfoType; @@ -43,7 +43,7 @@ import static com.intellij.psi.SyntaxTraverser.psiTraverser; class ModuleHighlightUtil { static HighlightInfo checkPackageStatement(@NotNull PsiPackageStatement statement, @NotNull PsiFile file, @Nullable PsiJavaModule module) { if (PsiUtil.isModuleFile(file)) { - String message = JavaErrorMessages.message("module.no.package"); + String message = JavaErrorBundle.message("module.no.package"); HighlightInfo info = HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(statement).descriptionAndTooltip(message).create(); QuickFixAction.registerQuickFixAction(info, factory().createDeleteFix(statement)); return info; @@ -54,7 +54,7 @@ class ModuleHighlightUtil { if (packageName != null) { PsiJavaModule origin = JavaModuleGraphUtil.findOrigin(module, packageName); if (origin != null) { - String message = JavaErrorMessages.message("module.conflicting.packages", packageName, origin.getName()); + String message = JavaErrorBundle.message("module.conflicting.packages", packageName, origin.getName()); return HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(statement).descriptionAndTooltip(message).create(); } } @@ -65,7 +65,7 @@ class ModuleHighlightUtil { static HighlightInfo checkFileName(@NotNull PsiJavaModule element, @NotNull PsiFile file) { if (!PsiJavaModule.MODULE_INFO_FILE.equals(file.getName())) { - String message = JavaErrorMessages.message("module.file.wrong.name"); + String message = JavaErrorBundle.message("module.file.wrong.name"); HighlightInfo info = HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(range(element)).descriptionAndTooltip(message).create(); QuickFixAction.registerQuickFixAction(info, factory().createRenameFileFix(PsiJavaModule.MODULE_INFO_FILE)); return info; @@ -80,10 +80,11 @@ class ModuleHighlightUtil { Project project = file.getProject(); Collection others = FilenameIndex.getVirtualFilesByName(project, PsiJavaModule.MODULE_INFO_FILE, module.getModuleScope()); if (others.size() > 1) { - String message = JavaErrorMessages.message("module.file.duplicate"); + String message = JavaErrorBundle.message("module.file.duplicate"); HighlightInfo info = HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(range(element)).descriptionAndTooltip(message).create(); others.stream().map(f -> PsiManager.getInstance(project).findFile(f)).filter(f -> f != file).findFirst().ifPresent( - duplicate -> QuickFixAction.registerQuickFixAction(info, new GoToSymbolFix(duplicate, JavaErrorMessages.message("module.open.duplicate.text"))) + duplicate -> QuickFixAction.registerQuickFixAction(info, new GoToSymbolFix(duplicate, JavaErrorBundle + .message("module.open.duplicate.text"))) ); return info; } @@ -105,13 +106,13 @@ class ModuleHighlightUtil { private static void checkDuplicateRefs(Iterable statements, Function ref, - @PropertyKey(resourceBundle = JavaErrorMessages.BUNDLE) String key, + @PropertyKey(resourceBundle = JavaErrorBundle.BUNDLE) String key, List results) { Set filter = new THashSet<>(); for (T statement : statements) { String refText = ref.apply(statement); if (refText != null && !filter.add(refText)) { - String message = JavaErrorMessages.message(key, refText); + String message = JavaErrorBundle.message(key, refText); HighlightInfo info = HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(statement).descriptionAndTooltip(message).create(); QuickFixAction.registerQuickFixAction(info, factory().createDeleteFix(statement)); QuickFixAction.registerQuickFixAction(info, MergeModuleStatementsFix.createFix(statement)); @@ -138,7 +139,7 @@ class ModuleHighlightUtil { String className = qName(ref); String packageName = StringUtil.getPackageName(className); if (!exports.contains(packageName) && !uses.contains(className)) { - String message = JavaErrorMessages.message("module.service.unused"); + String message = JavaErrorBundle.message("module.service.unused"); HighlightInfo info = HighlightInfo.newHighlightInfo(HighlightInfoType.WARNING).range(range(ref)).descriptionAndTooltip(message).create(); QuickFixAction.registerQuickFixAction(info, new AddExportsDirectiveFix(module, packageName, "")); QuickFixAction.registerQuickFixAction(info, new AddUsesDirectiveFix(module, className)); @@ -162,7 +163,7 @@ class ModuleHighlightUtil { if (vFile != null) { VirtualFile root = ProjectFileIndex.SERVICE.getInstance(file.getProject()).getSourceRootForFile(vFile); if (root != null && !root.equals(vFile.getParent())) { - String message = JavaErrorMessages.message("module.file.wrong.location"); + String message = JavaErrorBundle.message("module.file.wrong.location"); HighlightInfo info = HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(range(element)).descriptionAndTooltip(message).create(); QuickFixAction.registerQuickFixAction(info, new MoveFileFix(vFile, root, QuickFixBundle.message("move.file.to.source.root.text"))); return info; @@ -180,15 +181,15 @@ class ModuleHighlightUtil { PsiJavaModule target = ref.resolve(); if (target == null) { if (ref.multiResolve(true).length == 0) { - String message = JavaErrorMessages.message("module.not.found", refElement.getReferenceText()); + String message = JavaErrorBundle.message("module.not.found", refElement.getReferenceText()); return HighlightInfo.newHighlightInfo(HighlightInfoType.WRONG_REF).range(refElement).descriptionAndTooltip(message).create(); } else if (ref.multiResolve(false).length > 1) { - String message = JavaErrorMessages.message("module.ambiguous", refElement.getReferenceText()); + String message = JavaErrorBundle.message("module.ambiguous", refElement.getReferenceText()); return HighlightInfo.newHighlightInfo(HighlightInfoType.WARNING).range(refElement).descriptionAndTooltip(message).create(); } else { - String message = JavaErrorMessages.message("module.not.on.path", refElement.getReferenceText()); + String message = JavaErrorBundle.message("module.not.on.path", refElement.getReferenceText()); HighlightInfo info = HighlightInfo.newHighlightInfo(HighlightInfoType.WRONG_REF).range(refElement).descriptionAndTooltip(message).create(); factory().registerOrderEntryFixes(new QuickFixActionRegistrarImpl(info), ref); return info; @@ -196,7 +197,7 @@ class ModuleHighlightUtil { } PsiJavaModule container = (PsiJavaModule)statement.getParent(); if (target == container) { - String message = JavaErrorMessages.message("module.cyclic.dependence", container.getName()); + String message = JavaErrorBundle.message("module.cyclic.dependence", container.getName()); return HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(refElement).descriptionAndTooltip(message).create(); } else { @@ -204,7 +205,7 @@ class ModuleHighlightUtil { if (cycle.contains(container)) { Stream stream = cycle.stream().map(PsiJavaModule::getName); if (ApplicationManager.getApplication().isUnitTestMode()) stream = stream.sorted(); - String message = JavaErrorMessages.message("module.cyclic.dependence", stream.collect(Collectors.joining(", "))); + String message = JavaErrorBundle.message("module.cyclic.dependence", stream.collect(Collectors.joining(", "))); return HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(refElement).descriptionAndTooltip(message).create(); } } @@ -218,7 +219,7 @@ class ModuleHighlightUtil { if (statement.getRole() == Role.OPENS && (parent = statement.getParent()) instanceof PsiJavaModule && ((PsiJavaModule)parent).hasModifierProperty(PsiModifier.OPEN)) { - String message = JavaErrorMessages.message("module.opens.in.weak.module"); + String message = JavaErrorBundle.message("module.opens.in.weak.module"); HighlightInfo info = HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(statement).descriptionAndTooltip(message).create(); QuickFixAction.registerQuickFixAction(info, factory().createModifierListFix((PsiModifierListOwner)parent, PsiModifier.OPEN, false, false)); QuickFixAction.registerQuickFixAction(info, factory().createDeleteFix(statement)); @@ -243,13 +244,13 @@ class ModuleHighlightUtil { boolean opens = statement.getRole() == Role.OPENS; HighlightInfoType type = opens ? HighlightInfoType.WARNING : HighlightInfoType.ERROR; if (directories.length == 0) { - String message = JavaErrorMessages.message("package.not.found", packageName); + String message = JavaErrorBundle.message("package.not.found", packageName); HighlightInfo info = HighlightInfo.newHighlightInfo(type).range(refElement).descriptionAndTooltip(message).create(); QuickFixAction.registerQuickFixAction(info, factory().createCreateClassInPackageInModuleFix(module, packageName)); return info; } if (packageName != null && isPackageEmpty(directories, packageName, opens)) { - String message = JavaErrorMessages.message("package.is.empty", packageName); + String message = JavaErrorBundle.message("package.is.empty", packageName); HighlightInfo info = HighlightInfo.newHighlightInfo(type).range(refElement).descriptionAndTooltip(message).create(); QuickFixAction.registerQuickFixAction(info, factory().createCreateClassInPackageInModuleFix(module, packageName)); return info; @@ -280,12 +281,12 @@ class ModuleHighlightUtil { assert ref != null : statement; if (!targets.add(refText)) { boolean exports = statement.getRole() == Role.EXPORTS; - String message = JavaErrorMessages.message(exports ? "module.duplicate.exports.target" : "module.duplicate.opens.target", refText); + String message = JavaErrorBundle.message(exports ? "module.duplicate.exports.target" : "module.duplicate.opens.target", refText); HighlightInfo info = duplicateReference(refElement, message); results.add(info); } else if (ref.multiResolve(true).length == 0) { - String message = JavaErrorMessages.message("module.not.found", refElement.getReferenceText()); + String message = JavaErrorBundle.message("module.not.found", refElement.getReferenceText()); results.add(HighlightInfo.newHighlightInfo(HighlightInfoType.WARNING).range(refElement).descriptionAndTooltip(message).create()); } } @@ -297,11 +298,11 @@ class ModuleHighlightUtil { if (refElement != null) { PsiElement target = refElement.resolve(); if (!(target instanceof PsiClass)) { - String message = JavaErrorMessages.message("cannot.resolve.symbol", refElement.getReferenceName()); + String message = JavaErrorBundle.message("cannot.resolve.symbol", refElement.getReferenceName()); return HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(range(refElement)).descriptionAndTooltip(message).create(); } else if (((PsiClass)target).isEnum()) { - String message = JavaErrorMessages.message("module.service.enum", ((PsiClass)target).getName()); + String message = JavaErrorBundle.message("module.service.enum", ((PsiClass)target).getName()); return HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(range(refElement)).descriptionAndTooltip(message).create(); } } @@ -322,7 +323,7 @@ class ModuleHighlightUtil { for (PsiJavaCodeReferenceElement implRef : implRefList.getReferenceElements()) { String refText = implRef.getQualifiedName(); if (!filter.add(refText)) { - String message = JavaErrorMessages.message("module.duplicate.impl", refText); + String message = JavaErrorBundle.message("module.duplicate.impl", refText); HighlightInfo info = duplicateReference(implRef, message); results.add(info); continue; @@ -335,7 +336,7 @@ class ModuleHighlightUtil { PsiClass implClass = (PsiClass)implTarget; if (findModuleForFile(file) != findModuleForFile(implClass.getContainingFile())) { - String message = JavaErrorMessages.message("module.service.alien"); + String message = JavaErrorBundle.message("module.service.alien"); results.add(HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(range(implRef)).descriptionAndTooltip(message).create()); } @@ -346,26 +347,26 @@ class ModuleHighlightUtil { PsiType type = provider.getReturnType(); PsiClass typeClass = type instanceof PsiClassType ? ((PsiClassType)type).resolve() : null; if (!InheritanceUtil.isInheritorOrSelf(typeClass, (PsiClass)intTarget, true)) { - String message = JavaErrorMessages.message("module.service.provider.type", implClass.getName()); + String message = JavaErrorBundle.message("module.service.provider.type", implClass.getName()); results.add(HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(range(implRef)).descriptionAndTooltip(message).create()); } } else if (InheritanceUtil.isInheritorOrSelf(implClass, (PsiClass)intTarget, true)) { if (implClass.hasModifierProperty(PsiModifier.ABSTRACT)) { - String message = JavaErrorMessages.message("module.service.abstract", implClass.getName()); + String message = JavaErrorBundle.message("module.service.abstract", implClass.getName()); results.add(HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(range(implRef)).descriptionAndTooltip(message).create()); } else if (!(ClassUtil.isTopLevelClass(implClass) || implClass.hasModifierProperty(PsiModifier.STATIC))) { - String message = JavaErrorMessages.message("module.service.inner", implClass.getName()); + String message = JavaErrorBundle.message("module.service.inner", implClass.getName()); results.add(HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(range(implRef)).descriptionAndTooltip(message).create()); } else if (!PsiUtil.hasDefaultConstructor(implClass)) { - String message = JavaErrorMessages.message("module.service.no.ctor", implClass.getName()); + String message = JavaErrorBundle.message("module.service.no.ctor", implClass.getName()); results.add(HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(range(implRef)).descriptionAndTooltip(message).create()); } } else { - String message = JavaErrorMessages.message("module.service.impl"); + String message = JavaErrorBundle.message("module.service.impl"); results.add(HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(range(implRef)).descriptionAndTooltip(message).create()); } } @@ -377,7 +378,7 @@ class ModuleHighlightUtil { static HighlightInfo checkClashingReads(@NotNull PsiJavaModule module) { Trinity conflict = JavaModuleGraphUtil.findConflict(module); if (conflict != null) { - String message = JavaErrorMessages.message( + String message = JavaErrorBundle.message( "module.conflicting.reads", module.getName(), conflict.first, conflict.second.getName(), conflict.third.getName()); return HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(range(module)).descriptionAndTooltip(message).create(); } @@ -393,7 +394,7 @@ class ModuleHighlightUtil { .filter(PsiKeyword.class) .map(keyword -> { @PsiModifier.ModifierConstant String modifier = keyword.getText(); - String message = JavaErrorMessages.message("modifier.not.allowed", modifier); + String message = JavaErrorBundle.message("modifier.not.allowed", modifier); HighlightInfo info = HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(keyword).descriptionAndTooltip(message).create(); QuickFixAction.registerQuickFixAction(info, factory().createModifierListFix(modList, modifier, false, false)); return info; diff --git a/java/java-analysis-impl/src/com/intellij/codeInsight/daemon/impl/analysis/PostHighlightingVisitor.java b/java/java-analysis-impl/src/com/intellij/codeInsight/daemon/impl/analysis/PostHighlightingVisitor.java index e36bb4212ca5..e6474a3d1bec 100644 --- a/java/java-analysis-impl/src/com/intellij/codeInsight/daemon/impl/analysis/PostHighlightingVisitor.java +++ b/java/java-analysis-impl/src/com/intellij/codeInsight/daemon/impl/analysis/PostHighlightingVisitor.java @@ -3,7 +3,7 @@ package com.intellij.codeInsight.daemon.impl.analysis; import com.intellij.codeInsight.daemon.HighlightDisplayKey; import com.intellij.codeInsight.daemon.ImplicitUsageProvider; -import com.intellij.codeInsight.daemon.JavaErrorMessages; +import com.intellij.codeInsight.daemon.JavaErrorBundle; import com.intellij.codeInsight.daemon.UnusedImportProvider; import com.intellij.codeInsight.daemon.impl.*; import com.intellij.codeInsight.daemon.impl.quickfix.QuickFixAction; @@ -247,7 +247,7 @@ class PostHighlightingVisitor { if (UnusedSymbolUtil.isImplicitUsage(myProject, variable)) return null; if (!myRefCountHolder.isReferenced(variable)) { - String message = JavaErrorMessages.message("local.variable.is.never.used", identifier.getText()); + String message = JavaErrorBundle.message("local.variable.is.never.used", identifier.getText()); HighlightInfo highlightInfo = UnusedSymbolUtil.createUnusedSymbolInfo(identifier, message, myDeadCodeInfoType); IntentionAction fix = variable instanceof PsiResourceVariable ? QuickFixFactory.getInstance().createRenameToIgnoredFix(variable) : QuickFixFactory.getInstance().createRemoveUnusedVariableFix(variable); QuickFixAction.registerQuickFixAction(highlightInfo, fix, myDeadCodeKey); @@ -255,7 +255,7 @@ class PostHighlightingVisitor { } if (!myRefCountHolder.isReferencedForRead(variable) && !UnusedSymbolUtil.isImplicitRead(myProject, variable)) { - String message = JavaErrorMessages.message("local.variable.is.not.used.for.reading", identifier.getText()); + String message = JavaErrorBundle.message("local.variable.is.not.used.for.reading", identifier.getText()); HighlightInfo highlightInfo = UnusedSymbolUtil.createUnusedSymbolInfo(identifier, message, myDeadCodeInfoType); QuickFixAction.registerQuickFixAction(highlightInfo, QuickFixFactory.getInstance().createRemoveUnusedVariableFix(variable), myDeadCodeKey); return highlightInfo; @@ -264,7 +264,7 @@ class PostHighlightingVisitor { if (!variable.hasInitializer() && !myRefCountHolder.isReferencedForWrite(variable) && !UnusedSymbolUtil.isImplicitWrite(myProject, variable)) { - String message = JavaErrorMessages.message("local.variable.is.not.assigned", identifier.getText()); + String message = JavaErrorBundle.message("local.variable.is.not.assigned", identifier.getText()); final HighlightInfo unusedSymbolInfo = UnusedSymbolUtil.createUnusedSymbolInfo(identifier, message, myDeadCodeInfoType); QuickFixAction .registerQuickFixAction(unusedSymbolInfo, QuickFixFactory.getInstance().createAddVariableInitializerFix(variable), myDeadCodeKey); @@ -286,7 +286,7 @@ class PostHighlightingVisitor { if (field.hasModifierProperty(PsiModifier.PRIVATE)) { final QuickFixFactory quickFixFactory = QuickFixFactory.getInstance(); if (!myRefCountHolder.isReferenced(field) && !UnusedSymbolUtil.isImplicitUsage(myProject, field)) { - String message = JavaErrorMessages.message("private.field.is.not.used", identifier.getText()); + String message = JavaErrorBundle.message("private.field.is.not.used", identifier.getText()); HighlightInfo highlightInfo = suggestionsToMakeFieldUsed(field, identifier, message); if (!field.hasInitializer() && !field.hasModifierProperty(PsiModifier.FINAL)) { @@ -298,7 +298,7 @@ class PostHighlightingVisitor { final boolean readReferenced = myRefCountHolder.isReferencedForRead(field); if (!readReferenced && !UnusedSymbolUtil.isImplicitRead(project, field)) { - String message = JavaErrorMessages.message("private.field.is.not.used.for.reading", identifier.getText()); + String message = JavaErrorBundle.message("private.field.is.not.used.for.reading", identifier.getText()); return suggestionsToMakeFieldUsed(field, identifier, message); } @@ -307,7 +307,7 @@ class PostHighlightingVisitor { } final boolean writeReferenced = myRefCountHolder.isReferencedForWrite(field); if (!writeReferenced && !UnusedSymbolUtil.isImplicitWrite(project, field)) { - String message = JavaErrorMessages.message("private.field.is.not.assigned", identifier.getText()); + String message = JavaErrorBundle.message("private.field.is.not.assigned", identifier.getText()); final HighlightInfo info = UnusedSymbolUtil.createUnusedSymbolInfo(identifier, message, myDeadCodeInfoType); QuickFixAction.registerQuickFixAction(info, quickFixFactory.createCreateGetterOrSetterFix(false, true, field), myDeadCodeKey); @@ -327,7 +327,7 @@ class PostHighlightingVisitor { } else if (UnusedSymbolUtil.isFieldUnused(myProject, myFile, field, progress, helper)) { if (UnusedSymbolUtil.isImplicitWrite(myProject, field)) { - String message = JavaErrorMessages.message("private.field.is.not.used.for.reading", identifier.getText()); + String message = JavaErrorBundle.message("private.field.is.not.used.for.reading", identifier.getText()); HighlightInfo highlightInfo = UnusedSymbolUtil.createUnusedSymbolInfo(identifier, message, myDeadCodeInfoType); QuickFixAction.registerQuickFixAction(highlightInfo, QuickFixFactory.getInstance().createSafeDeleteFix(field), myDeadCodeKey); return highlightInfo; @@ -401,7 +401,7 @@ class PostHighlightingVisitor { private HighlightInfo checkUnusedParameter(@NotNull PsiParameter parameter, @NotNull PsiIdentifier identifier) { if (!myRefCountHolder.isReferenced(parameter) && !UnusedSymbolUtil.isImplicitUsage(myProject, parameter)) { - String message = JavaErrorMessages.message("parameter.is.not.used", identifier.getText()); + String message = JavaErrorBundle.message("parameter.is.not.used", identifier.getText()); return UnusedSymbolUtil.createUnusedSymbolInfo(identifier, message, myDeadCodeInfoType); } return null; @@ -422,7 +422,7 @@ class PostHighlightingVisitor { key = method.isConstructor() ? "constructor.is.not.used" : "method.is.not.used"; } String symbolName = HighlightMessageUtil.getSymbolName(method, PsiSubstitutor.EMPTY); - String message = JavaErrorMessages.message(key, symbolName); + String message = JavaErrorBundle.message(key, symbolName); final HighlightInfo highlightInfo = UnusedSymbolUtil.createUnusedSymbolInfo(identifier, message, myDeadCodeInfoType); QuickFixAction.registerQuickFixAction(highlightInfo, QuickFixFactory.getInstance().createSafeDeleteFix(method), myDeadCodeKey); SpecialAnnotationsUtilBase.createAddToSpecialAnnotationFixes(method, annoName -> { @@ -467,14 +467,14 @@ class PostHighlightingVisitor { private static HighlightInfo formatUnusedSymbolHighlightInfo(@NotNull final Project project, - @NotNull @PropertyKey(resourceBundle = JavaErrorMessages.BUNDLE) String pattern, + @NotNull @PropertyKey(resourceBundle = JavaErrorBundle.BUNDLE) String pattern, @NotNull final PsiNameIdentifierOwner aClass, @NotNull final String element, HighlightDisplayKey highlightDisplayKey, @NotNull HighlightInfoType highlightInfoType, @NotNull PsiElement identifier) { String symbolName = aClass.getName(); - String message = JavaErrorMessages.message(pattern, symbolName); + String message = JavaErrorBundle.message(pattern, symbolName); final HighlightInfo highlightInfo = UnusedSymbolUtil.createUnusedSymbolInfo(identifier, message, highlightInfoType); QuickFixAction.registerQuickFixAction(highlightInfo, QuickFixFactory.getInstance().createSafeDeleteFix(aClass), highlightDisplayKey); SpecialAnnotationsUtilBase.createAddToSpecialAnnotationFixes((PsiModifierListOwner)aClass, annoName -> { diff --git a/java/java-analysis-impl/src/com/intellij/codeInspection/NumericOverflowInspection.java b/java/java-analysis-impl/src/com/intellij/codeInspection/NumericOverflowInspection.java index 504b6363a0d1..be7fc9e85a7c 100644 --- a/java/java-analysis-impl/src/com/intellij/codeInspection/NumericOverflowInspection.java +++ b/java/java-analysis-impl/src/com/intellij/codeInspection/NumericOverflowInspection.java @@ -2,7 +2,7 @@ package com.intellij.codeInspection; import com.intellij.codeInsight.daemon.GroupNames; -import com.intellij.codeInsight.daemon.JavaErrorMessages; +import com.intellij.codeInsight.daemon.JavaErrorBundle; import com.intellij.codeInspection.ui.SingleCheckboxOptionsPanel; import com.intellij.openapi.project.Project; import com.intellij.openapi.util.Key; @@ -58,7 +58,7 @@ public class NumericOverflowInspection extends AbstractBaseJavaLocalInspectionTo public void visitExpression(PsiExpression expression) { boolean hasOverflow = hasOverflow(expression, holder.getProject()); if (hasOverflow && (!ignoreLeftShiftWithNegativeResult || !isLeftShiftWithNegativeResult(expression, holder.getProject()))) { - holder.registerProblem(expression, JavaErrorMessages.message("numeric.overflow.in.expression"), ProblemHighlightType.GENERIC_ERROR_OR_WARNING); + holder.registerProblem(expression, JavaErrorBundle.message("numeric.overflow.in.expression"), ProblemHighlightType.GENERIC_ERROR_OR_WARNING); } } }; diff --git a/java/java-analysis-impl/src/com/intellij/codeInspection/accessStaticViaInstance/AccessStaticViaInstanceBase.java b/java/java-analysis-impl/src/com/intellij/codeInspection/accessStaticViaInstance/AccessStaticViaInstanceBase.java index 49362e7f9d4d..756a3c2fd39e 100644 --- a/java/java-analysis-impl/src/com/intellij/codeInspection/accessStaticViaInstance/AccessStaticViaInstanceBase.java +++ b/java/java-analysis-impl/src/com/intellij/codeInspection/accessStaticViaInstance/AccessStaticViaInstanceBase.java @@ -1,11 +1,14 @@ // Copyright 2000-2017 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. package com.intellij.codeInspection.accessStaticViaInstance; -import com.intellij.codeInsight.daemon.JavaErrorMessages; +import com.intellij.codeInsight.daemon.JavaErrorBundle; import com.intellij.codeInsight.daemon.impl.analysis.HighlightMessageUtil; import com.intellij.codeInsight.daemon.impl.analysis.JavaHighlightUtil; import com.intellij.codeInsight.daemon.impl.quickfix.RemoveUnusedVariableUtil; -import com.intellij.codeInspection.*; +import com.intellij.codeInspection.AbstractBaseJavaLocalInspectionTool; +import com.intellij.codeInspection.CleanupLocalInspectionTool; +import com.intellij.codeInspection.LocalQuickFix; +import com.intellij.codeInspection.ProblemsHolder; import com.intellij.psi.*; import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.NotNull; @@ -69,9 +72,9 @@ public class AccessStaticViaInstanceBase extends AbstractBaseJavaLocalInspection PsiClass containingClass = ((PsiMember)resolved).getContainingClass(); if (containingClass != null && containingClass.isInterface()) return; - String description = JavaErrorMessages.message("static.member.accessed.via.instance.reference", - JavaHighlightUtil.formatType(qualifierExpression.getType()), - HighlightMessageUtil.getSymbolName(resolved, result.getSubstitutor())); + String description = JavaErrorBundle.message("static.member.accessed.via.instance.reference", + JavaHighlightUtil.formatType(qualifierExpression.getType()), + HighlightMessageUtil.getSymbolName(resolved, result.getSubstitutor())); if (!onTheFly) { if (RemoveUnusedVariableUtil.checkSideEffects(qualifierExpression, null, new ArrayList<>())) { holder.registerProblem(expr, description); diff --git a/java/java-analysis-impl/src/com/intellij/codeInspection/compiler/JavacQuirksInspectionVisitor.java b/java/java-analysis-impl/src/com/intellij/codeInspection/compiler/JavacQuirksInspectionVisitor.java index a8a85741b4e3..9e8754f7a5c9 100644 --- a/java/java-analysis-impl/src/com/intellij/codeInspection/compiler/JavacQuirksInspectionVisitor.java +++ b/java/java-analysis-impl/src/com/intellij/codeInspection/compiler/JavacQuirksInspectionVisitor.java @@ -1,7 +1,7 @@ // Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. package com.intellij.codeInspection.compiler; -import com.intellij.codeInsight.daemon.JavaErrorMessages; +import com.intellij.codeInsight.daemon.JavaErrorBundle; import com.intellij.codeInsight.daemon.QuickFixBundle; import com.intellij.codeInsight.daemon.impl.actions.SuppressByJavaCommentFix; import com.intellij.codeInsight.daemon.impl.analysis.JavaHighlightUtil; @@ -90,9 +90,9 @@ public class JavacQuirksInspectionVisitor extends JavaElementVisitor { if (JavaSdkVersion.JDK_1_6.equals(JavaVersionService.getInstance().getJavaSdkVersion(assignment)) && PsiType.getJavaLangObject(assignment.getManager(), assignment.getResolveScope()).equals(lType)) { String operatorText = operationSign.getText().substring(0, operationSign.getText().length() - 1); - String message = JavaErrorMessages.message("binary.operator.not.applicable", operatorText, - JavaHighlightUtil.formatType(lType), - JavaHighlightUtil.formatType(rExpression.getType())); + String message = JavaErrorBundle.message("binary.operator.not.applicable", operatorText, + JavaHighlightUtil.formatType(lType), + JavaHighlightUtil.formatType(rExpression.getType())); myHolder.registerProblem(assignment, message, ProblemHighlightType.GENERIC_ERROR_OR_WARNING, new ReplaceAssignmentOperatorWithAssignmentFix(operationSign.getText())); diff --git a/java/java-analysis-impl/src/com/intellij/codeInspection/deprecation/DeprecatedApiUsageProcessor.java b/java/java-analysis-impl/src/com/intellij/codeInspection/deprecation/DeprecatedApiUsageProcessor.java index 5ebab5d4201f..20a9aec5e4e4 100644 --- a/java/java-analysis-impl/src/com/intellij/codeInspection/deprecation/DeprecatedApiUsageProcessor.java +++ b/java/java-analysis-impl/src/com/intellij/codeInspection/deprecation/DeprecatedApiUsageProcessor.java @@ -2,7 +2,7 @@ package com.intellij.codeInspection.deprecation; import com.intellij.codeInsight.ExternalAnnotationsManager; -import com.intellij.codeInsight.daemon.JavaErrorMessages; +import com.intellij.codeInsight.daemon.JavaErrorBundle; import com.intellij.codeInspection.ProblemHighlightType; import com.intellij.codeInspection.ProblemsHolder; import com.intellij.codeInspection.apiUsage.ApiUsageProcessor; @@ -91,10 +91,10 @@ public final class DeprecatedApiUsageProcessor implements ApiUsageProcessor { if (elementToHighlight == null) { return; } - String description = JavaErrorMessages.message(myForRemoval + String description = JavaErrorBundle.message(myForRemoval ? "marked.for.removal.default.constructor" : "deprecated.default.constructor", - instantiatedClass.getQualifiedName()); + instantiatedClass.getQualifiedName()); myHolder.registerProblem(elementToHighlight, getDescription(description, myForRemoval, myHighlightType), myHighlightType); } } @@ -113,8 +113,8 @@ public final class DeprecatedApiUsageProcessor implements ApiUsageProcessor { } if (overriddenMethod.isDeprecated() && myForRemoval == isForRemovalAttributeSet(overriddenMethod)) { - String description = JavaErrorMessages.message(myForRemoval ? "overrides.marked.for.removal.method" : "overrides.deprecated.method", - getPresentableName(aClass)); + String description = JavaErrorBundle.message(myForRemoval ? "overrides.marked.for.removal.method" : "overrides.deprecated.method", + getPresentableName(aClass)); myHolder.registerProblem(methodNameElement, getDescription(description, myForRemoval, myHighlightType), myHighlightType); } } diff --git a/java/java-analysis-impl/src/com/intellij/codeInspection/deprecation/DeprecationInspectionBase.java b/java/java-analysis-impl/src/com/intellij/codeInspection/deprecation/DeprecationInspectionBase.java index 9dd46499070f..0abc1b351062 100644 --- a/java/java-analysis-impl/src/com/intellij/codeInspection/deprecation/DeprecationInspectionBase.java +++ b/java/java-analysis-impl/src/com/intellij/codeInspection/deprecation/DeprecationInspectionBase.java @@ -2,7 +2,7 @@ package com.intellij.codeInspection.deprecation; import com.intellij.codeInsight.AnnotationUtil; -import com.intellij.codeInsight.daemon.JavaErrorMessages; +import com.intellij.codeInsight.daemon.JavaErrorBundle; import com.intellij.codeInsight.daemon.impl.analysis.HighlightMessageUtil; import com.intellij.codeInspection.LocalInspectionTool; import com.intellij.codeInspection.LocalQuickFix; @@ -70,8 +70,8 @@ public abstract class DeprecationInspectionBase extends LocalInspectionTool { if (ignoreImportStatements && isElementInsideImportStatement(elementToHighlight)) return; - String description = JavaErrorMessages.message(forRemoval ? "marked.for.removal.symbol" : "deprecated.symbol", - getPresentableName(element)); + String description = JavaErrorBundle.message(forRemoval ? "marked.for.removal.symbol" : "deprecated.symbol", + getPresentableName(element)); LocalQuickFix replacementQuickFix = getReplacementQuickFix(element, elementToHighlight); diff --git a/java/java-analysis-impl/src/com/intellij/codeInspection/unneededThrows/RedundantThrowsDeclarationLocalInspection.java b/java/java-analysis-impl/src/com/intellij/codeInspection/unneededThrows/RedundantThrowsDeclarationLocalInspection.java index c2468e8cb7e1..39a9f1818d2b 100644 --- a/java/java-analysis-impl/src/com/intellij/codeInspection/unneededThrows/RedundantThrowsDeclarationLocalInspection.java +++ b/java/java-analysis-impl/src/com/intellij/codeInspection/unneededThrows/RedundantThrowsDeclarationLocalInspection.java @@ -2,7 +2,7 @@ package com.intellij.codeInspection.unneededThrows; import com.intellij.codeInsight.ExceptionUtil; -import com.intellij.codeInsight.daemon.JavaErrorMessages; +import com.intellij.codeInsight.daemon.JavaErrorBundle; import com.intellij.codeInsight.daemon.impl.analysis.JavaHighlightUtil; import com.intellij.codeInsight.daemon.impl.quickfix.MethodThrowsFix; import com.intellij.codeInspection.*; @@ -96,7 +96,7 @@ public class RedundantThrowsDeclarationLocalInspection extends AbstractBaseJavaL return candidates.stream().map(exceptionType -> { PsiJavaCodeReferenceElement reference = exceptionType.ref; - String description = JavaErrorMessages.message("exception.is.never.thrown", JavaHighlightUtil.formatType(exceptionType.type)); + String description = JavaErrorBundle.message("exception.is.never.thrown", JavaHighlightUtil.formatType(exceptionType.type)); LocalQuickFix quickFix = new MethodThrowsFix.Remove(method, exceptionType.type, false); return inspectionManager.createProblemDescriptor(reference, description, quickFix, ProblemHighlightType.LIKE_UNUSED_SYMBOL, true); }).toArray(ProblemDescriptor[]::new); diff --git a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/analysis/JavaErrorQuickFixProvider.java b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/analysis/JavaErrorQuickFixProvider.java index 8f689ed5efdd..3a30d721bb57 100644 --- a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/analysis/JavaErrorQuickFixProvider.java +++ b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/analysis/JavaErrorQuickFixProvider.java @@ -1,7 +1,7 @@ // Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. package com.intellij.codeInsight.daemon.impl.analysis; -import com.intellij.codeInsight.daemon.JavaErrorMessages; +import com.intellij.codeInsight.daemon.JavaErrorBundle; import com.intellij.codeInsight.daemon.impl.HighlightInfo; import com.intellij.codeInsight.daemon.impl.quickfix.AddExceptionToCatchFix; import com.intellij.codeInsight.daemon.impl.quickfix.AddFinallyFix; @@ -20,12 +20,12 @@ public class JavaErrorQuickFixProvider implements ErrorQuickFixProvider { public void registerErrorQuickFix(@NotNull PsiErrorElement errorElement, @NotNull HighlightInfo highlightInfo) { PsiElement parent = errorElement.getParent(); if (parent instanceof PsiTryStatement && errorElement.getErrorDescription().equals( - JavaErrorMessages.message("expected.catch.or.finally"))) { + JavaErrorBundle.message("expected.catch.or.finally"))) { QuickFixAction.registerQuickFixAction(highlightInfo, new AddExceptionToCatchFix(false)); QuickFixAction.registerQuickFixAction(highlightInfo, new AddFinallyFix((PsiTryStatement)parent)); } if (parent instanceof PsiSwitchLabeledRuleStatement && errorElement.getErrorDescription().equals( - JavaErrorMessages.message("expected.switch.rule"))) { + JavaErrorBundle.message("expected.switch.rule"))) { QuickFixAction.registerQuickFixAction( highlightInfo, QUICK_FIX_FACTORY.createWrapSwitchRuleStatementsIntoBlockFix((PsiSwitchLabeledRuleStatement)parent)); } diff --git a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/CreateFromUsageUtils.java b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/CreateFromUsageUtils.java index a5c7ad2ba277..7a8691a96cda 100644 --- a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/CreateFromUsageUtils.java +++ b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/CreateFromUsageUtils.java @@ -17,7 +17,7 @@ package com.intellij.codeInsight.daemon.impl.quickfix; import com.intellij.codeInsight.*; import com.intellij.codeInsight.completion.proc.VariablesProcessor; -import com.intellij.codeInsight.daemon.JavaErrorMessages; +import com.intellij.codeInsight.daemon.JavaErrorBundle; import com.intellij.codeInsight.daemon.QuickFixBundle; import com.intellij.codeInsight.generation.OverrideImplementUtil; import com.intellij.codeInsight.generation.PsiGenerationInfo; @@ -189,7 +189,7 @@ public class CreateFromUsageUtils { if (oldBody == null) { PsiElement last = method.getLastChild(); if (last instanceof PsiErrorElement && - JavaErrorMessages.message("expected.lbrace.or.semicolon").equals(((PsiErrorElement)last).getErrorDescription())) { + JavaErrorBundle.message("expected.lbrace.or.semicolon").equals(((PsiErrorElement)last).getErrorDescription())) { oldBody = last; } } diff --git a/java/java-impl/src/com/intellij/codeInsight/generation/RecordConstructorChooserDialog.java b/java/java-impl/src/com/intellij/codeInsight/generation/RecordConstructorChooserDialog.java index 555d66f4cacb..a9cd7aa59307 100644 --- a/java/java-impl/src/com/intellij/codeInsight/generation/RecordConstructorChooserDialog.java +++ b/java/java-impl/src/com/intellij/codeInsight/generation/RecordConstructorChooserDialog.java @@ -2,7 +2,7 @@ package com.intellij.codeInsight.generation; import com.intellij.codeInsight.CodeInsightBundle; -import com.intellij.codeInsight.daemon.JavaErrorMessages; +import com.intellij.codeInsight.daemon.JavaErrorBundle; import com.intellij.openapi.application.ApplicationBundle; import com.intellij.openapi.ui.DialogWrapper; import com.intellij.openapi.ui.VerticalFlowLayout; @@ -23,8 +23,8 @@ final class RecordConstructorChooserDialog extends DialogWrapper { myRecordClass = recordClass; setTitle(CodeInsightBundle.message("generate.record.constructor.title")); setOKButtonText(CodeInsightBundle.message("generate.button.title")); - myCompact = new JBRadioButton(JavaErrorMessages.message("record.compact.constructor"), true); - myCanonical = new JBRadioButton(JavaErrorMessages.message("record.canonical.constructor"), false); + myCompact = new JBRadioButton(JavaErrorBundle.message("record.compact.constructor"), true); + myCanonical = new JBRadioButton(JavaErrorBundle.message("record.canonical.constructor"), false); myCustom = new JBRadioButton(ApplicationBundle.message("custom.option"), false); init(); } diff --git a/java/java-impl/src/com/intellij/codeInspection/reflectiveAccess/JavaLangInvokeHandleSignatureInspection.java b/java/java-impl/src/com/intellij/codeInspection/reflectiveAccess/JavaLangInvokeHandleSignatureInspection.java index 4379a6df9cd0..7a0be3c0337e 100644 --- a/java/java-impl/src/com/intellij/codeInspection/reflectiveAccess/JavaLangInvokeHandleSignatureInspection.java +++ b/java/java-impl/src/com/intellij/codeInspection/reflectiveAccess/JavaLangInvokeHandleSignatureInspection.java @@ -1,7 +1,7 @@ // Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. package com.intellij.codeInspection.reflectiveAccess; -import com.intellij.codeInsight.daemon.JavaErrorMessages; +import com.intellij.codeInsight.daemon.JavaErrorBundle; import com.intellij.codeInsight.lookup.*; import com.intellij.codeInspection.*; import com.intellij.openapi.application.ApplicationManager; @@ -164,7 +164,7 @@ public class JavaLangInvokeHandleSignatureInspection extends AbstractBaseJavaLoc fix = ReplaceSignatureQuickFix .createFix(constructorTypeExpression, ownerClassName, validSignatures, true, holder.isOnTheFly()); } - holder.registerProblem(constructorTypeExpression, JavaErrorMessages.message("cannot.resolve.constructor", declarationText), fix); + holder.registerProblem(constructorTypeExpression, JavaErrorBundle.message("cannot.resolve.constructor", declarationText), fix); } } } @@ -215,7 +215,7 @@ public class JavaLangInvokeHandleSignatureInspection extends AbstractBaseJavaLoc if (!ownerClass.isExact()) return; final PsiMethod[] methods = ownerClass.getPsiClass().findMethodsByName(methodName, true); if (methods.length == 0) { - holder.registerProblem(methodNameExpression, JavaErrorMessages.message("cannot.resolve.method", methodName)); + holder.registerProblem(methodNameExpression, JavaErrorBundle.message("cannot.resolve.method", methodName)); return; } @@ -245,7 +245,7 @@ public class JavaLangInvokeHandleSignatureInspection extends AbstractBaseJavaLoc .collect(Collectors.toList()); final LocalQuickFix fix = ReplaceSignatureQuickFix.createFix(methodTypeExpression, methodName, validSignatures, false, holder.isOnTheFly()); - holder.registerProblem(methodTypeExpression, JavaErrorMessages.message("cannot.resolve.method", declarationText), fix); + holder.registerProblem(methodTypeExpression, JavaErrorBundle.message("cannot.resolve.method", declarationText), fix); return; } if (!isAbstractAllowed) { diff --git a/java/java-impl/src/com/intellij/codeInspection/suspiciousNameCombination/SuspiciousNameCombinationInspection.java b/java/java-impl/src/com/intellij/codeInspection/suspiciousNameCombination/SuspiciousNameCombinationInspection.java index 07cca8ebab81..ddcaf0325991 100644 --- a/java/java-impl/src/com/intellij/codeInspection/suspiciousNameCombination/SuspiciousNameCombinationInspection.java +++ b/java/java-impl/src/com/intellij/codeInspection/suspiciousNameCombination/SuspiciousNameCombinationInspection.java @@ -17,7 +17,7 @@ package com.intellij.codeInspection.suspiciousNameCombination; import com.intellij.codeInsight.daemon.GroupNames; -import com.intellij.codeInsight.daemon.JavaErrorMessages; +import com.intellij.codeInsight.daemon.JavaErrorBundle; import com.intellij.codeInspection.AbstractBaseJavaLocalInspectionTool; import com.intellij.codeInspection.InspectionsBundle; import com.intellij.codeInspection.ProblemsHolder; @@ -277,7 +277,7 @@ public class SuspiciousNameCombinationInspection extends AbstractBaseJavaLocalIn String nameGroup1 = findNameGroup(name); String nameGroup2 = findNameGroup(referenceName); if (nameGroup1 != null && nameGroup2 != null && !nameGroup1.equals(nameGroup2)) { - myProblemsHolder.registerProblem(location, JavaErrorMessages.message(key, referenceName, name)); + myProblemsHolder.registerProblem(location, JavaErrorBundle.message(key, referenceName, name)); } } diff --git a/java/java-impl/src/com/intellij/codeInspection/uncheckedWarnings/UncheckedWarningLocalInspection.java b/java/java-impl/src/com/intellij/codeInspection/uncheckedWarnings/UncheckedWarningLocalInspection.java index b7483a37e597..5164990b2f5a 100644 --- a/java/java-impl/src/com/intellij/codeInspection/uncheckedWarnings/UncheckedWarningLocalInspection.java +++ b/java/java-impl/src/com/intellij/codeInspection/uncheckedWarnings/UncheckedWarningLocalInspection.java @@ -1,7 +1,7 @@ // Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. package com.intellij.codeInspection.uncheckedWarnings; -import com.intellij.codeInsight.daemon.JavaErrorMessages; +import com.intellij.codeInsight.daemon.JavaErrorBundle; import com.intellij.codeInsight.daemon.impl.analysis.JavaGenericsUtil; import com.intellij.codeInsight.daemon.impl.analysis.JavaHighlightUtil; import com.intellij.codeInsight.daemon.impl.quickfix.GenerifyFileFix; @@ -9,7 +9,10 @@ import com.intellij.codeInsight.daemon.impl.quickfix.VariableArrayTypeFix; import com.intellij.codeInsight.intention.IntentionAction; import com.intellij.codeInsight.intention.QuickFixFactory; import com.intellij.codeInsight.quickfix.ChangeVariableTypeQuickFixProvider; -import com.intellij.codeInspection.*; +import com.intellij.codeInspection.AbstractBaseJavaLocalInspectionTool; +import com.intellij.codeInspection.LocalInspectionToolSession; +import com.intellij.codeInspection.LocalQuickFix; +import com.intellij.codeInspection.ProblemsHolder; import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.projectRoots.JavaSdkVersion; import com.intellij.openapi.projectRoots.JavaVersionService; @@ -262,7 +265,7 @@ public class UncheckedWarningLocalInspection extends AbstractBaseJavaLocalInspec if (!TypeConversionUtil.areTypesConvertible(exprType, castType)) return; if (JavaGenericsUtil.isUncheckedCast(castType, exprType)) { final String description = - JavaErrorMessages.message("generics.unchecked.cast", JavaHighlightUtil.formatType(exprType), JavaHighlightUtil + JavaErrorBundle.message("generics.unchecked.cast", JavaHighlightUtil.formatType(exprType), JavaHighlightUtil .formatType(castType)); registerProblem(description, operand, expression, myGenerifyFixes); } @@ -401,9 +404,9 @@ public class UncheckedWarningLocalInspection extends AbstractBaseJavaLocalInspec if (itemType == null) continue; if (!TypeConversionUtil.isAssignable(componentType, itemType)) continue; if (JavaGenericsUtil.isRawToGeneric(componentType, itemType)) { - String description = JavaErrorMessages.message("generics.unchecked.assignment", - JavaHighlightUtil.formatType(itemType), - JavaHighlightUtil.formatType(componentType)); + String description = JavaErrorBundle.message("generics.unchecked.assignment", + JavaHighlightUtil.formatType(itemType), + JavaHighlightUtil.formatType(componentType)); if (!arrayTypeFixChecked) { final PsiType checkResult = JavaHighlightUtil.sameType(initializers); fix = checkResult != null ? VariableArrayTypeFix.createFix(arrayInitializer, checkResult) : null; @@ -424,9 +427,9 @@ public class UncheckedWarningLocalInspection extends AbstractBaseJavaLocalInspec if (parameterType == null || itemType == null) return; if (!TypeConversionUtil.isAssignable(parameterType, itemType)) return; if (JavaGenericsUtil.isRawToGeneric(parameterType, itemType)) { - String description = JavaErrorMessages.message("generics.unchecked.assignment", - JavaHighlightUtil.formatType(itemType), - JavaHighlightUtil.formatType(parameterType)); + String description = JavaErrorBundle.message("generics.unchecked.assignment", + JavaHighlightUtil.formatType(itemType), + JavaHighlightUtil.formatType(parameterType)); registerProblem(description, expression, parameter, fixesSupplier.get()); } } @@ -448,9 +451,9 @@ public class UncheckedWarningLocalInspection extends AbstractBaseJavaLocalInspec final PsiType overriderReturnType = method.getReturnType(); if (baseReturnType == null || overriderReturnType == null) return; if (JavaGenericsUtil.isRawToGeneric(baseReturnType, overriderReturnType)) { - final String message = JavaErrorMessages.message("unchecked.overriding.incompatible.return.type", - JavaHighlightUtil.formatType(overriderReturnType), - JavaHighlightUtil.formatType(baseReturnType)); + final String message = JavaErrorBundle.message("unchecked.overriding.incompatible.return.type", + JavaHighlightUtil.formatType(overriderReturnType), + JavaHighlightUtil.formatType(baseReturnType)); final PsiTypeElement returnTypeElement = method.getReturnTypeElement(); LOG.assertTrue(returnTypeElement != null); @@ -513,7 +516,7 @@ public class UncheckedWarningLocalInspection extends AbstractBaseJavaLocalInspec final PsiType subst = substitutor.substitute(parameter); for (PsiClassType classType : extendsListTypes) { if (JavaGenericsUtil.isRawToGeneric(substitutor.substitute(classType), subst)) { - return JavaErrorMessages.message("generics.unchecked.call", JavaHighlightUtil.formatMethod(method)); + return JavaErrorBundle.message("generics.unchecked.call", JavaHighlightUtil.formatMethod(method)); } } } @@ -524,9 +527,9 @@ public class UncheckedWarningLocalInspection extends AbstractBaseJavaLocalInspec if (PsiTypesUtil.isUncheckedCall(resolveResult)) { final PsiElementFactory elementFactory = JavaPsiFacade.getElementFactory(method.getProject()); PsiType type = elementFactory.createType(method.getContainingClass(), substitutor); - return JavaErrorMessages.message("generics.unchecked.call.to.member.of.raw.type", - JavaHighlightUtil.formatMethod(method), - JavaHighlightUtil.formatType(type)); + return JavaErrorBundle.message("generics.unchecked.call.to.member.of.raw.type", + JavaHighlightUtil.formatMethod(method), + JavaHighlightUtil.formatType(type)); } return null; } diff --git a/java/java-impl/src/com/intellij/codeInspection/wrongPackageStatement/WrongPackageStatementInspection.java b/java/java-impl/src/com/intellij/codeInspection/wrongPackageStatement/WrongPackageStatementInspection.java index e3ea07036320..efd93e813c52 100644 --- a/java/java-impl/src/com/intellij/codeInspection/wrongPackageStatement/WrongPackageStatementInspection.java +++ b/java/java-impl/src/com/intellij/codeInspection/wrongPackageStatement/WrongPackageStatementInspection.java @@ -16,7 +16,7 @@ package com.intellij.codeInspection.wrongPackageStatement; import com.intellij.codeHighlighting.HighlightDisplayLevel; -import com.intellij.codeInsight.daemon.JavaErrorMessages; +import com.intellij.codeInsight.daemon.JavaErrorBundle; import com.intellij.codeInspection.*; import com.intellij.openapi.application.ApplicationManager; import com.intellij.openapi.util.Comparing; @@ -59,7 +59,7 @@ public class WrongPackageStatementInspection extends AbstractBaseJavaLocalInspec String packageName = dirPackage.getQualifiedName(); if (!Comparing.strEqual(packageName, "", true) && packageStatement == null) { - String description = JavaErrorMessages.message("missing.package.statement", packageName); + String description = JavaErrorBundle.message("missing.package.statement", packageName); final LocalQuickFix fix = PsiDirectoryFactory.getInstance(file.getProject()).isValidPackageName(packageName) ? new AdjustPackageNameFix(packageName) : null; @@ -78,9 +78,9 @@ public class WrongPackageStatementInspection extends AbstractBaseJavaLocalInspec addMoveToPackageFix(file, packName, availableFixes); } if (!availableFixes.isEmpty()){ - String description = JavaErrorMessages.message("package.name.file.path.mismatch", - packageReference.getQualifiedName(), - dirPackage.getQualifiedName()); + String description = JavaErrorBundle.message("package.name.file.path.mismatch", + packageReference.getQualifiedName(), + dirPackage.getQualifiedName()); LocalQuickFix[] fixes = availableFixes.toArray(LocalQuickFix.EMPTY_ARRAY); ProblemDescriptor descriptor = manager.createProblemDescriptor(packageStatement.getPackageReference(), description, isOnTheFly, diff --git a/java/java-impl/src/com/intellij/psi/impl/JavaPlatformModuleSystem.kt b/java/java-impl/src/com/intellij/psi/impl/JavaPlatformModuleSystem.kt index 580e663a82ac..fda8c0265533 100644 --- a/java/java-impl/src/com/intellij/psi/impl/JavaPlatformModuleSystem.kt +++ b/java/java-impl/src/com/intellij/psi/impl/JavaPlatformModuleSystem.kt @@ -4,7 +4,7 @@ package com.intellij.psi.impl import com.intellij.codeInsight.JavaModuleSystemEx import com.intellij.codeInsight.JavaModuleSystemEx.ErrorWithFixes import com.intellij.codeInsight.daemon.DaemonCodeAnalyzer -import com.intellij.codeInsight.daemon.JavaErrorMessages +import com.intellij.codeInsight.daemon.JavaErrorBundle import com.intellij.codeInsight.daemon.QuickFixBundle import com.intellij.codeInsight.daemon.impl.analysis.JavaModuleGraphUtil import com.intellij.codeInsight.daemon.impl.quickfix.AddExportsDirectiveFix @@ -52,7 +52,8 @@ class JavaPlatformModuleSystem : JavaModuleSystemEx { val test = index.isInTestSourceContent(useVFile) val dirs = target.getDirectories(module.getModuleWithDependenciesAndLibrariesScope(test)) if (dirs.isEmpty()) { - return if (quick) ERR else ErrorWithFixes(JavaErrorMessages.message("package.not.found", target.qualifiedName)) + return if (quick) ERR else ErrorWithFixes( + JavaErrorBundle.message("package.not.found", target.qualifiedName)) } val error = checkAccess(dirs[0], useFile, target.qualifiedName, quick) return when { @@ -98,7 +99,7 @@ class JavaPlatformModuleSystem : JavaModuleSystemEx { } if (!isRoot) { return if (quick) ERR else ErrorWithFixes( - JavaErrorMessages.message("module.access.not.in.graph", packageName, targetName), + JavaErrorBundle.message("module.access.not.in.graph", packageName, targetName), listOf(AddModulesOptionFix(module, targetName))) } } @@ -114,8 +115,10 @@ class JavaPlatformModuleSystem : JavaModuleSystemEx { else -> emptyList() } return when (useModule) { - null -> ErrorWithFixes(JavaErrorMessages.message("module.access.from.unnamed", packageName, targetName), fixes) - else -> ErrorWithFixes(JavaErrorMessages.message("module.access.from.named", packageName, targetName, useName), fixes) + null -> ErrorWithFixes( + JavaErrorBundle.message("module.access.from.unnamed", packageName, targetName), fixes) + else -> ErrorWithFixes( + JavaErrorBundle.message("module.access.from.named", packageName, targetName, useName), fixes) } } @@ -123,14 +126,16 @@ class JavaPlatformModuleSystem : JavaModuleSystemEx { return when { quick -> ERR PsiNameHelper.isValidModuleName(targetName, useModule) -> ErrorWithFixes( - JavaErrorMessages.message("module.access.does.not.read", packageName, targetName, useName), + JavaErrorBundle.message("module.access.does.not.read", packageName, targetName, useName), listOf(AddRequiresDirectiveFix(useModule, targetName))) - else -> ErrorWithFixes(JavaErrorMessages.message("module.access.bad.name", packageName, targetName)) + else -> ErrorWithFixes( + JavaErrorBundle.message("module.access.bad.name", packageName, targetName)) } } } else if (useModule != null) { - return if (quick) ERR else ErrorWithFixes(JavaErrorMessages.message("module.access.to.unnamed", packageName, useModule.name)) + return if (quick) ERR else ErrorWithFixes( + JavaErrorBundle.message("module.access.to.unnamed", packageName, useModule.name)) } return null diff --git a/java/java-impl/src/com/intellij/psi/impl/source/resolve/reference/impl/providers/JavaClassReferenceSet.java b/java/java-impl/src/com/intellij/psi/impl/source/resolve/reference/impl/providers/JavaClassReferenceSet.java index 818ab7101844..12dd09ca17e5 100644 --- a/java/java-impl/src/com/intellij/psi/impl/source/resolve/reference/impl/providers/JavaClassReferenceSet.java +++ b/java/java-impl/src/com/intellij/psi/impl/source/resolve/reference/impl/providers/JavaClassReferenceSet.java @@ -15,7 +15,7 @@ */ package com.intellij.psi.impl.source.resolve.reference.impl.providers; -import com.intellij.codeInsight.daemon.JavaErrorMessages; +import com.intellij.codeInsight.daemon.JavaErrorBundle; import com.intellij.lang.xml.XMLLanguage; import com.intellij.openapi.util.TextRange; import com.intellij.openapi.util.text.StringUtil; @@ -274,8 +274,8 @@ public class JavaClassReferenceSet { @NotNull public String getUnresolvedMessagePattern(int index){ if (canReferencePackage(index)) { - return JavaErrorMessages.message("error.cannot.resolve.class.or.package"); + return JavaErrorBundle.message("error.cannot.resolve.class.or.package"); } - return JavaErrorMessages.message("error.cannot.resolve.class"); + return JavaErrorBundle.message("error.cannot.resolve.class"); } } diff --git a/java/java-impl/src/com/intellij/psi/impl/source/resolve/reference/impl/providers/PsiPackageReference.java b/java/java-impl/src/com/intellij/psi/impl/source/resolve/reference/impl/providers/PsiPackageReference.java index 027840693c9e..fa7a17083845 100644 --- a/java/java-impl/src/com/intellij/psi/impl/source/resolve/reference/impl/providers/PsiPackageReference.java +++ b/java/java-impl/src/com/intellij/psi/impl/source/resolve/reference/impl/providers/PsiPackageReference.java @@ -2,7 +2,7 @@ package com.intellij.psi.impl.source.resolve.reference.impl.providers; import com.intellij.codeInsight.daemon.EmptyResolveMessageProvider; -import com.intellij.codeInsight.daemon.JavaErrorMessages; +import com.intellij.codeInsight.daemon.JavaErrorBundle; import com.intellij.openapi.util.TextRange; import com.intellij.psi.*; import com.intellij.util.IncorrectOperationException; @@ -50,7 +50,7 @@ public class PsiPackageReference extends PsiPolyVariantReferenceBase @Override public String getUnresolvedMessagePattern() { //noinspection UnresolvedPropertyKey - return JavaErrorMessages.message("cannot.resolve.package"); + return JavaErrorBundle.message("cannot.resolve.package"); } @Override diff --git a/java/java-psi-impl/src/com/intellij/codeInsight/daemon/JavaErrorBundle.java b/java/java-psi-impl/src/com/intellij/codeInsight/daemon/JavaErrorBundle.java new file mode 100644 index 000000000000..8ce842483eb4 --- /dev/null +++ b/java/java-psi-impl/src/com/intellij/codeInsight/daemon/JavaErrorBundle.java @@ -0,0 +1,38 @@ +/* + * Copyright 2000-2013 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.intellij.codeInsight.daemon; + +import com.intellij.DynamicBundle; +import org.jetbrains.annotations.NonNls; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.PropertyKey; + +/** + * @author max + */ +public class JavaErrorBundle extends DynamicBundle { + @NonNls public static final String BUNDLE = "messages.JavaErrorBundle"; + public static final JavaErrorBundle INSTANCE = new JavaErrorBundle(); + + @NotNull + public static String message(@NotNull @PropertyKey(resourceBundle = BUNDLE) String key, @NotNull Object... params) { + return INSTANCE.getMessage(key, params); + } + + JavaErrorBundle() { + super(BUNDLE); + } +} 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 633c8bfa35d3..d7d410dbca1a 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 @@ -1,39 +1,12 @@ -/* - * Copyright 2000-2013 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +// Copyright 2000-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. package com.intellij.codeInsight.daemon; -import com.intellij.DynamicBundle; -import org.jetbrains.annotations.NonNls; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.PropertyKey; +import org.jetbrains.annotations.ApiStatus; /** - * @author max + * @deprecated use JavaErrorBundle */ -public class JavaErrorMessages extends DynamicBundle { - - @NotNull - public static String message(@NotNull @PropertyKey(resourceBundle = BUNDLE) String key, @NotNull Object... params) { - return INSTANCE.getMessage(key, params); - } - - public static final JavaErrorMessages INSTANCE = new JavaErrorMessages(); - @NonNls public static final String BUNDLE = "messages.JavaErrorMessages"; - - private JavaErrorMessages() { - super(BUNDLE); - } +@Deprecated +@ApiStatus.ScheduledForRemoval(inVersion = "2020.3") +public class JavaErrorMessages extends JavaErrorBundle { } diff --git a/java/java-psi-impl/src/com/intellij/lang/java/parser/DeclarationParser.java b/java/java-psi-impl/src/com/intellij/lang/java/parser/DeclarationParser.java index e6d60de7c623..5b60998fa684 100644 --- a/java/java-psi-impl/src/com/intellij/lang/java/parser/DeclarationParser.java +++ b/java/java-psi-impl/src/com/intellij/lang/java/parser/DeclarationParser.java @@ -1,7 +1,7 @@ // Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. package com.intellij.lang.java.parser; -import com.intellij.codeInsight.daemon.JavaErrorMessages; +import com.intellij.codeInsight.daemon.JavaErrorBundle; import com.intellij.lang.PsiBuilder; import com.intellij.openapi.util.Pair; import com.intellij.pom.java.LanguageLevel; @@ -78,7 +78,7 @@ public class DeclarationParser { final boolean isEnum = (keywordTokenType == JavaTokenType.ENUM_KEYWORD); if (!expect(builder, JavaTokenType.IDENTIFIER)) { - error(builder, JavaErrorMessages.message("expected.identifier")); + error(builder, JavaErrorBundle.message("expected.identifier")); declaration.drop(); return null; } @@ -98,7 +98,7 @@ public class DeclarationParser { while (BEFORE_LBRACE_ELEMENTS_SET.contains(builder.getTokenType())) { builder.advanceLexer(); } - error.error(JavaErrorMessages.message("expected.lbrace")); + error.error(JavaErrorBundle.message("expected.lbrace")); } if (builder.getTokenType() == JavaTokenType.LBRACE) { @@ -113,7 +113,7 @@ public class DeclarationParser { final PsiBuilder.Marker extra = parse(builder, Context.CLASS); if (extra != null && AFTER_END_DECLARATION_SET.contains(exprType(extra))) { if (!declarationsAfterEnd) { - error(builder, JavaErrorMessages.message("expected.class.or.interface"), extra); + error(builder, JavaErrorBundle.message("expected.class.or.interface"), extra); } declarationsAfterEnd = true; position.drop(); @@ -141,7 +141,7 @@ public class DeclarationParser { } if (builder.getTokenType() == JavaTokenType.PRIVATE_KEYWORD || builder.getTokenType() == JavaTokenType.PROTECTED_KEYWORD) { - error(builder, JavaErrorMessages.message("expected.semicolon")); + error(builder, JavaErrorBundle.message("expected.semicolon")); return; } @@ -149,7 +149,7 @@ public class DeclarationParser { if (enumConstant == null && builder.getTokenType() == JavaTokenType.COMMA && first) { IElementType next = builder.lookAhead(1); if (next != JavaTokenType.SEMICOLON && next != JavaTokenType.RBRACE) { - error(builder, JavaErrorMessages.message("expected.identifier")); + error(builder, JavaErrorBundle.message("expected.identifier")); } } @@ -158,7 +158,7 @@ public class DeclarationParser { if (!expect(builder, JavaTokenType.COMMA) && builder.getTokenType() != null && builder.getTokenType() != JavaTokenType.SEMICOLON) { - error(builder, JavaErrorMessages.message("expected.comma.or.semicolon")); + error(builder, JavaErrorBundle.message("expected.comma.or.semicolon")); return; } } @@ -203,7 +203,7 @@ public class DeclarationParser { if (tokenType == JavaTokenType.SEMICOLON) { if (invalidElements != null) { - invalidElements.error(JavaErrorMessages.message("unexpected.token")); + invalidElements.error(JavaErrorBundle.message("unexpected.token")); invalidElements = null; } builder.advanceLexer(); @@ -213,7 +213,7 @@ public class DeclarationParser { final PsiBuilder.Marker declaration = parse(builder, context); if (declaration != null) { if (invalidElements != null) { - invalidElements.errorBefore(JavaErrorMessages.message("unexpected.token"), declaration); + invalidElements.errorBefore(JavaErrorBundle.message("unexpected.token"), declaration); invalidElements = null; } continue; @@ -231,7 +231,7 @@ public class DeclarationParser { } if (invalidElements != null) { - invalidElements.error(JavaErrorMessages.message("unexpected.token")); + invalidElements.error(JavaErrorBundle.message("unexpected.token")); } } @@ -286,14 +286,14 @@ public class DeclarationParser { } if (context == Context.FILE) { - error(builder, JavaErrorMessages.message("expected.class.or.interface"), typeParams); + error(builder, JavaErrorBundle.message("expected.class.or.interface"), typeParams); declaration.drop(); return modList; } if (builder.getTokenType() == JavaTokenType.LBRACE) { if (context == Context.CODE_BLOCK) { - error(builder, JavaErrorMessages.message("expected.identifier.or.type"), null); + error(builder, JavaErrorBundle.message("expected.identifier.or.type"), null); declaration.drop(); return modList; } @@ -303,7 +303,7 @@ public class DeclarationParser { if (typeParams != null) { PsiBuilder.Marker error = typeParams.precede(); - error.errorBefore(JavaErrorMessages.message("unexpected.token"), codeBlock); + error.errorBefore(JavaErrorBundle.message("unexpected.token"), codeBlock); } done(declaration, JavaElementType.CLASS_INITIALIZER); @@ -338,7 +338,7 @@ public class DeclarationParser { if (!expect(builder, JavaTokenType.IDENTIFIER)) { PsiBuilder.Marker primitive = builder.mark(); builder.advanceLexer(); - primitive.error(JavaErrorMessages.message("expected.identifier")); + primitive.error(JavaErrorBundle.message("expected.identifier")); } if (builder.getTokenType() == JavaTokenType.LPARENTH) { @@ -360,7 +360,7 @@ public class DeclarationParser { if (type == null) { PsiBuilder.Marker error = typeParams != null ? typeParams.precede() : builder.mark(); - error.error(JavaErrorMessages.message("expected.identifier.or.type")); + error.error(JavaErrorBundle.message("expected.identifier.or.type")); declaration.drop(); return modList; } @@ -370,9 +370,9 @@ public class DeclarationParser { Boolean.FALSE.equals(modListInfo.second) || (type.isPrimitive && builder.getTokenType() != JavaTokenType.DOT)) { if (typeParams != null) { - typeParams.precede().errorBefore(JavaErrorMessages.message("unexpected.token"), type.marker); + typeParams.precede().errorBefore(JavaErrorBundle.message("unexpected.token"), type.marker); } - builder.error(JavaErrorMessages.message("expected.identifier")); + builder.error(JavaErrorBundle.message("expected.identifier")); declaration.drop(); return modList; } @@ -392,7 +392,7 @@ public class DeclarationParser { } if (typeParams != null) { - typeParams.precede().errorBefore(JavaErrorMessages.message("unexpected.token"), type.marker); + typeParams.precede().errorBefore(JavaErrorBundle.message("unexpected.token"), type.marker); } return parseFieldOrLocalVariable(builder, declaration, declarationStart, context); } @@ -464,7 +464,7 @@ public class DeclarationParser { } if (!expect(builder, APPEND_TO_METHOD_SET)) break; } - error.error(JavaErrorMessages.message("expected.lbrace.or.semicolon")); + error.error(JavaErrorBundle.message("expected.lbrace.or.semicolon")); } if (!expect(builder, JavaTokenType.SEMICOLON)) { @@ -528,7 +528,7 @@ public class DeclarationParser { final boolean noLastElement = !delimiterExpected && (!noElements && !resources || noElements && resources); if (noLastElement) { final String key = lambda ? "expected.parameter" : "expected.identifier.or.type"; - error(builder, JavaErrorMessages.message(key)); + error(builder, JavaErrorBundle.message(key)); } if (tokenType == JavaTokenType.RPARENTH) { if (invalidElements != null) { @@ -544,7 +544,7 @@ public class DeclarationParser { } invalidElements = null; if (leftParenth) { - error(builder, JavaErrorMessages.message("expected.rparen")); + error(builder, JavaErrorBundle.message("expected.rparen")); } } } @@ -580,7 +580,7 @@ public class DeclarationParser { if (invalidElements == null) { if (builder.getTokenType() == delimiter) { - error(builder, JavaErrorMessages.message(noElementMsg)); + error(builder, JavaErrorBundle.message(noElementMsg)); builder.advanceLexer(); if (noElements && resources) { noElements = false; @@ -589,7 +589,7 @@ public class DeclarationParser { } else { invalidElements = builder.mark(); - errorMessage = JavaErrorMessages.message(delimiterExpected ? noDelimiterMsg : noElementMsg); + errorMessage = JavaErrorBundle.message(delimiterExpected ? noDelimiterMsg : noElementMsg); } } @@ -661,7 +661,7 @@ public class DeclarationParser { return null; } else { - error(builder, JavaErrorMessages.message("expected.type")); + error(builder, JavaErrorBundle.message("expected.type")); emptyElement(builder, JavaElementType.TYPE); } } @@ -691,14 +691,14 @@ public class DeclarationParser { } } else { - error(builder, JavaErrorMessages.message("expected.identifier")); + error(builder, JavaErrorBundle.message("expected.identifier")); param.drop(); return modListInfo.first; } if (expectOrError(builder, JavaTokenType.EQ, "expected.eq")) { if (myParser.getExpressionParser().parse(builder) == null) { - error(builder, JavaErrorMessages.message("expected.expression")); + error(builder, JavaErrorBundle.message("expected.expression")); } } @@ -739,7 +739,7 @@ public class DeclarationParser { shouldRollback = false; } else { - error(builder, JavaErrorMessages.message("expected.expression")); + error(builder, JavaErrorBundle.message("expected.expression")); unclosed = true; break; } @@ -750,7 +750,7 @@ public class DeclarationParser { builder.advanceLexer(); if (builder.getTokenType() != JavaTokenType.IDENTIFIER) { - error(builder, JavaErrorMessages.message("expected.identifier")); + error(builder, JavaErrorBundle.message("expected.identifier")); unclosed = true; eatSemicolon = false; openMarker = false; @@ -780,7 +780,7 @@ public class DeclarationParser { } if (!unclosed) { - error(builder, JavaErrorMessages.message("expected.semicolon")); + error(builder, JavaErrorBundle.message("expected.semicolon")); } } @@ -791,7 +791,7 @@ public class DeclarationParser { return declaration; } - private boolean eatBrackets(PsiBuilder builder, @Nullable @PropertyKey(resourceBundle = JavaErrorMessages.BUNDLE) String errorKey) { + private boolean eatBrackets(PsiBuilder builder, @Nullable @PropertyKey(resourceBundle = JavaErrorBundle.BUNDLE) String errorKey) { IElementType tokenType = builder.getTokenType(); if (tokenType != JavaTokenType.LBRACKET && tokenType != JavaTokenType.AT) return true; @@ -817,7 +817,7 @@ public class DeclarationParser { } if (errorKey != null) { - marker.error(JavaErrorMessages.message(errorKey)); + marker.error(JavaErrorBundle.message(errorKey)); } else { marker.drop(); @@ -825,7 +825,7 @@ public class DeclarationParser { boolean paired = count % 2 == 0; if (!paired) { - error(builder, JavaErrorMessages.message("expected.rbracket")); + error(builder, JavaErrorBundle.message("expected.rbracket")); } return paired; } @@ -853,7 +853,7 @@ public class DeclarationParser { classRef = myParser.getReferenceParser().parseJavaCodeReference(builder, true, false, false, false); } if (classRef == null) { - error(builder, JavaErrorMessages.message("expected.class.reference")); + error(builder, JavaErrorBundle.message("expected.class.reference")); } parseAnnotationParameterList(builder); @@ -882,7 +882,7 @@ public class DeclarationParser { while (true) { final IElementType tokenType = builder.getTokenType(); if (tokenType == null) { - error(builder, JavaErrorMessages.message("expected.parameter")); + error(builder, JavaErrorBundle.message("expected.parameter")); break; } else if (expect(builder, JavaTokenType.RPARENTH)) { @@ -894,7 +894,7 @@ public class DeclarationParser { builder.advanceLexer(); final boolean hasParamName = parseAnnotationParameter(builder, false); if (!isFirstParamNamed && hasParamName && !isFirstParamWarned) { - errorStart.errorBefore(JavaErrorMessages.message("annotation.name.is.missing"), errorEnd); + errorStart.errorBefore(JavaErrorBundle.message("annotation.name.is.missing"), errorEnd); isFirstParamWarned = true; } else { @@ -903,7 +903,7 @@ public class DeclarationParser { errorEnd.drop(); } else if (!afterBad) { - error(builder, JavaErrorMessages.message("expected.comma.or.rparen")); + error(builder, JavaErrorBundle.message("expected.comma.or.rparen")); builder.advanceLexer(); afterBad = true; } @@ -946,7 +946,7 @@ public class DeclarationParser { if (result == null) { result = builder.mark(); - result.error(JavaErrorMessages.message("expected.value")); + result.error(JavaErrorBundle.message("expected.value")); } } diff --git a/java/java-psi-impl/src/com/intellij/lang/java/parser/ExpressionParser.java b/java/java-psi-impl/src/com/intellij/lang/java/parser/ExpressionParser.java index 764da22c14d2..4975866c8ce7 100644 --- a/java/java-psi-impl/src/com/intellij/lang/java/parser/ExpressionParser.java +++ b/java/java-psi-impl/src/com/intellij/lang/java/parser/ExpressionParser.java @@ -1,7 +1,7 @@ // Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. package com.intellij.lang.java.parser; -import com.intellij.codeInsight.daemon.JavaErrorMessages; +import com.intellij.codeInsight.daemon.JavaErrorBundle; import com.intellij.lang.PsiBuilder; import com.intellij.lang.WhitespacesBinders; import com.intellij.openapi.util.Key; @@ -17,7 +17,7 @@ import org.jetbrains.annotations.PropertyKey; import java.util.function.Function; -import static com.intellij.codeInsight.daemon.JavaErrorMessages.BUNDLE; +import static com.intellij.codeInsight.daemon.JavaErrorBundle.BUNDLE; import static com.intellij.lang.PsiBuilderUtil.*; import static com.intellij.lang.java.parser.JavaParserUtil.*; @@ -90,7 +90,7 @@ public class ExpressionParser { final PsiBuilder.Marker right = parse(builder); if (right == null) { - error(builder, JavaErrorMessages.message("expected.expression")); + error(builder, JavaErrorBundle.message("expected.expression")); } assignment.done(JavaElementType.ASSIGNMENT_EXPRESSION); @@ -111,13 +111,13 @@ public class ExpressionParser { final PsiBuilder.Marker truePart = parse(builder); if (truePart == null) { - error(builder, JavaErrorMessages.message("expected.expression")); + error(builder, JavaErrorBundle.message("expected.expression")); ternary.done(JavaElementType.CONDITIONAL_EXPRESSION); return ternary; } if (builder.getTokenType() != JavaTokenType.COLON) { - error(builder, JavaErrorMessages.message("expected.colon")); + error(builder, JavaErrorBundle.message("expected.colon")); ternary.done(JavaElementType.CONDITIONAL_EXPRESSION); return ternary; } @@ -125,7 +125,7 @@ public class ExpressionParser { final PsiBuilder.Marker falsePart = parseConditional(builder); if (falsePart == null) { - error(builder, JavaErrorMessages.message("expected.expression")); + error(builder, JavaErrorBundle.message("expected.expression")); ternary.done(JavaElementType.CONDITIONAL_EXPRESSION); return ternary; } @@ -218,7 +218,7 @@ public class ExpressionParser { // save result = result.precede(); if (right == null) { - error(builder, JavaErrorMessages.message("expected.expression")); + error(builder, JavaErrorBundle.message("expected.expression")); } result.done(operandCount > 2 ? JavaElementType.POLYADIC_EXPRESSION : JavaElementType.BINARY_EXPRESSION); if (right == null) break; @@ -256,7 +256,7 @@ public class ExpressionParser { final PsiBuilder.Marker right = patternExpected ? parsePattern(builder) : parseExpression(builder, ExprType.SHIFT); if (right == null) { - error(builder, JavaErrorMessages.message(patternExpected ? "expected.type" : "expected.expression")); + error(builder, JavaErrorBundle.message(patternExpected ? "expected.type" : "expected.expression")); expression.done(toCreate); return expression; } @@ -278,7 +278,7 @@ public class ExpressionParser { final PsiBuilder.Marker operand = parseUnary(builder); if (operand == null) { - error(builder, JavaErrorMessages.message("expected.expression")); + error(builder, JavaErrorBundle.message("expected.expression")); } unary.done(JavaElementType.PREFIX_EXPRESSION); @@ -307,7 +307,7 @@ public class ExpressionParser { return parsePostfix(builder); } else { - error(builder, JavaErrorMessages.message("expected.expression")); + error(builder, JavaErrorBundle.message("expected.expression")); } } @@ -364,7 +364,7 @@ public class ExpressionParser { if (dotTokenType == JavaTokenType.CLASS_KEYWORD && exprType(expr) == JavaElementType.REFERENCE_EXPRESSION) { if (breakPoint == BreakPoint.P1 && builder.getCurrentOffset() == breakOffset) { - error(builder, JavaErrorMessages.message("expected.identifier")); + error(builder, JavaErrorBundle.message("expected.identifier")); drop(startMarker, dotPos); return expr; } @@ -431,7 +431,7 @@ public class ExpressionParser { dotPos.rollbackTo(); builder.advanceLexer(); myParser.getReferenceParser().parseReferenceParameterList(builder, false, false); - error(builder, JavaErrorMessages.message("expected.identifier")); + error(builder, JavaErrorBundle.message("expected.identifier")); refExpr.done(JavaElementType.REFERENCE_EXPRESSION); startMarker.drop(); return refExpr; @@ -480,14 +480,14 @@ public class ExpressionParser { final PsiBuilder.Marker index = parse(builder); if (index == null) { - error(builder, JavaErrorMessages.message("expected.expression")); + error(builder, JavaErrorBundle.message("expected.expression")); arrayAccess.done(JavaElementType.ARRAY_ACCESS_EXPRESSION); startMarker.drop(); return arrayAccess; } if (builder.getTokenType() != JavaTokenType.RBRACKET) { - error(builder, JavaErrorMessages.message("expected.rbracket")); + error(builder, JavaErrorBundle.message("expected.rbracket")); arrayAccess.done(JavaElementType.ARRAY_ACCESS_EXPRESSION); startMarker.drop(); return arrayAccess; @@ -540,12 +540,12 @@ public class ExpressionParser { final PsiBuilder.Marker inner = parse(builder); if (inner == null) { - error(builder, JavaErrorMessages.message("expected.expression")); + error(builder, JavaErrorBundle.message("expected.expression")); } if (!expect(builder, JavaTokenType.RPARENTH)) { if (inner != null) { - error(builder, JavaErrorMessages.message("expected.rparen")); + error(builder, JavaErrorBundle.message("expected.rparen")); } } @@ -659,7 +659,7 @@ public class ExpressionParser { } if (builder.getTokenType() == null) { - error(builder, JavaErrorMessages.message("expected.rbrace")); + error(builder, JavaErrorBundle.message("expected.rbrace")); break; } @@ -669,10 +669,10 @@ public class ExpressionParser { advance(builder, 2); break; } - builder.error(JavaErrorMessages.message(missingElementKey)); + builder.error(JavaErrorBundle.message(missingElementKey)); } else if (builder.getTokenType() != JavaTokenType.RBRACE) { - error(builder, JavaErrorMessages.message("expected.rbrace")); + error(builder, JavaErrorBundle.message("expected.rbrace")); break; } } @@ -681,7 +681,7 @@ public class ExpressionParser { IElementType tokenType = builder.getTokenType(); if (!expect(builder, JavaTokenType.COMMA) && tokenType != JavaTokenType.RBRACE) { - error(builder, JavaErrorMessages.message("expected.comma")); + error(builder, JavaErrorBundle.message("expected.comma")); } } @@ -703,7 +703,7 @@ public class ExpressionParser { rollbackTo(anno); refOrType = myParser.getReferenceParser().parseJavaCodeReference(builder, true, true, true, true); if (refOrType == null) { - error(builder, JavaErrorMessages.message("expected.identifier")); + error(builder, JavaErrorBundle.message("expected.identifier")); newExpr.done(JavaElementType.NEW_EXPRESSION); return newExpr; } @@ -713,7 +713,7 @@ public class ExpressionParser { builder.advanceLexer(); } else { - error(builder, JavaErrorMessages.message("expected.identifier")); + error(builder, JavaErrorBundle.message("expected.identifier")); newExpr.done(JavaElementType.NEW_EXPRESSION); return newExpr; } @@ -733,7 +733,7 @@ public class ExpressionParser { if (builder.getTokenType() != JavaTokenType.LBRACKET) { rollbackTo(anno); - error(builder, JavaErrorMessages.message(refOrType == null ? "expected.lbracket" : "expected.lparen.or.lbracket")); + error(builder, JavaErrorBundle.message(refOrType == null ? "expected.lbracket" : "expected.lparen.or.lbracket")); newExpr.done(JavaElementType.NEW_EXPRESSION); return newExpr; } @@ -768,7 +768,7 @@ public class ExpressionParser { parseArrayInitializer(builder); } else { - error(builder, JavaErrorMessages.message("expected.array.initializer")); + error(builder, JavaErrorBundle.message("expected.array.initializer")); } } @@ -830,7 +830,7 @@ public class ExpressionParser { myParser.getReferenceParser().parseReferenceParameterList(builder, false, false); if (!expect(builder, JavaTokenType.IDENTIFIER) && !expect(builder, JavaTokenType.NEW_KEYWORD)) { - error(builder, JavaErrorMessages.message("expected.identifier")); + error(builder, JavaErrorBundle.message("expected.identifier")); } start.done(JavaElementType.METHOD_REF_EXPRESSION); @@ -911,7 +911,7 @@ public class ExpressionParser { } if (body == null) { - builder.error(JavaErrorMessages.message("expected.lbrace")); + builder.error(JavaErrorBundle.message("expected.lbrace")); } start.done(JavaElementType.LAMBDA_EXPRESSION); @@ -936,7 +936,7 @@ public class ExpressionParser { } else { hasError = true; - error(builder, JavaErrorMessages.message("expected.comma.or.rparen")); + error(builder, JavaErrorBundle.message("expected.comma.or.rparen")); emptyExpression(builder); } } @@ -945,7 +945,7 @@ public class ExpressionParser { final PsiBuilder.Marker arg = parse(builder); if (arg == null) { if (!hasError) { - error(builder, JavaErrorMessages.message("expected.expression")); + error(builder, JavaErrorBundle.message("expected.expression")); emptyExpression(builder); } if (!ARGS_LIST_CONTINUE.contains(builder.getTokenType())) break; diff --git a/java/java-psi-impl/src/com/intellij/lang/java/parser/FileParser.java b/java/java-psi-impl/src/com/intellij/lang/java/parser/FileParser.java index ab0862fc8297..e328784318d1 100644 --- a/java/java-psi-impl/src/com/intellij/lang/java/parser/FileParser.java +++ b/java/java-psi-impl/src/com/intellij/lang/java/parser/FileParser.java @@ -2,7 +2,7 @@ package com.intellij.lang.java.parser; import com.intellij.AbstractBundle; -import com.intellij.codeInsight.daemon.JavaErrorMessages; +import com.intellij.codeInsight.daemon.JavaErrorBundle; import com.intellij.lang.PsiBuilder; import com.intellij.openapi.util.Pair; import com.intellij.psi.JavaTokenType; @@ -31,7 +31,7 @@ public class FileParser { } public void parse(@NotNull PsiBuilder builder) { - parseFile(builder, FileParser::stopImportListParsing, JavaErrorMessages.INSTANCE, "expected.class.or.interface"); + parseFile(builder, FileParser::stopImportListParsing, JavaErrorBundle.INSTANCE, "expected.class.or.interface"); } public void parseFile(@NotNull PsiBuilder builder, @@ -114,7 +114,7 @@ public class FileParser { PsiBuilder.Marker ref = myParser.getReferenceParser().parseJavaCodeReference(builder, true, false, false, false); if (ref == null) { - statement.error(JavaErrorMessages.message("expected.class.or.interface")); + statement.error(JavaErrorBundle.message("expected.class.or.interface")); return; } @@ -142,7 +142,7 @@ public class FileParser { if (statement != null) { isEmpty = false; if (invalidElements != null) { - invalidElements.errorBefore(JavaErrorMessages.message("unexpected.token"), statement); + invalidElements.errorBefore(JavaErrorBundle.message("unexpected.token"), statement); invalidElements = null; } continue; diff --git a/java/java-psi-impl/src/com/intellij/lang/java/parser/JShellParser.java b/java/java-psi-impl/src/com/intellij/lang/java/parser/JShellParser.java index 4f1b833b1692..a58483c7e561 100644 --- a/java/java-psi-impl/src/com/intellij/lang/java/parser/JShellParser.java +++ b/java/java-psi-impl/src/com/intellij/lang/java/parser/JShellParser.java @@ -15,7 +15,7 @@ */ package com.intellij.lang.java.parser; -import com.intellij.codeInsight.daemon.JavaErrorMessages; +import com.intellij.codeInsight.daemon.JavaErrorBundle; import com.intellij.lang.LighterASTNode; import com.intellij.lang.PsiBuilder; import com.intellij.openapi.util.Condition; @@ -115,7 +115,7 @@ public class JShellParser extends JavaParser { } if (!builder.eof()) { - builder.mark().error(JavaErrorMessages.message("unexpected.token")); + builder.mark().error(JavaErrorBundle.message("unexpected.token")); while (!builder.eof()) { builder.advanceLexer(); } diff --git a/java/java-psi-impl/src/com/intellij/lang/java/parser/JavaParserUtil.java b/java/java-psi-impl/src/com/intellij/lang/java/parser/JavaParserUtil.java index 2215c3a59f42..fcedf2bb9aa1 100644 --- a/java/java-psi-impl/src/com/intellij/lang/java/parser/JavaParserUtil.java +++ b/java/java-psi-impl/src/com/intellij/lang/java/parser/JavaParserUtil.java @@ -1,7 +1,7 @@ // Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. package com.intellij.lang.java.parser; -import com.intellij.codeInsight.daemon.JavaErrorMessages; +import com.intellij.codeInsight.daemon.JavaErrorBundle; import com.intellij.lang.*; import com.intellij.lang.impl.PsiBuilderAdapter; import com.intellij.lang.java.JavaLanguage; @@ -193,7 +193,7 @@ public class JavaParserUtil { if (!eatAll) throw new AssertionError("Unexpected token: '" + builder.getTokenText() + "'"); final PsiBuilder.Marker extras = builder.mark(); while (!builder.eof()) builder.advanceLexer(); - extras.error(JavaErrorMessages.message("unexpected.tokens")); + extras.error(JavaErrorBundle.message("unexpected.tokens")); } root.done(chameleon.getElementType()); @@ -226,17 +226,17 @@ public class JavaParserUtil { } } - public static boolean expectOrError(PsiBuilder builder, TokenSet expected, @PropertyKey(resourceBundle = JavaErrorMessages.BUNDLE) String key) { + public static boolean expectOrError(PsiBuilder builder, TokenSet expected, @PropertyKey(resourceBundle = JavaErrorBundle.BUNDLE) String key) { if (!PsiBuilderUtil.expect(builder, expected)) { - error(builder, JavaErrorMessages.message(key)); + error(builder, JavaErrorBundle.message(key)); return false; } return true; } - public static boolean expectOrError(PsiBuilder builder, IElementType expected, @PropertyKey(resourceBundle = JavaErrorMessages.BUNDLE) String key) { + public static boolean expectOrError(PsiBuilder builder, IElementType expected, @PropertyKey(resourceBundle = JavaErrorBundle.BUNDLE) String key) { if (!PsiBuilderUtil.expect(builder, expected)) { - error(builder, JavaErrorMessages.message(key)); + error(builder, JavaErrorBundle.message(key)); return false; } return true; diff --git a/java/java-psi-impl/src/com/intellij/lang/java/parser/ModuleParser.java b/java/java-psi-impl/src/com/intellij/lang/java/parser/ModuleParser.java index 48f7997c2168..8b7fed36b1ba 100644 --- a/java/java-psi-impl/src/com/intellij/lang/java/parser/ModuleParser.java +++ b/java/java-psi-impl/src/com/intellij/lang/java/parser/ModuleParser.java @@ -15,7 +15,7 @@ */ package com.intellij.lang.java.parser; -import com.intellij.codeInsight.daemon.JavaErrorMessages; +import com.intellij.codeInsight.daemon.JavaErrorBundle; import com.intellij.lang.PsiBuilder; import com.intellij.psi.JavaTokenType; import com.intellij.psi.PsiKeyword; @@ -67,27 +67,27 @@ public class ModuleParser { } else { module.drop(); - parseExtras(builder, JavaErrorMessages.message("expected.module.declaration")); + parseExtras(builder, JavaErrorBundle.message("expected.module.declaration")); return module; } if (parseName(builder) == null) { module.drop(); if (builder.getTokenType() != null) { - parseExtras(builder, JavaErrorMessages.message("expected.module.declaration")); + parseExtras(builder, JavaErrorBundle.message("expected.module.declaration")); } else { - error(builder, JavaErrorMessages.message("expected.identifier")); + error(builder, JavaErrorBundle.message("expected.identifier")); } return module; } if (!expect(builder, JavaTokenType.LBRACE)) { if (builder.getTokenType() != null) { - parseExtras(builder, JavaErrorMessages.message("expected.module.declaration")); + parseExtras(builder, JavaErrorBundle.message("expected.module.declaration")); } else { - error(builder, JavaErrorMessages.message("expected.lbrace")); + error(builder, JavaErrorBundle.message("expected.lbrace")); } } else { @@ -97,7 +97,7 @@ public class ModuleParser { JavaParserUtil.done(module, JavaElementType.MODULE); if (builder.getTokenType() != null) { - parseExtras(builder, JavaErrorMessages.message("unexpected.tokens")); + parseExtras(builder, JavaErrorBundle.message("unexpected.tokens")); } return module; @@ -111,11 +111,11 @@ public class ModuleParser { while (true) { IElementType t = builder.getTokenType(); if (t == JavaTokenType.IDENTIFIER) { - if (!idExpected) error(builder, JavaErrorMessages.message("expected.dot")); + if (!idExpected) error(builder, JavaErrorBundle.message("expected.dot")); idExpected = false; } else if (t == JavaTokenType.DOT) { - if (idExpected) error(builder, JavaErrorMessages.message("expected.identifier")); + if (idExpected) error(builder, JavaErrorBundle.message("expected.identifier")); idExpected = true; } else break; @@ -124,7 +124,7 @@ public class ModuleParser { } if (!empty) { - if (idExpected) error(builder, JavaErrorMessages.message("expected.identifier")); + if (idExpected) error(builder, JavaErrorBundle.message("expected.identifier")); nameElement.done(JavaElementType.MODULE_REFERENCE); return nameElement; } @@ -145,7 +145,7 @@ public class ModuleParser { if (token == JavaTokenType.SEMICOLON) { if (invalid != null) { - invalid.error(JavaErrorMessages.message("expected.module.statement")); + invalid.error(JavaErrorBundle.message("expected.module.statement")); invalid = null; } builder.advanceLexer(); @@ -158,17 +158,17 @@ public class ModuleParser { builder.advanceLexer(); } else if (invalid != null) { - invalid.errorBefore(JavaErrorMessages.message("expected.module.statement"), statement); + invalid.errorBefore(JavaErrorBundle.message("expected.module.statement"), statement); invalid = null; } } if (invalid != null) { - invalid.error(JavaErrorMessages.message("expected.module.statement")); + invalid.error(JavaErrorBundle.message("expected.module.statement")); } if (!expect(builder, JavaTokenType.RBRACE) && invalid == null) { - error(builder, JavaErrorMessages.message("expected.rbrace")); + error(builder, JavaErrorBundle.message("expected.rbrace")); } } @@ -238,7 +238,7 @@ public class ModuleParser { } } else { - error(builder, JavaErrorMessages.message("expected.package.reference")); + error(builder, JavaErrorBundle.message("expected.package.reference")); hasError = true; } @@ -261,7 +261,7 @@ public class ModuleParser { semicolon(builder); } else { - error(builder, JavaErrorMessages.message("expected.class.reference")); + error(builder, JavaErrorBundle.message("expected.class.reference")); expect(builder, JavaTokenType.SEMICOLON); } @@ -275,7 +275,7 @@ public class ModuleParser { mapAndAdvance(builder, JavaTokenType.PROVIDES_KEYWORD); if (parseClassOrPackageRef(builder) == null) { - error(builder, JavaErrorMessages.message("expected.class.reference")); + error(builder, JavaErrorBundle.message("expected.class.reference")); hasError = true; } @@ -288,10 +288,10 @@ public class ModuleParser { if (next == JavaTokenType.IDENTIFIER && !STATEMENT_KEYWORDS.contains(builder.getTokenText())) { PsiBuilder.Marker marker = builder.mark(); builder.advanceLexer(); - marker.error(JavaErrorMessages.message("expected.with")); + marker.error(JavaErrorBundle.message("expected.with")); } else { - error(builder, JavaErrorMessages.message("expected.with")); + error(builder, JavaErrorBundle.message("expected.with")); } hasError = true; } @@ -310,7 +310,7 @@ public class ModuleParser { private static PsiBuilder.Marker parseNameRef(PsiBuilder builder) { PsiBuilder.Marker name = parseName(builder); if (name == null) { - error(builder, JavaErrorMessages.message("expected.identifier")); + error(builder, JavaErrorBundle.message("expected.identifier")); } return name; } diff --git a/java/java-psi-impl/src/com/intellij/lang/java/parser/ReferenceParser.java b/java/java-psi-impl/src/com/intellij/lang/java/parser/ReferenceParser.java index 1cdff2efb091..474c6bde1a05 100644 --- a/java/java-psi-impl/src/com/intellij/lang/java/parser/ReferenceParser.java +++ b/java/java-psi-impl/src/com/intellij/lang/java/parser/ReferenceParser.java @@ -1,7 +1,7 @@ // Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. package com.intellij.lang.java.parser; -import com.intellij.codeInsight.daemon.JavaErrorMessages; +import com.intellij.codeInsight.daemon.JavaErrorBundle; import com.intellij.lang.PsiBuilder; import com.intellij.pom.java.LanguageLevel; import com.intellij.psi.JavaTokenType; @@ -66,7 +66,7 @@ public class ReferenceParser { builder.advanceLexer(); IElementType tokenType = builder.getTokenType(); if (tokenType != JavaTokenType.IDENTIFIER && tokenType != JavaTokenType.AT) { - error(builder, JavaErrorMessages.message("expected.identifier")); + error(builder, JavaErrorBundle.message("expected.identifier")); } parseTypeInfo(builder, flags, false); } @@ -126,7 +126,7 @@ public class ReferenceParser { emptyElement(builder, JavaElementType.DIAMOND_TYPE); } else { - error(builder, JavaErrorMessages.message("expected.identifier")); + error(builder, JavaErrorBundle.message("expected.identifier")); typeInfo.hasErrors = true; } type.done(JavaElementType.TYPE); @@ -136,7 +136,7 @@ public class ReferenceParser { else { type.drop(); if (anno != null && isSet(flags, INCOMPLETE_ANNO)) { - error(builder, JavaErrorMessages.message("expected.type")); + error(builder, JavaErrorBundle.message("expected.type")); typeInfo.marker = anno; typeInfo.hasErrors = true; return typeInfo; @@ -177,7 +177,7 @@ public class ReferenceParser { private void completeWildcardType(PsiBuilder builder, boolean wildcard, PsiBuilder.Marker type) { if (expect(builder, WILDCARD_KEYWORD_SET)) { if (parseTypeInfo(builder, EAT_LAST_DOT) == null) { - error(builder, JavaErrorMessages.message("expected.type")); + error(builder, JavaErrorBundle.message("expected.type")); } } @@ -185,7 +185,7 @@ public class ReferenceParser { type.done(JavaElementType.TYPE); } else { - type.error(JavaErrorMessages.message("wildcard.not.expected")); + type.error(JavaErrorBundle.message("wildcard.not.expected")); } } @@ -210,7 +210,7 @@ public class ReferenceParser { if (!expect(builder, JavaTokenType.IDENTIFIER)) { refElement.rollbackTo(); if (isImport) { - error(builder, JavaErrorMessages.message("expected.identifier")); + error(builder, JavaErrorBundle.message("expected.identifier")); } typeInfo.hasErrors = true; return null; @@ -247,10 +247,10 @@ public class ReferenceParser { typeInfo.hasErrors = true; if (isImport) { - error(builder, JavaErrorMessages.message("import.statement.identifier.or.asterisk.expected.")); + error(builder, JavaErrorBundle.message("import.statement.identifier.or.asterisk.expected.")); } else { - error(builder, JavaErrorMessages.message("expected.identifier")); + error(builder, JavaErrorBundle.message("expected.identifier")); } dotPos.drop(); return refElement; @@ -282,7 +282,7 @@ public class ReferenceParser { boolean isOk = true; while (true) { if (parseTypeInfo(builder, flags, true) == null) { - error(builder, JavaErrorMessages.message("expected.identifier")); + error(builder, JavaErrorBundle.message("expected.identifier")); } else { IElementType tokenType = builder.getTokenType(); @@ -316,7 +316,7 @@ public class ReferenceParser { do { PsiBuilder.Marker param = parseTypeParameter(builder); if (param == null) { - error(builder, JavaErrorMessages.message("expected.type.parameter")); + error(builder, JavaErrorBundle.message("expected.type.parameter")); } } while (expect(builder, JavaTokenType.COMMA)); @@ -327,15 +327,15 @@ public class ReferenceParser { if (builder.lookAhead(1) == JavaTokenType.GT) { PsiBuilder.Marker errorElement = builder.mark(); builder.advanceLexer(); - errorElement.error(JavaErrorMessages.message("unexpected.identifier")); + errorElement.error(JavaErrorBundle.message("unexpected.identifier")); builder.advanceLexer(); } else { - error(builder, JavaErrorMessages.message("expected.gt")); + error(builder, JavaErrorBundle.message("expected.gt")); } } else { - error(builder, JavaErrorMessages.message("expected.gt")); + error(builder, JavaErrorBundle.message("expected.gt")); } } @@ -365,7 +365,7 @@ public class ReferenceParser { param.done(JavaElementType.TYPE_PARAMETER); } else { - param.error(JavaErrorMessages.message("wildcard.not.expected")); + param.error(JavaErrorBundle.message("wildcard.not.expected")); } return param; } @@ -379,7 +379,7 @@ public class ReferenceParser { endsWithError = false; PsiBuilder.Marker classReference = parseJavaCodeReference(builder, false, true, false, false); if (classReference == null) { - error(builder, JavaErrorMessages.message("expected.identifier")); + error(builder, JavaErrorBundle.message("expected.identifier")); endsWithError = true; } } @@ -390,7 +390,7 @@ public class ReferenceParser { element.done(type); } else { - element.error(JavaErrorMessages.message("bound.not.expected")); + element.error(JavaErrorBundle.message("bound.not.expected")); } return endsWithError; } diff --git a/java/java-psi-impl/src/com/intellij/lang/java/parser/StatementParser.java b/java/java-psi-impl/src/com/intellij/lang/java/parser/StatementParser.java index 52a63e028f04..6c741f6e3401 100644 --- a/java/java-psi-impl/src/com/intellij/lang/java/parser/StatementParser.java +++ b/java/java-psi-impl/src/com/intellij/lang/java/parser/StatementParser.java @@ -1,7 +1,7 @@ // Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. package com.intellij.lang.java.parser; -import com.intellij.codeInsight.daemon.JavaErrorMessages; +import com.intellij.codeInsight.daemon.JavaErrorBundle; import com.intellij.lang.PsiBuilder; import com.intellij.lang.WhitespacesBinders; import com.intellij.pom.java.LanguageLevel; @@ -80,16 +80,16 @@ public class StatementParser { PsiBuilder.Marker error = builder.mark(); builder.advanceLexer(); if (tokenType == JavaTokenType.ELSE_KEYWORD) { - error.error(JavaErrorMessages.message("else.without.if")); + error.error(JavaErrorBundle.message("else.without.if")); } else if (tokenType == JavaTokenType.CATCH_KEYWORD) { - error.error(JavaErrorMessages.message("catch.without.try")); + error.error(JavaErrorBundle.message("catch.without.try")); } else if (tokenType == JavaTokenType.FINALLY_KEYWORD) { - error.error(JavaErrorMessages.message("finally.without.try")); + error.error(JavaErrorBundle.message("finally.without.try")); } else { - error.error(JavaErrorMessages.message("unexpected.token")); + error.error(JavaErrorBundle.message("unexpected.token")); } } } @@ -165,7 +165,7 @@ public class StatementParser { PsiBuilder.Marker decl = myParser.getDeclarationParser().parse(builder, DeclarationParser.Context.CODE_BLOCK); if (decl == null) { PsiBuilder.Marker marker = myParser.getReferenceParser().parseType(builder, 0); - error(builder, JavaErrorMessages.message("expected.identifier")); + error(builder, JavaErrorBundle.message("expected.identifier")); if (marker == null) builder.advanceLexer(); } done(declStatement, JavaElementType.DECLARATION_STATEMENT); @@ -251,12 +251,12 @@ public class StatementParser { if (parseExprInParenth(builder)) { PsiBuilder.Marker thenStatement = parseStatement(builder); if (thenStatement == null) { - error(builder, JavaErrorMessages.message("expected.statement")); + error(builder, JavaErrorBundle.message("expected.statement")); } else if (expect(builder, JavaTokenType.ELSE_KEYWORD)) { PsiBuilder.Marker elseStatement = parseStatement(builder); if (elseStatement == null) { - error(builder, JavaErrorMessages.message("expected.statement")); + error(builder, JavaErrorBundle.message("expected.statement")); } } } @@ -276,7 +276,7 @@ public class StatementParser { builder.advanceLexer(); if (!expect(builder, JavaTokenType.LPARENTH)) { - error(builder, JavaErrorMessages.message("expected.lparen")); + error(builder, JavaErrorBundle.message("expected.lparen")); done(statement, JavaElementType.FOR_STATEMENT); return statement; } @@ -296,7 +296,7 @@ public class StatementParser { @NotNull private PsiBuilder.Marker parseForLoopFromInitializer(PsiBuilder builder, PsiBuilder.Marker statement) { if (parseStatement(builder) == null) { - error(builder, JavaErrorMessages.message("expected.statement")); + error(builder, JavaErrorBundle.message("expected.statement")); if (!expect(builder, JavaTokenType.RPARENTH)) { done(statement, JavaElementType.FOR_STATEMENT); return statement; @@ -313,7 +313,7 @@ public class StatementParser { if (!expect(builder, JavaTokenType.SEMICOLON)) { if (!missingSemicolon) { - error(builder, JavaErrorMessages.message("expected.semicolon")); + error(builder, JavaErrorBundle.message("expected.semicolon")); } if (!expect(builder, JavaTokenType.RPARENTH)) { done(statement, JavaElementType.FOR_STATEMENT); @@ -323,7 +323,7 @@ public class StatementParser { else { parseForUpdateExpressions(builder); if (!expect(builder, JavaTokenType.RPARENTH)) { - error(builder, JavaErrorMessages.message("expected.rparen")); + error(builder, JavaErrorBundle.message("expected.rparen")); done(statement, JavaElementType.FOR_STATEMENT); return statement; } @@ -332,7 +332,7 @@ public class StatementParser { PsiBuilder.Marker bodyStatement = parseStatement(builder); if (bodyStatement == null) { - error(builder, JavaErrorMessages.message("expected.statement")); + error(builder, JavaErrorBundle.message("expected.statement")); } done(statement, JavaElementType.FOR_STATEMENT); @@ -363,7 +363,7 @@ public class StatementParser { builder.advanceLexer(); PsiBuilder.Marker nextExpression = myParser.getExpressionParser().parse(builder); if (nextExpression == null) { - error(builder, JavaErrorMessages.message("expected.expression")); + error(builder, JavaErrorBundle.message("expected.expression")); } } while (builder.getTokenType() == JavaTokenType.COMMA); @@ -380,11 +380,11 @@ public class StatementParser { builder.advanceLexer(); if (myParser.getExpressionParser().parse(builder) == null) { - error(builder, JavaErrorMessages.message("expected.expression")); + error(builder, JavaErrorBundle.message("expected.expression")); } if (expectOrError(builder, JavaTokenType.RPARENTH, "expected.rparen") && parseStatement(builder) == null) { - error(builder, JavaErrorMessages.message("expected.statement")); + error(builder, JavaErrorBundle.message("expected.statement")); } done(statement, JavaElementType.FOREACH_STATEMENT); @@ -398,10 +398,10 @@ public class StatementParser { PsiBuilder.Marker body = parseStatement(builder); if (body == null) { - error(builder, JavaErrorMessages.message("expected.statement")); + error(builder, JavaErrorBundle.message("expected.statement")); } else if (!expect(builder, JavaTokenType.WHILE_KEYWORD)) { - error(builder, JavaErrorMessages.message("expected.while")); + error(builder, JavaErrorBundle.message("expected.while")); } else if (parseExprInParenth(builder)) { semicolon(builder); @@ -426,7 +426,7 @@ public class StatementParser { do { PsiBuilder.Marker nextExpression = myParser.getExpressionParser().parseCaseLabel(builder); if (nextExpression == null) { - error(builder, JavaErrorMessages.message("expected.expression")); + error(builder, JavaErrorBundle.message("expected.expression")); } } while (expect(builder, JavaTokenType.COMMA)); @@ -442,7 +442,7 @@ public class StatementParser { if (builder.getTokenType() == JavaTokenType.SEMICOLON) { PsiBuilder.Marker mark = builder.mark(); while (builder.getTokenType() == JavaTokenType.SEMICOLON) builder.advanceLexer(); - mark.error(JavaErrorMessages.message("expected.switch.label")); + mark.error(JavaErrorBundle.message("expected.switch.label")); } } else if (builder.getTokenType() == JavaTokenType.THROW_KEYWORD) { @@ -454,7 +454,7 @@ public class StatementParser { body.done(JavaElementType.EXPRESSION_STATEMENT); } else { - error(builder, JavaErrorMessages.message("expected.switch.rule")); + error(builder, JavaErrorBundle.message("expected.switch.rule")); expect(builder, JavaTokenType.SEMICOLON); } done(statement, JavaElementType.SWITCH_LABELED_RULE); @@ -484,7 +484,7 @@ public class StatementParser { builder.advanceLexer(); if (myParser.getExpressionParser().parse(builder) == null) { - error(builder, JavaErrorMessages.message("expected.expression")); + error(builder, JavaErrorBundle.message("expected.expression")); } else { semicolon(builder); @@ -520,7 +520,7 @@ public class StatementParser { builder.advanceLexer(); if (myParser.getExpressionParser().parse(builder) == null) { - error(builder, JavaErrorMessages.message("expected.expression")); + error(builder, JavaErrorBundle.message("expected.expression")); } else { semicolon(builder); @@ -547,10 +547,10 @@ public class StatementParser { PsiBuilder.Marker tryBlock = parseCodeBlock(builder, true); if (tryBlock == null) { - error(builder, JavaErrorMessages.message("expected.lbrace")); + error(builder, JavaErrorBundle.message("expected.lbrace")); } else if (!hasResourceList && !TRY_CLOSERS_SET.contains(builder.getTokenType())) { - error(builder, JavaErrorMessages.message("expected.catch.or.finally")); + error(builder, JavaErrorBundle.message("expected.catch.or.finally")); } else { while (builder.getTokenType() == JavaTokenType.CATCH_KEYWORD) { @@ -560,7 +560,7 @@ public class StatementParser { if (expect(builder, JavaTokenType.FINALLY_KEYWORD)) { PsiBuilder.Marker finallyBlock = parseCodeBlock(builder, true); if (finallyBlock == null) { - error(builder, JavaErrorMessages.message("expected.lbrace")); + error(builder, JavaErrorBundle.message("expected.lbrace")); } } } @@ -575,25 +575,25 @@ public class StatementParser { builder.advanceLexer(); if (!expect(builder, JavaTokenType.LPARENTH)) { - error(builder, JavaErrorMessages.message("expected.lparen")); + error(builder, JavaErrorBundle.message("expected.lparen")); done(section, JavaElementType.CATCH_SECTION); return false; } PsiBuilder.Marker param = myParser.getDeclarationParser().parseParameter(builder, false, true, false); if (param == null) { - error(builder, JavaErrorMessages.message("expected.parameter")); + error(builder, JavaErrorBundle.message("expected.parameter")); } if (!expect(builder, JavaTokenType.RPARENTH)) { - error(builder, JavaErrorMessages.message("expected.rparen")); + error(builder, JavaErrorBundle.message("expected.rparen")); done(section, JavaElementType.CATCH_SECTION); return false; } PsiBuilder.Marker body = parseCodeBlock(builder, true); if (body == null) { - error(builder, JavaErrorMessages.message("expected.lbrace")); + error(builder, JavaErrorBundle.message("expected.lbrace")); done(section, JavaElementType.CATCH_SECTION); return false; } @@ -608,10 +608,10 @@ public class StatementParser { builder.advanceLexer(); if (myParser.getExpressionParser().parse(builder) == null) { - error(builder, JavaErrorMessages.message("expected.boolean.expression")); + error(builder, JavaErrorBundle.message("expected.boolean.expression")); } else if (expect(builder, JavaTokenType.COLON) && myParser.getExpressionParser().parse(builder) == null) { - error(builder, JavaErrorMessages.message("expected.expression")); + error(builder, JavaErrorBundle.message("expected.expression")); } else { semicolon(builder); @@ -637,7 +637,7 @@ public class StatementParser { if (parseExprInParenth(builder)) { PsiBuilder.Marker body = block ? parseCodeBlock(builder, true) : parseStatement(builder); if (body == null) { - error(builder, JavaErrorMessages.message(block ? "expected.lbrace" : "expected.statement")); + error(builder, JavaErrorBundle.message(block ? "expected.lbrace" : "expected.statement")); } } @@ -647,7 +647,7 @@ public class StatementParser { private boolean parseExprInParenth(PsiBuilder builder) { if (!expect(builder, JavaTokenType.LPARENTH)) { - error(builder, JavaErrorMessages.message("expected.lparen")); + error(builder, JavaErrorBundle.message("expected.lparen")); return false; } @@ -655,7 +655,7 @@ public class StatementParser { PsiBuilder.Marker expr = myParser.getExpressionParser().parse(builder); if (expr == null || builder.getTokenType() == JavaTokenType.SEMICOLON) { beforeExpr.rollbackTo(); - error(builder, JavaErrorMessages.message("expected.expression")); + error(builder, JavaErrorBundle.message("expected.expression")); if (builder.getTokenType() != JavaTokenType.RPARENTH) { return false; } @@ -663,7 +663,7 @@ public class StatementParser { else { beforeExpr.drop(); if (builder.getTokenType() != JavaTokenType.RPARENTH) { - error(builder, JavaErrorMessages.message("expected.rparen")); + error(builder, JavaErrorBundle.message("expected.rparen")); return false; } } diff --git a/java/java-psi-impl/src/com/intellij/psi/controlFlow/ControlFlowAnalyzer.java b/java/java-psi-impl/src/com/intellij/psi/controlFlow/ControlFlowAnalyzer.java index ae93b0428e04..306c63111a22 100644 --- a/java/java-psi-impl/src/com/intellij/psi/controlFlow/ControlFlowAnalyzer.java +++ b/java/java-psi-impl/src/com/intellij/psi/controlFlow/ControlFlowAnalyzer.java @@ -2,7 +2,7 @@ package com.intellij.psi.controlFlow; import com.intellij.codeInsight.ExceptionUtil; -import com.intellij.codeInsight.daemon.JavaErrorMessages; +import com.intellij.codeInsight.daemon.JavaErrorBundle; import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.progress.ProgressManager; import com.intellij.openapi.project.Project; @@ -200,7 +200,7 @@ class ControlFlowAnalyzer extends JavaElementVisitor { for (PsiElement child = element.getFirstChild(); child != null; child = child.getNextSibling()) { ProgressManager.checkCanceled(); if (child instanceof PsiErrorElement && - !Comparing.strEqual(((PsiErrorElement)child).getErrorDescription(), JavaErrorMessages.message("expected.semicolon"))) { + !Comparing.strEqual(((PsiErrorElement)child).getErrorDescription(), JavaErrorBundle.message("expected.semicolon"))) { // do not perform control flow analysis for incomplete code throw new AnalysisCanceledSoftException(element); } diff --git a/java/java-psi-impl/src/com/intellij/psi/impl/source/PsiImportStaticReferenceElementImpl.java b/java/java-psi-impl/src/com/intellij/psi/impl/source/PsiImportStaticReferenceElementImpl.java index a77119bb8a36..57d264e96872 100644 --- a/java/java-psi-impl/src/com/intellij/psi/impl/source/PsiImportStaticReferenceElementImpl.java +++ b/java/java-psi-impl/src/com/intellij/psi/impl/source/PsiImportStaticReferenceElementImpl.java @@ -15,7 +15,7 @@ */ package com.intellij.psi.impl.source; -import com.intellij.codeInsight.daemon.JavaErrorMessages; +import com.intellij.codeInsight.daemon.JavaErrorBundle; import com.intellij.lang.ASTNode; import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.util.TextRange; @@ -138,7 +138,8 @@ public class PsiImportStaticReferenceElementImpl extends CompositePsiElement imp else { final LeafElement dot = Factory.createSingleLeafElement(JavaTokenType.DOT, ".", 0, 1, SharedImplUtil.findCharTableByTree(newRef), getManager()); newRef.rawInsertAfterMe(dot); - final CompositeElement errorElement = Factory.createErrorElement(JavaErrorMessages.message("import.statement.identifier.or.asterisk.expected.")); + final CompositeElement errorElement = Factory.createErrorElement( + JavaErrorBundle.message("import.statement.identifier.or.asterisk.expected.")); dot.rawInsertAfterMe(errorElement); final CompositeElement parentComposite = (CompositeElement)SourceTreeToPsiMap.psiElementToTree(getParent()); parentComposite.addInternal(newRef, errorElement, this, Boolean.TRUE); diff --git a/java/java-psi-impl/src/com/intellij/psi/impl/source/javadoc/ClassReferenceTagInfo.java b/java/java-psi-impl/src/com/intellij/psi/impl/source/javadoc/ClassReferenceTagInfo.java index a41d2967db37..a6629e663566 100644 --- a/java/java-psi-impl/src/com/intellij/psi/impl/source/javadoc/ClassReferenceTagInfo.java +++ b/java/java-psi-impl/src/com/intellij/psi/impl/source/javadoc/ClassReferenceTagInfo.java @@ -1,7 +1,7 @@ // Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. package com.intellij.psi.impl.source.javadoc; -import com.intellij.codeInsight.daemon.JavaErrorMessages; +import com.intellij.codeInsight.daemon.JavaErrorBundle; import com.intellij.psi.PsiElement; import com.intellij.psi.PsiJavaCodeReferenceElement; import com.intellij.psi.PsiReference; @@ -29,12 +29,12 @@ abstract class ClassReferenceTagInfo implements JavadocTagInfo { public String checkTagValue(PsiDocTagValue value) { PsiElement refHolder = value != null ? value.getFirstChild() : null; if (refHolder == null) { - return JavaErrorMessages.message("javadoc.ref.tag.class.ref.expected"); + return JavaErrorBundle.message("javadoc.ref.tag.class.ref.expected"); } PsiElement refElement = refHolder.getFirstChild(); if (!(refElement instanceof PsiJavaCodeReferenceElement)) { - return JavaErrorMessages.message("javadoc.exception.tag.wrong.tag.value"); + return JavaErrorBundle.message("javadoc.exception.tag.wrong.tag.value"); } return null; diff --git a/java/java-psi-impl/src/com/intellij/psi/impl/source/javadoc/ExceptionTagInfo.java b/java/java-psi-impl/src/com/intellij/psi/impl/source/javadoc/ExceptionTagInfo.java index ffcb465f68af..ad2726bfc145 100644 --- a/java/java-psi-impl/src/com/intellij/psi/impl/source/javadoc/ExceptionTagInfo.java +++ b/java/java-psi-impl/src/com/intellij/psi/impl/source/javadoc/ExceptionTagInfo.java @@ -1,7 +1,7 @@ // Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. package com.intellij.psi.impl.source.javadoc; -import com.intellij.codeInsight.daemon.JavaErrorMessages; +import com.intellij.codeInsight.daemon.JavaErrorBundle; import com.intellij.psi.*; import com.intellij.psi.javadoc.PsiDocTagValue; import com.intellij.psi.util.PsiTreeUtil; @@ -31,7 +31,7 @@ class ExceptionTagInfo extends ClassReferenceTagInfo { PsiClass throwable = JavaPsiFacade.getInstance(value.getProject()).findClass(CommonClassNames.JAVA_LANG_THROWABLE, value.getResolveScope()); if (throwable != null && !exceptionClass.equals(throwable) && !exceptionClass.isInheritor(throwable, true)) { - return JavaErrorMessages.message("javadoc.exception.tag.class.is.not.throwable", exceptionClass.getQualifiedName()); + return JavaErrorBundle.message("javadoc.exception.tag.class.is.not.throwable", exceptionClass.getQualifiedName()); } PsiClass runtimeException = JavaPsiFacade.getInstance(value.getProject()).findClass(CommonClassNames.JAVA_LANG_RUNTIME_EXCEPTION, value.getResolveScope()); @@ -54,6 +54,6 @@ class ExceptionTagInfo extends ClassReferenceTagInfo { } } - return JavaErrorMessages.message("javadoc.exception.tag.exception.is.not.thrown", exceptionClass.getName(), method.getName()); + return JavaErrorBundle.message("javadoc.exception.tag.exception.is.not.thrown", exceptionClass.getName(), method.getName()); } } \ No newline at end of file diff --git a/java/java-psi-impl/src/com/intellij/psi/impl/source/javadoc/ParamDocTagInfo.java b/java/java-psi-impl/src/com/intellij/psi/impl/source/javadoc/ParamDocTagInfo.java index af91d31fb6f3..33e3a5cbc7ad 100644 --- a/java/java-psi-impl/src/com/intellij/psi/impl/source/javadoc/ParamDocTagInfo.java +++ b/java/java-psi-impl/src/com/intellij/psi/impl/source/javadoc/ParamDocTagInfo.java @@ -15,7 +15,7 @@ */ package com.intellij.psi.impl.source.javadoc; -import com.intellij.codeInsight.daemon.JavaErrorMessages; +import com.intellij.codeInsight.daemon.JavaErrorBundle; import com.intellij.lang.ASTNode; import com.intellij.psi.*; import com.intellij.psi.javadoc.JavadocTagInfo; @@ -44,16 +44,16 @@ class ParamDocTagInfo implements JavadocTagInfo { @Override public String checkTagValue(PsiDocTagValue value) { - if (value == null) return JavaErrorMessages.message("javadoc.param.tag.parameter.name.expected"); + if (value == null) return JavaErrorBundle.message("javadoc.param.tag.parameter.name.expected"); final ASTNode firstChildNode = value.getNode().getFirstChildNode(); if (firstChildNode != null && firstChildNode.getElementType().equals(JavaDocTokenType.DOC_TAG_VALUE_LT)) { if (value.getNode().findChildByType(JavaDocTokenType.DOC_TAG_VALUE_TOKEN) == null) { - return JavaErrorMessages.message("javadoc.param.tag.type.parameter.name.expected"); + return JavaErrorBundle.message("javadoc.param.tag.type.parameter.name.expected"); } if (value.getNode().findChildByType(JavaDocTokenType.DOC_TAG_VALUE_GT) == null) { - return JavaErrorMessages.message("javadoc.param.tag.type.parameter.gt.expected"); + return JavaErrorBundle.message("javadoc.param.tag.type.parameter.gt.expected"); } } return null; diff --git a/java/java-psi-impl/src/com/intellij/psi/impl/source/javadoc/ValueDocTagInfo.java b/java/java-psi-impl/src/com/intellij/psi/impl/source/javadoc/ValueDocTagInfo.java index dcfca2b52970..b950d60b127d 100644 --- a/java/java-psi-impl/src/com/intellij/psi/impl/source/javadoc/ValueDocTagInfo.java +++ b/java/java-psi-impl/src/com/intellij/psi/impl/source/javadoc/ValueDocTagInfo.java @@ -15,7 +15,7 @@ */ package com.intellij.psi.impl.source.javadoc; -import com.intellij.codeInsight.daemon.JavaErrorMessages; +import com.intellij.codeInsight.daemon.JavaErrorBundle; import com.intellij.psi.PsiElement; import com.intellij.psi.PsiField; import com.intellij.psi.PsiModifier; @@ -49,7 +49,7 @@ public class ValueDocTagInfo implements JavadocTagInfo { boolean hasReference = (value != null && value.getFirstChild() != null); if (hasReference) { if (!PsiUtil.isLanguageLevel5OrHigher(value)) { - return JavaErrorMessages.message("javadoc.value.tag.jdk15.required"); + return JavaErrorBundle.message("javadoc.value.tag.jdk15.required"); } } @@ -59,15 +59,15 @@ public class ValueDocTagInfo implements JavadocTagInfo { PsiElement target = reference.resolve(); if (target != null) { if (!(target instanceof PsiField)) { - return JavaErrorMessages.message("javadoc.value.field.required"); + return JavaErrorBundle.message("javadoc.value.field.required"); } PsiField field = (PsiField) target; if (!field.hasModifierProperty(PsiModifier.STATIC)) { - return JavaErrorMessages.message("javadoc.value.static.field.required"); + return JavaErrorBundle.message("javadoc.value.static.field.required"); } if (field.getInitializer() == null || JavaConstantExpressionEvaluator.computeConstantExpression(field.getInitializer(), false) == null) { - return JavaErrorMessages.message("javadoc.value.field.with.initializer.required"); + return JavaErrorBundle.message("javadoc.value.field.with.initializer.required"); } } } diff --git a/java/java-psi-impl/src/messages/JavaErrorMessages.properties b/java/java-psi-impl/src/messages/JavaErrorBundle.properties similarity index 100% rename from java/java-psi-impl/src/messages/JavaErrorMessages.properties rename to java/java-psi-impl/src/messages/JavaErrorBundle.properties diff --git a/java/manifest/src/org/jetbrains/lang/manifest/header/impl/ClassReferenceParser.java b/java/manifest/src/org/jetbrains/lang/manifest/header/impl/ClassReferenceParser.java index 509b5f8c8ea6..32e478141fdf 100644 --- a/java/manifest/src/org/jetbrains/lang/manifest/header/impl/ClassReferenceParser.java +++ b/java/manifest/src/org/jetbrains/lang/manifest/header/impl/ClassReferenceParser.java @@ -15,7 +15,7 @@ */ package org.jetbrains.lang.manifest.header.impl; -import com.intellij.codeInsight.daemon.JavaErrorMessages; +import com.intellij.codeInsight.daemon.JavaErrorBundle; import com.intellij.codeInspection.ProblemHighlightType; import com.intellij.lang.annotation.Annotation; import com.intellij.lang.annotation.AnnotationHolder; @@ -79,7 +79,7 @@ public class ClassReferenceParser extends StandardHeaderParser { GlobalSearchScope scope = module != null ? module.getModuleWithDependenciesAndLibrariesScope(false) : ProjectScope.getAllScope(project); PsiClass aClass = JavaPsiFacade.getInstance(project).findClass(className, scope); if (aClass == null) { - String message = JavaErrorMessages.message("error.cannot.resolve.class", className); + String message = JavaErrorBundle.message("error.cannot.resolve.class", className); Annotation anno = holder.createErrorAnnotation(valuePart.getHighlightingRange(), message); anno.setHighlightType(ProblemHighlightType.LIKE_UNKNOWN_SYMBOL); return true; diff --git a/java/typeMigration/src/com/intellij/refactoring/typeMigration/intentions/ChangeClassParametersIntention.java b/java/typeMigration/src/com/intellij/refactoring/typeMigration/intentions/ChangeClassParametersIntention.java index 1a31403baa6a..fa37cc28bbae 100644 --- a/java/typeMigration/src/com/intellij/refactoring/typeMigration/intentions/ChangeClassParametersIntention.java +++ b/java/typeMigration/src/com/intellij/refactoring/typeMigration/intentions/ChangeClassParametersIntention.java @@ -3,7 +3,7 @@ // found in the LICENSE file. package com.intellij.refactoring.typeMigration.intentions; -import com.intellij.codeInsight.daemon.JavaErrorMessages; +import com.intellij.codeInsight.daemon.JavaErrorBundle; import com.intellij.codeInsight.hint.HintManager; import com.intellij.codeInsight.intention.PsiElementBaseIntentionAction; import com.intellij.codeInsight.intention.impl.TypeExpression; @@ -108,14 +108,14 @@ public class ChangeClassParametersIntention extends PsiElementBaseIntentionActio final PsiType targetParam = elementFactory.createTypeFromText(myNewType, aClass); if (!(targetParam instanceof PsiClassType)) { HintManager.getInstance().showErrorHint(editor, - JavaErrorMessages.message("generics.type.argument.cannot.be.of.primitive.type")); + JavaErrorBundle.message("generics.type.argument.cannot.be.of.primitive.type")); return; } final PsiClassType classType = (PsiClassType)targetParam; final PsiClass target = classType.resolve(); if (target == null) { - HintManager.getInstance().showErrorHint(editor, JavaErrorMessages.message("cannot.resolve.symbol", - classType.getPresentableText())); + HintManager.getInstance().showErrorHint(editor, JavaErrorBundle.message("cannot.resolve.symbol", + classType.getPresentableText())); return; } final TypeMigrationRules myRules = new TypeMigrationRules(project); diff --git a/plugins/InspectionGadgets/src/com/siyeh/ig/jdk/ForwardCompatibilityInspection.java b/plugins/InspectionGadgets/src/com/siyeh/ig/jdk/ForwardCompatibilityInspection.java index 1cee410aadcc..784885a0470c 100644 --- a/plugins/InspectionGadgets/src/com/siyeh/ig/jdk/ForwardCompatibilityInspection.java +++ b/plugins/InspectionGadgets/src/com/siyeh/ig/jdk/ForwardCompatibilityInspection.java @@ -1,7 +1,7 @@ // Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. package com.siyeh.ig.jdk; -import com.intellij.codeInsight.daemon.JavaErrorMessages; +import com.intellij.codeInsight.daemon.JavaErrorBundle; import com.intellij.codeInsight.intention.QuickFixFactory; import com.intellij.codeInspection.AbstractBaseJavaLocalInspectionTool; import com.intellij.codeInspection.LocalQuickFix; @@ -40,28 +40,28 @@ public class ForwardCompatibilityInspection extends AbstractBaseJavaLocalInspect case PsiKeyword.ASSERT: if (languageLevel.isLessThan(LanguageLevel.JDK_1_4) && (parent instanceof PsiClass || parent instanceof PsiMethod || parent instanceof PsiVariable)) { - return JavaErrorMessages.message("assert.identifier.warn"); + return JavaErrorBundle.message("assert.identifier.warn"); } break; case PsiKeyword.ENUM: if (languageLevel.isLessThan(LanguageLevel.JDK_1_5) && (parent instanceof PsiClass || parent instanceof PsiMethod || parent instanceof PsiVariable)) { - return JavaErrorMessages.message("enum.identifier.warn"); + return JavaErrorBundle.message("enum.identifier.warn"); } break; case "_": if (languageLevel.isLessThan(LanguageLevel.JDK_1_9)) { - return JavaErrorMessages.message("underscore.identifier.warn"); + return JavaErrorBundle.message("underscore.identifier.warn"); } break; case PsiKeyword.VAR: if (languageLevel.isLessThan(LanguageLevel.JDK_10) && parent instanceof PsiClass) { - return JavaErrorMessages.message("var.identifier.warn"); + return JavaErrorBundle.message("var.identifier.warn"); } break; case PsiKeyword.YIELD: if (languageLevel.isLessThan(LanguageLevel.JDK_X) && parent instanceof PsiClass) { - return JavaErrorMessages.message("yield.identifier.warn"); + return JavaErrorBundle.message("yield.identifier.warn"); } break; } @@ -75,7 +75,7 @@ public class ForwardCompatibilityInspection extends AbstractBaseJavaLocalInspect if (nameElement != null && PsiKeyword.YIELD.equals(nameElement.getText()) && ref.getQualifierExpression() == null && languageLevel.isLessThan(LanguageLevel.JDK_X)) { PsiExpression qualifier = ExpressionUtils.getEffectiveQualifier(expression.getMethodExpression()); - holder.registerProblem(nameElement, JavaErrorMessages.message("yield.unqualified.method.warn"), + holder.registerProblem(nameElement, JavaErrorBundle.message("yield.unqualified.method.warn"), qualifier == null ? null : new QualifyCallFix(), new RenameFix()); } } @@ -90,7 +90,7 @@ public class ForwardCompatibilityInspection extends AbstractBaseJavaLocalInspect if (parent instanceof PsiModifierList) { PsiElement grand = parent.getParent(); if (grand instanceof PsiRequiresStatement && PsiJavaModule.JAVA_BASE.equals(((PsiRequiresStatement)grand).getModuleName())) { - String message = JavaErrorMessages.message("module.unwanted.modifier.warn"); + String message = JavaErrorBundle.message("module.unwanted.modifier.warn"); LocalQuickFix fix = QuickFixFactory.getInstance().createModifierListFix((PsiModifierList)parent, modifier, false, false); holder.registerProblem(keyword, message, fix); } 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 ce119554566a..0866085c718a 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 @@ -1,7 +1,7 @@ // Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. package org.jetbrains.plugins.groovy.annotator.checkers; -import com.intellij.codeInsight.daemon.JavaErrorMessages; +import com.intellij.codeInsight.daemon.JavaErrorBundle; import com.intellij.lang.annotation.AnnotationHolder; import com.intellij.openapi.extensions.ExtensionPointName; import com.intellij.openapi.util.Pair; @@ -43,9 +43,9 @@ public abstract class CustomAnnotationChecker { PsiElement ownerToUse = owner instanceof PsiModifierList ? ((PsiElement)owner).getParent() : (PsiElement)owner; PsiAnnotation.TargetType[] elementTypeFields = GrAnnotationImpl.getApplicableElementTypeFields(ownerToUse); if (elementTypeFields.length != 0 && !GrAnnotationImpl.isAnnotationApplicableTo(annotation, elementTypeFields)) { - String annotationTargetText = JavaErrorMessages.message("annotation.target." + elementTypeFields[0]); + String annotationTargetText = JavaErrorBundle.message("annotation.target." + elementTypeFields[0]); GrCodeReferenceElement ref = annotation.getClassReference(); - return JavaErrorMessages.message("annotation.not.applicable", ref.getText(), annotationTargetText); + return JavaErrorBundle.message("annotation.not.applicable", ref.getText(), annotationTargetText); } return null; diff --git a/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/annotator/checkers/FieldAnnotationChecker.java b/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/annotator/checkers/FieldAnnotationChecker.java index 34591bdbf952..dde1ae1aaf53 100644 --- a/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/annotator/checkers/FieldAnnotationChecker.java +++ b/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/annotator/checkers/FieldAnnotationChecker.java @@ -15,7 +15,7 @@ */ package org.jetbrains.plugins.groovy.annotator.checkers; -import com.intellij.codeInsight.daemon.JavaErrorMessages; +import com.intellij.codeInsight.daemon.JavaErrorBundle; import com.intellij.lang.annotation.AnnotationHolder; import com.intellij.psi.PsiAnnotation; import com.intellij.psi.PsiAnnotationOwner; @@ -59,8 +59,8 @@ public class FieldAnnotationChecker extends CustomAnnotationChecker { if (!GrAnnotationImpl.isAnnotationApplicableTo(annotation, PsiAnnotation.TargetType.LOCAL_VARIABLE)) { GrCodeReferenceElement ref = annotation.getClassReference(); - String target = JavaErrorMessages.message("annotation.target.LOCAL_VARIABLE"); - String description = JavaErrorMessages.message("annotation.not.applicable", ref.getText(), target); + String target = JavaErrorBundle.message("annotation.target.LOCAL_VARIABLE"); + String description = JavaErrorBundle.message("annotation.not.applicable", ref.getText(), target); holder.createErrorAnnotation(ref, description); }