Skip to content

fix: improve ParseDiagnostic display format#330

Merged
bartlomieju merged 1 commit into
denoland:mainfrom
bartlomieju:fix/improve-parse-diagnostic-display
May 2, 2026
Merged

fix: improve ParseDiagnostic display format#330
bartlomieju merged 1 commit into
denoland:mainfrom
bartlomieju:fix/improve-parse-diagnostic-display

Conversation

@bartlomieju
Copy link
Copy Markdown
Member

@bartlomieju bartlomieju commented Mar 14, 2026

Summary

  • Add SyntaxError: prefix to ParseDiagnostic::Display output
  • Show line numbers with pipe margins and move location after the snippet
  • Refactor get_range_text_highlight into get_range_highlight_entries returning structured HighlightEntry data instead of a plain string

Before:

Expression expected at file:///my_file.ts:1:22

  setTimeout(() => {}),
                       ~

After:

SyntaxError: Expression expected
  |
1 | setTimeout(() => {}),
  |                      ~
    at file:///my_file.ts:1:22

Context

This was requested as part of denoland/deno_graph#637 (review) — the formatting logic belongs in deno_ast rather than being done by parsing the display string in deno_graph.

bartlomieju added a commit to bartlomieju/deno_graph that referenced this pull request Mar 14, 2026
Remove string-parsing logic (clean_parse_message, format_parse_diagnostic)
from deno_graph and delegate to deno_ast's improved ParseDiagnostic::Display.

See: denoland/deno_ast#330

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Comment thread src/types.rs Outdated
Comment thread src/parsing.rs Outdated
@bartlomieju bartlomieju force-pushed the fix/improve-parse-diagnostic-display branch from 5d01e64 to 97631e5 Compare March 14, 2026 14:06
bartlomieju added a commit to bartlomieju/deno_graph that referenced this pull request Mar 14, 2026
Remove string-parsing logic (clean_parse_message, format_parse_diagnostic)
from deno_graph and delegate to deno_ast's improved ParseDiagnostic::Display.

See: denoland/deno_ast#330

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@bartlomieju bartlomieju force-pushed the fix/improve-parse-diagnostic-display branch from 97631e5 to 4dccfb4 Compare March 14, 2026 14:07
@bartlomieju bartlomieju requested a review from dsherret March 14, 2026 14:07
Restructure the error display to show line numbers with pipe margins,
add SyntaxError: prefix, and move the location after the snippet.

Refactors get_range_text_highlight to return structured HighlightEntry
data instead of a plain string, enabling direct formatting with line
numbers without string parsing.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@bartlomieju bartlomieju force-pushed the fix/improve-parse-diagnostic-display branch from 4dccfb4 to beb69fe Compare March 14, 2026 14:24
@bartlomieju bartlomieju merged commit 27fd940 into denoland:main May 2, 2026
2 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