Skip to content

refactor: organise LSP backed + improved diagnostics - #12

Merged
KyrylR merged 2 commits into
masterfrom
feature/diagnostic-refactoring
Aug 19, 2026
Merged

refactor: organise LSP backed + improved diagnostics#12
KyrylR merged 2 commits into
masterfrom
feature/diagnostic-refactoring

Conversation

@KyrylR

@KyrylR KyrylR commented Aug 19, 2026

Copy link
Copy Markdown
Collaborator

Refactors the LSP analysis pipeline while fixing semantic highlighting and cross-file diagnostics.

Semantic highlighting

  • Replaces string-length-based call highlighting with lexer/span-based token extraction.
  • Highlights only callable identifiers instead of entire generic call expressions.
  • Separately highlights built-ins and function-valued generic arguments, such as array_fold and consume_budget.
  • Leaves punctuation, numeric bounds, and generic syntax to TextMate.
  • Preserves jet namespace/function splitting, macros, type casts, declarations, and UTF-16-safe positions.

Cross-file diagnostics

  • Retains compiler source maps in each analysis result.
  • Publishes imported-file errors against their actual file URI and source range, including unopened files.
  • Supports code, file-wide, and global diagnostic locations.
  • Preserves secondary labels as related information and includes compiler notes/help.
  • Retains filtering for synthetic entry-point noise and remapping for duplicate imported main errors.

Architecture

  • Introduces AnalysisSnapshot as the immutable result of analyzing an open root.
  • Introduces SourceSet as the authoritative compiler file-ID-to-URI/text mapping.
  • Extracts semantic tokens, diagnostics, and navigation into dedicated modules.
  • Introduces WorkspaceState to own open-root analyses and diagnostic publication policy.
  • Moves parsing, dependency resolution, type checking, source-map preservation, and visible-function construction out of the LSP backend.
  • Reduces the backend to protocol handling and feature orchestration.
  • Simplifies general utilities by moving analysis-specific logic into appropriate modules.

Diagnostic lifecycle

  • Atomically replaces each root’s diagnostic contribution.
  • Clears stale diagnostics when dependencies disappear or errors are corrected.
  • Aggregates and deduplicates diagnostics from roots sharing a dependency.
  • Gives directly analyzed unsaved buffers precedence over saved dependency copies.
  • Recomputes diagnostics when documents close.
  • Rejects stale analysis results by document version.
  • Sends versions only for directly analyzed documents.

Validation

  • Adds regression coverage for generic calls, built-ins, casts, jets, macros, UTF-16 positions, imported-file ranges, unopened dependencies, shared dependencies, deduplication, unsaved-buffer precedence, stale cleanup, document close, and duplicate imported main.
  • Rust tests, strict Clippy, formatting checks, and the complete VS Code validation suite pass.

@KyrylR
KyrylR requested a review from gerau August 19, 2026 09:57

@gerau gerau 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.

ACK 66d21d5; tested locally with VScode

comments are small nits, otherwise it is looking good

Comment thread src/analysis.rs
Comment thread src/analysis.rs
@KyrylR
KyrylR merged commit 1a6ea20 into master Aug 19, 2026
11 checks passed
@KyrylR
KyrylR deleted the feature/diagnostic-refactoring branch August 19, 2026 12:31
@KyrylR
KyrylR restored the feature/diagnostic-refactoring branch August 25, 2026 13:34
@KyrylR
KyrylR deleted the feature/diagnostic-refactoring branch August 25, 2026 13:34
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