Repository navigation
refactor(kotlin-wasm): read WIT with the shared AST parser instead of regexes - #76
Merged
Merged
Conversation
… regexes ParseWit scanned lines with funcRegex, ifaceRegex and packageRegex, which broke on multi-line functions, comments and versioned packages, and listed resource methods as interface functions. It now uses the lenient AST parser from tools/common/wit/ast, and MapTypeToKotlin maps the parsed type structurally instead of splitting strings on commas. Item 3 of #66. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
3 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Item 3 of #66 (Kotlin wasm side). Uses the shared parser from #73 and the
staticfix from #75, both synced here.please_kotlin_wasm.ParseWitscanned lines withfuncRegex,ifaceRegex,packageRegex. That missed functions over several lines, versioned packages, and put resource methods in the interface. Now:ParseWitusesast.ParseFileLenient(skipsuse/variant/flags, as the line scanner effectively did), keeping its old output (WitInterface, package asa.b).MapTypeToKotlin(*ast.TypeRef)replacesMapWitTypeToKotlin(string), which splitresult<...>on commas and so broke on nested generics. Same mapping for everything it handled;tupleis now an error naming the function and parameter instead of a bogus generated name.packagetake the package of another file in the directory (a WIT package spans its directory); before they got none.Not touched:
DetectPackage/hasClassInSourcesalso use regexes, but on Kotlin source, not WIT (separate item).Tests: the old mapping test, rewritten over parsed types plus nested generics; a structure test (comments, multi-line function, versioned package, use/variant/flags, a resource, a second file without package, a non-.wit file); tuple and syntax errors.
plz test //tools/please_kotlin_wasm/...: 13 passed.🤖 Generated with Claude Code