Skip to content

add value completion. - #67

Open
srivastava-diya wants to merge 9 commits into
hyperjump-io:mainfrom
srivastava-diya:value-completion-simple
Open

add value completion.#67
srivastava-diya wants to merge 9 commits into
hyperjump-io:mainfrom
srivastava-diya:value-completion-simple

Conversation

@srivastava-diya

@srivastava-diya srivastava-diya commented Aug 6, 2026

Copy link
Copy Markdown
Collaborator

Description

  1. Suggests values for a property based on what its schema allows. Completion.ts is now an orchestrator over two providers PropertyCompletion for keys, ValueCompletion for values and MatchingSchemaCollector is split into AnnotationEvaluationPlugin and CompletionEvaluationPlugin.

  2. What it suggests

  • const / enum → the exact permitted values
  • type → a snippet placeholder per type ("", {}, [], true/false, null, number, integer)
  • both, when a schema permits specific values and anything beyond them, for Eg.
"anyOf": [
  {"enum": ["uri","ipv4","ipv6"]}, 
  {"type": "string"}
] 
  1. Keywords handled
    type enum const not allOf anyOf oneOf if/then/else $ref properties additionalProperties required

  2. There are two paths, and they exist for different reasons:

  • Evaluation hooks observe the validator running, keyed by instance pointer. This covers combinators at the object level, at any nesting depth, including inside array items.
  • resolveValueInfo helper reads a property's own subschema statically, because when we're typing "color": there's no value yet for the validator to go into. That path has to interpret applicator keywords itself, which is why $ref and then/else appear there explicitly.

Out of scope for this PR.

  • Filtering keywords (minLength, pattern, minimum, …) will be a follow-up.
  • Decorations will be seperate PR

Testing

45 value-completion tests (1 skipped) , all asserting the complete response. Value tests are grouped by keyword with comment markers.

Comment thread language-server/src/features/PropertyCompletion.test.ts Outdated
Comment thread language-server/src/features/ValueCompletion.ts Outdated
Comment thread language-server/src/features/ValueCompletion.ts Outdated
@srivastava-diya
srivastava-diya force-pushed the value-completion-simple branch from b37520c to 3d7462f Compare August 17, 2026 20:14
@srivastava-diya
srivastava-diya marked this pull request as ready for review August 17, 2026 20:17
@srivastava-diya srivastava-diya changed the title use completionProvider and seperate value and key completion. add value completion. Aug 17, 2026

@jdesrosiers jdesrosiers left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I pushed a few minor updates for style and performance. But, more importantly, I added a couple tests to expose some edge cases that were missed.

Overall, I'm not comfortable with how complex this got. I feel like there must be simpler way, but it's ok for now.

@jdesrosiers
jdesrosiers force-pushed the value-completion-simple branch from ad49419 to 64c03b9 Compare August 23, 2026 22:38
@srivastava-diya

Copy link
Copy Markdown
Collaborator Author

I added a couple tests to expose some edge cases that were missed.

Thanks for adding those.

Overall, I'm not comfortable with how complex this got. I feel like there must be simpler way, but it's ok for now.

i know, it looks pretty overwhelming, i am working on simplifying the logic, i'll update you with the progress very soon.

context.negated = keywordId === "https://json-schema.org/keyword/not" ? !negated : negated;
context.isAnyOf = keywordId === "https://json-schema.org/keyword/anyOf" ? true : (schemaContext.isAnyOf ?? false);
context.isOneOf = keywordId === "https://json-schema.org/keyword/oneOf" ? true : (schemaContext.isOneOf ?? false);
context.inIfCondition = keywordId === "https://json-schema.org/keyword/if" ? true : (schemaContext.inIfCondition ?? false);

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if is a condition, not a constraint, it tests the data, it doesn't restrict it so without this flag we will walk into the if subschema and record its properties as a real constraint on the same property. That constraint then gets intersected with the property's actual schema, which wrongly narrows the completions, hence this flag is necessary.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants