Metals: Implement textDocument/references

Created on 27 Nov 2018  路  4Comments  路  Source: scalameta/metals

Restart of #70

https://github.com/Microsoft/language-server-protocol/blob/master/protocol.md#textDocument_references

The references request is sent from the client to the server to resolve project-wide references for the symbol denoted by the given text document position.

Most helpful comment

I took a stab at this issue today in and made good progress on reducing the memory usage and speeding up indexing times, WIP branch https://github.com/scalameta/metals/compare/master...olafurpg:references.

For the akka build with 220k loc Scala, assuming everything has been compiled, it takes <1s on a cold server to index all SemanticDB files and the resulting index uses 3.5Mb memory. Most reference requests respond around ~10ms on average, with few outliers in the 100-600ms range. Here's VS Code displaying ~6k references to String on a cold server on the first request

2018-12-16 11 42 57

The remaining challenge before we can merge that branch is to implement "cascade compilation", to ensure that all relevant build targets in the workspace have been compiled. Currently, Metals only compiles the build target of the open file but for "find references" we need to also compile build targets that transitively depend on that file.

All 4 comments

I took a stab at this issue today in and made good progress on reducing the memory usage and speeding up indexing times, WIP branch https://github.com/scalameta/metals/compare/master...olafurpg:references.

For the akka build with 220k loc Scala, assuming everything has been compiled, it takes <1s on a cold server to index all SemanticDB files and the resulting index uses 3.5Mb memory. Most reference requests respond around ~10ms on average, with few outliers in the 100-600ms range. Here's VS Code displaying ~6k references to String on a cold server on the first request

2018-12-16 11 42 57

The remaining challenge before we can merge that branch is to implement "cascade compilation", to ensure that all relevant build targets in the workspace have been compiled. Currently, Metals only compiles the build target of the open file but for "find references" we need to also compile build targets that transitively depend on that file.

PR adding cascade compilation is up #430, which is a blocking issue before we can add references.

Cascade compilation was merged in #467 so the next step is to add "find references" :)

Pending fix #469

Was this page helpful?
0 / 5 - 0 ratings