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

Method visitPascalNode

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

* Handle Pascal-specific AST structures. * Returns true if the node was fully handled and children should be skipped.

(node: SyntaxNode)

Source from the content-addressed store, hash-verified

9058 * Returns true if the node was fully handled and children should be skipped.
9059 */
9060 private visitPascalNode(node: SyntaxNode): boolean {
9061 const nodeType = node.type;
9062
9063 // Unit/Program/Library → module node
9064 if (nodeType === 'unit' || nodeType === 'program' || nodeType === 'library') {
9065 const moduleNameNode = node.namedChildren.find(
9066 (c: SyntaxNode) => c.type === 'moduleName'
9067 );
9068 const name = moduleNameNode ? getNodeText(moduleNameNode, this.source) : '';
9069 // Fallback to filename without extension if module name is empty
9070 const moduleName = name || path.basename(this.filePath).replace(/\.[^.]+$/, '');
9071 this.createNode('module', moduleName, node);
9072 // Continue visiting children (interface/implementation sections)
9073 for (let i = 0; i < node.namedChildCount; i++) {
9074 const child = node.namedChild(i);
9075 if (child) this.visitNode(child);
9076 }
9077 return true;
9078 }
9079
9080 // declType wraps declClass/declIntf/declEnum/type-alias
9081 // The name lives on declType, the inner node determines the kind
9082 if (nodeType === 'declType') {
9083 this.extractPascalDeclType(node);
9084 return true;
9085 }
9086
9087 // declUses → import nodes for each unit name
9088 if (nodeType === 'declUses') {
9089 this.extractPascalUses(node);
9090 return true;
9091 }
9092
9093 // declConsts → container; visit children for individual declConst
9094 if (nodeType === 'declConsts') {
9095 for (let i = 0; i < node.namedChildCount; i++) {
9096 const child = node.namedChild(i);
9097 if (child?.type === 'declConst') {
9098 this.extractPascalConst(child);
9099 }
9100 }
9101 return true;
9102 }
9103
9104 // declConst at top level (outside declConsts)
9105 if (nodeType === 'declConst') {
9106 this.extractPascalConst(node);
9107 return true;
9108 }
9109
9110 // declTypes → container for type declarations
9111 if (nodeType === 'declTypes') {
9112 for (let i = 0; i < node.namedChildCount; i++) {
9113 const child = node.namedChild(i);
9114 if (child) this.visitNode(child);
9115 }
9116 return true;
9117 }

Callers 1

dispatchNodeMethod · 0.95

Calls 11

createNodeMethod · 0.95
visitNodeMethod · 0.95
extractPascalDeclTypeMethod · 0.95
extractPascalUsesMethod · 0.95
extractPascalConstMethod · 0.95
extractPascalDefProcMethod · 0.95
extractPascalCallMethod · 0.95
visitPascalBlockMethod · 0.95
getNodeTextFunction · 0.90
getChildByFieldFunction · 0.90
pushMethod · 0.80

Tested by

no test coverage detected