Skip to content

refactor: remove duplicated code & split constraint solver - #34

Merged
desertthunder merged 3 commits into
mainfrom
refactor/constraint-dupes
May 11, 2026
Merged

desertthunder merged 3 commits into
mainfrom
refactor/constraint-dupes

Conversation

@desertthunder

Copy link
Copy Markdown
Contributor

This PR refactors duplicated constraint, AST, source-position, and annotation helper logic into shared modules while preserving existing analyzer and LSP behavior.

Changes

Constraint solver modularization
  • Split the constraint crate's solver implementation into focused modules for models, generation context, control-flow tracking, pattern compatibility, equality, calls, attributes, protocols, pattern constraints, joins, narrowing, state, and error recovery.
  • Kept constraint types crate-local
  • Deduplicated shared pattern/class compatibility helpers into and reused them across pattern validation and solver paths.
Shared parser and AST helpers
  • Added parser-level SourceRange and byte-offset helpers so analyzer, constraints, and server code no longer need local line/column conversion copies.
  • Added shared AstNode helpers for source ranges, statement/body traversal, child expression traversal, binding names, and target display.
  • Added structured comprehension targets via Comprehension::target_node, allowing destructuring bindings to use AST-backed extraction instead of string splitting when available.
  • Added parser test builders for common AST node shapes and coverage for source ranges, traversal helpers, comprehension targets, pattern binding names, and UTF-8 source-position conversion.
Analyzer, server, and core cleanup
  • Updated analyzer walker/data-flow code to consume parser-owned source and binding helpers.
  • Updated server diagnostics, inlay hints, semantic tokens, workspace parsing, and analysis code to use shared AST/source helpers.

@desertthunder
desertthunder requested review from Copilot and removed request for Copilot May 11, 2026 04:49
@desertthunder
desertthunder enabled auto-merge (squash) May 11, 2026 04:50
@desertthunder
desertthunder merged commit d30b9cb into main May 11, 2026
4 checks passed
@desertthunder
desertthunder deleted the refactor/constraint-dupes branch May 11, 2026 04:54
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.

1 participant