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

Method visitPascalNode

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

6169 * Returns true if the node was fully handled and children should be skipped.
6170 */
6171 private visitPascalNode(node: SyntaxNode): boolean {
6172 const nodeType = node.type;
6173
6174 // Unit/Program/Library → module node
6175 if (nodeType === 'unit' || nodeType === 'program' || nodeType === 'library') {
6176 const moduleNameNode = node.namedChildren.find(
6177 (c: SyntaxNode) => c.type === 'moduleName'
6178 );
6179 const name = moduleNameNode ? getNodeText(moduleNameNode, this.source) : '';
6180 // Fallback to filename without extension if module name is empty
6181 const moduleName = name || path.basename(this.filePath).replace(/\.[^.]+$/, '');
6182 this.createNode('module', moduleName, node);
6183 // Continue visiting children (interface/implementation sections)
6184 for (let i = 0; i < node.namedChildCount; i++) {
6185 const child = node.namedChild(i);
6186 if (child) this.visitNode(child);
6187 }
6188 return true;
6189 }
6190
6191 // declType wraps declClass/declIntf/declEnum/type-alias
6192 // The name lives on declType, the inner node determines the kind
6193 if (nodeType === 'declType') {
6194 this.extractPascalDeclType(node);
6195 return true;
6196 }
6197
6198 // declUses → import nodes for each unit name
6199 if (nodeType === 'declUses') {
6200 this.extractPascalUses(node);
6201 return true;
6202 }
6203
6204 // declConsts → container; visit children for individual declConst
6205 if (nodeType === 'declConsts') {
6206 for (let i = 0; i < node.namedChildCount; i++) {
6207 const child = node.namedChild(i);
6208 if (child?.type === 'declConst') {
6209 this.extractPascalConst(child);
6210 }
6211 }
6212 return true;
6213 }
6214
6215 // declConst at top level (outside declConsts)
6216 if (nodeType === 'declConst') {
6217 this.extractPascalConst(node);
6218 return true;
6219 }
6220
6221 // declTypes → container for type declarations
6222 if (nodeType === 'declTypes') {
6223 for (let i = 0; i < node.namedChildCount; i++) {
6224 const child = node.namedChild(i);
6225 if (child) this.visitNode(child);
6226 }
6227 return true;
6228 }

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