diff options
| author | Daniel Gavin <danielgavin5@hotmail.com> | 2022-01-12 10:59:56 +0100 |
|---|---|---|
| committer | Daniel Gavin <danielgavin5@hotmail.com> | 2022-01-12 10:59:56 +0100 |
| commit | cfc631db5eae7b61f85084310b26b76b2285ce1a (patch) | |
| tree | 2dc127b3dc8346eb44d307380d87c6a207a77726 /src | |
| parent | 3f3eb27677088d86cd7e0331f98385d497d0966a (diff) | |
refractor
Diffstat (limited to 'src')
| -rw-r--r-- | src/analysis/analysis.odin | 8 | ||||
| -rw-r--r-- | src/index/symbol.odin | 1 | ||||
| -rw-r--r-- | src/server/documents.odin | 21 | ||||
| -rw-r--r-- | src/server/signature.odin | 5 |
4 files changed, 11 insertions, 24 deletions
diff --git a/src/analysis/analysis.odin b/src/analysis/analysis.odin index 9419801..a34cc5f 100644 --- a/src/analysis/analysis.odin +++ b/src/analysis/analysis.odin @@ -845,6 +845,8 @@ resolve_type_expression :: proc(ast_context: ^AstContext, node: ^ast.Expr) -> (i return symbol, true; } + context.temp_allocator = context.allocator; + if symbol, ok := internal_resolve_type_expression(ast_context, node); ok { cached_symbol := index.new_clone_symbol(symbol); ast_context.symbol_cache[node.pos.offset] = cast(rawptr)cached_symbol; @@ -1119,6 +1121,8 @@ resolve_type_identifier :: proc(ast_context: ^AstContext, node: ast.Ident) -> (i return symbol, true; } + context.temp_allocator = context.allocator; + if symbol, ok := internal_resolve_type_identifier(ast_context, node); ok { cached_symbol := index.new_clone_symbol(symbol); ast_context.symbol_cache[node.pos.offset] = cast(rawptr)cached_symbol; @@ -2685,13 +2689,9 @@ is_lhs_comp_lit :: proc(position_context: ^DocumentPositionContext) -> bool { field_exists_in_comp_lit :: proc(comp_lit: ^ast.Comp_Lit, name: string) -> bool { for elem in comp_lit.elems { - if field, ok := elem.derived.(ast.Field_Value); ok { - if field.field != nil { - if ident, ok := field.field.derived.(ast.Ident); ok { - if ident.name == name { return true; } diff --git a/src/index/symbol.odin b/src/index/symbol.odin index dfdb66c..385663b 100644 --- a/src/index/symbol.odin +++ b/src/index/symbol.odin @@ -145,7 +145,6 @@ new_clone_symbol :: proc(data: Symbol, allocator := context.allocator) -> (^Symb } free_symbol :: proc(symbol: Symbol, allocator: mem.Allocator) { - if symbol.signature != "" && symbol.signature != "struct" && symbol.signature != "union" && symbol.signature != "enum" && symbol.signature != "bitset" { diff --git a/src/server/documents.odin b/src/server/documents.odin index 71e6cd0..da7bcb5 100644 --- a/src/server/documents.odin +++ b/src/server/documents.odin @@ -30,7 +30,6 @@ DocumentStorage :: struct { document_storage: DocumentStorage; document_storage_shutdown :: proc() { - for k, v in document_storage.documents { delete(k); } @@ -45,7 +44,6 @@ document_storage_shutdown :: proc() { } document_get_allocator :: proc() -> ^common.Scratch_Allocator { - if len(document_storage.free_allocators) > 0 { return pop(&document_storage.free_allocators); } else { @@ -60,7 +58,6 @@ document_free_allocator :: proc(allocator: ^common.Scratch_Allocator) { } document_get :: proc(uri_string: string) -> ^common.Document { - uri, parsed_ok := common.parse_uri(uri_string, context.temp_allocator); if !parsed_ok { @@ -79,7 +76,6 @@ document_get :: proc(uri_string: string) -> ^common.Document { } document_release :: proc(document: ^common.Document) { - if document != nil { intrinsics.atomic_sub(&document.operating_on, 1); } @@ -90,7 +86,6 @@ document_release :: proc(document: ^common.Document) { */ document_open :: proc(uri_string: string, text: string, config: ^common.Config, writer: ^Writer) -> common.Error { - uri, parsed_ok := common.parse_uri(uri_string, context.allocator); if !parsed_ok { @@ -99,7 +94,6 @@ document_open :: proc(uri_string: string, text: string, config: ^common.Config, } if document := &document_storage.documents[uri.path]; document != nil { - if document.client_owned { log.errorf("Client called open on an already open document: %v ", document.uri.path); return .InvalidRequest; @@ -115,7 +109,6 @@ document_open :: proc(uri_string: string, text: string, config: ^common.Config, return err; } } else { - document := common.Document { uri = uri, text = transmute([]u8)text, @@ -124,8 +117,6 @@ document_open :: proc(uri_string: string, text: string, config: ^common.Config, allocator = document_get_allocator(), }; - document.symbol_cache = make(map[int]rawptr, 10, common.scratch_allocator(document.allocator)); - if err := document_refresh(&document, config, writer); err != .None { return err; } @@ -142,7 +133,6 @@ document_open :: proc(uri_string: string, text: string, config: ^common.Config, Function that applies changes to the given document through incremental syncronization */ document_apply_changes :: proc(uri_string: string, changes: [dynamic]TextDocumentContentChangeEvent, config: ^common.Config, writer: ^Writer) -> common.Error { - uri, parsed_ok := common.parse_uri(uri_string, context.temp_allocator); if !parsed_ok { @@ -157,7 +147,6 @@ document_apply_changes :: proc(uri_string: string, changes: [dynamic]TextDocumen } for change in changes { - //for some reason sublime doesn't seem to care even if i tell it to do incremental sync if range, ok := change.range.(common.Range); ok { @@ -218,7 +207,6 @@ document_apply_changes :: proc(uri_string: string, changes: [dynamic]TextDocumen } document_close :: proc(uri_string: string) -> common.Error { - log.infof("document_close: %v", uri_string); uri, parsed_ok := common.parse_uri(uri_string, context.temp_allocator); @@ -250,7 +238,6 @@ document_close :: proc(uri_string: string) -> common.Error { } document_refresh :: proc(document: ^common.Document, config: ^common.Config, writer: ^Writer) -> common.Error { - clear(&document.symbol_cache); errors, ok := parse_document(document, config); if !ok { @@ -266,7 +253,6 @@ document_refresh :: proc(document: ^common.Document, config: ^common.Config, wri }; for error, i in errors { - params.diagnostics[i] = Diagnostic { range = common.Range { start = common.Position { @@ -294,7 +280,6 @@ document_refresh :: proc(document: ^common.Document, config: ^common.Config, wri } if writer != nil && len(errors) == 0 { - //send empty diagnosis to remove the clients errors if document.diagnosed_errors { @@ -327,7 +312,6 @@ parser_error_handler :: proc(pos: tokenizer.Pos, msg: string, args: ..any) { } parse_document :: proc(document: ^common.Document, config: ^common.Config) -> ([]ParserError, bool) { - p := parser.Parser { err = parser_error_handler, warn = common.parser_warning_handler, @@ -340,6 +324,8 @@ parse_document :: proc(document: ^common.Document, config: ^common.Config) -> ([ context.allocator = common.scratch_allocator(document.allocator); + document.symbol_cache = make(map[int]rawptr, 10, common.scratch_allocator(document.allocator)); + //have to cheat the parser since it really wants to parse an entire package with the new changes... pkg := new(ast.Package); pkg.kind = .Normal; @@ -362,7 +348,6 @@ parse_document :: proc(document: ^common.Document, config: ^common.Config) -> ([ } for imp, index in document.ast.imports { - if i := strings.index(imp.fullpath, "\""); i == -1 { continue; } @@ -375,7 +360,7 @@ parse_document :: proc(document: ^common.Document, config: ^common.Config) -> ([ } collection := imp.fullpath[1:i]; - p := imp.fullpath[i + 1:len(imp.fullpath) - 1]; + p := imp.fullpath[i + 1:len(imp.fullpath) - 1]; dir, ok := config.collections[collection]; diff --git a/src/server/signature.odin b/src/server/signature.odin index cc04cd5..3dcbacd 100644 --- a/src/server/signature.odin +++ b/src/server/signature.odin @@ -113,7 +113,6 @@ seperate_proc_field_arguments :: proc(procedure: ^index.Symbol) { } } - get_signature_information :: proc(document: ^common.Document, position: common.Position) -> (SignatureHelp, bool) { using analysis; @@ -149,6 +148,10 @@ get_signature_information :: proc(document: ^common.Document, position: common.P call: index.Symbol; call, ok = resolve_type_expression(&ast_context, position_context.call); + if !ok { + return signature_help, true; + } + seperate_proc_field_arguments(&call); signature_information := make([dynamic]SignatureInformation, context.temp_allocator); |