Repository navigation
feat: resolve JSX elements as call edges in the TypeScript/JavaScript plugin - #23
Merged
Merged
Conversation
… plugin Mounting a function component (<Foo />, <Foo>...</Foo>, <Foo.Bar />) is now resolved as a call, through the same identifier/member resolution _CallCollector already applies to call_expression - imports, local top-level functions, and the existing one-hop Foo.Bar limit. JSX desugars to a call, so this fits the existing Call edge concept. A lowercase intrinsic element (<div />) and a fragment (<>...</>) are never calls. A tag naming a class stays unresolved: a class has no single id in this plugin, only its methods do, so wiring it to the constructor would mean something the runtime doesn't (render() via the reconciler, not new). Closes #19
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.
Closes #19.
Mounting a function component (
<Foo />,<Foo>...</Foo>,<Foo.Bar />) is now resolved as a Call edge, through the same identifier/member resolution_CallCollectoralready applies tocall_expression- imports, local top-level functions, and the existing one-hopFoo.Barlimit. JSX desugars to a call, so it fits the existing Call edge concept rather than needing a new one.<div />) is never a call - JSX's own capitalization convention distinguishes a component from a DOM element.<>...</>) has no tag name and is never a call.<Foo />to the constructor would mean something the runtime doesn't - the real call isrender()via the reconciler.<Ns.Deep.Thing />) and hand-writtenReact.createElement(...)stay unresolved, same as the equivalent non-JSX call shapes.Extended
sample_typescript_project/withList.tsx: a function component that renders an imported component (resolves), a lowercase host element and a fragment (neither resolves), and the existingItemclass as a tag (stays unresolved).Verification
python -m backend.analyzerbefore/after on all three sample projects:sample_project: 16 functions / 17 edges, byte-identical.sample_rust_project: 8 functions / 6 edges, byte-identical.sample_typescript_project: 16→18 functions, 16→17 edges - exactly the two new fixture functions and the one newList → Rowedge; nothing else changed.Also hand-tested the resolver against namespace-import tags, object-literal member tags, and the one-hop member-chain limit.
backend.mainstill imports cleanly.