mirror of
https://github.com/colbymchenry/codegraph.git
synced 2026-10-29 06:46:49 +08:00
fix(js,ts): .tsx and .jsx classes link their overrides as .ts and .js classes do (#2828)
The interface-impl pass links a base class's or an interface's method
to each subclass's override, so a call through the base reaches the
method that runs. It took a class's methods, and its supertype, by
language: typescript and javascript were in its language set, and tsx
and jsx were not. A class in a .tsx or .jsx file got no override
edges, and neither did a .ts class whose base or interface was in a
.tsx file. The pass's own gate, the static/instance split of #2761
and the other JS-family lists already count tsx and jsx, and the
set's history (#494, #708) gives no reason for leaving them out.
tsx and jsx are now in the set, so these classes get the edges that
.ts and .js classes get, statics paired with statics.
Validation: the new test fails 4 of 4 on main 013b91c1 and passes 4
of 4 on the fix, and dropping tsx or jsx alone from the set fails the
tests for it. A/B against main on 11 repos: outline gains 262 override
edges in 42 base-subclass pairs (26 emails overriding BaseEmail's
subject, render and preview; editor nodes, marks and extensions
overriding Node, Mark and Extension) and lexical 27 in 12, grouped by
pair and sampled against the source, none pairing a static with an
instance method. Nodes and all other edges are unchanged. excalidraw,
social-app, insomnia, two .jsx apps and the controls (three, webpack,
flask, gin) are byte-identical: their .tsx classes extend React's or
other packages' classes. explore on outline now leads with the flow
BaseEmail.send -> render -> WelcomeEmail.render, where main finds
none. A sync that adds an interface method, adds an override and
drops a subclass's base matches a fresh index. The pass takes 65-108
ms on both arms, and index time, median of 3 interleaved runs on
lexical, outline, excalidraw and social-app, is +1.7% in total, noise.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
58eb57a324
commit
5b47bc4963
@@ -820,16 +820,17 @@ async function cppOverrideEdges(queries: QueryBuilder, ctx: ResolutionContext, o
|
||||
// kind that holds methods" — i.e. the shape this loop expects. Swift and
|
||||
// Scala fit shape-wise (Swift `protocol`/`class`, Scala `trait`/`class`)
|
||||
// and are added below; their concrete-side nodes can be a `struct` (Swift)
|
||||
// or an `object` (Scala) so the loop also iterates those kinds.
|
||||
// or an `object` (Scala) so the loop also iterates those kinds. A `.tsx` or
|
||||
// `.jsx` class is a TypeScript or JavaScript class, and its base or interface
|
||||
// is often in a `.ts` file, or the other way round.
|
||||
const IFACE_OVERRIDE_LANGS = new Set([
|
||||
'java', 'kotlin', 'csharp', 'typescript', 'javascript', 'swift', 'scala', 'go', 'rust',
|
||||
'java', 'kotlin', 'csharp', 'typescript', 'tsx', 'javascript', 'jsx', 'swift', 'scala', 'go', 'rust',
|
||||
'arkts',
|
||||
]);
|
||||
/**
|
||||
* Languages whose static and instance methods override only their own kind:
|
||||
* a JS/TS class's statics are inherited and overridden by the subclass's
|
||||
* statics, its instance methods by instance methods (#2761). tsx and jsx
|
||||
* follow the same rule, though this pass doesn't walk their classes today.
|
||||
* statics, its instance methods by instance methods (#2761).
|
||||
*/
|
||||
const STATIC_SPLIT_LANGS: ReadonlySet<string> = new Set(['typescript', 'tsx', 'javascript', 'jsx']);
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user