From a248fe4a847a8b438a0a5bc0e89043b2355b56d6 Mon Sep 17 00:00:00 2001 From: Mikhail Golubev Date: Tue, 27 Jan 2015 16:34:51 +0300 Subject: [PATCH] IDEA-134372 Do not warn about scalar top-level values in JSON files (according to RFC-7159) --- .../inspectionDescriptions/JsonStandardCompliance.html | 2 +- json/src/com/intellij/json/JsonBundle.properties | 1 - .../json/codeinsight/JsonStandardComplianceInspection.java | 3 --- json/tests/test/com/intellij/json/JsonHighlightingTest.java | 3 ++- .../ComplianceProblemsLiteralTopLevelValueIsAllowed.json | 1 + .../testData/highlighting/ComplianceProblemsTopLevelValue.json | 1 - 6 files changed, 4 insertions(+), 7 deletions(-) create mode 100644 json/tests/testData/highlighting/ComplianceProblemsLiteralTopLevelValueIsAllowed.json delete mode 100644 json/tests/testData/highlighting/ComplianceProblemsTopLevelValue.json diff --git a/json/resources/inspectionDescriptions/JsonStandardCompliance.html b/json/resources/inspectionDescriptions/JsonStandardCompliance.html index dc5855374bda..12ca8a1796f5 100644 --- a/json/resources/inspectionDescriptions/JsonStandardCompliance.html +++ b/json/resources/inspectionDescriptions/JsonStandardCompliance.html @@ -1,5 +1,5 @@ -This inspection checks that *.json files comply with JSON specification (RFC-4627).
+This inspection checks that JSON files conform to language specification (RFC-7159).
\ No newline at end of file diff --git a/json/src/com/intellij/json/JsonBundle.properties b/json/src/com/intellij/json/JsonBundle.properties index eda0a292162b..be56875b9138 100644 --- a/json/src/com/intellij/json/JsonBundle.properties +++ b/json/src/com/intellij/json/JsonBundle.properties @@ -9,7 +9,6 @@ msg.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.illegal.top.level.value=JSON standard allows only object or array as top-level value 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 diff --git a/json/src/com/intellij/json/codeinsight/JsonStandardComplianceInspection.java b/json/src/com/intellij/json/codeinsight/JsonStandardComplianceInspection.java index e3b402351569..58dab5945dfc 100644 --- a/json/src/com/intellij/json/codeinsight/JsonStandardComplianceInspection.java +++ b/json/src/com/intellij/json/codeinsight/JsonStandardComplianceInspection.java @@ -72,9 +72,6 @@ public class JsonStandardComplianceInspection extends LocalInspectionTool { @Override public void visitLiteral(@NotNull JsonLiteral literal) { - if (literal.getParent() instanceof JsonFile) { - holder.registerProblem(literal, JsonBundle.message("msg.compliance.problem.illegal.top.level.value")); - } if (JsonPsiUtil.isPropertyKey(literal) && !JsonPsiUtil.getElementTextWithoutHostEscaping(literal).startsWith("\"")) { holder.registerProblem(literal, JsonBundle.message("msg.compliance.problem.illegal.property.key"), new AddDoubleQuotesFix()); } diff --git a/json/tests/test/com/intellij/json/JsonHighlightingTest.java b/json/tests/test/com/intellij/json/JsonHighlightingTest.java index 55669514cf2d..cd06086e2688 100644 --- a/json/tests/test/com/intellij/json/JsonHighlightingTest.java +++ b/json/tests/test/com/intellij/json/JsonHighlightingTest.java @@ -25,7 +25,8 @@ public class JsonHighlightingTest extends JsonTestCase { doTest(); } - public void testComplianceProblemsTopLevelValue() { + // IDEA-134372 + public void testComplianceProblemsLiteralTopLevelValueIsAllowed() { enableStandardComplianceInspection(true); doTest(); } diff --git a/json/tests/testData/highlighting/ComplianceProblemsLiteralTopLevelValueIsAllowed.json b/json/tests/testData/highlighting/ComplianceProblemsLiteralTopLevelValueIsAllowed.json new file mode 100644 index 000000000000..ec747fa47ddb --- /dev/null +++ b/json/tests/testData/highlighting/ComplianceProblemsLiteralTopLevelValueIsAllowed.json @@ -0,0 +1 @@ +null \ No newline at end of file diff --git a/json/tests/testData/highlighting/ComplianceProblemsTopLevelValue.json b/json/tests/testData/highlighting/ComplianceProblemsTopLevelValue.json deleted file mode 100644 index 211a7b597d5d..000000000000 --- a/json/tests/testData/highlighting/ComplianceProblemsTopLevelValue.json +++ /dev/null @@ -1 +0,0 @@ -null \ No newline at end of file -- 2.32.0