MCPcopy Create free account
hub / github.com/colbymchenry/codegraph / visitNode

Method visitNode

src/extraction/tree-sitter.ts:942–1309  ·  view source on GitHub ↗

* Visit a node and extract information

(node: SyntaxNode)

Source from the content-addressed store, hash-verified

940 * Visit a node and extract information
941 */
942 private visitNode(node: SyntaxNode): void {
943 if (!this.extractor) return;
944
945 const nodeType = node.type;
946 let skipChildren = false;
947
948 // Language-specific custom visitor hook
949 if (this.extractor.visitNode) {
950 const ctx = this.makeExtractorContext();
951 const handled = this.extractor.visitNode(node, ctx);
952 if (handled) {
953 // The hook consumed this subtree, so the walkers below never descend
954 // into it — scan it for function-as-value candidates (#756). Scala's
955 // hook handles val/var definitions (`val table = Seq(targetCb)`), for
956 // example. The scan is capture-only and halts at nested functions.
957 this.scanFnRefSubtree(node, 0);
958 return;
959 }
960 }
961
962 // Pascal-specific AST handling
963 if (this.language === 'pascal') {
964 skipChildren = this.visitPascalNode(node);
965 if (skipChildren) return;
966 }
967
968 // C++ namespace blocks: carry the namespace name as a qualifiedName prefix
969 // while walking the body, so `namespace flash { void compute_attn(); }`
970 // indexes compute_attn with qualifiedName `flash::compute_attn` and a
971 // namespace-qualified call (`flash::compute_attn(...)`) resolves by exact
972 // qualified match instead of never resolving — C++ namespaces previously
973 // left no trace in qualifiedNames at all, so every `ns::fn()` call site
974 // was a permanently dead edge (surfaced by #387 flow validation on
975 // flash-attention/cutlass, whose kernel dispatch is namespace-qualified).
976 // C++17 nested forms (`namespace a::b {`) prefix as written. An anonymous
977 // namespace falls through to the generic walk — its contents stay bare,
978 // matching how call sites spell them.
979 if (this.language === 'cpp' && nodeType === 'namespace_definition') {
980 const nameNode = getChildByField(node, 'name');
981 const nsName = nameNode ? getNodeText(nameNode, this.source) : '';
982 if (nsName) {
983 this.namespacePrefix.push(nsName);
984 for (let i = 0; i < node.namedChildCount; i++) {
985 const child = node.namedChild(i);
986 if (child) this.visitNode(child);
987 }
988 this.namespacePrefix.pop();
989 return;
990 }
991 }
992
993 // Function-as-value capture (#756) — independent of the dispatch ladder
994 // below (the captured container types have no other handler there), so it
995 // can never shadow or be shadowed by an extraction branch.
996 this.maybeCaptureFnRefs(node, nodeType);
997
998 // Check for function declarations
999 // For Python/Ruby, function_definition inside a class should be treated as method

Callers 9

extractMethod · 0.95
extractClassMethod · 0.95
extractInterfaceMethod · 0.95
extractStructMethod · 0.95
extractEnumMethod · 0.95
extractTypeAliasMethod · 0.95
extractAnonymousClassMethod · 0.95
visitPascalNodeMethod · 0.95
extractPascalDeclTypeMethod · 0.95

Calls 15

makeExtractorContextMethod · 0.95
scanFnRefSubtreeMethod · 0.95
visitPascalNodeMethod · 0.95
maybeCaptureFnRefsMethod · 0.95
isInsideClassLikeNodeMethod · 0.95
extractMethodMethod · 0.95
extractFunctionMethod · 0.95
extractStructMethod · 0.95
extractEnumMethod · 0.95
extractInterfaceMethod · 0.95
extractClassMethod · 0.95
extractPropertyMethod · 0.95

Tested by

no test coverage detected