Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
06a1191
onHover recognition of comments above a function
osman362 Feb 23, 2024
8d7c323
onHover returns content of description_string
osman362 Feb 26, 2024
5faba65
description_string content inside hover pop-up
osman362 Feb 26, 2024
f331353
Hover shows Class Descriptions
osman362 Feb 29, 2024
aa25db2
Hover showing Inputs, Outputs & Parameters
osman362 Mar 1, 2024
6dc77cc
Refactor Code
osman362 Mar 1, 2024
06088b6
Merge remote-tracking branch 'origin/main' into patch
AnHeuermann Mar 7, 2024
ea2bc8c
Adding E2E test for onHover, fixing issues
AnHeuermann Mar 7, 2024
739d885
Only search for identifiers in onHover
AnHeuermann Mar 8, 2024
e7df72f
Simplify "getAllDeclarations" function
AnHeuermann Mar 8, 2024
6dc22e7
Improving hover content display
AnHeuermann Mar 8, 2024
08de30b
Fixing doc string for no documentation
AnHeuermann Mar 8, 2024
85bbe3f
Merge remote-tracking branch 'origin/main' into patch
AnHeuermann May 23, 2024
24f92c8
Adding TODOs and linting
AnHeuermann May 23, 2024
1db8672
Merge origin/main into patch and adapt hover feature to new architecture
AnHeuermann Jun 5, 2026
2808978
Add unit tests for hover feature
AnHeuermann Jun 5, 2026
5afa1e7
Fix CI E2E test: pin VS Code version and cache download
AnHeuermann Jun 5, 2026
62f0bb3
Merge remote-tracking branch 'origin/main' into patch
AnHeuermann Jun 22, 2026
5f1fceb
Fix go-to-declaration for standalone files shadowed by same-named lib…
AnHeuermann Jun 22, 2026
149ba61
Merge remote-tracking branch 'origin/main' into patch
AnHeuermann Jun 22, 2026
ff5500f
Fix linter warning
AnHeuermann Jun 22, 2026
d38773f
Clean up
AnHeuermann Jun 22, 2026
d9f5548
Merge remote-tracking branch 'origin/main' into patch
AnHeuermann Jun 22, 2026
c3ce267
Clean up
AnHeuermann Jun 22, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ features:

![Goto Declaration](images/goto_declaration_demo.png)

- Hover provider for declared symbols.

![Hover](images/hover_demo.png)

## Configuration

### Loading external Modelica libraries
Expand Down
85 changes: 50 additions & 35 deletions client/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"description": "VSCode part of a language server",
"author": "Andreas Heuermann, Osman Karabel, Evan Hedbor, PaddiM8",
"license": "OSMC-PL-1-8",
"version": "0.2.3",
"version": "0.3.0",
"publisher": "vscode",
"repository": {
"type": "git",
Expand Down
108 changes: 108 additions & 0 deletions client/src/test/onHover.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
/*
* This file is part of OpenModelica.
*
* Copyright (c) 1998-2026, Open Source Modelica Consortium (OSMC),
* c/o Linköpings universitet, Department of Computer and Information Science,
* SE-58183 Linköping, Sweden.
*
* All rights reserved.
*
* THIS PROGRAM IS PROVIDED UNDER THE TERMS OF AGPL VERSION 3 LICENSE OR
* THIS OSMC PUBLIC LICENSE (OSMC-PL) VERSION 1.8.
* ANY USE, REPRODUCTION OR DISTRIBUTION OF THIS PROGRAM CONSTITUTES
* RECIPIENT'S ACCEPTANCE OF THE OSMC PUBLIC LICENSE OR THE GNU AGPL
* VERSION 3, ACCORDING TO RECIPIENTS CHOICE.
*
* The OpenModelica software and the OSMC (Open Source Modelica Consortium)
* Public License (OSMC-PL) are obtained from OSMC, either from the above
* address, from the URLs:
* http://www.openmodelica.org or
* https://github.com/OpenModelica/ or
* http://www.ida.liu.se/projects/OpenModelica,
* and in the OpenModelica distribution.
*
* GNU AGPL version 3 is obtained from:
* https://www.gnu.org/licenses/licenses.html#GPL
*
* This program is distributed WITHOUT ANY WARRANTY; without
* even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE, EXCEPT AS EXPRESSLY SET FORTH
* IN THE BY RECIPIENT SELECTED SUBSIDIARY LICENSE CONDITIONS OF OSMC-PL.
*
* See the full OSMC Public License conditions for more details.
*
*/

import * as fs from 'fs';
import * as vscode from 'vscode';
import * as assert from 'assert';
import { getDocUri, getDocPath, activate, executeProviderUntilResult } from './helper';

suite('onHover information', async () => {
test('Step', async () => {
const docUri = getDocUri('step.mo');
const position = new vscode.Position(19, 25);
const content = new vscode.MarkdownString(
fs.readFileSync(getDocPath('step.md'), 'utf-8'));
const expectedHoverInstances: vscode.Hover[] = [
new vscode.Hover(content)
];

await testOnHover(docUri, position, expectedHoverInstances);
});

test('velocityOfSound_ph', async () => {
const docUri = getDocUri('velocityOfSound_ph.mo');
const position = new vscode.Position(0, 20);
const content = new vscode.MarkdownString(
fs.readFileSync(getDocPath('velocityOfSound_ph.md'), 'utf-8'));
const expectedHoverInstances: vscode.Hover[] = [
new vscode.Hover(content)
];

await testOnHover(docUri, position, expectedHoverInstances);
});
});

async function testOnHover(
uri: vscode.Uri,
position: vscode.Position,
expectedHoverInstances: vscode.Hover[]
) {
await activate(uri);

// Execute `vscode.executeHoverProvider` to execute all hover providers
const actualHoverInstances = await executeProviderUntilResult<vscode.Hover[]>(
"vscode.executeHoverProvider",
[uri, position],
);

assertHoverInstancesEqual(expectedHoverInstances, actualHoverInstances);
}

function assertHoverInstancesEqual(expected: vscode.Hover[], actual: vscode.Hover[]) {
assert.strictEqual(expected.length, actual.length, 'Array lengths do not match.');

for (let i = 0; i < expected.length; i++) {
const expectedHover = expected[i];
const actualHover = actual[i];

let expectedContent = "";
for (let j = 0; j < expectedHover.contents.length; j++) {
const content = expectedHover.contents[j];
if (content instanceof vscode.MarkdownString) {
expectedContent += content.value;
}
}

let actualContent = "";
for (let j = 0; j < actualHover.contents.length; j++) {
const content = actualHover.contents[j];
if (content instanceof vscode.MarkdownString) {
actualContent += content.value;
}
}

assert.strictEqual(actualContent.trim(), expectedContent.trim(), `Content does not match expected content.`);
}
}
7 changes: 7 additions & 0 deletions client/testFixture/MyLibrary/Examples/M.mo
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
within MyLibrary.Examples;

model M "MWE Modelica Model"
Real x(start = 1.0, fixed = true);
equation
der(x) = -0.5*x;
end M;
4 changes: 4 additions & 0 deletions client/testFixture/MyLibrary/Examples/package.mo
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
within MyLibrary;

package Examples
end Examples;
1 change: 1 addition & 0 deletions client/testFixture/MyLibrary/Examples/package.order
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
M
2 changes: 2 additions & 0 deletions client/testFixture/MyLibrary/package.mo
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
package MyLibrary "My Modelica Library"
end MyLibrary;
1 change: 1 addition & 0 deletions client/testFixture/MyLibrary/package.order
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Examples
20 changes: 20 additions & 0 deletions client/testFixture/step.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
```modelica
class Modelica_Blocks_Sources_Step "Generate step signal of type Real"
```
---

**Parameter Inputs**
```modelica
parameter input Real height = 1.0 "Height of step";
```
**Outputs**
```modelica
output Real y "Connector of Real output signal";
```

**Parameter**
```modelica
parameter input Real height = 1.0 "Height of step";
parameter Real offset = 0.0 "Offset of output signal y";
parameter Real startTime(quantity = "Time", unit = "s") = 0.0 "Output y = offset for time < startTime";
```
Loading
Loading