implement property key completion - #53
Conversation
|
I had a doubt, for example lets look at this {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"type": "object",
"oneOf": [
{
"properties": {
"foo": { "type": "string" },
"bar": { "type": "string" }
}
},
{
"properties": {
"foo": { "type": "string" },
"baz": { "type": "string" }
}
}
]
}And a user is typing this instance {
"$schema": "${fixtureSchemaUri}",
""
}here two |
|
also i wanted to ask if i am proceeding correctly? and if i am then how should i strengthen |
Sure.
This one is interesting, gonna add a test that covers this behavior. |
… from any alternative where that property fails.
jdesrosiers
left a comment
There was a problem hiding this comment.
I only had time to get through the tests, but they look great! I think the only thing left for this issue if figuring out what how not should work.
| expect(completions).toEqual([ | ||
| { label: "foo", kind: CompletionItemKind.Property } | ||
| ]); |
There was a problem hiding this comment.
I think this should include "a" as well, right? "c" is passing in alternative 2, but there is nothing in alternative 1 that matches "c" and fails. So, I would expect both "a" and "foo" to be suggested.
There was a problem hiding this comment.
Yes makes sense, I'll add the "a" as well
yeah and in addition to that i also need to implement the auto |
|
I'd consider that value completion to me. Let's get this merged first and work on that next. |
|
|
||
| type SchemaAnnotationContext = ValidationContext & { | ||
| pendingAnnotations?: Annotation; | ||
| declaredProperties?: string[]; |
There was a problem hiding this comment.
The property names a single branch's properties keyword declares, it lives on the branch's schemaContext
| type SchemaAnnotationContext = ValidationContext & { | ||
| pendingAnnotations?: Annotation; | ||
| declaredProperties?: string[]; | ||
| passedProperties?: Set<string>; |
There was a problem hiding this comment.
passedProperties the names of properties whose values were valid, added there by each property's own check as it finishes.
| pendingAnnotations?: Annotation; | ||
| declaredProperties?: string[]; | ||
| passedProperties?: Set<string>; | ||
| failedProperties?: Set<string>; |
There was a problem hiding this comment.
failedProperties Same as above, but for evaluations that returned not valid. Also keyword-scoped so properties, additionalProperties, and patternProperties each accumulate their own.
| declaredProperties?: string[]; | ||
| passedProperties?: Set<string>; | ||
| failedProperties?: Set<string>; | ||
| rejectedProperties?: Set<string>; |
There was a problem hiding this comment.
rejectedProperties The branch level union of every failedProperties set added in from properties additionalproperties , patternproperties under that branch
|
Hey @jdesrosiers following up on |
|
I think this is ready for a look. Property key completion is working with |




Adds property-key completion, for
propertieskeyword for now.MatchingSchemaCollector collects the
propertieskeyword's value directly during validation through afterKeyword.Completion and Hover now resolve the AST node via findNodeAtPosition and read annotations from it.
validateSchema uses jsonc.parse.
Tests: no properties, flat properties, nested object properties.