Include class variables in jump-to-def query

This commit is contained in:
Harry Maclean
2021-08-05 15:55:38 +01:00
parent e84ebe2b94
commit e72f1399cb
4 changed files with 31 additions and 8 deletions

View File

@@ -7,7 +7,6 @@
/*
* TODO:
* - class variables
* - should `Foo.new` point to `Foo#initialize`?
*/
@@ -24,6 +23,8 @@ where
LocalVariableLoc(src, target) = loc and kind = "variable"
or
InstanceVariableLoc(src, target) = loc and kind = "instance variable"
or
ClassVariableLoc(src, target) = loc and kind = "class variable"
select src, target, kind
/**
@@ -61,6 +62,11 @@ newtype DefLoc =
m.getName() = "initialize" and
write.getVariable() = read.getVariable()
)
} or
/** A class variable */
ClassVariableLoc(ClassVariableReadAccess read, ClassVariableWriteAccess write) {
read.getVariable() = write.getVariable() and
not exists(MethodBase m | m.getAChild+() = write)
}
/**