@@ -139,7 +139,7 @@ class CanonicalName extends @symbol {
139139 else
140140 if exists ( root .getGlobalName ( ) )
141141 then result instanceof GlobalScope
142- else result = getADefinitionNode ( ) .getContainer ( ) .getScope ( )
142+ else result = getADefinition ( ) .getContainer ( ) .getScope ( )
143143 )
144144 }
145145
@@ -149,10 +149,15 @@ class CanonicalName extends @symbol {
149149 else result = getParent ( ) .getRootName ( )
150150 }
151151
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 ( ) }
156161
157162 /**
158163 * Gets a string describing the root scope of this canonical name.
@@ -168,11 +173,9 @@ class CanonicalName extends @symbol {
168173 if exists ( root .getGlobalName ( ) )
169174 then result = "global scope"
170175 else
171- if exists ( root .getADefinitionNode ( ) )
176+ if exists ( root .getADefinition ( ) )
172177 then
173- exists ( StmtContainer container |
174- container = root .getADefinitionNode ( ) .getContainer ( )
175- |
178+ exists ( StmtContainer container | container = root .getADefinition ( ) .getContainer ( ) |
176179 result = container .( TopLevel ) .getFile ( ) .getRelativePath ( )
177180 or
178181 not container instanceof TopLevel and
@@ -218,12 +221,12 @@ class TypeName extends CanonicalName {
218221 /**
219222 * Gets a definition of the type with this canonical name, if any.
220223 */
221- TypeDefinition getADefinition ( ) { ast_node_symbol ( result , this ) }
224+ override TypeDefinition getADefinition ( ) { ast_node_symbol ( result , this ) }
222225
223226 /**
224227 * Gets a type annotation that refers to this type name.
225228 */
226- TypeAccess getAnAccess ( ) { result .getTypeName ( ) = this }
229+ override TypeAccess getAnAccess ( ) { result .getTypeName ( ) = this }
227230
228231 /**
229232 * Gets a type that refers to this canonical name.
@@ -258,14 +261,14 @@ class Namespace extends CanonicalName {
258261 }
259262
260263 /**
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.
262265 */
263- NamespaceDefinition getADefinition ( ) { ast_node_symbol ( result , this ) }
266+ override NamespaceDefinition getADefinition ( ) { ast_node_symbol ( result , this ) }
264267
265268 /**
266269 * Gets a part of a type annotation that refers to this namespace.
267270 */
268- NamespaceAccess getAnAccess ( ) { result .getNamespace ( ) = this }
271+ override NamespaceAccess getAnAccess ( ) { result .getNamespace ( ) = this }
269272
270273 /** Gets a namespace nested in this one. */
271274 Namespace getNamespaceMember ( string name ) {
@@ -307,7 +310,18 @@ class CanonicalFunctionName extends CanonicalName {
307310 /**
308311 * Gets a function with this canonical name.
309312 */
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+ }
311325
312326 /**
313327 * Gets the implementation of this function, if it exists.
0 commit comments