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 multiple SemanticTokensProvider per document selector #212650

Open
BoykoAlex opened this issue May 14, 2024 · 3 comments
Open

Support multiple SemanticTokensProvider per document selector #212650

BoykoAlex opened this issue May 14, 2024 · 3 comments
Labels
feature-request Request for new features or functionality semantic-tokens Semantic tokens issues
Milestone

Comments

@BoykoAlex
Copy link
Contributor

BoykoAlex commented May 14, 2024

Currently there is very basic support for multiple semantic tokens provider for the same language. The first provider that computed some tokens is used. (See #135580). This feature was also requested in #135599 but didn't look like anything got pushed to fix it...

However, in reality, tokens from multiple semantic token providers need to be taken into account. For example Java annotations in the case of Spring can have JPQL, HQL or native SQL queries depending on annotation parameters and JARs on the classpath. Seems that best approach for such use case in Semantic Tokens. However, since JDT LS also has SemanticTokensProvider any Spring specific SemanticTokenProvider would conflict with the JDT LS provider.

Looking at https:/microsoft/vscode/blob/main/src/vs/editor/common/services/semanticTokensProviderStyling.ts#L142 i have a feeling that the restriction of effectively having one token provider giving tokens can be lifted if switched to SemanticTokens[]

(cc: @martinlippert)

@alexdima alexdima added feature-request Request for new features or functionality semantic-tokens Semantic tokens issues labels Jun 4, 2024
@alexdima alexdima removed their assignment Jun 4, 2024
@vscodenpa vscodenpa added this to the Backlog Candidates milestone Jun 4, 2024
@vscodenpa
Copy link

This feature request is now a candidate for our backlog. The community has 60 days to upvote the issue. If it receives 20 upvotes we will move it to our backlog. If not, we will close it. To learn more about how we handle feature requests, please see our documentation.

Happy Coding!

@vscodenpa
Copy link

🙂 This feature request received a sufficient number of community upvotes and we moved it to our backlog. To learn more about how we handle feature requests, please see our documentation.

Happy Coding!

@vscodenpa vscodenpa modified the milestones: Backlog Candidates, Backlog Jun 8, 2024
@BoykoAlex
Copy link
Contributor Author

I have noticed that a few semantic token providers for the same language where only one provides non-null results isn't working so not sure if this #135602 works as expected or maybe I misunderstood something...

I took semantic-tokens-sample from https:/BoykoAlex/vscode-extension-samples. Added:

In the activate(...) function of the extension.ts

context.subscriptions.push(vscode.languages.registerDocumentSemanticTokensProvider({ language: "java" }, new JavaSemanticTokensProvider(), legend));

Where the JavaSemanticTokensProvider:

import {CancellationToken, DocumentSemanticTokensProvider, ProviderResult, SemanticTokens, TextDocument} from "vscode";

export class JavaSemanticTokensProvider implements DocumentSemanticTokensProvider {
	provideDocumentSemanticTokens(document: TextDocument, token: CancellationToken): ProviderResult<SemanticTokens> {
		return Promise.resolve(null);
	}
}

Also changed activation on event in package.json:

	"activationEvents": [
		"onStartupFinished"
	],

After all this i see that JDT LS provided semantic tokens are not present.

(See https:/BoykoAlex/vscode-extension-samples/tree/multi-semantic-token-providers and don't forget to install Java extension pack or RedHat Java extension)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature-request Request for new features or functionality semantic-tokens Semantic tokens issues
Projects
None yet
Development

No branches or pull requests

3 participants