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

Method visitPascalNode

src/extraction/tree-sitter.ts:6118–6251  ·  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

6116 * Returns true if the node was fully handled and children should be skipped.
6117 */
6118 private visitPascalNode(node: SyntaxNode): boolean {
6119 const nodeType = node.type;
6120
6121 // Unit/Program/Library → module node
6122 if (nodeType === 'unit' || nodeType === 'program' || nodeType === 'library') {
6123 const moduleNameNode = node.namedChildren.find(
6124 (c: SyntaxNode) => c.type === 'moduleName'
6125 );
6126 const name = moduleNameNode ? getNodeText(moduleNameNode, this.source) : '';
6127 // Fallback to filename without extension if module name is empty
6128 const moduleName = name || path.basename(this.filePath).replace(/\.[^.]+$/, '');
6129 this.createNode('module', moduleName, node);
6130 // Continue visiting children (interface/implementation sections)
6131 for (let i = 0; i < node.namedChildCount; i++) {
6132 const child = node.namedChild(i);
6133 if (child) this.visitNode(child);
6134 }
6135 return true;
6136 }
6137
6138 // declType wraps declClass/declIntf/declEnum/type-alias
6139 // The name lives on declType, the inner node determines the kind
6140 if (nodeType === 'declType') {
6141 this.extractPascalDeclType(node);
6142 return true;
6143 }
6144
6145 // declUses → import nodes for each unit name
6146 if (nodeType === 'declUses') {
6147 this.extractPascalUses(node);
6148 return true;
6149 }
6150
6151 // declConsts → container; visit children for individual declConst
6152 if (nodeType === 'declConsts') {
6153 for (let i = 0; i < node.namedChildCount; i++) {
6154 const child = node.namedChild(i);
6155 if (child?.type === 'declConst') {
6156 this.extractPascalConst(child);
6157 }
6158 }
6159 return true;
6160 }
6161
6162 // declConst at top level (outside declConsts)
6163 if (nodeType === 'declConst') {
6164 this.extractPascalConst(node);
6165 return true;
6166 }
6167
6168 // declTypes → container for type declarations
6169 if (nodeType === 'declTypes') {
6170 for (let i = 0; i < node.namedChildCount; i++) {
6171 const child = node.namedChild(i);
6172 if (child) this.visitNode(child);
6173 }
6174 return true;
6175 }

Callers 1

visitNodeMethod · 0.95

Calls 10

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

Tested by

no test coverage detected