@@ -34,7 +34,6 @@ const goto = @import("features/goto.zig");
3434const hover_handler = @import ("features/hover.zig" );
3535const selection_range = @import ("features/selection_range.zig" );
3636const diagnostics_gen = @import ("features/diagnostics.zig" );
37- const TrigramStore = @import ("TrigramStore.zig" );
3837
3938const BuildOnSave = diagnostics_gen .BuildOnSave ;
4039const BuildOnSaveSupport = build_runner_shared .BuildOnSaveSupport ;
@@ -1517,68 +1516,7 @@ fn selectionRangeHandler(server: *Server, arena: std.mem.Allocator, request: typ
15171516}
15181517
15191518fn workspaceSymbolHandler (server : * Server , arena : std.mem.Allocator , request : types.WorkspaceSymbolParams ) Error ! lsp. ResultType ("workspace/symbol" ) {
1520- if (request .query .len < 3 ) return null ;
1521-
1522- const handles = try server .document_store .loadTrigramStores ();
1523- defer server .document_store .allocator .free (handles );
1524-
1525- var symbols : std .ArrayListUnmanaged (types .WorkspaceSymbol ) = .empty ;
1526- var declaration_buffer : std .ArrayListUnmanaged (TrigramStore .Declaration .Index ) = .empty ;
1527-
1528- for (handles ) | handle | {
1529- const trigram_store = handle .getTrigramStoreCached ();
1530-
1531- declaration_buffer .clearRetainingCapacity ();
1532- try trigram_store .declarationsForQuery (arena , request .query , & declaration_buffer );
1533-
1534- const SortContext = struct {
1535- names : []const std.zig.Ast.TokenIndex ,
1536- fn lessThan (ctx : @This (), lhs : TrigramStore .Declaration .Index , rhs : TrigramStore .Declaration .Index ) bool {
1537- return ctx .names [@intFromEnum (lhs )] < ctx .names [@intFromEnum (rhs )];
1538- }
1539- };
1540-
1541- std .mem .sortUnstable (
1542- TrigramStore .Declaration .Index ,
1543- declaration_buffer .items ,
1544- SortContext { .names = trigram_store .declarations .items (.name ) },
1545- SortContext .lessThan ,
1546- );
1547-
1548- const slice = trigram_store .declarations .slice ();
1549- const names = slice .items (.name );
1550-
1551- var last_index : usize = 0 ;
1552- var last_position : offsets.Position = .{ .line = 0 , .character = 0 };
1553-
1554- try symbols .ensureUnusedCapacity (arena , declaration_buffer .items .len );
1555- for (declaration_buffer .items ) | declaration | {
1556- const name_token = names [@intFromEnum (declaration )];
1557- const loc = offsets .identifierTokenToNameLoc (handle .tree , name_token );
1558- const name = offsets .identifierTokenToNameSlice (handle .tree , name_token );
1559-
1560- const start_position = offsets .advancePosition (handle .tree .source , last_position , last_index , loc .start , server .offset_encoding );
1561- const end_position = offsets .advancePosition (handle .tree .source , start_position , loc .start , loc .end , server .offset_encoding );
1562- last_index = loc .end ;
1563- last_position = end_position ;
1564-
1565- symbols .appendAssumeCapacity (.{
1566- .name = name ,
1567- .kind = .Variable ,
1568- .location = .{
1569- .Location = .{
1570- .uri = handle .uri ,
1571- .range = .{
1572- .start = start_position ,
1573- .end = end_position ,
1574- },
1575- },
1576- },
1577- });
1578- }
1579- }
1580-
1581- return .{ .array_of_WorkspaceSymbol = symbols .items };
1519+ return try @import ("features/workspace_symbols.zig" ).handler (server , arena , request );
15821520}
15831521
15841522const HandledRequestParams = union (enum ) {
0 commit comments