diff options
| author | Daniel Gavin <danielgavin5@hotmail.com> | 2022-11-02 15:50:11 +0100 |
|---|---|---|
| committer | Daniel Gavin <danielgavin5@hotmail.com> | 2022-11-02 15:50:11 +0100 |
| commit | b3b366132e9eb184f21007eccf58342e8e0fb2ad (patch) | |
| tree | 69bdeed63359505435ed4987c76dbaf2f7f3c044 /src | |
| parent | f2de3dd0dfe96365191e49d233d145a3b49ee41c (diff) | |
Prevent completion in basic literals
Diffstat (limited to 'src')
| -rw-r--r-- | src/server/analysis.odin | 2 | ||||
| -rw-r--r-- | src/server/completion.odin | 13 |
2 files changed, 12 insertions, 3 deletions
diff --git a/src/server/analysis.odin b/src/server/analysis.odin index 2eef852..06e93cc 100644 --- a/src/server/analysis.odin +++ b/src/server/analysis.odin @@ -40,6 +40,7 @@ DocumentPositionContext :: struct { returns: ^ast.Return_Stmt, //used for completion comp_lit: ^ast.Comp_Lit, //used for completion parent_comp_lit: ^ast.Comp_Lit, //used for completion + basic_lit: ^ast.Basic_Lit, struct_type: ^ast.Struct_Type, union_type: ^ast.Union_Type, bitset_type: ^ast.Bit_Set_Type, @@ -4723,6 +4724,7 @@ get_document_position_node :: proc( } case ^Undef: case ^Basic_Lit: + position_context.basic_lit = cast(^Basic_Lit)node case ^Matrix_Index_Expr: get_document_position(n.expr, position_context) get_document_position(n.row_index, position_context) diff --git a/src/server/completion.odin b/src/server/completion.odin index 59e762c..f046815 100644 --- a/src/server/completion.odin +++ b/src/server/completion.odin @@ -100,7 +100,7 @@ get_completion_list :: proc( if position_context.import_stmt != nil { completion_type = .Package } - + done: if position_context.switch_type_stmt != nil && position_context.case_clause != nil { @@ -126,6 +126,13 @@ get_completion_list :: proc( } } + //Currently we do not do any completion in string literals, but it could be possible in the future for formatted strings + if position_context.basic_lit != nil { + if _, ok := position_context.basic_lit.derived.(^ast.Basic_Lit); ok { + return list, true + } + } + switch completion_type { case .Comp_Lit: get_comp_lit_completion(&ast_context, &position_context, &list) @@ -1035,8 +1042,8 @@ get_identifier_completion :: proc( if position_context.identifier != nil { if ident, ok := position_context.identifier.derived.(^ast.Ident); ok { lookup_name = ident.name - } - } + } + } pkgs := make([dynamic]string, context.temp_allocator) |