Skip to content
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

Consider reducing redundancy between declaration and references #25

Open
LukaszMendakiewicz opened this issue Mar 13, 2019 · 1 comment
Labels
feature-request Request for new features or functionality
Milestone

Comments

@LukaszMendakiewicz
Copy link

Consider the following C++ code:

void foo(); // R1
void foo(); // R2

where R1 and R2 indicate two distinct Range vertices.

Following the current LSIF spec, the output should contain the following vertices:

  1. Range for R1
  2. Range for R2
  3. ResultSet
  4. DeclarationResult
  5. ReferenceResult

and the following edges:

a) 1 -> 3; refersTo
b) 2 -> 3; refersTo
c) 3 -> 4; textDocument/declaration
d) 3 -> 5; textDocument/references
e) 5 -> 1; item (property=declaration)
f) 5 -> 2; item (property=declaration)
g) 4 -> 1
h) 4 -> 2

Note that "e" and "f" could be implicit edges (inlined into array), and "g" and "h" in the current spec are implicit edges (formed by the result field array in DeclarationResult), but that does not affect the crux of the issues.

The crux is that "e" is redundant with "g", and "f" is redundant with "h", and such redundancy would be repeated for every additional declaration in the source code.

Similar redundancy would be present for DefinitionResult and item (property=definition), although on much smaller scale (in general, there is only one definition for a given ResultSet).

I propose that declaration and definition edges going out of ReferenceResult are dropped. They can easily be reconstructed for serving textDocument/references query by augmenting that result set with the results from textDocument/declaration and textDocument/definition from the same ResultSet. Note also that after dropping these edges, "property" field on the "item" edge will no longer be necessary, since "reference" and "referenceResult" could be distinguished by the type of the incoming vertex of the "item" edge.

Are there languages that would make the above not possible?

@dbaeumer dbaeumer added this to the April 2019 milestone Apr 2, 2019
@dbaeumer dbaeumer modified the milestones: April 2019, August 2019 Aug 12, 2019
@dbaeumer dbaeumer modified the milestones: August 2019, October 2019 Sep 30, 2019
@dbaeumer dbaeumer modified the milestones: October 2019, On Deck Oct 28, 2020
@dbaeumer
Copy link
Member

I see the point however I wouldn't make the implicit (e.g. saying that when searching for references we say that the DB needs to consider textDocument/declaration edges). I would rather introduce to link a reference result to a declaration result using an item edge with the property declarationResult. The makes it explicit.

@dbaeumer dbaeumer added the feature-request Request for new features or functionality label Oct 19, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature-request Request for new features or functionality
Projects
None yet
Development

No branches or pull requests

2 participants