-
Notifications
You must be signed in to change notification settings - Fork 3
fix: Add support for unresolved fields from mixins #116
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
162aac2
to
e4f99dd
Compare
e4f99dd
to
2d6cd31
Compare
7fa5c45
to
0ba671e
Compare
if (sym.exists()) { // TODO(varun): Is this early exit justified? | ||
// Maybe it is possible to hit this in multiple ancestors? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Follow-up: Test this in a running Sourcegraph instance with an inheritance hierarchy involving multiple classes. In that situation, it seems like the transitive linkage should be happening through relation traversal. E.g. if C < B < A
then C.@f
would be defined by B.@f
which would be defined by A.@f
. In that case, we should check if all references to A.@f
show up when we do Find references on C.@f
.
If that does work, then remove this TODO with a brief explanation.
6cceb98
to
c7c31bc
Compare
554e6e1
to
3195c29
Compare
This makes it consistent with other SCIPState caches. There is a risk of higher memory usage but it removes the risk of confusion/incorrect navigation in the presence of unrelated identically-named classes in different files.
Something seems to be off with the ref panel, preventing manual testing. Let's merge this first... I'll file a follow-up issue for manual testing. https://github.com/sourcegraph/sourcegraph/issues/42499 |
Motivation
Mixins are used very frequently. We should have better code nav for them.
TODO
Manually test Go to Def and Find References when an undeclared field is present in different files. (Currently, this will create two different SymbolInformation values for the same symbol in different files.)
Manually test an inheritance hierarchy involving multiple classes. In that situation, it seems like the transitive linkage should be happening through relation traversal. E.g. if
C < B < A
thenC.@f
would be defined byB.@f
which would be defined byA.@f
. In that case, we should check if all references toA.@f
show up when we do Find references onC.@f
. There is a TODO related to this, which should be updated/removed.Remove debugging statements
Right now, we emit a SymbolInformation is emitted when a definition is emitted, but it is possible for a field inside a class coming from a mixin to not have any definition inside the class. Consider:
The code is currently set up so that:
@f
inget_f
will useC#@f
. (← Not sure if this is a good idea though, see next point.)@f
insideD
, so no relationship is emitted. (Additionally, it is not guaranteed that we can modifyC#@f
'sSymbolInformation
, sinceC
may be coming from a different index altogether. -- This makes me question if we should be instead usingD@#f
for the occurrence of@f
instead.)It is unclear to me what exactly we should do. There are a couple of options:
D#@f
(what location should be used?), and attach reference relationships to it which connect it toM#@f
andC#@f
.@f
inD
, one forC#@f
and another forM#@f
.More tests, including for complex include chains
Test plan
See included automated tests.