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

Method visitPascalNode

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

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

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