@@ -31,6 +31,7 @@ export class FileIndexer {
31
31
public readonly input : Input ,
32
32
public readonly document : scip . scip . Document ,
33
33
public readonly globalSymbolTable : Map < ts . Node , ScipSymbol > ,
34
+ public readonly globalConstructorTable : Map < ts . ClassDeclaration , boolean > ,
34
35
public readonly packages : Packages ,
35
36
public readonly sourceFile : ts . SourceFile
36
37
) {
@@ -110,6 +111,21 @@ export class FileIndexer {
110
111
return symbol
111
112
}
112
113
114
+ private hasConstructor ( classDeclaration : ts . ClassDeclaration ) : boolean {
115
+ const cached = this . globalConstructorTable . get ( classDeclaration )
116
+ if ( cached !== undefined ) return cached
117
+
118
+ for ( const member of classDeclaration . members ) {
119
+ if ( ts . isConstructorDeclaration ( member ) ) {
120
+ this . globalConstructorTable . set ( classDeclaration , true )
121
+ return true
122
+ }
123
+ }
124
+
125
+ this . globalConstructorTable . set ( classDeclaration , false )
126
+ return false
127
+ }
128
+
113
129
private visitSymbolOccurrence ( node : ts . Node , sym : ts . Symbol ) : void {
114
130
const range = Range . fromNode ( node ) . toLsif ( )
115
131
let role = 0
@@ -136,7 +152,8 @@ export class FileIndexer {
136
152
( ( ts . isIdentifier ( node ) && ts . isNewExpression ( node . parent ) ) ||
137
153
( ts . isPropertyAccessExpression ( node . parent ) &&
138
154
ts . isNewExpression ( node . parent . parent ) ) ) &&
139
- ts . isClassDeclaration ( declaration )
155
+ ts . isClassDeclaration ( declaration ) &&
156
+ this . hasConstructor ( declaration )
140
157
) {
141
158
scipSymbol = ScipSymbol . global (
142
159
scipSymbol ,
0 commit comments