Skip to content

Implementation of the Hover feature#20

Merged
AnHeuermann merged 24 commits into
OpenModelica:mainfrom
AnHeuermann:patch
Jun 22, 2026
Merged

Implementation of the Hover feature#20
AnHeuermann merged 24 commits into
OpenModelica:mainfrom
AnHeuermann:patch

Conversation

@osman362

@osman362 osman362 commented Mar 1, 2024

Copy link
Copy Markdown
Contributor

The Goal

This pull request introduces the hover information functionality of the Language Server Protocol for Modelica. The goal of this feature is to provide users with detailed information about Modelica classes, including descriptions, inputs, outputs, and parameters, directly within the hover pop-up interface.

Implementation Details

  • Hover Information Extraction: I developed utility functions that are extracting relevant information for classes, inputs, outputs, and parameters. This involved navigating the AST to identify description_string nodes for descriptions and component_clause nodes and their children checking if they include the keywords input, output, parameter (as we can't differentiate these in the AST) for declarations.
  • Markdown Formatting: The extracted information is presented in a readable and structured format by using Markdown. This includes the class description, inputs, outputs, and parameters, each formatted within blocks for clarity.

What Follows Next

  • Unit Testing: Integration of unit tests to ensure the reliability and correctness of the implemented hover information feature.
  • Additional Features: Including more detailed documentation, examples of usage, or references to Modelica documentation.

osman362 and others added 7 commits February 23, 2024 21:20
- onHover method recognizes comments above a function and shows the content inside the hover information
- output.md file is a reference on how the hover information should look like
- step.mo is a test fixture for the hover method
@AnHeuermann

Copy link
Copy Markdown
Member

The basics are working now.
The only remaining thing I would like to add is the ability to find definitions with fully qualified names.

E.g. from the DrumBoilder example I would like to get velocityOfSound_ph documentation in every location.

@AnHeuermann AnHeuermann marked this pull request as draft March 8, 2024 16:24
@AnHeuermann AnHeuermann linked an issue May 23, 2024 that may be closed by this pull request
3 tasks
AnHeuermann and others added 3 commits May 23, 2024 11:42
- Resolve all merge conflicts between the hover feature branch and main
- Adapt onHover to use the new ModelicaProject/resolveReference architecture
- Refactor extractHoverInformation to accept class_definition nodes directly
- Add findHoverInfo to Analyzer using resolveReference with local fallback
- Fix standalone library documents not stored in the documents map
- Fix standalone library name to use declared class name (not filename)
- Add rename() method to ModelicaLibrary

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- extractHoverInformation: null check, inputs section
- Analyzer.findHoverInfo: definition site, qualified name reference,
  within-clause fully qualified name resolution

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@AnHeuermann AnHeuermann marked this pull request as ready for review June 5, 2026 15:47
@AnHeuermann

Copy link
Copy Markdown
Member

Looking good!

image image image image

AnHeuermann and others added 7 commits June 5, 2026 18:13
Add `version: 'stable'` to runTests() to avoid the inferred-version
resolution path (which also fetches insider versions and is more
network-dependent). Add actions/cache for .vscode-test so repeated
CI runs reuse the downloaded VS Code instead of re-fetching every time.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…raries

The client e2e test `onDeclaration()` failed because resolving a local
variable returned no location when the workspace contained two libraries
with the same name (the standalone MyLibrary.mo and the MyLibrary/
directory package).

Two underlying bugs:

- analyzer.ts resolved nested workspace entries with
  `path.resolve(nestedRelative)`, which resolves against the process CWD
  instead of the workspace directory, so nested library packages were
  discovered inconsistently. Resolve against `libraryPath` instead.

- resolveAbsoluteReference only tried the first library matching a name
  via `find`, giving up if it didn't contain the symbol. Iterate over all
  same-named libraries until one resolves the full reference chain.

Also make the e2e tests poll the provider until results are available
(executeProviderUntilResult) instead of relying on a single fixed
sleep(5000), which was racy on CI and always paid the full delay.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@AnHeuermann AnHeuermann merged commit 091736f into OpenModelica:main Jun 22, 2026
3 checks passed
@AnHeuermann AnHeuermann deleted the patch branch June 22, 2026 12:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Implement Hover Request

2 participants