Skip to content

refactor(wit): discover worlds and package with the AST parser - #74

Merged
walterjgsp merged 2 commits into
witfrom
fix/wit-discovery-ast
Oct 4, 2026
Merged

walterjgsp merged 2 commits into
witfrom
fix/wit-discovery-ast

Conversation

@walterjgsp

Copy link
Copy Markdown
Contributor

Item 3 of #66 (wit side). Depends on the shared parser from #73, already synced here.

DiscoverWorlds/DiscoverPackage scanned lines with worldRegex/packageRegex. The package regex did not match package wasi:cli@0.2.0; at all (returned empty), and a line scan can't tell a comment or a second declaration on the same line. They now use ast.ParseFileLenient (skips use/variant/flags, which discovery doesn't need).

  • Behaviour kept: non-recursive directory scan in sorted order, worlds deduplicated in first-seen order, first package wins, a missing path is an error.
  • Behaviour changed on purpose: a file that does not parse is an error naming the file (generation parses strictly anyway); before, it was skipped silently.
  • tools/please_wit/ast is removed; imports, BUILD deps and docs point to tools/common/wit/ast.
  • Removed the tests of the deleted regex helpers; added 5 for what they got wrong (versioned package, comments, two worlds on a line, unmodelled declarations, syntax error).

plz test //tools/please_wit/... //tools/common/wit/...: 325 passed.

🤖 Generated with Claude Code

walterjgsp and others added 2 commits October 4, 2026 15:19
DiscoverWorlds and DiscoverPackage scanned lines with regexes that missed versioned packages and tripped on comments. They now use the shared lenient AST parser from tools/common/wit/ast, and the branch's copy of the parser is removed. Item 3 of #66.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@walterjgsp
walterjgsp merged commit cea7621 into wit Oct 4, 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.

1 participant