feat(extraction): same-file value-reference edges for impact analysis — 15 languages (#897)
Adds same-file value-reference edges (reader symbol → const/var it reads) so impact analysis catches a constant's same-file consumers, closing the 'change this table, break its readers' hole. 15 languages validated S/M/L on public OSS: TS/JS/tsx, Go, Python, Rust, Ruby, C, Java, C#, PHP, Scala, Kotlin, Swift, Dart, Pascal/Delphi (+ Svelte/Vue/Astro inherited). Edges-only — node count identical on/off; default ON, CODEGRAPH_VALUE_REFS=0 opts out.
This commit is contained in:
@@ -133,6 +133,28 @@ export const dartExtractor: LanguageExtractor = {
|
||||
callTypes: [], // Dart calls use identifier+selector, handled via extractBareCall
|
||||
variableTypes: [],
|
||||
extraClassNodeTypes: ['mixin_declaration', 'extension_declaration'],
|
||||
// A Dart `static_final_declaration` is exactly a top-level or class-`static`
|
||||
// `const`/`final` — the shared-constant idiom — so extract it as `constant`
|
||||
// for value-reference edges. Instance fields, `var`, and typed declarations
|
||||
// use `initialized_identifier`, and method-locals use
|
||||
// `initialized_variable_definition`; neither is this node, so there are no
|
||||
// instance/local leaks to guard. The name is the first `identifier`; its
|
||||
// parent scope (`file:` top-level / `class:` static member) comes from the
|
||||
// node stack, both of which the value-reference target gate accepts.
|
||||
visitNode: (node, ctx) => {
|
||||
if (node.type === 'static_final_declaration') {
|
||||
const nameNode = node.namedChildren.find((c: SyntaxNode) => c.type === 'identifier');
|
||||
if (nameNode) {
|
||||
const valueNode = nameNode.nextNamedSibling;
|
||||
const initValue = valueNode ? getNodeText(valueNode, ctx.source).slice(0, 100) : undefined;
|
||||
ctx.createNode('constant', getNodeText(nameNode, ctx.source), node, {
|
||||
signature: initValue ? `= ${initValue}${initValue.length >= 100 ? '...' : ''}` : undefined,
|
||||
});
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
},
|
||||
resolveBody: (node, bodyField) => {
|
||||
// Dart: function_body is a next sibling of function_signature/method_signature
|
||||
if (node.type === 'function_signature' || node.type === 'method_signature') {
|
||||
|
||||
Reference in New Issue
Block a user