Section 2.5.3Source:
server/src/parser/extractors/SymbolExtractor.tsClasses & Methods
Extracting class declarations and expressions, classifying method kinds (regular, getters, setters, private), and maintaining parent class pointers.
Source:
server/src/parser/extractors/SymbolExtractor.tsMethod Kinds & Classification
When extracting class methods, the extractor classifies the method into a specific MethodKind:
| Method Kind | AST Node / Condition | Example 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
1234567891011if (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.