Use better structured names of properties in JsonBundle

This commit is contained in:
Mikhail Golubev
2015-06-09 16:55:42 +03:00
parent 8c83ffcb30
commit bf747f5524
8 changed files with 53 additions and 47 deletions
@@ -2,30 +2,35 @@ json.array=array
json.object=object
json.property=property
msg.missing.closing.quote=Missing closing quote
msg.illegal.escape.sequence=Illegal escape sequence
msg.illegal.unicode.escape.sequence=Illegal unicode escape sequence
msg.illegal.floating.point.literal=Illegal floating point literal
syntax.error.missing.closing.quote=Missing closing quote
syntax.error.illegal.escape.sequence=Illegal escape sequence
syntax.error.illegal.unicode.escape.sequence=Illegal unicode escape sequence
syntax.error.illegal.floating.point.literal=Illegal floating point literal
msg.compliance.problem.comments=JSON standard does not allow comments. Use JSMin or similar tool to remove comments before parsing.
msg.compliance.problem.single.quoted.strings=JSON standard does not allow single quoted strings
msg.compliance.problem.identifier=JSON standard does not allow identifiers
msg.compliance.problem.illegal.property.key=JSON standard allows only double quoted string as property key
msg.compliance.problem.trailing.comma=JSON standard does not allow trailing comma
msg.compliance.problem.multiple.top.level.values=JSON standard allows only one top-level value
# Inspections
json.inspection.group=JSON
msg.formatting.options.panel.coding.style=Formatting options
msg.formatting.options.panel.align.properties=Align object &properties:
msg.align.properties.none=Do not align
msg.align.properties.on.colon=On colon
msg.align.properties.on.value=On value
inspection.compliance.name=Compliance with JSON standard
inspection.compliance.msg.comments=JSON standard does not allow comments. Use JSMin or similar tool to remove comments before parsing.
inspection.compliance.msg.single.quoted.strings=JSON standard does not allow single quoted strings
inspection.compliance.msg.identifier=JSON standard does not allow identifiers
inspection.compliance.msg.illegal.property.key=JSON standard allows only double quoted string as property key
inspection.compliance.msg.trailing.comma=JSON standard does not allow trailing comma
inspection.compliance.msg.multiple.top.level.values=JSON standard allows only one top-level value
name.json.inspection.group=JSON
name.standard.compliance.inspection=Compliance with JSON standard
name.add.double.quotes.quickfix=Wrap with double quotes
name.surround.with.object.literal=object literal
inspection.compliance.option.comments=Warn about comments
inspection.compliance.option.multiple.top.level.values=Warn about multiple top-level values
option.warn.about.comments.name=Warn about comments
option.warn.about.multiple.top.level.values.name=Warn about multiple top-level values
# Formatter
formatter.other.tab.group.title=Formatting options
formatter.other.tab.label.align.properties=Align object &properties:
formatter.align.properties.none=Do not align
formatter.align.properties.on.colon=On colon
formatter.align.properties.on.value=On value
# Quickfixes and editor actions
quickfix.add.double.quotes.desc=Wrap with double quotes
surround.with.object.literal.desc=object literal
json.template.context.type=JSON
@@ -55,7 +55,7 @@ public class JsonLiteralAnnotator implements Annotator {
// Check that string literal is closed properly
if (length <= 1 || text.charAt(0) != text.charAt(length - 1) || JsonPsiUtil.isEscapedChar(text, length - 1)) {
holder.createErrorAnnotation(element, JsonBundle.message("msg.missing.closing.quote"));
holder.createErrorAnnotation(element, JsonBundle.message("syntax.error.missing.closing.quote"));
}
// Check escapes
@@ -65,17 +65,18 @@ public class JsonLiteralAnnotator implements Annotator {
if (fragmentText.startsWith("\\") && fragmentText.length() > 1 && !VALID_ESCAPE.matcher(fragmentText).matches()) {
final TextRange fragmentRange = fragment.getFirst();
if (fragmentText.startsWith("\\u")) {
holder.createErrorAnnotation(fragmentRange.shiftRight(elementOffset), JsonBundle.message("msg.illegal.unicode.escape.sequence"));
holder.createErrorAnnotation(fragmentRange.shiftRight(elementOffset), JsonBundle.message(
"syntax.error.illegal.unicode.escape.sequence"));
}
else {
holder.createErrorAnnotation(fragmentRange.shiftRight(elementOffset), JsonBundle.message("msg.illegal.escape.sequence"));
holder.createErrorAnnotation(fragmentRange.shiftRight(elementOffset), JsonBundle.message("syntax.error.illegal.escape.sequence"));
}
}
}
}
else if (element instanceof JsonNumberLiteral) {
if (!VALID_NUMBER_LITERAL.matcher(text).matches()) {
holder.createErrorAnnotation(element, JsonBundle.message("msg.illegal.floating.point.literal"));
holder.createErrorAnnotation(element, JsonBundle.message("syntax.error.illegal.floating.point.literal"));
}
}
}
@@ -40,7 +40,7 @@ public class JsonStandardComplianceInspection extends LocalInspectionTool {
@NotNull
public String getDisplayName() {
return JsonBundle.message("name.standard.compliance.inspection");
return JsonBundle.message("inspection.compliance.name");
}
@NotNull
@@ -57,7 +57,7 @@ public class JsonStandardComplianceInspection extends LocalInspectionTool {
public void visitComment(PsiComment comment) {
if (myWarnAboutComments) {
if (JsonStandardComplianceProvider.shouldWarnAboutComment(comment)) {
holder.registerProblem(comment, JsonBundle.message("msg.compliance.problem.comments"), ProblemHighlightType.WEAK_WARNING);
holder.registerProblem(comment, JsonBundle.message("inspection.compliance.msg.comments"), ProblemHighlightType.WEAK_WARNING);
}
}
}
@@ -65,7 +65,7 @@ public class JsonStandardComplianceInspection extends LocalInspectionTool {
@Override
public void visitStringLiteral(@NotNull JsonStringLiteral stringLiteral) {
if (JsonPsiUtil.getElementTextWithoutHostEscaping(stringLiteral).startsWith("'")) {
holder.registerProblem(stringLiteral, JsonBundle.message("msg.compliance.problem.single.quoted.strings"),
holder.registerProblem(stringLiteral, JsonBundle.message("inspection.compliance.msg.single.quoted.strings"),
new AddDoubleQuotesFix());
}
// May be illegal property key as well
@@ -75,14 +75,14 @@ public class JsonStandardComplianceInspection extends LocalInspectionTool {
@Override
public void visitLiteral(@NotNull JsonLiteral literal) {
if (JsonPsiUtil.isPropertyKey(literal) && !JsonPsiUtil.getElementTextWithoutHostEscaping(literal).startsWith("\"")) {
holder.registerProblem(literal, JsonBundle.message("msg.compliance.problem.illegal.property.key"), new AddDoubleQuotesFix());
holder.registerProblem(literal, JsonBundle.message("inspection.compliance.msg.illegal.property.key"), new AddDoubleQuotesFix());
}
super.visitLiteral(literal);
}
@Override
public void visitReferenceExpression(@NotNull JsonReferenceExpression reference) {
holder.registerProblem(reference, JsonBundle.message("msg.compliance.problem.identifier"), new AddDoubleQuotesFix());
holder.registerProblem(reference, JsonBundle.message("inspection.compliance.msg.identifier"), new AddDoubleQuotesFix());
// May be illegal property key as well
super.visitReferenceExpression(reference);
}
@@ -91,7 +91,7 @@ public class JsonStandardComplianceInspection extends LocalInspectionTool {
public void visitArray(@NotNull JsonArray array) {
final PsiElement trailingComma = findTrailingComma(array, JsonElementTypes.R_BRACKET);
if (trailingComma != null) {
holder.registerProblem(trailingComma, JsonBundle.message("msg.compliance.problem.trailing.comma"));
holder.registerProblem(trailingComma, JsonBundle.message("inspection.compliance.msg.trailing.comma"));
}
super.visitArray(array);
}
@@ -100,7 +100,7 @@ public class JsonStandardComplianceInspection extends LocalInspectionTool {
public void visitObject(@NotNull JsonObject object) {
final PsiElement trailingComma = findTrailingComma(object, JsonElementTypes.R_CURLY);
if (trailingComma != null) {
holder.registerProblem(trailingComma, JsonBundle.message("msg.compliance.problem.trailing.comma"));
holder.registerProblem(trailingComma, JsonBundle.message("inspection.compliance.msg.trailing.comma"));
}
super.visitObject(object);
}
@@ -110,7 +110,7 @@ public class JsonStandardComplianceInspection extends LocalInspectionTool {
if (value.getContainingFile() instanceof JsonFile) {
final JsonFile jsonFile = (JsonFile)value.getContainingFile();
if (myWarnAboutMultipleTopLevelValues && value.getParent() == jsonFile && value != jsonFile.getTopLevelValue()) {
holder.registerProblem(value, JsonBundle.message("msg.compliance.problem.multiple.top.level.values"));
holder.registerProblem(value, JsonBundle.message("inspection.compliance.msg.multiple.top.level.values"));
}
}
}
@@ -134,8 +134,8 @@ public class JsonStandardComplianceInspection extends LocalInspectionTool {
@Override
public JComponent createOptionsPanel() {
final MultipleCheckboxOptionsPanel optionsPanel = new MultipleCheckboxOptionsPanel(this);
optionsPanel.addCheckbox(JsonBundle.message("option.warn.about.comments.name"), "myWarnAboutComments");
optionsPanel.addCheckbox(JsonBundle.message("option.warn.about.multiple.top.level.values.name"), "myWarnAboutMultipleTopLevelValues");
optionsPanel.addCheckbox(JsonBundle.message("inspection.compliance.option.comments"), "myWarnAboutComments");
optionsPanel.addCheckbox(JsonBundle.message("inspection.compliance.option.multiple.top.level.values"), "myWarnAboutMultipleTopLevelValues");
return optionsPanel;
}
@@ -143,7 +143,7 @@ public class JsonStandardComplianceInspection extends LocalInspectionTool {
@NotNull
@Override
public String getName() {
return JsonBundle.message("name.add.double.quotes.quickfix");
return JsonBundle.message("quickfix.add.double.quotes.desc");
}
@NotNull
@@ -32,7 +32,7 @@
<clientProperties>
<BorderFactoryClass class="java.lang.String" value="com.intellij.ui.IdeBorderFactory$PlainSmallWithIndent"/>
</clientProperties>
<border type="line" title-resource-bundle="com/intellij/json/JsonBundle" title-key="msg.formatting.options.panel.coding.style">
<border type="line" title-resource-bundle="com/intellij/json/JsonBundle" title-key="formatter.other.tab.group.title">
<font/>
<title-color color="-16777216"/>
</border>
@@ -43,7 +43,7 @@
</constraints>
<properties>
<labelFor value="9b7e4"/>
<text resource-bundle="com/intellij/json/JsonBundle" key="msg.formatting.options.panel.align.properties"/>
<text resource-bundle="com/intellij/json/JsonBundle" key="formatter.other.tab.label.align.properties"/>
</properties>
</component>
<component id="9b7e4" class="javax.swing.JComboBox" binding="myPropertiesAlignmentCombo">
@@ -39,9 +39,9 @@ public class JsonCodeStyleSettings extends CustomCodeStyleSettings {
}
public enum PropertyAlignment {
DO_NOT_ALIGN(JsonBundle.message("msg.align.properties.none"), 0),
ALIGN_ON_VALUE(JsonBundle.message("msg.align.properties.on.value"), 1),
ALIGN_ON_COLON(JsonBundle.message("msg.align.properties.on.colon"), 2);
DO_NOT_ALIGN(JsonBundle.message("formatter.align.properties.none"), 0),
ALIGN_ON_VALUE(JsonBundle.message("formatter.align.properties.on.value"), 1),
ALIGN_ON_COLON(JsonBundle.message("formatter.align.properties.on.colon"), 2);
private final String myDescription;
private final int myId;
@@ -38,7 +38,7 @@ import org.jetbrains.annotations.Nullable;
public class JsonWithObjectLiteralSurrounder implements Surrounder {
@Override
public String getTemplateDescription() {
return JsonBundle.message("name.surround.with.object.literal");
return JsonBundle.message("surround.with.object.literal.desc");
}
@Override
@@ -36,7 +36,7 @@ public class JsonQuickFixTest extends JsonTestCase {
private void checkWrapInDoubleQuotes(@NotNull String before, @NotNull String after) {
myFixture.configureByText(JsonFileType.INSTANCE, before);
myFixture.enableInspections(JsonStandardComplianceInspection.class);
final IntentionAction intentionAction = myFixture.getAvailableIntention(JsonBundle.message("name.add.double.quotes.quickfix"));
final IntentionAction intentionAction = myFixture.getAvailableIntention(JsonBundle.message("quickfix.add.double.quotes.desc"));
assertNotNull(intentionAction);
myFixture.launchAction(intentionAction);
myFixture.checkResult(after);
@@ -45,10 +45,10 @@ public class JsonQuickFixTest extends JsonTestCase {
// Moved from JavaScript
public void testJSON2() {
doTest(JsonStandardComplianceInspection.class, JsonBundle.message("name.add.double.quotes.quickfix"));
doTest(JsonStandardComplianceInspection.class, JsonBundle.message("quickfix.add.double.quotes.desc"));
}
public void testJSON3() {
doTest(JsonStandardComplianceInspection.class, JsonBundle.message("name.add.double.quotes.quickfix"));
doTest(JsonStandardComplianceInspection.class, JsonBundle.message("quickfix.add.double.quotes.desc"));
}
}
@@ -50,8 +50,8 @@
<annotator language="JSON" implementationClass="com.intellij.json.codeinsight.JsonLiteralAnnotator"/>
<!-- Inspections -->
<localInspection language="JSON" shortName="JsonStandardCompliance" key="name.standard.compliance.inspection"
groupKey="name.json.inspection.group" enabledByDefault="true" level="ERROR"
<localInspection language="JSON" shortName="JsonStandardCompliance" key="inspection.compliance.name"
groupKey="json.inspection.group" enabledByDefault="true" level="ERROR"
bundle="com.intellij.json.JsonBundle"
implementationClass="com.intellij.json.codeinsight.JsonStandardComplianceInspection"/>