diff --git a/json/resources/messages/JsonBundle.properties b/json/resources/messages/JsonBundle.properties index 3d84677e4aa8..4035fd057b64 100644 --- a/json/resources/messages/JsonBundle.properties +++ b/json/resources/messages/JsonBundle.properties @@ -55,6 +55,7 @@ action.ConsoleView.ShowAsJsonAction.text=Show as JSON #json schema json.schema.add.schema.chooser.title=Select JSON Schema File json.schema.annotation.not.allowed.property=Property ''{0}'' is not allowed +json.schema.annotation.not.allowed.property.possibly.typo=Property ''{0}'' is not allowed. A typo? json.schema.conflicting.mappings=Warning: conflicting mappings. Show details json.schema.file.selector.title=Schema file or URL: json.schema.version.selector.title=Schema version: @@ -104,6 +105,7 @@ sorry.this.fix.is.not.available.in.batch.mode=Sorry, this fix is not available i replace.with.allowed.value=Replace with allowed value json.schema=JSON Schema remove.prohibited.property=Remove prohibited property +fix.property.name.spelling=Adjust spelling to ''{0}'' add.missing.0=Add missing {0} add.missing.properties=Add missing properties intention.add.not.required.properties.text=Fill in all properties from JSON schema diff --git a/json/src/com/jetbrains/jsonSchema/impl/JsonValidationError.java b/json/src/com/jetbrains/jsonSchema/impl/JsonValidationError.java index d997cd60bba1..ba45eaf8262f 100644 --- a/json/src/com/jetbrains/jsonSchema/impl/JsonValidationError.java +++ b/json/src/com/jetbrains/jsonSchema/impl/JsonValidationError.java @@ -8,6 +8,7 @@ import com.intellij.openapi.util.NlsSafe; import com.jetbrains.jsonSchema.extension.JsonErrorPriority; import com.jetbrains.jsonSchema.extension.JsonLikeSyntaxAdapter; import com.jetbrains.jsonSchema.impl.fixes.AddMissingPropertyFix; +import com.jetbrains.jsonSchema.impl.fixes.FixPropertyNameTypoFix; import com.jetbrains.jsonSchema.impl.fixes.RemoveProhibitedPropertyFix; import com.jetbrains.jsonSchema.impl.fixes.SuggestEnumValuesFix; import org.jetbrains.annotations.NotNull; @@ -16,6 +17,7 @@ import org.jetbrains.annotations.Nullable; import java.util.ArrayList; import java.util.Collection; import java.util.Iterator; +import java.util.List; import java.util.stream.Collectors; public final class JsonValidationError { @@ -113,9 +115,11 @@ public final class JsonValidationError { public static final class ProhibitedPropertyIssueData implements IssueData { public final @NlsSafe String propertyName; + public final List<@NlsSafe String> typoCandidates; - public ProhibitedPropertyIssueData(@NlsSafe String propertyName) { + public ProhibitedPropertyIssueData(@NlsSafe String propertyName, List<@NlsSafe String> typoCandidates) { this.propertyName = propertyName; + this.typoCandidates = typoCandidates; } } @@ -156,10 +160,22 @@ public final class JsonValidationError { case MissingOneOfProperty, MissingAnyOfProperty -> ((MissingOneOfPropsIssueData)myIssueData).myExclusiveOptions.stream().map(d -> new AddMissingPropertyFix(d, quickFixAdapter)) .toArray(LocalQuickFix[]::new); - case ProhibitedProperty -> - new RemoveProhibitedPropertyFix[]{new RemoveProhibitedPropertyFix((ProhibitedPropertyIssueData)myIssueData, quickFixAdapter)}; + case ProhibitedProperty -> getProhibitedPropertyFixes(quickFixAdapter); case NonEnumValue -> new SuggestEnumValuesFix[]{new SuggestEnumValuesFix(quickFixAdapter)}; default -> LocalQuickFix.EMPTY_ARRAY; }; } + + private LocalQuickFix @NotNull [] getProhibitedPropertyFixes(@NotNull JsonLikeSyntaxAdapter quickFixAdapter) { + ProhibitedPropertyIssueData data = (ProhibitedPropertyIssueData)myIssueData; + if (data.typoCandidates.isEmpty()) { + return new RemoveProhibitedPropertyFix[]{new RemoveProhibitedPropertyFix(data, quickFixAdapter)}; + } + ArrayList allFixes = new ArrayList<>(); + for (@NlsSafe String candidate : data.typoCandidates) { + allFixes.add(new FixPropertyNameTypoFix(candidate, quickFixAdapter)); + } + allFixes.add(new RemoveProhibitedPropertyFix(data, quickFixAdapter)); + return allFixes.toArray(LocalQuickFix[]::new); + } } diff --git a/json/src/com/jetbrains/jsonSchema/impl/fixes/FixPropertyNameTypoFix.java b/json/src/com/jetbrains/jsonSchema/impl/fixes/FixPropertyNameTypoFix.java new file mode 100644 index 000000000000..9463f5567c97 --- /dev/null +++ b/json/src/com/jetbrains/jsonSchema/impl/fixes/FixPropertyNameTypoFix.java @@ -0,0 +1,41 @@ +// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. +package com.jetbrains.jsonSchema.impl.fixes; + +import com.intellij.json.JsonBundle; +import com.intellij.modcommand.ModPsiUpdater; +import com.intellij.modcommand.PsiUpdateModCommandQuickFix; +import com.intellij.openapi.project.Project; +import com.intellij.psi.PsiElement; +import com.jetbrains.jsonSchema.extension.JsonLikePsiWalker; +import com.jetbrains.jsonSchema.extension.JsonLikeSyntaxAdapter; +import com.jetbrains.jsonSchema.extension.adapters.JsonPropertyAdapter; +import org.jetbrains.annotations.Nls; +import org.jetbrains.annotations.NotNull; + +public class FixPropertyNameTypoFix extends PsiUpdateModCommandQuickFix { + private final String myAltName; + private final JsonLikeSyntaxAdapter myQuickFixAdapter; + + public FixPropertyNameTypoFix(String altName, + JsonLikeSyntaxAdapter quickFixAdapter) { + myAltName = altName; + myQuickFixAdapter = quickFixAdapter; + } + + @Override + public @Nls(capitalization = Nls.Capitalization.Sentence) @NotNull String getFamilyName() { + return JsonBundle.message("fix.property.name.spelling", myAltName); + } + + @Override + protected void applyFix(@NotNull Project project, @NotNull PsiElement element, @NotNull ModPsiUpdater updater) { + JsonLikePsiWalker walker = JsonLikePsiWalker.getWalker(element); + if (walker == null) return; + JsonPropertyAdapter parentProperty = walker.getParentPropertyAdapter(element); + if (parentProperty == null) return; + PsiElement newProperty = walker.getSyntaxAdapter(project).createProperty(myAltName, "foo", project); + parentProperty.getNameValueAdapter().getDelegate().replace( + walker.getParentPropertyAdapter(newProperty).getNameValueAdapter().getDelegate() + ); + } +} diff --git a/json/src/com/jetbrains/jsonSchema/impl/fixes/RemoveProhibitedPropertyFix.java b/json/src/com/jetbrains/jsonSchema/impl/fixes/RemoveProhibitedPropertyFix.java index c2edbccc6ef3..5e95de36b2b8 100644 --- a/json/src/com/jetbrains/jsonSchema/impl/fixes/RemoveProhibitedPropertyFix.java +++ b/json/src/com/jetbrains/jsonSchema/impl/fixes/RemoveProhibitedPropertyFix.java @@ -8,6 +8,7 @@ import com.intellij.openapi.project.Project; import com.intellij.psi.PsiElement; import com.jetbrains.jsonSchema.extension.JsonLikePsiWalker; import com.jetbrains.jsonSchema.extension.JsonLikeSyntaxAdapter; +import com.jetbrains.jsonSchema.extension.adapters.JsonPropertyAdapter; import com.jetbrains.jsonSchema.impl.JsonValidationError; import org.jetbrains.annotations.Nls; import org.jetbrains.annotations.NotNull; @@ -38,7 +39,8 @@ public final class RemoveProhibitedPropertyFix extends PsiUpdateModCommandQuickF protected void applyFix(@NotNull Project project, @NotNull PsiElement element, @NotNull ModPsiUpdater updater) { JsonLikePsiWalker walker = JsonLikePsiWalker.getWalker(element); if (walker == null) return; - assert myData.propertyName.equals(Objects.requireNonNull(walker.getParentPropertyAdapter(element)).getName()); - myQuickFixAdapter.removeProperty(element); + JsonPropertyAdapter parentProperty = walker.getParentPropertyAdapter(element); + assert myData.propertyName.equals(Objects.requireNonNull(parentProperty).getName()); + myQuickFixAdapter.removeProperty(parentProperty.getDelegate()); } } diff --git a/json/src/com/jetbrains/jsonSchema/impl/validations/ObjectValidation.java b/json/src/com/jetbrains/jsonSchema/impl/validations/ObjectValidation.java index 56b06a3f8984..68c5bebeb3dd 100644 --- a/json/src/com/jetbrains/jsonSchema/impl/validations/ObjectValidation.java +++ b/json/src/com/jetbrains/jsonSchema/impl/validations/ObjectValidation.java @@ -3,12 +3,14 @@ package com.jetbrains.jsonSchema.impl.validations; import com.intellij.json.JsonBundle; import com.intellij.json.pointer.JsonPointerPosition; +import com.intellij.openapi.util.NlsSafe; import com.intellij.openapi.util.Pair; import com.intellij.openapi.util.Ref; import com.intellij.openapi.util.registry.Registry; import com.intellij.openapi.util.text.StringUtil; import com.intellij.util.ThreeState; import com.intellij.util.containers.ContainerUtil; +import com.intellij.util.text.EditDistance; import com.jetbrains.jsonSchema.extension.JsonErrorPriority; import com.jetbrains.jsonSchema.extension.JsonSchemaValidation; import com.jetbrains.jsonSchema.extension.JsonValidationHost; @@ -16,6 +18,7 @@ import com.jetbrains.jsonSchema.extension.adapters.JsonObjectValueAdapter; import com.jetbrains.jsonSchema.extension.adapters.JsonPropertyAdapter; import com.jetbrains.jsonSchema.extension.adapters.JsonValueAdapter; import com.jetbrains.jsonSchema.impl.*; +import kotlin.collections.CollectionsKt; import one.util.streamex.StreamEx; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -38,6 +41,8 @@ public final class ObjectValidation implements JsonSchemaValidation { return checkObject(propValue, schema, consumer, options); } + private static final int MIN_LENGTH_TO_FIX_TYPOS = 3; + private static boolean checkObject(@NotNull JsonValueAdapter value, @NotNull JsonSchemaObject schema, JsonValidationHost consumer, @@ -52,8 +57,8 @@ public final class ObjectValidation implements JsonSchemaValidation { for (JsonPropertyAdapter property : propertyList) { final String name = StringUtil.notNullize(property.getName()); JsonSchemaObject propertyNamesSchema = schema.getPropertyNamesSchema(); + JsonValueAdapter nameValueAdapter = property.getNameValueAdapter(); if (propertyNamesSchema != null) { - JsonValueAdapter nameValueAdapter = property.getNameValueAdapter(); if (nameValueAdapter != null) { JsonValidationHost checker = consumer.checkByMatchResult(nameValueAdapter, consumer.resolve(propertyNamesSchema, nameValueAdapter), options); @@ -68,9 +73,21 @@ public final class ObjectValidation implements JsonSchemaValidation { final JsonPointerPosition step = JsonPointerPosition.createSingleProperty(name); final Pair pair = doSingleStep(step, schema); if (ThreeState.NO.equals(pair.getFirst()) && !set.contains(name)) { - consumer.error(JsonBundle.message("json.schema.annotation.not.allowed.property", name), property.getDelegate(), + Iterator propertyNamesIterator = schema.getPropertyNames(); + List<@NlsSafe String> typoCandidates = CollectionsKt.filter( + iteratorToList(propertyNamesIterator), + s -> EditDistance.optimalAlignment(s, name, false, 1) <= 1 + ); + consumer.error(JsonBundle.message( + name.length() < MIN_LENGTH_TO_FIX_TYPOS || typoCandidates.isEmpty() ? + "json.schema.annotation.not.allowed.property" : + "json.schema.annotation.not.allowed.property.possibly.typo", name), + nameValueAdapter != null ? nameValueAdapter.getDelegate() : property.getDelegate(), JsonValidationError.FixableIssueKind.ProhibitedProperty, - new JsonValidationError.ProhibitedPropertyIssueData(name), JsonErrorPriority.LOW_PRIORITY); + new JsonValidationError.ProhibitedPropertyIssueData( + name, + name.length() >= MIN_LENGTH_TO_FIX_TYPOS ? typoCandidates : Collections.emptyList() + ), JsonErrorPriority.LOW_PRIORITY); isValid = false; if (options.shouldStopValidationAfterAnyErrorFound()) return false; } @@ -143,6 +160,22 @@ public final class ObjectValidation implements JsonSchemaValidation { return checkUnevaluatedPropertiesSchemaViolation(consumer, schema, object, options); } + private static @NotNull ArrayList<@NlsSafe String> iteratorToList(Iterator propertyNamesIterator) { + return Collections.list( + new Enumeration<>() { + @Override + public boolean hasMoreElements() { + return propertyNamesIterator.hasNext(); + } + + @Override + public String nextElement() { + return propertyNamesIterator.next(); + } + } + ); + } + private static boolean checkUnevaluatedPropertiesSchemaViolation(@NotNull JsonValidationHost consumer, @NotNull JsonSchemaObject schemaNode, @NotNull JsonObjectValueAdapter inspectedObject, @@ -195,7 +228,8 @@ public final class ObjectValidation implements JsonSchemaValidation { if (defaultValue == null) { if (Registry.is("json.schema.object.v2")) { defaultValue = schema.getExampleByName(req); - } else { + } + else { var example = schema.getExample(); defaultValue = example == null ? null : example.get(req); } @@ -287,7 +321,8 @@ public final class ObjectValidation implements JsonSchemaValidation { var existingProperties = ContainerUtil.map(objectValueAdapter.getPropertyList(), JsonPropertyAdapter::getName); Iterable iter = (() -> schema.getPropertyNames()); - var missingProperties = StreamSupport.stream(iter.spliterator(), false).filter(it -> !existingProperties.contains(it)).collect(Collectors.toSet()); + var missingProperties = + StreamSupport.stream(iter.spliterator(), false).filter(it -> !existingProperties.contains(it)).collect(Collectors.toSet()); var missingPropertiesData = createMissingPropertiesData(schema, missingProperties, validationHost, objectValueAdapter); validationHost.error( JsonBundle.message("schema.validation.missing.not.required.property.or.properties", missingPropertiesData.getMessage(false)), diff --git a/json/tests/test/com/jetbrains/jsonSchema/JsonSchemaHighlightingTest.java b/json/tests/test/com/jetbrains/jsonSchema/JsonSchemaHighlightingTest.java index bbdf113c23b9..623f82fffaef 100644 --- a/json/tests/test/com/jetbrains/jsonSchema/JsonSchemaHighlightingTest.java +++ b/json/tests/test/com/jetbrains/jsonSchema/JsonSchemaHighlightingTest.java @@ -191,7 +191,7 @@ public class JsonSchemaHighlightingTest extends JsonSchemaHighlightingTestBase { public void testAdditionalPropertiesDisabled() { @Language("JSON") final String schema = "{\"type\": \"object\", \"properties\": {\"prop\": {}}, \"additionalProperties\": false}"; // not sure abt inner object - doTest(schema, "{\"prop\": {}, \"someStuff\": 20}"); + doTest(schema, "{\"prop\": {}, \"someStuff\": 20}"); } public void testAdditionalPropertiesSchema() { @@ -268,7 +268,7 @@ public class JsonSchemaHighlightingTest extends JsonSchemaHighlightingTestBase { "\"innerType\":{}, \"innerValue\":{}" + "}, \"additionalProperties\": false" + "}}"); - doTest(schema, "{\"prop\": [{\"innerType\":{}, \"alien\":{}}]}"); + doTest(schema, "{\"prop\": [{\"innerType\":{}, \"alien\":{}}]}"); } public void testObjectDeeperInArray() { @@ -279,7 +279,7 @@ public class JsonSchemaHighlightingTest extends JsonSchemaHighlightingTestBase { "}, \"additionalProperties\": false" + "}}"); doTest(schema, - "{\"prop\": [{\"innerType\":{\"only\": true, \"hidden\": false}}]}"); + "{\"prop\": [{\"innerType\":{\"only\": true, \"hidden\": false}}]}"); } public void testInnerObjectPropValueInArray() { @@ -292,7 +292,7 @@ public class JsonSchemaHighlightingTest extends JsonSchemaHighlightingTestBase { @Language("JSON") final String schema = "{\"allOf\": [{\"type\": \"object\", \"properties\": {\"first\": {}}}," + " {\"properties\": {\"second\": {\"enum\": [33,44]}}}], \"additionalProperties\": false}"; doTest(schema, "{\"first\": {}, \"second\": null}"); - doTest(schema, "{\"first\": {}, \"second\": 44, \"other\": 15}"); + doTest(schema, "{\"first\": {}, \"second\": 44, \"other\": 15}"); doTest(schema, "{\"first\": {}, \"second\": 12}"); } @@ -302,7 +302,7 @@ public class JsonSchemaHighlightingTest extends JsonSchemaHighlightingTestBase { @Language("JSON") final String schema = "{\"properties\": {\"prop\": {\"oneOf\": [" + subSchema1 + ", " + subSchema2 + "]}}}"; //doTest(schema, "{\"prop\": [{\"kilo\": 20}]}"); //doTest(schema, "{\"prop\": 5}"); - doTest(schema, "{\"prop\": [{\"foxtrot\": 15, \"kilo\": 20}]}"); + doTest(schema, "{\"prop\": [{\"foxtrot\": 15, \"kilo\": 20}]}"); } public void testIntegerTypeWithMinMax() throws Exception { @@ -454,7 +454,7 @@ public class JsonSchemaHighlightingTest extends JsonSchemaHighlightingTestBase { } public void testRootObjectRedefinedAdditionalPropertiesForbidden() { - doTest(rootObjectRedefinedSchema(), "{\"a\": true," + + doTest(rootObjectRedefinedSchema(), "{\"a\": true," + "\"r1\": \"allowed!\"}"); } @@ -1204,14 +1204,14 @@ public class JsonSchemaHighlightingTest extends JsonSchemaHighlightingTestBase { "subject": { "discriminator": "first", "first": false, - "second": false + "second": false } }"""); doTest(schemaText, """ { "subject": { "discriminator": "second", - "first": false, + "first": false, "second": false } }"""); diff --git a/json/tests/test/com/jetbrains/jsonSchema/fixes/JsonSchemaQuickFixTest.java b/json/tests/test/com/jetbrains/jsonSchema/fixes/JsonSchemaQuickFixTest.java index 972139a92d46..6f6f4c69b50b 100644 --- a/json/tests/test/com/jetbrains/jsonSchema/fixes/JsonSchemaQuickFixTest.java +++ b/json/tests/test/com/jetbrains/jsonSchema/fixes/JsonSchemaQuickFixTest.java @@ -75,10 +75,10 @@ public class JsonSchemaQuickFixTest extends JsonSchemaQuickFixTestBase { "additionalProperties": false }"""; String fixName = "Remove prohibited property 'b'"; - doTest(schema, "{\"a\": 5, \"b\": 6, \"c\": 7}", fixName, "{\"a\": 5,\n \"c\": 7}"); - doTest(schema, "{\"a\": 5, \"c\": 7, \"b\": 6}", fixName, "{\"a\": 5, \"c\": 7}"); - doTest(schema, "{\"b\": 6, \"a\": 5, \"c\": 7}", fixName, "{\n \"a\": 5, \"c\": 7}"); - doTest(schema, "{\"b\": 6}", fixName, "{}"); + doTest(schema, "{\"a\": 5, \"b\": 6, \"c\": 7}", fixName, "{\"a\": 5,\n \"c\": 7}"); + doTest(schema, "{\"a\": 5, \"c\": 7, \"b\": 6}", fixName, "{\"a\": 5, \"c\": 7}"); + doTest(schema, "{\"b\": 6, \"a\": 5, \"c\": 7}", fixName, "{\n \"a\": 5, \"c\": 7}"); + doTest(schema, "{\"b\": 6}", fixName, "{}"); } public void testRemoveProhibitedPropertyInjection() { @@ -98,7 +98,7 @@ public class JsonSchemaQuickFixTest extends JsonSchemaQuickFixTestBase { doTest(schema, """ {"outer": "{\\"inner\\": \ {\\"x\\": 1, \\"y\ - \\": 2}}"}""", + \\": 2}}"}""", "Remove prohibited property 'y'", """ {"outer": "{\\"inner\\": {\\"x\\": 1}}"}"""); } diff --git a/json/tests/test/com/jetbrains/jsonSchema/newerFormats/JsonSchema2020FeaturesTest.kt b/json/tests/test/com/jetbrains/jsonSchema/newerFormats/JsonSchema2020FeaturesTest.kt index e276213249a6..361ce9689bcb 100644 --- a/json/tests/test/com/jetbrains/jsonSchema/newerFormats/JsonSchema2020FeaturesTest.kt +++ b/json/tests/test/com/jetbrains/jsonSchema/newerFormats/JsonSchema2020FeaturesTest.kt @@ -424,7 +424,7 @@ internal class JsonSchema2020FeaturesTest : JsonSchemaVersionTestBase() { { "foo": { "${dollar}ref": "...", - "prohibitedAdditionalProperty": 123 + "prohibitedAdditionalProperty": 123 } } """.trimIndent(), diff --git a/json/tests/testData/jsonSchema/highlighting/anyOnePropertySelection.json b/json/tests/testData/jsonSchema/highlighting/anyOnePropertySelection.json index 3cd625495ce1..8a8cb4d89fba 100644 --- a/json/tests/testData/jsonSchema/highlighting/anyOnePropertySelection.json +++ b/json/tests/testData/jsonSchema/highlighting/anyOnePropertySelection.json @@ -2,6 +2,6 @@ "anyOne": { "a112": 9, "b111": 9, - "ccc": true + "ccc": true } } \ No newline at end of file diff --git a/json/tests/testData/jsonSchema/highlighting/anyOneTypeSelection.json b/json/tests/testData/jsonSchema/highlighting/anyOneTypeSelection.json index 8f3921c07abc..babd857641e9 100644 --- a/json/tests/testData/jsonSchema/highlighting/anyOneTypeSelection.json +++ b/json/tests/testData/jsonSchema/highlighting/anyOneTypeSelection.json @@ -1,5 +1,5 @@ { "about1": "var1", "b_111": true, - "ccc": 18 + "ccc": 18 } diff --git a/json/tests/testData/jsonSchema/highlighting/resharper/test002.json b/json/tests/testData/jsonSchema/highlighting/resharper/test002.json index e81411144ddc..90e6e99e8b64 100644 --- a/json/tests/testData/jsonSchema/highlighting/resharper/test002.json +++ b/json/tests/testData/jsonSchema/highlighting/resharper/test002.json @@ -1,5 +1,5 @@ { "a": 6, - "b": "a" + "b": "a" } diff --git a/json/tests/testData/jsonSchema/highlighting/resharper/test004.json b/json/tests/testData/jsonSchema/highlighting/resharper/test004.json index a83da57f691c..d499ee44afdf 100644 --- a/json/tests/testData/jsonSchema/highlighting/resharper/test004.json +++ b/json/tests/testData/jsonSchema/highlighting/resharper/test004.json @@ -1,12 +1,12 @@ { "a": "a", - "c": 7, - "b": "c": 7, + "b": 5, "x25": "q", "x255": 7, "0x256": true, - "x025": "fail" + "x025": "fail" } diff --git a/json/tests/testData/jsonSchema/highlighting/resharper/test004_2.json b/json/tests/testData/jsonSchema/highlighting/resharper/test004_2.json index 83adfc494d3f..550b3643daf7 100644 --- a/json/tests/testData/jsonSchema/highlighting/resharper/test004_2.json +++ b/json/tests/testData/jsonSchema/highlighting/resharper/test004_2.json @@ -1,9 +1,9 @@ { - "b": 5, + "b": 5, "x25": "q", "x255": 7, "0x256": true, - "x025": "fail" + "x025": "fail" } diff --git a/json/tests/testData/jsonSchema/highlighting/testCycledWithRootRefInNotSchema.json b/json/tests/testData/jsonSchema/highlighting/testCycledWithRootRefInNotSchema.json index ca1e40c317c6..3ad3d46e460b 100644 --- a/json/tests/testData/jsonSchema/highlighting/testCycledWithRootRefInNotSchema.json +++ b/json/tests/testData/jsonSchema/highlighting/testCycledWithRootRefInNotSchema.json @@ -1,10 +1,10 @@ { "testProp": { "testProp": { - "alala": { - } + "alala": { + } } }, - "alala": { - } + "alala": { + } } \ No newline at end of file diff --git a/json/tests/testData/jsonSchema/highlighting/testCycledWithRootRefSchema.json b/json/tests/testData/jsonSchema/highlighting/testCycledWithRootRefSchema.json index 35f1949ea7b1..de89f0dde08e 100644 --- a/json/tests/testData/jsonSchema/highlighting/testCycledWithRootRefSchema.json +++ b/json/tests/testData/jsonSchema/highlighting/testCycledWithRootRefSchema.json @@ -6,5 +6,5 @@ } } }, - "aaa": 1 + "aaa": 1 } \ No newline at end of file diff --git a/plugins/yaml/testSrc/org/jetbrains/yaml/schema/YamlByJsonSchemaHighlightingTest.java b/plugins/yaml/testSrc/org/jetbrains/yaml/schema/YamlByJsonSchemaHighlightingTest.java index 61987f47da02..45c8ffd8ef83 100644 --- a/plugins/yaml/testSrc/org/jetbrains/yaml/schema/YamlByJsonSchemaHighlightingTest.java +++ b/plugins/yaml/testSrc/org/jetbrains/yaml/schema/YamlByJsonSchemaHighlightingTest.java @@ -187,7 +187,7 @@ public class YamlByJsonSchemaHighlightingTest extends JsonSchemaHighlightingTest public void testAdditionalPropertiesDisabled() { @Language("JSON") final String schema = "{\"type\": \"object\", \"properties\": {\"prop\": {}}, \"additionalProperties\": false}"; // not sure abt inner object - doTest(schema, "prop:\n q: true\nsomeStuff: 20"); + doTest(schema, "prop:\n q: true\nsomeStuff: 20"); } public void testAdditionalPropertiesSchema() { @@ -270,7 +270,7 @@ public class YamlByJsonSchemaHighlightingTest extends JsonSchemaHighlightingTest "\"innerType\":{}, \"innerValue\":{}" + "}, \"additionalProperties\": false" + "}}"); - doTest(schema, "prop:\n- innerType: aaa\n alien: bee"); + doTest(schema, "prop:\n- innerType: aaa\n alien: bee"); } public void testObjectDeeperInArray() { @@ -281,7 +281,7 @@ public class YamlByJsonSchemaHighlightingTest extends JsonSchemaHighlightingTest "}, \"additionalProperties\": false" + "}}"); doTest(schema, - "prop:\n- innerType:\n only: true\n hidden: false"); + "prop:\n- innerType:\n only: true\n hidden: false"); } public void testInnerObjectPropValueInArray() { @@ -294,7 +294,7 @@ public class YamlByJsonSchemaHighlightingTest extends JsonSchemaHighlightingTest @Language("JSON") final String schema = "{\"allOf\": [{\"type\": \"object\", \"properties\": {\"first\": {}}}," + " {\"properties\": {\"second\": {\"enum\": [33,44]}}}], \"additionalProperties\": false}"; // doTest(schema, "first: true\nsecond: null"); - doTest(schema, "first: true\nsecond: 44\nother: 15"); + doTest(schema, "first: true\nsecond: 44\nother: 15"); doTest(schema, "first: true\nsecond: 12"); } @@ -302,7 +302,7 @@ public class YamlByJsonSchemaHighlightingTest extends JsonSchemaHighlightingTest final String subSchema1 = "{\"enum\": [1,2,3,4,5]}"; final String subSchema2 = "{\"type\": \"array\", \"items\": {\"properties\": {\"kilo\": {}}, \"additionalProperties\": false}}"; @Language("JSON") final String schema = "{\"properties\": {\"prop\": {\"oneOf\": [" + subSchema1 + ", " + subSchema2 + "]}}}"; - doTest(schema, "prop:\n - foxtrot: 15\n kilo: 20"); + doTest(schema, "prop:\n - foxtrot: 15\n kilo: 20"); } public void testPatternPropertiesHighlighting() { @@ -392,7 +392,7 @@ public class YamlByJsonSchemaHighlightingTest extends JsonSchemaHighlightingTest public void testRootObjectRedefinedAdditionalPropertiesForbidden() { - doTest(rootObjectRedefinedSchema(), "a: true\n" + + doTest(rootObjectRedefinedSchema(), "a: true\n" + "r1: allowed!"); } diff --git a/plugins/yaml/testSrc/org/jetbrains/yaml/schema/YamlByJsonSchemaQuickFixTest.java b/plugins/yaml/testSrc/org/jetbrains/yaml/schema/YamlByJsonSchemaQuickFixTest.java index 1e3b72c3b7ec..86842f342bc5 100644 --- a/plugins/yaml/testSrc/org/jetbrains/yaml/schema/YamlByJsonSchemaQuickFixTest.java +++ b/plugins/yaml/testSrc/org/jetbrains/yaml/schema/YamlByJsonSchemaQuickFixTest.java @@ -53,7 +53,7 @@ public class YamlByJsonSchemaQuickFixTest extends JsonSchemaQuickFixTestBase { "c": {} }, "additionalProperties": false - }""", "a: 5\nb: 6\nc: 7", "Remove prohibited property 'b'", "a: 5\n" + + }""", "a: 5\nb: 6\nc: 7", "Remove prohibited property 'b'", "a: 5\n" + "c: 7"); } diff --git a/plugins/yaml/testSrc/org/jetbrains/yaml/schema/YamlByYamlSchemaHighlightingTest.java b/plugins/yaml/testSrc/org/jetbrains/yaml/schema/YamlByYamlSchemaHighlightingTest.java index 4f2a156130cb..d7c0ce249a45 100644 --- a/plugins/yaml/testSrc/org/jetbrains/yaml/schema/YamlByYamlSchemaHighlightingTest.java +++ b/plugins/yaml/testSrc/org/jetbrains/yaml/schema/YamlByYamlSchemaHighlightingTest.java @@ -218,7 +218,7 @@ public class YamlByYamlSchemaHighlightingTest extends JsonSchemaHighlightingTest public void testAdditionalPropertiesDisabled() { @Language("YAML") final String schema = "{\"type\": \"object\", \"properties\": {\"prop\": {}}, \"additionalProperties\": false}"; // not sure abt inner object - doTestYaml(schema, "prop:\n q: true\nsomeStuff: 20"); + doTestYaml(schema, "prop:\n q: true\nsomeStuff: 20"); } public void testAdditionalPropertiesSchema() { @@ -301,7 +301,7 @@ public class YamlByYamlSchemaHighlightingTest extends JsonSchemaHighlightingTest "\"innerType\":{}, \"innerValue\":{}" + "}, \"additionalProperties\": false" + "}}"); - doTestYaml(schema, "prop:\n- innerType: aaa\n alien: bee"); + doTestYaml(schema, "prop:\n- innerType: aaa\n alien: bee"); } public void testObjectDeeperInArray() { @@ -312,7 +312,7 @@ public class YamlByYamlSchemaHighlightingTest extends JsonSchemaHighlightingTest "}, \"additionalProperties\": false" + "}}"); doTestYaml(schema, - "prop:\n- innerType:\n only: true\n hidden: false"); + "prop:\n- innerType:\n only: true\n hidden: false"); } public void testInnerObjectPropValueInArray() { @@ -325,7 +325,7 @@ public class YamlByYamlSchemaHighlightingTest extends JsonSchemaHighlightingTest @Language("YAML") final String schema = "{\"allOf\": [{\"type\": \"object\", \"properties\": {\"first\": {}}}," + " {\"properties\": {\"second\": {\"enum\": [33,44]}}}], \"additionalProperties\": false}"; // doTestYaml(schema, "first: true\nsecond: null"); - doTestYaml(schema, "first: true\nsecond: 44\nother: 15"); + doTestYaml(schema, "first: true\nsecond: 44\nother: 15"); doTestYaml(schema, "first: true\nsecond: 12"); } @@ -333,7 +333,7 @@ public class YamlByYamlSchemaHighlightingTest extends JsonSchemaHighlightingTest final String subSchema1 = "{\"enum\": [1,2,3,4,5]}"; final String subSchema2 = "{\"type\": \"array\", \"items\": {\"properties\": {\"kilo\": {}}, \"additionalProperties\": false}}"; @Language("YAML") final String schema = "{\"properties\": {\"prop\": {\"oneOf\": [" + subSchema1 + ", " + subSchema2 + "]}}}"; - doTestYaml(schema, "prop:\n - foxtrot: 15\n kilo: 20"); + doTestYaml(schema, "prop:\n - foxtrot: 15\n kilo: 20"); } public void testPatternPropertiesHighlighting() { @@ -423,7 +423,7 @@ public class YamlByYamlSchemaHighlightingTest extends JsonSchemaHighlightingTest public void testRootObjectRedefinedAdditionalPropertiesForbidden() { - doTestYaml(rootObjectRedefinedSchema(), "a: true\n" + + doTestYaml(rootObjectRedefinedSchema(), "a: true\n" + "r1: allowed!"); }