[java-i18n] fixes

GitOrigin-RevId: 6c6aa131594515157bad57a25703e147cd529f88
This commit is contained in:
Ilyas Selimov
2020-08-06 06:17:39 +00:00
committed by intellij-monorepo-bot
parent 29d0109376
commit 39c3b20e3d
10 changed files with 48 additions and 23 deletions
@@ -455,3 +455,5 @@ special.field.string.length=String length
special.field.collection.size=Size
special.field.unboxed.value=Unboxed value
special.field.optional.value=Optional value
text.unused.import.in.template=Unused import (specified in template)
text.raw.ctor.reference.with.type.parameters=Raw constructor reference with explicit type parameters for constructor
@@ -7,6 +7,7 @@ import com.intellij.codeInsight.daemon.impl.HighlightInfoType;
import com.intellij.codeInsight.daemon.impl.quickfix.QuickFixAction;
import com.intellij.codeInsight.daemon.impl.quickfix.QuickFixActionRegistrarImpl;
import com.intellij.codeInsight.intention.QuickFixFactory;
import com.intellij.codeInspection.CommonQuickFixBundle;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.project.DumbService;
import com.intellij.openapi.project.IndexNotReadyException;
@@ -482,13 +483,19 @@ public final class GenericsHighlightUtil {
continue;
}
final String message = unrelatedDefaults != null ? " inherits unrelated defaults for " : " inherits abstract and default for ";
final HighlightInfo info = HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(classIdentifier).descriptionAndTooltip(
HighlightUtil.formatClass(aClass) +
message +
JavaHighlightUtil.formatMethod(defaultMethod) + " from types " +
(unrelatedDefaults != null ? unrelatedDefaults
: HighlightUtil.formatClass(defaultMethodContainingClass) + " and " + HighlightUtil.formatClass(unrelatedMethodContainingClass)))
final String message;
if (unrelatedDefaults == null) {
message = JavaErrorBundle.message("text.class.inherits.abstract.and.default", HighlightUtil.formatClass(aClass),
JavaHighlightUtil.formatMethod(defaultMethod),
HighlightUtil.formatClass(defaultMethodContainingClass),
HighlightUtil.formatClass(unrelatedMethodContainingClass));
}
else {
message = JavaErrorBundle.message("text.class.inherits.unrelated.defaults", HighlightUtil.formatClass(aClass),
JavaHighlightUtil.formatMethod(defaultMethod), unrelatedDefaults);
}
final HighlightInfo info = HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(classIdentifier)
.descriptionAndTooltip(message)
.create();
QuickFixAction.registerQuickFixAction(info, QUICK_FIX_FACTORY.createImplementMethodsFix(aClass));
return info;
@@ -516,7 +523,8 @@ public final class GenericsHighlightUtil {
}
if (classes.size() > 1) {
return HighlightUtil.formatClass(classes.get(0)) + " and " + HighlightUtil.formatClass(classes.get(1));
return CommonQuickFixBundle.message("fix.x.and.y", HighlightUtil.formatClass(classes.get(0)),
HighlightUtil.formatClass(classes.get(1)));
}
}
@@ -1312,8 +1320,8 @@ public final class GenericsHighlightUtil {
resolved instanceof PsiTypeParameterListOwner &&
((PsiTypeParameterListOwner)resolved).hasTypeParameters() &&
!((PsiTypeParameterListOwner)resolved).hasModifierProperty(PsiModifier.STATIC)) {
return HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(parent).descriptionAndTooltip(
"Improper formed type; some type parameters are missing").create();
final String message = JavaErrorBundle.message("text.improper.formed.type");
return HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(parent).descriptionAndTooltip(message).create();
}
return null;
}
@@ -1344,7 +1352,8 @@ public final class GenericsHighlightUtil {
}
}
if (hiddenClass != null) {
return HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).descriptionAndTooltip(hiddenClass.getName() + " is not accessible in current context").range(ref).create();
final String message = JavaErrorBundle.message("text.class.is.not.accessible", hiddenClass.getName());
return HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).description(message).range(ref).create();
}
}
}
@@ -1512,7 +1521,7 @@ public final class GenericsHighlightUtil {
final String qualifiedName = aClass.getQualifiedName();
if (qualifiedName != null && factory.findClass(qualifiedName, resolveScope) == null) {
return "Cannot access " + HighlightUtil.formatClass(aClass);
return JavaErrorBundle.message("text.class.cannot.access", HighlightUtil.formatClass(aClass));
}
if (!checkParameters){
@@ -15,6 +15,7 @@ import com.intellij.codeInsight.highlighting.HighlightUsagesDescriptionLocation;
import com.intellij.codeInsight.intention.IntentionAction;
import com.intellij.codeInsight.intention.QuickFixFactory;
import com.intellij.codeInsight.quickfix.UnresolvedReferenceQuickFixProvider;
import com.intellij.codeInspection.CommonQuickFixBundle;
import com.intellij.codeInspection.LocalQuickFixOnPsiElementAsIntentionAdapter;
import com.intellij.java.analysis.JavaAnalysisBundle;
import com.intellij.lang.findUsages.LanguageFindUsages;
@@ -268,7 +269,8 @@ public final class HighlightUtil {
if (!TypesDistinctProver.provablyDistinct(pair.first, pair.second)) {
return true;
}
differentArgumentsMessage.set(pair.first.getPresentableText() + " and " + pair.second.getPresentableText());
differentArgumentsMessage.set(CommonQuickFixBundle.message("fix.x.and.y", pair.first.getPresentableText(),
pair.second.getPresentableText()));
return false;
});
if (sameGenericParameterization != null) {
@@ -668,8 +670,8 @@ public final class HighlightUtil {
if (vFile != null) {
final String path = FileUtil.toSystemIndependentName(vFile.getPath());
String linkText = "<a href=\"#navigation/" + path + ":" + oldVariable.getTextOffset() + "\">" + variable.getName() + "</a>";
builder = builder.description(description)
.escapedToolTip("<html>" + JavaErrorBundle.message("variable.already.defined", linkText) + "</html>");
String tip = CommonQuickFixBundle.message("fix.link", JavaErrorBundle.message("variable.already.defined", linkText));
builder = builder.description(description).escapedToolTip(tip);
}
else {
builder = builder.descriptionAndTooltip(description);
@@ -800,7 +802,7 @@ public final class HighlightUtil {
HighlightInfoType highlightType = getUnhandledExceptionHighlightType(resource);
if (highlightType == null) return null;
String description = getUnhandledExceptionsDescriptor(unhandled, "auto-closeable resource");
String description = getUnhandledExceptionsDescriptor(unhandled, JavaErrorBundle.message("auto.closeable.resource"));
HighlightInfo highlight = HighlightInfo.newHighlightInfo(highlightType).range(resource).descriptionAndTooltip(description).create();
HighlightFixUtil.registerUnhandledExceptionFixes(resource, highlight);
return highlight;
@@ -560,7 +560,8 @@ class PostHighlightingVisitor {
VirtualFile file = PsiUtilCore.getVirtualFile(myFile);
Set<String> imports = file != null ? file.getCopyableUserData(ImportsHighlightUtil.IMPORTS_FROM_TEMPLATE) : null;
boolean predefinedImport = imports != null && imports.contains(importStatement.getText());
String description = !predefinedImport ? JavaAnalysisBundle.message("unused.import.statement") : "Unused import (specified in template)";
String description = !predefinedImport ? JavaAnalysisBundle.message("unused.import.statement") :
JavaAnalysisBundle.message("text.unused.import.in.template");
HighlightInfo info = HighlightInfo.newHighlightInfo(JavaHighlightInfoTypes.UNUSED_IMPORT)
.range(importStatement)
.descriptionAndTooltip(description)
@@ -4,6 +4,7 @@ package com.intellij.codeInsight.daemon.impl.analysis;
import com.intellij.codeInsight.daemon.JavaErrorBundle;
import com.intellij.codeInsight.daemon.impl.HighlightInfo;
import com.intellij.codeInsight.daemon.impl.HighlightInfoType;
import com.intellij.java.analysis.JavaAnalysisBundle;
import com.intellij.psi.*;
import com.intellij.psi.util.*;
import org.jetbrains.annotations.NotNull;
@@ -18,7 +19,7 @@ public final class PsiMethodReferenceHighlightingUtil {
PsiElement resolve = ((PsiReferenceExpression)qualifier).resolve();
if (resolve instanceof PsiClass && ((PsiClass)resolve).hasTypeParameters()) {
return HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(expression)
.descriptionAndTooltip("Raw constructor reference with explicit type parameters for constructor").create();
.descriptionAndTooltip(JavaAnalysisBundle.message("text.raw.ctor.reference.with.type.parameters")).create();
}
}
}
@@ -5,6 +5,7 @@ package com.intellij.codeInsight.daemon.impl.quickfix;
import com.intellij.codeInsight.daemon.impl.HighlightInfo;
import com.intellij.codeInsight.intention.HighPriorityAction;
import com.intellij.codeInspection.CommonQuickFixBundle;
import com.intellij.codeInspection.LocalQuickFixAndIntentionActionOnPsiElement;
import com.intellij.codeInspection.util.IntentionName;
import com.intellij.java.analysis.JavaAnalysisBundle;
@@ -46,7 +47,7 @@ public class ReplaceGetClassWithClassLiteralFix extends LocalQuickFixAndIntentio
if (aClass == null) return false;
String className = aClass.getName();
if (className == null) return false;
myText = "Replace with " + className + "." + PsiKeyword.CLASS;
myText = CommonQuickFixBundle.message("fix.replace.with.x", className + "." + PsiKeyword.CLASS);
return super.isAvailable(project, file, startElement, endElement);
}
@@ -495,4 +495,10 @@ anonymous.classes.must.not.extend.sealed.classes=Anonymous classes must not exte
class.not.allowed.to.extend.sealed.class.from.another.package=Class is not allowed to extend sealed class from another package
class.not.allowed.to.extend.sealed.class.from.another.module=Class is not allowed to extend sealed class from another module
annotation.cannot.be.local=Local annotations are not allowed
create.class.action.this.not.valid.java.qualified.name=This is not a valid Java qualified name
create.class.action.this.not.valid.java.qualified.name=This is not a valid Java qualified name
text.class.inherits.abstract.and.default={0} inherits abstract and default for {1} from types {2} and {3}
text.class.inherits.unrelated.defaults={0} inherits unrelated defaults for {1} from types {2}
text.improper.formed.type=Improper formed type; some type parameters are missing
text.class.is.not.accessible={0} is not accessible in current context
text.class.cannot.access=Cannot access {0}
auto.closeable.resource=auto-closeable resource
@@ -1,4 +1,4 @@
// "Replace with Test.class" "true"
// "Replace with 'Test.class'" "true"
class Test {
static void foo() {
@@ -1,4 +1,4 @@
// "Replace with Test.class" "true"
// "Replace with 'Test.class'" "true"
class Test {
static void foo() {
@@ -28,4 +28,7 @@ fix.simplify=Simplify
fix.create.title=Create {0}
fix.create.title.x=Create {0} ''{1}''
fix.create.title.x.from.usage=Create {0} ''{1}'' from usage
fix.create.title.x.from.usage=Create {0} ''{1}'' from usage
fix.x.and.y={0} and {1}
fix.link=<html>{0}</html>