@@ -35,7 +35,9 @@ select src, target, kind
35
35
*/
36
36
newtype DefLoc =
37
37
/** A constant, module or class. */
38
- ConstantDefLoc ( ConstantReadAccess read , ConstantWriteAccess write ) { write = definitionOf ( read ) } or
38
+ ConstantDefLoc ( ConstantReadAccess read , ConstantWriteAccess write ) {
39
+ write = definitionOf ( resolveConstant ( read ) )
40
+ } or
39
41
/** A method call. */
40
42
MethodLoc ( MethodCall call , Method meth ) { meth = call .getATarget ( ) } or
41
43
/** A local variable. */
@@ -65,19 +67,22 @@ newtype DefLoc =
65
67
not exists ( MethodBase m | m .getAChild + ( ) = write )
66
68
}
67
69
68
- pragma [ noinline]
69
- ConstantWriteAccess definitionOf0 ( string fqn ) {
70
- fqn = resolveConstant ( _) and
71
- result =
72
- min ( ConstantWriteAccess w | w .getQualifiedName ( ) = fqn | w order by w .getLocation ( ) .toString ( ) )
73
- }
74
-
75
70
/**
76
71
* Gets the constant write that defines the given constant.
77
72
* Modules often don't have a unique definition, as they are opened multiple times in different
78
73
* files. In these cases we arbitrarily pick the definition with the lexicographically least
79
74
* location.
80
75
*/
81
- ConstantWriteAccess definitionOf ( ConstantReadAccess r ) {
82
- result = definitionOf0 ( resolveConstant ( r ) )
76
+ pragma [ noinline]
77
+ ConstantWriteAccess definitionOf ( string fqn ) {
78
+ fqn = resolveConstant ( _) and
79
+ result =
80
+ min ( ConstantWriteAccess w , Location l |
81
+ w .getQualifiedName ( ) = fqn and l = w .getLocation ( )
82
+ |
83
+ w
84
+ order by
85
+ l .getFile ( ) .getAbsolutePath ( ) , l .getStartLine ( ) , l .getStartColumn ( ) , l .getEndLine ( ) ,
86
+ l .getEndColumn ( )
87
+ )
83
88
}
0 commit comments