From 41fe85dc3a369c17016afa1aee717f442142c3bf Mon Sep 17 00:00:00 2001 From: DanielGavin Date: Sun, 14 Mar 2021 15:30:59 +0100 Subject: added bitset completion for all binary operators --- src/server/completion.odin | 40 +++++++++++++++++++++++++++++++++++++++- 1 file changed, 39 insertions(+), 1 deletion(-) (limited to 'src/server') diff --git a/src/server/completion.odin b/src/server/completion.odin index 238e7ca..762c36c 100644 --- a/src/server/completion.odin +++ b/src/server/completion.odin @@ -420,7 +420,7 @@ get_implicit_completion :: proc (ast_context: ^AstContext, position_context: ^Do append(&items, item); } } - } else if position_context.comp_lit != nil && position_context.binary != nil && (position_context.binary.op.text == "&") { + } else if position_context.comp_lit != nil && position_context.binary != nil && is_bitset_binary_operator(position_context.binary.op.text) { //bitsets context_node: ^ast.Expr; bitset_node: ^ast.Expr; @@ -814,3 +814,41 @@ get_type_switch_Completion :: proc (ast_context: ^AstContext, position_context: list.items = items[:]; } + +keyword_map: map[string]bool = { + "int" = true, + "uint" = true, + "string" = true, + "u64" = true, + "f32" = true, + "f64" = true, + "i64" = true, + "i32" = true, + "bool" = true, + "rawptr" = true, + "any" = true, + "u32" = true, + "true" = true, + "false" = true, + "nil" = true, + "byte" = true, + "u8" = true, + "i8" = true, +}; + +bitset_operators: map[string]bool = { + "|" = true, + "&" = true, + "&~" = true, + "~" = true, + "==" = true, + "!=" = true, + "<=" = true, + "<" = true, + ">=" = true, + ">" = true, +}; + +is_bitset_binary_operator :: proc(op: string) -> bool { + return op in bitset_operators; +} \ No newline at end of file -- cgit v1.2.3