Skip to content

Conversation

Copy link

Copilot AI commented Jan 23, 2026

  • Explore repository structure and understand the codebase
  • Run existing tests to confirm they pass (1194 tests passing)
  • Identify common parsing errors that should generate diagnostics
  • Extend diagnostics to detect and report syntax errors
  • Use the parser's built-in error detection (ParseError) for syntax errors
  • Added createDiagnosticFromParseError to convert parser errors to diagnostics
  • Added createDiagnosticFromError to handle generic Error exceptions
  • Updated getDiagnostics to call parser.parse() and capture any thrown errors
  • Updated tests to match the actual parser error messages (1210 tests passing)
  • Code review completed
Original prompt

Extend the diagnotics with other helpfull messages that can occur when an expression is invalid.


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI and others added 2 commits January 23, 2026 16:43
…s, comments)

Co-authored-by: Sander-Toonen <5106372+Sander-Toonen@users.noreply.github.com>
Co-authored-by: Sander-Toonen <5106372+Sander-Toonen@users.noreply.github.com>
Copilot stopped work on behalf of Sander-Toonen due to an error January 23, 2026 17:28
Copilot AI requested a review from Sander-Toonen January 23, 2026 17:28
@Sander-Toonen
Copy link

@copilot Please continue the previous task.

…rors

Co-authored-by: Sander-Toonen <5106372+Sander-Toonen@users.noreply.github.com>
Copy link
Author

Copilot AI commented Jan 23, 2026

@copilot Please continue the previous task.

Continued the task. Fixed the failing tests by updating them to match the actual parser error messages. Also added createDiagnosticFromError to handle generic Error exceptions (like "invalid object definition") in addition to ParseError instances. All 1210 tests now pass. Changes in commit 873b950.

@Sander-Toonen Sander-Toonen marked this pull request as ready for review January 23, 2026 17:58
Copilot AI review requested due to automatic review settings January 23, 2026 17:58
@Sander-Toonen Sander-Toonen merged commit 06f8773 into master Jan 23, 2026
8 checks passed
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This pull request extends the language service diagnostics to detect and report syntax errors in expressions. The implementation leverages the existing parser's error detection capabilities to provide helpful error messages for common syntax errors such as unclosed strings, unmatched brackets, unknown characters, and other parsing failures.

Changes:

  • Added syntax error detection by calling parser.parse() and catching thrown errors
  • Created helper functions createDiagnosticFromParseError and createDiagnosticFromError to convert parser errors into LSP diagnostics
  • Added comprehensive test coverage for various syntax error scenarios including unclosed strings, brackets, braces, and unknown characters

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
src/language-service/diagnostics.ts Added two new exported functions to create diagnostics from ParseError and generic Error objects, with appropriate position calculation and range highlighting
src/language-service/language-service.ts Modified getDiagnostics to parse expressions and catch syntax errors, importing the new diagnostic creation functions and handling tokenization failures gracefully
test/language-service/language-service.ts Added comprehensive test suite for syntax error diagnostics, covering unclosed delimiters, unknown characters, and valid expressions

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +43 to +44
createDiagnosticFromError,
TokenSpan
Copy link

Copilot AI Jan 23, 2026

Choose a reason for hiding this comment

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

The TokenSpan type is being imported from the diagnostics module, but it's only used internally within getDiagnostics and getDiagnosticsForDocument. Consider whether this export is necessary at the language-service module level, as it increases the API surface area without clear external usage.

Suggested change
createDiagnosticFromError,
TokenSpan
createDiagnosticFromError

Copilot uses AI. Check for mistakes.
* Analyzes the document for function calls and checks if they have the correct number of arguments.
* Returns diagnostics for function calls with incorrect argument counts.
* Returns diagnostics for function calls with incorrect argument counts, as well as
* syntax errors detected by the parser (unclosed strings, brackets, unknown characters, etc.).
Copy link

Copilot AI Jan 23, 2026

Choose a reason for hiding this comment

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

The comment states that this function returns diagnostics for "function calls with incorrect argument counts, as well as syntax errors detected by the parser" but it doesn't mention that it returns early without checking function arguments when tokenization fails. Consider updating the documentation to clarify that function argument checking is skipped when syntax errors prevent tokenization.

Suggested change
* syntax errors detected by the parser (unclosed strings, brackets, unknown characters, etc.).
* syntax errors detected by the parser (unclosed strings, brackets, unknown characters, etc.).
* If tokenization fails due to syntax errors, only syntax-error diagnostics are returned and
* function argument checking is skipped.

Copilot uses AI. Check for mistakes.
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