mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-01-08 15:09:39 +07:00
WEB-50759 JsonSchema: "deprecationMessage" not recognized when using "$ref" or "anyOf"
GitOrigin-RevId: 8854086ca20284308b5f09ea53c08d48ea513e43
This commit is contained in:
committed by
intellij-monorepo-bot
parent
b87bb253da
commit
c052e7855d
@@ -322,6 +322,9 @@ public final class JsonSchemaObject {
|
||||
if (!StringUtil.isEmptyOrSpaces(other.myHtmlDescription)) {
|
||||
myHtmlDescription = other.myHtmlDescription;
|
||||
}
|
||||
if (!StringUtil.isEmptyOrSpaces(other.myDeprecationMessage)) {
|
||||
myDeprecationMessage = other.myDeprecationMessage;
|
||||
}
|
||||
|
||||
myType = mergeTypes(myType, other.myType, other.myTypeVariants);
|
||||
|
||||
|
||||
@@ -10,6 +10,7 @@ import com.intellij.json.psi.JsonProperty;
|
||||
import com.intellij.json.psi.JsonValue;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.psi.PsiElementVisitor;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import com.jetbrains.jsonSchema.extension.JsonLikePsiWalker;
|
||||
import com.jetbrains.jsonSchema.ide.JsonSchemaService;
|
||||
import com.jetbrains.jsonSchema.impl.JsonSchemaObject;
|
||||
@@ -40,7 +41,14 @@ public class JsonSchemaDeprecationInspection extends JsonSchemaBasedInspectionBa
|
||||
if (position == null) return;
|
||||
|
||||
final MatchResult result = new JsonSchemaResolver(project, schema, position).detailedResolve();
|
||||
for (JsonSchemaObject object : result.mySchemas) {
|
||||
Iterable<JsonSchemaObject> iterable;
|
||||
if (result.myExcludingSchemas.size() == 1) {
|
||||
iterable = ContainerUtil.concat(result.mySchemas, result.myExcludingSchemas.get(0));
|
||||
} else {
|
||||
iterable = result.mySchemas;
|
||||
}
|
||||
|
||||
for (JsonSchemaObject object : iterable) {
|
||||
String message = object.getDeprecationMessage();
|
||||
if (message != null) {
|
||||
holder.registerProblem(o.getNameElement(), JsonBundle.message("property.0.is.deprecated.1", o.getName(), message));
|
||||
|
||||
@@ -10,10 +10,12 @@ import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.testFramework.PlatformTestUtil;
|
||||
import com.intellij.util.containers.Predicate;
|
||||
import com.jetbrains.jsonSchema.impl.inspections.JsonSchemaComplianceInspection;
|
||||
import com.jetbrains.jsonSchema.impl.inspections.JsonSchemaDeprecationInspection;
|
||||
import org.intellij.lang.annotations.Language;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@@ -1085,13 +1087,20 @@ public class JsonSchemaHighlightingTest extends JsonSchemaHighlightingTestBase {
|
||||
"}");
|
||||
}
|
||||
|
||||
public void testDeprecation() {
|
||||
doTest("{\"properties\": {\n" +
|
||||
" \"myPropertyXxx\": {\n" +
|
||||
" \"deprecationMessage\": \"Baz\",\n" +
|
||||
" \"description\": \"Foo bar\"\n" +
|
||||
" }\n" +
|
||||
" }}", "{ <weak_warning descr=\"Property 'myPropertyXxx' is deprecated: Baz\">\"myPropertyXxx\"</weak_warning>: \"a\" }");
|
||||
public void testDeprecation() throws IOException {
|
||||
myFixture.enableInspections(JsonSchemaDeprecationInspection.class);
|
||||
@Language("JSON") String schemaText = FileUtil.loadFile(new File(getTestDataPath() + "/deprecation.json"));
|
||||
configureInitially(schemaText,
|
||||
" {\n" +
|
||||
" \"framework\": \"vue\",\n" +
|
||||
" <weak_warning descr=\"Property 'directProperty' is deprecated: Baz\">\"directProperty\"</weak_warning>: <warning descr=\"Incompatible types.\n" +
|
||||
" Required: number. Actual: string.\">\"foo\"</warning>,\n" +
|
||||
" <weak_warning descr=\"Property 'vue-modifiers' is deprecated: Contribute Vue directives to /contributions/html/vue-directives\">\"vue-modifiers\"</weak_warning>: [{\n" +
|
||||
" \"name\": \"foo\"\n" +
|
||||
" }],\n" +
|
||||
" <weak_warning descr=\"Property 'description-markup' is deprecated: Use top-level property.\">\"description-markup\"</weak_warning>: \"html\"\n" +
|
||||
" }", "json");
|
||||
myFixture.checkHighlighting(true, false, true);
|
||||
}
|
||||
|
||||
public void testIfThenElseFlat() throws Exception {
|
||||
|
||||
66
json/tests/testData/jsonSchema/highlighting/deprecation.json
Normal file
66
json/tests/testData/jsonSchema/highlighting/deprecation.json
Normal file
@@ -0,0 +1,66 @@
|
||||
{
|
||||
"$schema": "https://json-schema.org/draft-04/schema#",
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"$schema": {
|
||||
"type": "string"
|
||||
},
|
||||
"directProperty": {
|
||||
"deprecationMessage": "Baz",
|
||||
"description": "Foo bar",
|
||||
"type": "number"
|
||||
},
|
||||
"framework": {
|
||||
"description": "Framework, for which the components are provided by the library",
|
||||
"type": "string"
|
||||
},
|
||||
"vue-modifiers": {
|
||||
"description": "Deprecated vue-specific property - contribute Vue directives to /contributions/html/vue-directives",
|
||||
"deprecationMessage": "Contribute Vue directives to /contributions/html/vue-directives",
|
||||
"type": "array",
|
||||
"items": {
|
||||
"$ref": "#/definitions/deprecated-html-attribute-vue-modifier"
|
||||
}
|
||||
},
|
||||
"description-markup": {
|
||||
"$ref": "#/definitions/deprecated-description-markup"
|
||||
}
|
||||
},
|
||||
"additionalProperties": false,
|
||||
"definitions": {
|
||||
"deprecated-description-markup": {
|
||||
"description": "Deprecated, use top-level property.",
|
||||
"deprecationMessage": "Use top-level property.",
|
||||
"oneOf": [
|
||||
{
|
||||
"$ref": "#/definitions/description-markup"
|
||||
}
|
||||
]
|
||||
},
|
||||
"description-markup": {
|
||||
"description": "Markup language in which descriptions are formatted",
|
||||
"type": "string",
|
||||
"default": "none",
|
||||
"enum": [
|
||||
"html",
|
||||
"markdown",
|
||||
"none"
|
||||
]
|
||||
},
|
||||
"deprecated-html-attribute-vue-modifier": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"name": {
|
||||
"type": "string"
|
||||
},
|
||||
"doc-url": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"name"
|
||||
],
|
||||
"additionalProperties": false
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user