Skip to content

Implement Go to Type Definition and Go to Implementation - #102

Merged
JKRT merged 3 commits into
OpenModelica:mainfrom
SVAGEN26:feat/type-definition
Sep 25, 2026
Merged

JKRT merged 3 commits into
OpenModelica:mainfrom
SVAGEN26:feat/type-definition

Conversation

@SVAGEN26

@SVAGEN26 SVAGEN26 commented Sep 25, 2026 •

Copy link
Copy Markdown
Contributor

This is JKRT_AGENTIC_ACCOUNT.

Go to Definition already opens concrete model and function bodies, but the separate Type Definition and Implementation requests were unhandled. This PR adds both advertised LSP handlers and completes the requests listed in #10.

Go to Type Definition navigates from filter in FirstOrder filter; to the declared FirstOrder class. Named aliases remain navigation targets. It reuses the existing resolver and lazy library loading, reads current source buffers, and selects the destination identifier.

Go to Implementation reuses Go to Definition's source targets, including concrete model/function bodies. It does not enumerate concrete subclasses of partial classes or resolve instance-specific redeclarations; those are separate enhancements. Both new handlers respect client location-link support and return no destination for unsupported documents or unresolved symbols. The READMEs document this scope.

Closes #10.

Validation:

  • 269 server tests passed with the coverage gate (84.35% lines, 82.04% branches overall). Real stdio tests cover both new requests, both location response formats, aliases/imports, unsaved type navigation, lazy external types, UTF-16/CRLF positions, concrete model/function and partial-class targets, unresolved symbols, and unsupported documents.
  • 17 VS Code integration tests passed with MetaModelica enabled, including the Implementation command and type navigation after an unsaved edit.
  • Bundle build, TypeScript compilation, and lint with zero warnings passed.

The coverage percentages are repository-wide; bundled-server protocol tests provide the behavioral checks for the new handlers.

Resolve component types through the existing library resolver, honor client location-link support, and verify navigation against the real server and VS Code.

Co-authored-by: JKRT <jtinnerholm@gmail.com>
Advertise and handle the implementation request with client-specific location formats. Test model, function and partial-class targets, unresolved symbols, unsupported documents, and the VS Code command.

Co-authored-by: JKRT <jtinnerholm@gmail.com>
@SVAGEN26 SVAGEN26 changed the title Implement Go to Type Definition Implement Go to Type Definition and Go to Implementation Sep 25, 2026
@SVAGEN26

Copy link
Copy Markdown
Contributor Author

Following our discussion, added textDocument/implementation using the existing Go to Definition targets, so clients can invoke the separate command. Updated the scope documentation and linked this PR to close #10. Concrete-subclass discovery remains a separate enhancement.

Added real-server tests for both response formats, model/function/partial-class targets, unresolved symbols and unsupported documents, plus a VS Code command test. All 269 server tests and 17 editor tests pass; coverage thresholds, build, compilation and lint also pass.

ModelicaDocument.update is async and throws when parsing fails. Without
await, that rejection escaped the surrounding try/catch as an unhandled
rejection, which can terminate the server. Awaiting it lets the catch
return null as intended.

Co-Authored-By: Claude <noreply@anthropic.com>
Comment thread server/src/analyzer.ts
// Loading may yield to edits. Read the latest buffer after the await so
// navigation does not race the asynchronous didOpen/didChange update.
const opened = currentDocument();
if (opened && document.getText() !== opened.getText()) await document.update(opened.getText());

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ModelicaDocument.update is async and throws when parser.parse returns null. This call was not awaited, so a parse failure became an unhandled rejection that the surrounding try/catch never saw. On Node that ends the server process by default (see the note in server.ts about an earlier crash from an unhandled rejection).

Trigger: the open buffer differs from the analyzer's copy and re-parsing it fails. A Type Definition request then kills the server instead of returning null.

Fixed in 5d2c99b by awaiting the call.

@JKRT
JKRT merged commit d525b9b into OpenModelica:main Sep 25, 2026
9 checks passed
@SVAGEN26
SVAGEN26 deleted the feat/type-definition branch September 25, 2026 13:10
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 remaining Goto Request

2 participants