@@ -139,7 +139,7 @@ class CanonicalName extends @symbol {
139
139
else
140
140
if exists ( root .getGlobalName ( ) )
141
141
then result instanceof GlobalScope
142
- else result = getADefinitionNode ( ) .getContainer ( ) .getScope ( )
142
+ else result = getADefinition ( ) .getContainer ( ) .getScope ( )
143
143
)
144
144
}
145
145
@@ -149,10 +149,15 @@ class CanonicalName extends @symbol {
149
149
else result = getParent ( ) .getRootName ( )
150
150
}
151
151
152
- private ExprOrStmt getADefinitionNode ( ) {
153
- result = this .( TypeName ) .getADefinition ( ) or
154
- result = this .( Namespace ) .getADefinition ( )
155
- }
152
+ /**
153
+ * Gets a definition of the entity with this canonical name.
154
+ */
155
+ ASTNode getADefinition ( ) { none ( ) }
156
+
157
+ /**
158
+ * Gets a use that refers to the entity with this canonical name.
159
+ */
160
+ ExprOrType getAnAccess ( ) { none ( ) }
156
161
157
162
/**
158
163
* Gets a string describing the root scope of this canonical name.
@@ -168,11 +173,9 @@ class CanonicalName extends @symbol {
168
173
if exists ( root .getGlobalName ( ) )
169
174
then result = "global scope"
170
175
else
171
- if exists ( root .getADefinitionNode ( ) )
176
+ if exists ( root .getADefinition ( ) )
172
177
then
173
- exists ( StmtContainer container |
174
- container = root .getADefinitionNode ( ) .getContainer ( )
175
- |
178
+ exists ( StmtContainer container | container = root .getADefinition ( ) .getContainer ( ) |
176
179
result = container .( TopLevel ) .getFile ( ) .getRelativePath ( )
177
180
or
178
181
not container instanceof TopLevel and
@@ -218,12 +221,12 @@ class TypeName extends CanonicalName {
218
221
/**
219
222
* Gets a definition of the type with this canonical name, if any.
220
223
*/
221
- TypeDefinition getADefinition ( ) { ast_node_symbol ( result , this ) }
224
+ override TypeDefinition getADefinition ( ) { ast_node_symbol ( result , this ) }
222
225
223
226
/**
224
227
* Gets a type annotation that refers to this type name.
225
228
*/
226
- TypeAccess getAnAccess ( ) { result .getTypeName ( ) = this }
229
+ override TypeAccess getAnAccess ( ) { result .getTypeName ( ) = this }
227
230
228
231
/**
229
232
* Gets a type that refers to this canonical name.
@@ -258,14 +261,14 @@ class Namespace extends CanonicalName {
258
261
}
259
262
260
263
/**
261
- * Gets a definition of the type with this canonical name, if any.
264
+ * Gets a definition of the namespace with this canonical name, if any.
262
265
*/
263
- NamespaceDefinition getADefinition ( ) { ast_node_symbol ( result , this ) }
266
+ override NamespaceDefinition getADefinition ( ) { ast_node_symbol ( result , this ) }
264
267
265
268
/**
266
269
* Gets a part of a type annotation that refers to this namespace.
267
270
*/
268
- NamespaceAccess getAnAccess ( ) { result .getNamespace ( ) = this }
271
+ override NamespaceAccess getAnAccess ( ) { result .getNamespace ( ) = this }
269
272
270
273
/** Gets a namespace nested in this one. */
271
274
Namespace getNamespaceMember ( string name ) {
@@ -307,7 +310,18 @@ class CanonicalFunctionName extends CanonicalName {
307
310
/**
308
311
* Gets a function with this canonical name.
309
312
*/
310
- Function getADefinition ( ) { ast_node_symbol ( result , this ) }
313
+ override Function getADefinition ( ) { ast_node_symbol ( result , this ) }
314
+
315
+ /**
316
+ * Gets an expression (such as a callee expression in a function call or `new` expression)
317
+ * that refers to a function with this canonical name.
318
+ */
319
+ override Expr getAnAccess ( ) {
320
+ exists ( InvokeExpr invk | ast_node_symbol ( invk , this ) | result = invk .getCallee ( ) )
321
+ or
322
+ ast_node_symbol ( result , this ) and
323
+ not result instanceof InvokeExpr
324
+ }
311
325
312
326
/**
313
327
* Gets the implementation of this function, if it exists.
0 commit comments