OpenModelica / modelica-language-server

A VS Code language server extension for Modelica.
Other
5 stars 2 forks source link

Basic Goto Declaration Support #22

Closed ehedbor closed 3 months ago

ehedbor commented 4 months ago

Adds a first draft of goto declaration. Also adds support for multiple files and incremental parsing.

There are some known issues with the implementation:

  1. Some language features like encapsulated packages and array indices in component expressions are not handled. These were not implemented due to lack of time.
  2. Components' superclasses are ignored in nested component accesses (e.g in foo.bar, bar will not be found if it was declared in a superclass of whatever foo is). This is due to a bug that caused infinite recursion when the feature was enabled.
  3. In case of a conflict, goto declaration will simply return the first declaration it finds. This may affect things like multiple inheritance (this begs the question: if multiple classes declare the same component, which one should be used?).
  4. In the case of import aliases, it was debated if goto declaration should take the user to the alias or to the original symbol. Right now the algorithm does the latter.
  5. We use LSP.LocationLinks to return the position of symbols we find. The advantage of this is that it allows one to separately specify both the declaration (VS Code shows this in tooltips) and the symbol being defined (VS Code highlights this when going to the declaration). However, we did not have time to define
  6. Although it is enabled, goto definition is not supported. Known differences include import aliases (see 4) and inner/outer declarations.
CLAassistant commented 4 months ago

CLA assistant check
All committers have signed the CLA.

AnHeuermann commented 4 months ago

In case of a conflict, goto declaration will simply return the first declaration it finds. This may affect things like multiple inheritance (this begs the question: if multiple classes declare the same component, which one should be used?).

The C++ language server extension from Microsoft will open a small view with a list of all definitions. We could at some point do something similar: grafik

ehedbor commented 4 months ago

Edit: added links to draft pull requests

We have more time to work on fixing the PR now. We plan on splitting things up into multiple pull requests as you requested. This means we'll have to basically manually rewrite the git history but it was a mess anyways so no harm there. Currently planning on the following:

  1. Add Prettier/other config stuff (see #23)
  2. Multi-file support (see #24)
  3. Incremental updates (see #25)
  4. Goto declaration (WIP)
PaddiM8 commented 3 months ago

Replaced by #26