Skip to content

Graphs that teach > graphs that impress. Turn any code into an interactive knowledge graph you can explore, search, and ask questions about. Works with Claude Code, Codex, Cursor, Copilot, Gemini CLI, and more.

fix(core): apply assignment evidence to TSX and JSX grammars

Lum110495486839b1f7
diff --git a/tests/skill/understand/test_incremental_symbols.test.mjs b/tests/skill/understand/test_incremental_symbols.test.mjs
index 5551472a..f9c899bb 100644
--- a/tests/skill/understand/test_incremental_symbols.test.mjs
+++ b/tests/skill/understand/test_incremental_symbols.test.mjs
@@ -18,6 +18,16 @@ const compare = (oldNodes, newNodes, oldSource, newSource) => compareFileSymbols
);
describe('incremental symbol matching', () => {
+ it.each(['ts', 'tsx', 'js', 'jsx', 'mts', 'cts', 'mjs', 'cjs'])('rejects computed assignment deletion evidence in .%s', extension => {
+ const filePath = `src/a.${extension}`;
+ const before = parser.analyzeFileStrict(filePath, 'class A { run() {} }');
+ const after = parser.analyzeFileStrict(filePath, 'class A { keep() {} }; A.prototype["r" + "un"] = function() {};');
+ expect(before.status).toBe('succeeded');
+ expect(after.status).toBe('succeeded');
+ const previous = graph([node('A.run', { filePath, id: `function:${filePath}:A.run` })]);
+ expect(compareFileSymbols(previous, graph([]), before, after).missing[0].status).toBe('unknown');
+ });
+
it.each([
['go', 'Run', 'package p\ntype A struct{}\ntype B struct{}\n', owner => `func (x ${owner}) Run() {}\n`, 'func Run() {}\n'],
['rs', 'run', 'struct A;\nstruct B;\n', owner => `impl ${owner} { fn run(&self) {} }\n`, 'fn run() {}\n'],
diff --git a/understand-anything-plugin/packages/core/src/plugins/tree-sitter-plugin.test.ts b/understand-anything-plugin/packages/core/src/plugins/tree-sitter-plugin.test.ts
index ed168542..909d7116 100644
--- a/understand-anything-plugin/packages/core/src/plugins/tree-sitter-plugin.test.ts
+++ b/understand-anything-plugin/packages/core/src/plugins/tree-sitter-plugin.test.ts
@@ -379,7 +379,7 @@ export class Greeter {
expect(strict.hasUnresolvedNames).toBe(false);
});
- it("exposes unresolved computed and escaped declaration names", () => {
+ it.each(["test.js", "test.jsx", "test.ts", "test.tsx"])("exposes unresolved computed and escaped names in %s", (filePath) => {
for (const code of [
'class A { ["r" + "un"]() {} keep() {} }',
String.raw`class A { r\u0075n() {} keep() {} }`,
@@ -389,13 +389,13 @@ export class Greeter {
'class A { keep() {} }; ({method: A.prototype[key]} = obj);',
String.raw`class A { keep() {} }; A.prototype.r\u0075n = function() {};`,
]) {
- const result = plugin.analyzeFileStrict("test.js", code);
+ const result = plugin.analyzeFileStrict(filePath, code);
expect(result.status).toBe("succeeded");
expect(result.hasUnresolvedNames).toBe(true);
}
- expect(plugin.analyzeFileStrict("test.js", String.raw`function keep(r\u0075n) { return r\u0075n; }`)
+ expect(plugin.analyzeFileStrict(filePath, String.raw`function keep(r\u0075n) { return r\u0075n; }`)
.hasUnresolvedNames).toBe(false);
- expect(plugin.analyzeFileStrict("test.js", 'class A { keep() { return this["x" + "y"]; } }')
+ expect(plugin.analyzeFileStrict(filePath, 'class A { keep() { return this["x" + "y"]; } }')
.hasUnresolvedNames).toBe(false);
});
});
diff --git a/understand-anything-plugin/packages/core/src/plugins/tree-sitter-plugin.ts b/understand-anything-plugin/packages/core/src/plugins/tree-sitter-plugin.ts
index 2f35156c..bafd715a 100644
--- a/understand-anything-plugin/packages/core/src/plugins/tree-sitter-plugin.ts
+++ b/understand-anything-plugin/packages/core/src/plugins/tree-sitter-plugin.ts
@@ -314,7 +314,7 @@ export class TreeSitterPlugin implements AnalyzerPlugin {
|| (methodName?.type === "string" && methodName.text.includes("\\"))) {
hasUnresolvedNames = true;
}
- if (!hasUnresolvedNames && ["typescript", "javascript"].includes(langKey!)
+ if (!hasUnresolvedNames && extractor.languageIds.some(id => id === "typescript" || id === "javascript")
&& ["assignment_expression", "augmented_assignment_expression"].includes(node.type)) {
// Methods can also be installed through prototype/object writes.
// Inspect the entire target for destructuring and wrapped accesses;