Skip to content

feat: refactor to use diagnostics providers#6

Merged
srivastava-diya merged 4 commits into
hyperjump-io:mainfrom
srivastava-diya:feature/schema-validation
Jun 1, 2026
Merged

feat: refactor to use diagnostics providers#6
srivastava-diya merged 4 commits into
hyperjump-io:mainfrom
srivastava-diya:feature/schema-validation

Conversation

@srivastava-diya
Copy link
Copy Markdown
Collaborator

Description

This PR adds JSON schema validation using @hyperjump/json-schema and @hyperjump/json-schema-errors

Changes

  1. In SyntaxValidation.ts : Extracted the syntax diagnostic logic from JsonValidation.ts into a standalone function getSyntaxDiagnostics(textDocument, parseErrors): Diagnostic[]. No server, no connection just input and output.

  2. In SchemaValidation.ts : A standalone function getSchemaDiagnostics(textDocument, tree, schemaUri, documentMap) that handles schema validation. It reads the $schema field from the document, parses the JSON, runs it through @hyperjump/json-schema's validate() with BASIC output format, and maps errors back to document ranges . Also contains MatchingSchemaCollector , an EvaluationPlugin that hooks into evaluation lifecycle via afterKeyword to collect per-instance-location schema matches. Not used for validation itself, but will power future features like hover tooltips and completions.

  3. In JsonValidation.ts : it acts as the orchestrator now. Calls both getSyntaxDiagnostics and getSchemaDiagnostics, and sends a single combined sendDiagnostics call thus prevents overwriting.

  4. Integrated @hyperjump/json-schema-errors for better error messages. Added a formatError helper that recursively formats nested anyOf/oneOf alternatives with indentation.

  5. Tests added: valid case, invalid case with message content assertions, and anyOf and OneOf formatting case.

Screenshots

Screenshot 2026-05-30 024931 Screenshot 2026-05-30 024915 Screenshot 2026-05-30 014744 Screenshot 2026-05-30 025112

@srivastava-diya srivastava-diya marked this pull request as draft May 30, 2026 12:58
Updated comment for clarity on onDidChangeContent handler.
@srivastava-diya srivastava-diya marked this pull request as ready for review May 30, 2026 13:22
@jdesrosiers jdesrosiers changed the title feat: add schema validation with human-readable error messages feat: refactor to use diagnostics providers Jun 1, 2026
@srivastava-diya srivastava-diya merged commit 0d9ff41 into hyperjump-io:main Jun 1, 2026
3 checks passed
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