Skip to content

Conversation

@heitor-lassarote
Copy link
Contributor

@heitor-lassarote heitor-lassarote commented Dec 15, 2025

This PR contains changes related to Serokell's second grant, third milestone.

Related PRs:

alexd1971 and others added 14 commits December 15, 2025 09:11
Problems:
1. Completion list contains not relevant identifiers
2. Completion item details contains only module name
3. Completion items lack of documentation.

Solution:
1. Analyze code block containing the current cursor position to show
only relevant identifiers.
2. When item type is available show the item type as a detail.
3. Show documentation if it exists for the completion item.
Problem: Currently implemented code actions `organize imports` and
`quick fix import` are implemented but not covered by tests.

Solution: Implement tests for `organize import` and `quick fix import`.
NB: currently organize imports does not work correctly. The
corresponding test is commented out for now and should be enabled
after organize imports is fixed.
Problem: `WorkspaceSymbol` capability handler is implemented but is not
covered by tests.

Solution: Implement `WorkspaceSymbol` capability tests.
NB: The implementation of the capability handler should be improved by
providing more relevant `SymbolKind`. After that tests should be fixed accordingly.
Problem: Document symbol capability handler is implemented but is not
covered by tests.

Solution: Implement tests for document symbol capability.
NB: The support for more symbol kinds should be added to the handler an
the tests.
Problem: Before we implement rename, we need prepare rename. This
request checks the validity of a rename.

Solution: Implement a simple handler that checks whether the position is
an ID node, that is not a keyword, or type name.
Problem: We need the references handler to implement rename. As it is
now, we can't easily call it, so let's refactor it out, into its own
file.

Solution: Copy and paste the references handler into a new file.
Problem: Now that prepare rename is implemented, we can implement
rename.

Solution: This request is simple: we find all references of whatever is
under the cursor, and create an edit for all of them. We add tests to
ensure this capability works as intended, by reusing both the
definitions and prepare rename tests.
Problem: When searching for an ID, we always assume it's a variable.
However, it could be a type.

Solution: For now, check if we are in a `TypD` and return a `'type'` if
so. This is not perfect, but gets the test to pass.
Problem:
1. Currently the language server returns full completion list relevant
for current scope. The list filtering is provided on client side.
Current test implementation implies filtering on server side.
2. One formatting test sometimes fail with timeout.

Solution:
1. Add completion items to expected list.
2. Intcearse timeout for the test.
Problem: signature help hint works only if we have typed AST available.
Until we don't input full function parameters we have invalid function
typing and building typed AST fails. That's why signature help is not
fully functional.

Solution: After implementing type recovery in motoko it became possible
to make signature help fully functional. Several regression tests was
added.
Problem: Now that we have better support for recovering the typed AST
for dot expressions in the compiler, we should also add a test for it in
the extension.

Solution: Add a test checking that we can complete from a local module
and another that we can complete from a nested module. While testing, I
found that we don't properly filter items based on their prefix, so I
added this case for completions from definitions.
Problem: According to the LSP specification, the server should not
filter items unless we send `isIncomplete` is `true`. However, this
would cause the client to recompute the list on every keystroke, and
since we rely on `findDefinitions`, which is slow, we don't want this.

Solution: Do not filter items based on a prefix. To check for the items,
order, and continuity in a subarray, we had to write a custom Jest
matcher. Set `isIncomplete` as `false` since we now send the complete
list.
Problem: Different projects can use different compiler versions. VSCode
extension should adapt to the project's version.

Solution:
1. If path to moc.js compiler is configured in the extension settings,
try to use that compiler.
2. If the configured moc.js does not exist in the path, try to download
it.
3. If path to moc.js not configured or there are problems with using it,
try to detect current project compiler version and download the compiler
if it does not exist.
4. Otherwise use default moc.js
Problem: tsconfig.json complains that all source files must be under
src, but the jest setup is outside.

Solution: Move the relevant files inside and update the config.
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.

2 participants