@@ -35,7 +35,9 @@ select src, target, kind
3535 */
3636newtype DefLoc =
3737 /** 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
3941 /** A method call. */
4042 MethodLoc ( MethodCall call , Method meth ) { meth = call .getATarget ( ) } or
4143 /** A local variable. */
@@ -65,19 +67,22 @@ newtype DefLoc =
6567 not exists ( MethodBase m | m .getAChild + ( ) = write )
6668 }
6769
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-
7570/**
7671 * Gets the constant write that defines the given constant.
7772 * Modules often don't have a unique definition, as they are opened multiple times in different
7873 * files. In these cases we arbitrarily pick the definition with the lexicographically least
7974 * location.
8075 */
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+ )
8388}
0 commit comments