diff options
| author | Daniel Gavin <danielgavin5@hotmail.com> | 2022-08-18 20:38:11 +0200 |
|---|---|---|
| committer | Daniel Gavin <danielgavin5@hotmail.com> | 2022-08-18 20:38:11 +0200 |
| commit | c2d22e05604e47aad77d0305385880687508912c (patch) | |
| tree | 107df9cd9291b32788526ea7040666f50c6957e4 /src/server | |
| parent | 20bcae6c14773217c6e9a3217150ac4468036e64 (diff) | |
Change resolve structure to fix debug crash in Odin
Diffstat (limited to 'src/server')
| -rw-r--r-- | src/server/caches.odin | 25 | ||||
| -rw-r--r-- | src/server/documents.odin | 2 | ||||
| -rw-r--r-- | src/server/requests.odin | 12 |
3 files changed, 22 insertions, 17 deletions
diff --git a/src/server/caches.odin b/src/server/caches.odin index 4acc3af..80128f4 100644 --- a/src/server/caches.odin +++ b/src/server/caches.odin @@ -5,26 +5,33 @@ import "shared:common" import "core:time" //Used in semantic tokens and inlay hints to handle the entire file being resolved. + +FileResolve :: struct { + symbols: map[uintptr]SymbolAndNode, +} + + FileResolveCache :: struct { - files: map[string]map[uintptr]SymbolAndNode, + files: map[string]FileResolve, } file_resolve_cache: FileResolveCache resolve_entire_file_cached :: proc(document: ^Document) -> map[uintptr]SymbolAndNode{ if document.uri.uri not_in file_resolve_cache.files { - file_resolve_cache.files[document.uri.uri] = resolve_entire_file( - document, - "", - .None, - common.scratch_allocator(document.allocator), - ) + file_resolve_cache.files[document.uri.uri] = FileResolve { + symbols = resolve_entire_file( + document, + "", + .None, + common.scratch_allocator(document.allocator), + ), + } } - return file_resolve_cache.files[document.uri.uri]; + return file_resolve_cache.files[document.uri.uri].symbols; } - BuildCache :: struct { loaded_pkgs: map[string]PackageCacheInfo, } diff --git a/src/server/documents.odin b/src/server/documents.odin index d5b0f09..52309ed 100644 --- a/src/server/documents.odin +++ b/src/server/documents.odin @@ -378,9 +378,7 @@ parse_document :: proc(document: ^Document, config: ^common.Config) -> ([]Parser current_errors = make([dynamic]ParserError, context.temp_allocator) if document.uri.uri in file_resolve_cache.files { - key := file_resolve_cache.files[document.uri.uri] delete_key(&file_resolve_cache.files, document.uri.uri) - delete(key) } free_all(common.scratch_allocator(document.allocator)) diff --git a/src/server/requests.odin b/src/server/requests.odin index cd2677f..29e78c1 100644 --- a/src/server/requests.odin +++ b/src/server/requests.odin @@ -889,8 +889,8 @@ request_semantic_token_full :: proc (params: json.Value, id: RequestId, config: if config.enable_semantic_tokens { resolve_entire_file_cached(document) - if cache_symbols, ok := file_resolve_cache.files[document.uri.uri]; ok { - symbols = get_semantic_tokens(document, range, cache_symbols) + if file, ok := file_resolve_cache.files[document.uri.uri]; ok { + symbols = get_semantic_tokens(document, range, file.symbols) } } @@ -923,8 +923,8 @@ request_semantic_token_range :: proc (params: json.Value, id: RequestId, config: symbols: SemanticTokens if config.enable_semantic_tokens { - if cache_symbols, ok := file_resolve_cache.files[document.uri.uri]; ok { - symbols = get_semantic_tokens(document, semantic_params.range, cache_symbols) + if file, ok := file_resolve_cache.files[document.uri.uri]; ok { + symbols = get_semantic_tokens(document, semantic_params.range, file.symbols) } } @@ -1025,8 +1025,8 @@ request_inlay_hint :: proc (params: json.Value, id: RequestId, config: ^common.C resolve_entire_file_cached(document) - if cache_symbols, ok := file_resolve_cache.files[document.uri.uri]; ok { - hints, ok = get_inlay_hints(document, cache_symbols) + if file, ok := file_resolve_cache.files[document.uri.uri]; ok { + hints, ok = get_inlay_hints(document, file.symbols) } if !ok { |