CodeGraph/docs
Section 2.5.3

Classes & Methods

Extracting class declarations and expressions, classifying method kinds (regular, getters, setters, private), and maintaining parent class pointers.

Source: server/src/parser/extractors/SymbolExtractor.ts

Method Kinds & Classification

When extracting class methods, the extractor classifies the method into a specific MethodKind:

Method KindAST Node / ConditionExample Code
"method"ClassMethod where kind === 'method'class A { run() {} }
"get"ClassMethod where kind === 'get'class A { get total() { return 10; } }
"set"ClassMethod where kind === 'set'class A { set total(v) {} }
"private"ClassPrivateMethod (PrivateName #key)class A { #executeInternal() {} }

Private Method Extraction

ECMAScript private methods (#privateMethod()) use PrivateName AST nodes rather than standard Identifier nodes. The extractor unwraps the identifier name safely:

Private Method Unwrapping
1
2
3
4
5
6
7
8
9
10
11
if (path.isClassPrivateMethod()) { const key = path.node.key; if (key.type === "PrivateName") { return key.id.name; // Extracts 'executeInternal' from '#executeInternal' } } private getMethodKind(path: NodePath<ClassMethod | ClassPrivateMethod | ObjectMethod>): MethodKind { if (path.isClassPrivateMethod()) return "private"; return path.node.kind === "get" || path.node.kind === "set" ? path.node.kind : "method"; }
Parent Class Linking
Because ClassDeclaration is a container visitor, the class symbol is placed on symbolStack. When any ClassMethod is visited, its parentSymbolId is automatically set to the class ID.