diff options
| author | DanielGavin <danielgavin5@hotmail.com> | 2025-09-23 21:55:03 +0200 |
|---|---|---|
| committer | DanielGavin <danielgavin5@hotmail.com> | 2025-09-23 21:55:03 +0200 |
| commit | 487158b00d62ea80bf1205ad59a6a67fe1804650 (patch) | |
| tree | 1212044824a9706e373bc1fd6f430c2cccdd26ce /src/server/file_resolve.odin | |
| parent | 1009de179a717c8b355acb8b1268fedc9b2d089c (diff) | |
Add proper support for ranged semantic tokens.semantic_tokens_range
Diffstat (limited to 'src/server/file_resolve.odin')
| -rw-r--r-- | src/server/file_resolve.odin | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/src/server/file_resolve.odin b/src/server/file_resolve.odin index 53fda8f..22d2d63 100644 --- a/src/server/file_resolve.odin +++ b/src/server/file_resolve.odin @@ -36,6 +36,45 @@ reset_position_context :: proc(position_context: ^DocumentPositionContext) { position_context.index = nil } +resolve_ranged_file :: proc( + document: ^Document, + range: common.Range, + allocator := context.allocator, +) -> map[uintptr]SymbolAndNode { + ast_context := make_ast_context( + document.ast, + document.imports, + document.package_name, + document.uri.uri, + document.fullpath, + allocator, + ) + + position_context: DocumentPositionContext + + get_globals(document.ast, &ast_context) + + ast_context.current_package = ast_context.document_package + + symbols := make(map[uintptr]SymbolAndNode, 10000, allocator) + + margin := 20 + + for decl in document.ast.decls { + if _, is_value := decl.derived.(^ast.Value_Decl); !is_value { + continue + } + + //Look for declarations that overlap with range + if range.start.line - margin <= decl.end.line && decl.pos.line <= range.end.line + margin { + resolve_decl(&position_context, &ast_context, document, decl, &symbols, .None, allocator) + clear(&ast_context.locals) + } + } + + return symbols +} + resolve_entire_file :: proc( document: ^Document, flag := ResolveReferenceFlag.None, |