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

inefficient semanticTokens/range on the end of the document #1977

Open
Techatrix opened this issue Jul 26, 2024 · 0 comments
Open

inefficient semanticTokens/range on the end of the document #1977

Techatrix opened this issue Jul 26, 2024 · 0 comments
Labels
enhancement New feature or request priority:low Low priority item

Comments

@Techatrix
Copy link
Member

Apply the following patch to semanticTokens/range and print which ast nodes will be traversed to generate semantic tokens.

diff --git a/src/Server.zig b/src/Server.zig
index 567de571..fec62c81 100644
--- a/src/Server.zig
+++ b/src/Server.zig
@@ -640,7 +640,7 @@ fn initializeHandler(server: *Server, arena: std.mem.Allocator, request: types.I
             },
             .semanticTokensProvider = .{
                 .SemanticTokensOptions = .{
-                    .full = .{ .bool = true },
+                    // .full = .{ .bool = true },
                     .range = .{ .bool = true },
                     .legend = .{
                         .tokenTypes = std.meta.fieldNames(semantic_tokens.TokenType),
diff --git a/src/features/semantic_tokens.zig b/src/features/semantic_tokens.zig
index dfd7b1a0..69fd55d8 100644
--- a/src/features/semantic_tokens.zig
+++ b/src/features/semantic_tokens.zig
@@ -1048,6 +1048,7 @@ pub fn writeSemanticTokens(
 
     // reverse the ast from the root declarations
     for (nodes) |child| {
+        std.debug.print("node: {d}\n", .{child});
         try writeNodeTokens(&builder, child);
     }

Then open a large file like Sema.zig or AstGen.zig and the move to the end of document.
ZLS will generate tokens for the entire document.

node: 3
node: 5
node: 7
node: 9

...

node: 140721
node: 140880
node: 140903
node: 140907
node: 140911
node: 140915
node: 140919
node: 140923
debug (server): Took 6527ms to process request-15-textDocument/semanticTokens/range on Thread 79111
@Techatrix Techatrix added enhancement New feature or request priority:low Low priority item labels Jul 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request priority:low Low priority item
Projects
None yet
Development

No branches or pull requests

1 participant