Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support workspace/semanticTokens/refresh #344

Closed
radeksimko opened this issue Jan 4, 2021 · 2 comments · Fixed by #630
Closed

Support workspace/semanticTokens/refresh #344

radeksimko opened this issue Jan 4, 2021 · 2 comments · Fixed by #630
Assignees
Labels
enhancement New feature or request textDocument/semanticTokens Semantic syntax highlighting workspace/semanticTokens

Comments

@radeksimko
Copy link
Member

radeksimko commented Jan 4, 2021

Current Version

0.11.0

Use-cases

Semantic token based highlighting is fully dependent on schema. Schema may change at runtime, even after it is initially obtained because, e.g.:

  • version of Terraform changes (or becomes known from being previously unknown)
  • new provider (schema) is added
  • existing provider (schema) is removed
  • version of existing provider (schema) changes (is upgraded or downgraded)

Proposal

Add change hooks to the StateStore which can be added when we're setting up the session and state stores, somewhere here

store, err := state.NewStateStore()
if err != nil {
return err
}
store.SetLogger(svc.logger)

The hook will need to check (via metadata in filesystem.DocumentStorage) whether the module has any open files currently and if so, then send workspace/semanticTokens/refresh notification to prompt the client to recompute semantic tokens.

Hooks can be implemented within the StateStore using memdb's Defer function on any relevant transactions.

@jpogran
Copy link
Contributor

jpogran commented Aug 26, 2021

Updated the module store to have a set of hooks to perform when an event is performed. Added a hook to send a workspace/semanticTokens/refresh notification to indicate the client should request updated tokens. Added events to update, set version, and update version actions in the module store.

When started the editor appears as expected, initial highlighting covers all the expected tokens except provider, which requires a second round trip once the local terraform version is parsed. The update version hook is called and a refresh notification is sent, but sometimes the syntax highlight is not changed for provider. Sometimes it happens immediatly, sometimes not until an edit to the current document is attempted. Using the token inspection command, I verified that the provider is correctly identified as a semantic token after the refresh event is sent, even if it isn't highlighted correctly.

Further investation is warranted to determine whether this is a problem with my implementation or with the rendering engine inside VSCode.

jpogran added a commit that referenced this issue Feb 3, 2022
Add ModuleChangeHooks to trigger semantic token refresh when specified parts of the schema are discovered after initialization.

Fixes #344
jpogran added a commit that referenced this issue Feb 4, 2022
Add ModuleChangeHooks to trigger semantic token refresh when specified parts of the schema are discovered after initialization.

Fixes #344
jpogran added a commit that referenced this issue Feb 8, 2022
Add ModuleChangeHooks to trigger semantic token refresh when specified parts of the schema are discovered after initialization.

Fixes #344
jpogran added a commit that referenced this issue Feb 9, 2022
* Enable Semantic Token Refresh

Add ModuleChangeHooks to trigger semantic token refresh when specified parts of the schema are discovered after initialization.

Fixes #344
@github-actions
Copy link

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.
If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 12, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request textDocument/semanticTokens Semantic syntax highlighting workspace/semanticTokens
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants