diff options
| author | DanielGavin <danielgavin5@hotmail.com> | 2021-03-18 10:44:09 +0100 |
|---|---|---|
| committer | DanielGavin <danielgavin5@hotmail.com> | 2021-03-18 10:44:09 +0100 |
| commit | 6ff8c1b780759d02156bf4c69c3c443ece12c160 (patch) | |
| tree | 1ce5fc6f27310952b814670cf8bffc8ddccd532b /src/server | |
| parent | 2313142359f69769b838b835f15c726d1ce2ebb4 (diff) | |
ran odinfmt
Diffstat (limited to 'src/server')
| -rw-r--r-- | src/server/analysis.odin | 214 | ||||
| -rw-r--r-- | src/server/background.odin | 2 | ||||
| -rw-r--r-- | src/server/completion.odin | 64 | ||||
| -rw-r--r-- | src/server/documents.odin | 60 | ||||
| -rw-r--r-- | src/server/format.odin | 5 | ||||
| -rw-r--r-- | src/server/hover.odin | 6 | ||||
| -rw-r--r-- | src/server/log.odin | 6 | ||||
| -rw-r--r-- | src/server/reader.odin | 10 | ||||
| -rw-r--r-- | src/server/requests.odin | 24 | ||||
| -rw-r--r-- | src/server/response.odin | 12 | ||||
| -rw-r--r-- | src/server/semantic_tokens.odin | 50 | ||||
| -rw-r--r-- | src/server/types.odin | 2 | ||||
| -rw-r--r-- | src/server/unmarshal.odin | 2 | ||||
| -rw-r--r-- | src/server/writer.odin | 6 |
14 files changed, 222 insertions, 241 deletions
diff --git a/src/server/analysis.odin b/src/server/analysis.odin index c8c1827..1ca1b43 100644 --- a/src/server/analysis.odin +++ b/src/server/analysis.odin @@ -82,7 +82,7 @@ AstContext :: struct { field_name: string, } -make_ast_context :: proc (file: ast.File, imports: []Package, package_name: string, allocator := context.temp_allocator) -> AstContext { +make_ast_context :: proc(file: ast.File, imports: []Package, package_name: string, allocator := context.temp_allocator) -> AstContext { ast_context := AstContext { locals = make(map[string][dynamic]DocumentLocal, 0, allocator), @@ -101,19 +101,20 @@ make_ast_context :: proc (file: ast.File, imports: []Package, package_name: stri return ast_context; } -tokenizer_error_handler :: proc (pos: tokenizer.Pos, msg: string, args: ..any) { +tokenizer_error_handler :: proc(pos: tokenizer.Pos, msg: string, args: ..any) { } /* Walk through the type expression while both the call expression and specialization type are the same */ -resolve_poly_spec :: proc { -resolve_poly_spec_node, -resolve_poly_spec_array, -resolve_poly_spec_dynamic_array}; +resolve_poly_spec :: proc{ + resolve_poly_spec_node, + resolve_poly_spec_array, + resolve_poly_spec_dynamic_array, +}; -resolve_poly_spec_array :: proc (ast_context: ^AstContext, call_array: $A/[]^$T, spec_array: $D/[]^$K, poly_map: ^map[string]^ast.Expr) { +resolve_poly_spec_array :: proc(ast_context: ^AstContext, call_array: $A/[]^$T, spec_array: $D/[]^$K, poly_map: ^map[string]^ast.Expr) { if len(call_array) != len(spec_array) { return; @@ -124,7 +125,7 @@ resolve_poly_spec_array :: proc (ast_context: ^AstContext, call_array: $A/[]^$T, } } -resolve_poly_spec_dynamic_array :: proc (ast_context: ^AstContext, call_array: $A/[dynamic]^$T, spec_array: $D/[dynamic]^$K, poly_map: ^map[string]^ast.Expr) { +resolve_poly_spec_dynamic_array :: proc(ast_context: ^AstContext, call_array: $A/[dynamic]^$T, spec_array: $D/[dynamic]^$K, poly_map: ^map[string]^ast.Expr) { if len(call_array) != len(spec_array) { return; @@ -135,7 +136,7 @@ resolve_poly_spec_dynamic_array :: proc (ast_context: ^AstContext, call_array: $ } } -get_poly_node_to_expr :: proc (node: ^ast.Node) -> ^ast.Expr { +get_poly_node_to_expr :: proc(node: ^ast.Node) -> ^ast.Expr { using ast; @@ -149,7 +150,7 @@ get_poly_node_to_expr :: proc (node: ^ast.Node) -> ^ast.Expr { return nil; } -resolve_poly_spec_node :: proc (ast_context: ^AstContext, call_node: ^ast.Node, spec_node: ^ast.Node, poly_map: ^map[string]^ast.Expr) { +resolve_poly_spec_node :: proc(ast_context: ^AstContext, call_node: ^ast.Node, spec_node: ^ast.Node, poly_map: ^map[string]^ast.Expr) { /* Note(Daniel, uncertain about the switch cases being enough or too little) @@ -281,7 +282,7 @@ resolve_poly_spec_node :: proc (ast_context: ^AstContext, call_node: ^ast.Node, } } -resolve_type_comp_literal :: proc (ast_context: ^AstContext, position_context: ^DocumentPositionContext, current_symbol: index.Symbol, current_comp_lit: ^ast.Comp_Lit) -> (index.Symbol, bool) { +resolve_type_comp_literal :: proc(ast_context: ^AstContext, position_context: ^DocumentPositionContext, current_symbol: index.Symbol, current_comp_lit: ^ast.Comp_Lit) -> (index.Symbol, bool) { if position_context.comp_lit == current_comp_lit { return current_symbol, true; @@ -316,11 +317,12 @@ resolve_type_comp_literal :: proc (ast_context: ^AstContext, position_context: ^ return current_symbol, true; } -resolve_generic_function :: proc { -resolve_generic_function_ast, -resolve_generic_function_symbol}; +resolve_generic_function :: proc{ + resolve_generic_function_ast, + resolve_generic_function_symbol, +}; -resolve_generic_function_symbol :: proc (ast_context: ^AstContext, params: []^ast.Field, results: []^ast.Field) -> (index.Symbol, bool) { +resolve_generic_function_symbol :: proc(ast_context: ^AstContext, params: []^ast.Field, results: []^ast.Field) -> (index.Symbol, bool) { using ast; if params == nil { @@ -410,16 +412,16 @@ resolve_generic_function_symbol :: proc (ast_context: ^AstContext, params: []^as } symbol.value = index.SymbolProcedureValue { - return_types = return_types[:], - arg_types = params, - }; + return_types = return_types[:], + arg_types = params, + }; //log.infof("return %v", poly_map); return symbol, true; } -resolve_generic_function_ast :: proc (ast_context: ^AstContext, proc_lit: ast.Proc_Lit) -> (index.Symbol, bool) { +resolve_generic_function_ast :: proc(ast_context: ^AstContext, proc_lit: ast.Proc_Lit) -> (index.Symbol, bool) { using ast; @@ -441,7 +443,7 @@ resolve_generic_function_ast :: proc (ast_context: ^AstContext, proc_lit: ast.Pr /* Figure out which function the call expression is using out of the list from proc group */ -resolve_function_overload :: proc (ast_context: ^AstContext, group: ast.Proc_Group) -> (index.Symbol, bool) { +resolve_function_overload :: proc(ast_context: ^AstContext, group: ast.Proc_Group) -> (index.Symbol, bool) { using ast; @@ -491,7 +493,7 @@ resolve_function_overload :: proc (ast_context: ^AstContext, group: ast.Proc_Gro return index.Symbol {}, false; } -resolve_basic_lit :: proc (ast_context: ^AstContext, basic_lit: ast.Basic_Lit) -> (index.Symbol, bool) { +resolve_basic_lit :: proc(ast_context: ^AstContext, basic_lit: ast.Basic_Lit) -> (index.Symbol, bool) { /* This is temporary, since basic lit is untyped, but either way it's going to be an ident representing a keyword. @@ -502,7 +504,7 @@ resolve_basic_lit :: proc (ast_context: ^AstContext, basic_lit: ast.Basic_Lit) - ident := index.new_type(ast.Ident, basic_lit.pos, basic_lit.end, context.temp_allocator); symbol := index.Symbol { - type = .Keyword + type = .Keyword, }; if v, ok := strconv.parse_bool(basic_lit.tok.text); ok { @@ -514,13 +516,13 @@ resolve_basic_lit :: proc (ast_context: ^AstContext, basic_lit: ast.Basic_Lit) - } symbol.value = index.SymbolGenericValue { - expr = ident - }; + expr = ident, + }; return symbol, true; } -resolve_type_expression :: proc (ast_context: ^AstContext, node: ^ast.Expr) -> (index.Symbol, bool) { +resolve_type_expression :: proc(ast_context: ^AstContext, node: ^ast.Expr) -> (index.Symbol, bool) { if node == nil { return {}, false; @@ -660,7 +662,7 @@ resolve_type_expression :: proc (ast_context: ^AstContext, node: ^ast.Expr) -> ( return index.Symbol {}, false; } -store_local :: proc (ast_context: ^AstContext, expr: ^ast.Expr, offset: int, name: string) { +store_local :: proc(ast_context: ^AstContext, expr: ^ast.Expr, offset: int, name: string) { local_stack := &ast_context.locals[name]; @@ -672,7 +674,7 @@ store_local :: proc (ast_context: ^AstContext, expr: ^ast.Expr, offset: int, nam append(local_stack, DocumentLocal {expr = expr, offset = offset}); } -get_local :: proc (ast_context: ^AstContext, offset: int, name: string) -> ^ast.Expr { +get_local :: proc(ast_context: ^AstContext, offset: int, name: string) -> ^ast.Expr { previous := 0; @@ -708,7 +710,7 @@ get_local :: proc (ast_context: ^AstContext, offset: int, name: string) -> ^ast. Function recusively goes through the identifier until it hits a struct, enum, procedure literals, since you can have chained variable declarations. ie. a := foo { test = 2}; b := a; c := b; */ -resolve_type_identifier :: proc (ast_context: ^AstContext, node: ast.Ident) -> (index.Symbol, bool) { +resolve_type_identifier :: proc(ast_context: ^AstContext, node: ast.Ident) -> (index.Symbol, bool) { using ast; @@ -823,7 +825,7 @@ resolve_type_identifier :: proc (ast_context: ^AstContext, node: ast.Ident) -> ( signature = node.name, pkg = ast_context.current_package, value = index.SymbolGenericValue { - expr = ident + expr = ident, }, }; return symbol, true; @@ -883,7 +885,7 @@ resolve_type_identifier :: proc (ast_context: ^AstContext, node: ast.Ident) -> ( return index.Symbol {}, false; } -resolve_ident_is_variable :: proc (ast_context: ^AstContext, node: ast.Ident) -> bool { +resolve_ident_is_variable :: proc(ast_context: ^AstContext, node: ast.Ident) -> bool { if v, ok := ast_context.variables[node.name]; ok && v { return true; @@ -896,7 +898,7 @@ resolve_ident_is_variable :: proc (ast_context: ^AstContext, node: ast.Ident) -> return false; } -resolve_ident_is_package :: proc (ast_context: ^AstContext, node: ast.Ident) -> bool { +resolve_ident_is_package :: proc(ast_context: ^AstContext, node: ast.Ident) -> bool { if strings.contains(node.name, "/") { return true; @@ -913,7 +915,7 @@ resolve_ident_is_package :: proc (ast_context: ^AstContext, node: ast.Ident) -> return false; } -expand_struct_usings :: proc (ast_context: ^AstContext, symbol: index.Symbol, value: index.SymbolStructValue) -> index.SymbolStructValue { +expand_struct_usings :: proc(ast_context: ^AstContext, symbol: index.Symbol, value: index.SymbolStructValue) -> index.SymbolStructValue { //ERROR no completion or over on names and types - generic resolve error names := slice.to_dynamic(value.names, context.temp_allocator); @@ -958,7 +960,7 @@ expand_struct_usings :: proc (ast_context: ^AstContext, symbol: index.Symbol, va }; } -resolve_symbol_return :: proc (ast_context: ^AstContext, symbol: index.Symbol, ok := true) -> (index.Symbol, bool) { +resolve_symbol_return :: proc(ast_context: ^AstContext, symbol: index.Symbol, ok := true) -> (index.Symbol, bool) { if !ok { return symbol, ok; @@ -995,7 +997,7 @@ resolve_symbol_return :: proc (ast_context: ^AstContext, symbol: index.Symbol, o return symbol, true; } -resolve_location_identifier :: proc (ast_context: ^AstContext, node: ast.Ident) -> (index.Symbol, bool) { +resolve_location_identifier :: proc(ast_context: ^AstContext, node: ast.Ident) -> (index.Symbol, bool) { symbol: index.Symbol; @@ -1010,7 +1012,7 @@ resolve_location_identifier :: proc (ast_context: ^AstContext, node: ast.Ident) return index.lookup(node.name, ast_context.document_package); } -resolve_first_symbol_from_binary_expression :: proc (ast_context: ^AstContext, binary: ^ast.Binary_Expr) -> (index.Symbol, bool) { +resolve_first_symbol_from_binary_expression :: proc(ast_context: ^AstContext, binary: ^ast.Binary_Expr) -> (index.Symbol, bool) { //Fairly simple function to find the earliest identifier symbol in binary expression. @@ -1020,14 +1022,11 @@ resolve_first_symbol_from_binary_expression :: proc (ast_context: ^AstContext, b if s, ok := resolve_type_identifier(ast_context, ident); ok { return s, ok; } - } - - else if _, ok := binary.left.derived.(ast.Binary_Expr); ok { + } else if _, ok := binary.left.derived.(ast.Binary_Expr); ok { if s, ok := resolve_first_symbol_from_binary_expression(ast_context, cast(^ast.Binary_Expr)binary.left); ok { return s, ok; } } - } if binary.right != nil { @@ -1035,9 +1034,7 @@ resolve_first_symbol_from_binary_expression :: proc (ast_context: ^AstContext, b if s, ok := resolve_type_identifier(ast_context, ident); ok { return s, ok; } - } - - else if _, ok := binary.right.derived.(ast.Binary_Expr); ok { + } else if _, ok := binary.right.derived.(ast.Binary_Expr); ok { if s, ok := resolve_first_symbol_from_binary_expression(ast_context, cast(^ast.Binary_Expr)binary.right); ok { return s, ok; } @@ -1047,31 +1044,31 @@ resolve_first_symbol_from_binary_expression :: proc (ast_context: ^AstContext, b return {}, false; } -make_pointer_ast :: proc (elem: ^ast.Expr) -> ^ast.Pointer_Type { +make_pointer_ast :: proc(elem: ^ast.Expr) -> ^ast.Pointer_Type { pointer := index.new_type(ast.Pointer_Type, elem.pos, elem.end, context.temp_allocator); pointer.elem = elem; return pointer; } -make_bool_ast :: proc () -> ^ast.Ident { +make_bool_ast :: proc() -> ^ast.Ident { ident := index.new_type(ast.Ident, {}, {}, context.temp_allocator); ident.name = bool_lit; return ident; } -make_int_ast :: proc () -> ^ast.Ident { +make_int_ast :: proc() -> ^ast.Ident { ident := index.new_type(ast.Ident, {}, {}, context.temp_allocator); ident.name = int_lit; return ident; } -get_package_from_node :: proc (node: ast.Node) -> string { +get_package_from_node :: proc(node: ast.Node) -> string { slashed, _ := filepath.to_slash(node.pos.file, context.temp_allocator); ret := strings.to_lower(path.dir(slashed, context.temp_allocator), context.temp_allocator); return ret; } -get_using_packages :: proc (ast_context: ^AstContext) -> []string { +get_using_packages :: proc(ast_context: ^AstContext) -> []string { usings := make([]string, len(ast_context.usings), context.temp_allocator); @@ -1093,7 +1090,7 @@ get_using_packages :: proc (ast_context: ^AstContext) -> []string { return usings; } -make_symbol_procedure_from_ast :: proc (ast_context: ^AstContext, n: ^ast.Node, v: ast.Proc_Type, name: string) -> index.Symbol { +make_symbol_procedure_from_ast :: proc(ast_context: ^AstContext, n: ^ast.Node, v: ast.Proc_Type, name: string) -> index.Symbol { symbol := index.Symbol { range = common.get_token_range(n^, ast_context.file.src), @@ -1125,14 +1122,14 @@ make_symbol_procedure_from_ast :: proc (ast_context: ^AstContext, n: ^ast.Node, } symbol.value = index.SymbolProcedureValue { - return_types = return_types[:], - arg_types = arg_types[:], - }; + return_types = return_types[:], + arg_types = arg_types[:], + }; return symbol; } -make_symbol_generic_from_ast :: proc (ast_context: ^AstContext, expr: ^ast.Expr) -> index.Symbol { +make_symbol_generic_from_ast :: proc(ast_context: ^AstContext, expr: ^ast.Expr) -> index.Symbol { symbol := index.Symbol { range = common.get_token_range(expr, ast_context.file.src), @@ -1142,13 +1139,13 @@ make_symbol_generic_from_ast :: proc (ast_context: ^AstContext, expr: ^ast.Expr) }; symbol.value = index.SymbolGenericValue { - expr = expr - }; + expr = expr, + }; return symbol; } -make_symbol_union_from_ast :: proc (ast_context: ^AstContext, v: ast.Union_Type, ident: ast.Ident) -> index.Symbol { +make_symbol_union_from_ast :: proc(ast_context: ^AstContext, v: ast.Union_Type, ident: ast.Ident) -> index.Symbol { symbol := index.Symbol { range = common.get_token_range(v, ast_context.file.src), @@ -1163,9 +1160,7 @@ make_symbol_union_from_ast :: proc (ast_context: ^AstContext, v: ast.Union_Type, if ident, ok := variant.derived.(ast.Ident); ok { append(&names, ident.name); - } - - else if selector, ok := variant.derived.(ast.Selector_Expr); ok { + } else if selector, ok := variant.derived.(ast.Selector_Expr); ok { if ident, ok := selector.field.derived.(ast.Ident); ok { append(&names, ident.name); @@ -1174,14 +1169,14 @@ make_symbol_union_from_ast :: proc (ast_context: ^AstContext, v: ast.Union_Type, } symbol.value = index.SymbolUnionValue { - names = names[:], - types = v.variants, + names = names[:], + types = v.variants, }; return symbol; } -make_symbol_enum_from_ast :: proc (ast_context: ^AstContext, v: ast.Enum_Type, ident: ast.Ident) -> index.Symbol { +make_symbol_enum_from_ast :: proc(ast_context: ^AstContext, v: ast.Enum_Type, ident: ast.Ident) -> index.Symbol { symbol := index.Symbol { range = common.get_token_range(v, ast_context.file.src), @@ -1202,13 +1197,13 @@ make_symbol_enum_from_ast :: proc (ast_context: ^AstContext, v: ast.Enum_Type, i } symbol.value = index.SymbolEnumValue { - names = names[:] - }; + names = names[:], + }; return symbol; } -make_symbol_bitset_from_ast :: proc (ast_context: ^AstContext, v: ast.Bit_Set_Type, ident: ast.Ident) -> index.Symbol { +make_symbol_bitset_from_ast :: proc(ast_context: ^AstContext, v: ast.Bit_Set_Type, ident: ast.Ident) -> index.Symbol { symbol := index.Symbol { range = common.get_token_range(v, ast_context.file.src), @@ -1218,13 +1213,13 @@ make_symbol_bitset_from_ast :: proc (ast_context: ^AstContext, v: ast.Bit_Set_Ty }; symbol.value = index.SymbolBitSetValue { - expr = v.elem - }; + expr = v.elem, + }; return symbol; } -make_symbol_struct_from_ast :: proc (ast_context: ^AstContext, v: ast.Struct_Type, ident: ast.Ident) -> index.Symbol { +make_symbol_struct_from_ast :: proc(ast_context: ^AstContext, v: ast.Struct_Type, ident: ast.Ident) -> index.Symbol { symbol := index.Symbol { range = common.get_token_range(v, ast_context.file.src), @@ -1252,10 +1247,10 @@ make_symbol_struct_from_ast :: proc (ast_context: ^AstContext, v: ast.Struct_Typ } symbol.value = index.SymbolStructValue { - names = names[:], - types = types[:], - usings = usings, - }; + names = names[:], + types = types[:], + usings = usings, + }; if v.poly_params != nil { resolve_poly_struct(ast_context, v, &symbol); @@ -1269,7 +1264,7 @@ make_symbol_struct_from_ast :: proc (ast_context: ^AstContext, v: ast.Struct_Typ return symbol; } -resolve_poly_struct :: proc (ast_context: ^AstContext, v: ast.Struct_Type, symbol: ^index.Symbol) { +resolve_poly_struct :: proc(ast_context: ^AstContext, v: ast.Struct_Type, symbol: ^index.Symbol) { if ast_context.call == nil { log.infof("no call"); @@ -1336,7 +1331,7 @@ resolve_poly_struct :: proc (ast_context: ^AstContext, v: ast.Struct_Type, symbo } } -get_globals :: proc (file: ast.File, ast_context: ^AstContext) { +get_globals :: proc(file: ast.File, ast_context: ^AstContext) { ast_context.variables["context"] = true; @@ -1348,7 +1343,7 @@ get_globals :: proc (file: ast.File, ast_context: ^AstContext) { } } -get_generic_assignment :: proc (file: ast.File, value: ^ast.Expr, ast_context: ^AstContext, results: ^[dynamic]^ast.Expr) { +get_generic_assignment :: proc(file: ast.File, value: ^ast.Expr, ast_context: ^AstContext, results: ^[dynamic]^ast.Expr) { using ast; @@ -1397,7 +1392,7 @@ get_generic_assignment :: proc (file: ast.File, value: ^ast.Expr, ast_context: ^ } } -get_locals_value_decl :: proc (file: ast.File, value_decl: ast.Value_Decl, ast_context: ^AstContext) { +get_locals_value_decl :: proc(file: ast.File, value_decl: ast.Value_Decl, ast_context: ^AstContext) { using ast; @@ -1428,7 +1423,7 @@ get_locals_value_decl :: proc (file: ast.File, value_decl: ast.Value_Decl, ast_c } } -get_locals_stmt :: proc (file: ast.File, stmt: ^ast.Stmt, ast_context: ^AstContext, document_position: ^DocumentPositionContext, save_assign := false) { +get_locals_stmt :: proc(file: ast.File, stmt: ^ast.Stmt, ast_context: ^AstContext, document_position: ^DocumentPositionContext, save_assign := false) { ast_context.use_locals = true; ast_context.use_globals = true; @@ -1479,7 +1474,7 @@ get_locals_stmt :: proc (file: ast.File, stmt: ^ast.Stmt, ast_context: ^AstConte } } -get_locals_using_stmt :: proc (file: ast.File, stmt: ast.Using_Stmt, ast_context: ^AstContext) { +get_locals_using_stmt :: proc(file: ast.File, stmt: ast.Using_Stmt, ast_context: ^AstContext) { for u in stmt.list { @@ -1504,7 +1499,7 @@ get_locals_using_stmt :: proc (file: ast.File, stmt: ast.Using_Stmt, ast_context } } -get_locals_assign_stmt :: proc (file: ast.File, stmt: ast.Assign_Stmt, ast_context: ^AstContext) { +get_locals_assign_stmt :: proc(file: ast.File, stmt: ast.Assign_Stmt, ast_context: ^AstContext) { using ast; @@ -1530,7 +1525,7 @@ get_locals_assign_stmt :: proc (file: ast.File, stmt: ast.Assign_Stmt, ast_conte } } -get_locals_if_stmt :: proc (file: ast.File, stmt: ast.If_Stmt, ast_context: ^AstContext, document_position: ^DocumentPositionContext) { +get_locals_if_stmt :: proc(file: ast.File, stmt: ast.If_Stmt, ast_context: ^AstContext, document_position: ^DocumentPositionContext) { if !(stmt.pos.offset <= document_position.position && document_position.position <= stmt.end.offset) { return; @@ -1541,7 +1536,7 @@ get_locals_if_stmt :: proc (file: ast.File, stmt: ast.If_Stmt, ast_context: ^Ast get_locals_stmt(file, stmt.else_stmt, ast_context, document_position); } -get_locals_for_range_stmt :: proc (file: ast.File, stmt: ast.Range_Stmt, ast_context: ^AstContext, document_position: ^DocumentPositionContext) { +get_locals_for_range_stmt :: proc(file: ast.File, stmt: ast.Range_Stmt, ast_context: ^AstContext, document_position: ^DocumentPositionContext) { using ast; @@ -1621,7 +1616,7 @@ get_locals_for_range_stmt :: proc (file: ast.File, stmt: ast.Range_Stmt, ast_con get_locals_stmt(file, stmt.body, ast_context, document_position); } -get_locals_for_stmt :: proc (file: ast.File, stmt: ast.For_Stmt, ast_context: ^AstContext, document_position: ^DocumentPositionContext) { +get_locals_for_stmt :: proc(file: ast.File, stmt: ast.For_Stmt, ast_context: ^AstContext, document_position: ^DocumentPositionContext) { if !(stmt.pos.offset <= document_position.position && document_position.position <= stmt.end.offset) { return; @@ -1631,7 +1626,7 @@ get_locals_for_stmt :: proc (file: ast.File, stmt: ast.For_Stmt, ast_context: ^A get_locals_stmt(file, stmt.body, ast_context, document_position); } -get_locals_switch_stmt :: proc (file: ast.File, stmt: ast.Switch_Stmt, ast_context: ^AstContext, document_position: ^DocumentPositionContext) { +get_locals_switch_stmt :: proc(file: ast.File, stmt: ast.Switch_Stmt, ast_context: ^AstContext, document_position: ^DocumentPositionContext) { if !(stmt.pos.offset <= document_position.position && document_position.position <= stmt.end.offset) { return; @@ -1640,7 +1635,7 @@ get_locals_switch_stmt :: proc (file: ast.File, stmt: ast.Switch_Stmt, ast_conte get_locals_stmt(file, stmt.body, ast_context, document_position); } -get_locals_type_switch_stmt :: proc (file: ast.File, stmt: ast.Type_Switch_Stmt, ast_context: ^AstContext, document_position: ^DocumentPositionContext) { +get_locals_type_switch_stmt :: proc(file: ast.File, stmt: ast.Type_Switch_Stmt, ast_context: ^AstContext, document_position: ^DocumentPositionContext) { using ast; @@ -1674,7 +1669,7 @@ get_locals_type_switch_stmt :: proc (file: ast.File, stmt: ast.Type_Switch_Stmt, } } -get_locals :: proc (file: ast.File, function: ^ast.Node, ast_context: ^AstContext, document_position: ^DocumentPositionContext) { +get_locals :: proc(file: ast.File, function: ^ast.Node, ast_context: ^AstContext, document_position: ^DocumentPositionContext) { proc_lit, ok := function.derived.(ast.Proc_Lit); @@ -1719,14 +1714,14 @@ get_locals :: proc (file: ast.File, function: ^ast.Node, ast_context: ^AstContex } } -clear_locals :: proc (ast_context: ^AstContext) { +clear_locals :: proc(ast_context: ^AstContext) { clear(&ast_context.locals); clear(&ast_context.parameters); clear(&ast_context.variables); clear(&ast_context.usings); } -concatenate_symbols_information :: proc (ast_context: ^AstContext, symbol: index.Symbol) -> string { +concatenate_symbols_information :: proc(ast_context: ^AstContext, symbol: index.Symbol) -> string { pkg := path.base(symbol.pkg, false, context.temp_allocator); @@ -1751,7 +1746,7 @@ concatenate_symbols_information :: proc (ast_context: ^AstContext, symbol: index return ""; //weird bug requires this } -get_definition_location :: proc (document: ^Document, position: common.Position) -> (common.Location, bool) { +get_definition_location :: proc(document: ^Document, position: common.Position) -> (common.Location, bool) { location: common.Location; @@ -1866,7 +1861,7 @@ get_definition_location :: proc (document: ^Document, position: common.Position) return location, true; } -write_hover_content :: proc (ast_context: ^AstContext, symbol: index.Symbol) -> MarkupContent { +write_hover_content :: proc(ast_context: ^AstContext, symbol: index.Symbol) -> MarkupContent { content: MarkupContent; cat := concatenate_symbols_information(ast_context, symbol); @@ -1881,7 +1876,7 @@ write_hover_content :: proc (ast_context: ^AstContext, symbol: index.Symbol) -> return content; } -get_signature :: proc (ast_context: ^AstContext, ident: ast.Ident, symbol: index.Symbol, was_variable := false) -> string { +get_signature :: proc(ast_context: ^AstContext, ident: ast.Ident, symbol: index.Symbol, was_variable := false) -> string { if symbol.type == .Function { return symbol.signature; @@ -1921,7 +1916,7 @@ get_signature :: proc (ast_context: ^AstContext, ident: ast.Ident, symbol: index return ident.name; } -get_signature_information :: proc (document: ^Document, position: common.Position) -> (SignatureHelp, bool) { +get_signature_information :: proc(document: ^Document, position: common.Position) -> (SignatureHelp, bool) { signature_help: SignatureHelp; @@ -1960,7 +1955,7 @@ get_signature_information :: proc (document: ^Document, position: common.Positio return signature_help, true; } -get_document_symbols :: proc (document: ^Document) -> []DocumentSymbol { +get_document_symbols :: proc(document: ^Document) -> []DocumentSymbol { ast_context := make_ast_context(document.ast, document.imports, document.package_name); @@ -1977,13 +1972,13 @@ get_document_symbols :: proc (document: ^Document) -> []DocumentSymbol { package_symbol.kind = .Package; package_symbol.name = path.base(document.package_name, false, context.temp_allocator); package_symbol.range = { - start = { - line = document.ast.decls[0].pos.line - }, - end = { - line = document.ast.decls[len(document.ast.decls) - 1].end.line - }, - }; + start = { + line = document.ast.decls[0].pos.line, + }, + end = { + line = document.ast.decls[len(document.ast.decls) - 1].end.line, + }, + }; package_symbol.selectionRange = package_symbol.range; children_symbols := make([dynamic]DocumentSymbol, context.temp_allocator); @@ -2024,7 +2019,7 @@ get_document_symbols :: proc (document: ^Document) -> []DocumentSymbol { /* Figure out what exactly is at the given position and whether it is in a function, struct, etc. */ -get_document_position_context :: proc (document: ^Document, position: common.Position, hint: DocumentPositionContextHint) -> (DocumentPositionContext, bool) { +get_document_position_context :: proc(document: ^Document, position: common.Position, hint: DocumentPositionContextHint) -> (DocumentPositionContext, bool) { position_context: DocumentPositionContext; @@ -2074,7 +2069,7 @@ get_document_position_context :: proc (document: ^Document, position: common.Pos return position_context, true; } -fallback_position_context_completion :: proc (document: ^Document, position: common.Position, position_context: ^DocumentPositionContext) { +fallback_position_context_completion :: proc(document: ^Document, position: common.Position, position_context: ^DocumentPositionContext) { paren_count: int; bracket_count: int; @@ -2243,7 +2238,7 @@ fallback_position_context_completion :: proc (document: ^Document, position: com } } -fallback_position_context_signature :: proc (document: ^Document, position: common.Position, position_context: ^DocumentPositionContext) { +fallback_position_context_signature :: proc(document: ^Document, position: common.Position, position_context: ^DocumentPositionContext) { paren_count: int; end: int; @@ -2312,30 +2307,31 @@ fallback_position_context_signature :: proc (document: ^Document, position: comm position_context.call = e; } -get_document_position :: proc { -get_document_position_array, -get_document_position_dynamic_array, -get_document_position_node}; +get_document_position :: proc{ + get_document_position_array, + get_document_position_dynamic_array, + get_document_position_node, +}; -get_document_position_array :: proc (array: $A/[]^$T, position_context: ^DocumentPositionContext) { +get_document_position_array :: proc(array: $A/[]^$T, position_context: ^DocumentPositionContext) { for elem, i in array { get_document_position(elem, position_context); } } -get_document_position_dynamic_array :: proc (array: $A/[dynamic]^$T, position_context: ^DocumentPositionContext) { +get_document_position_dynamic_array :: proc(array: $A/[dynamic]^$T, position_context: ^DocumentPositionContext) { for elem, i in array { get_document_position(elem, position_context); } } -position_in_node :: proc (node: ^ast.Node, position: common.AbsolutePosition) -> bool { +position_in_node :: proc(node: ^ast.Node, position: common.AbsolutePosition) -> bool { return node != nil && node.pos.offset <= position && position <= node.end.offset; } -get_document_position_node :: proc (node: ^ast.Node, position_context: ^DocumentPositionContext) { +get_document_position_node :: proc(node: ^ast.Node, position_context: ^DocumentPositionContext) { using ast; diff --git a/src/server/background.odin b/src/server/background.odin index 3cd8064..dd2d719 100644 --- a/src/server/background.odin +++ b/src/server/background.odin @@ -6,5 +6,5 @@ package server import "shared:index" -background_main :: proc () { +background_main :: proc() { } diff --git a/src/server/completion.odin b/src/server/completion.odin index 9793845..bd0e1f5 100644 --- a/src/server/completion.odin +++ b/src/server/completion.odin @@ -24,7 +24,7 @@ Completion_Type :: enum { Comp_Lit, } -get_completion_list :: proc (document: ^Document, position: common.Position) -> (CompletionList, bool) { +get_completion_list :: proc(document: ^Document, position: common.Position) -> (CompletionList, bool) { list: CompletionList; @@ -64,11 +64,8 @@ get_completion_list :: proc (document: ^Document, position: common.Position) -> if union_value, ok := symbol.value.(index.SymbolUnionValue); ok { completion_type = .Switch_Type; } - } - } - } switch completion_type { @@ -87,7 +84,7 @@ get_completion_list :: proc (document: ^Document, position: common.Position) -> return list, true; } -is_lhs_comp_lit :: proc (position_context: ^DocumentPositionContext) -> bool { +is_lhs_comp_lit :: proc(position_context: ^DocumentPositionContext) -> bool { if len(position_context.comp_lit.elems) == 0 { return true; @@ -111,7 +108,7 @@ is_lhs_comp_lit :: proc (position_context: ^DocumentPositionContext) -> bool { return true; } -field_exists_in_comp_lit :: proc (comp_lit: ^ast.Comp_Lit, name: string) -> bool { +field_exists_in_comp_lit :: proc(comp_lit: ^ast.Comp_Lit, name: string) -> bool { for elem in comp_lit.elems { @@ -132,11 +129,10 @@ field_exists_in_comp_lit :: proc (comp_lit: ^ast.Comp_Lit, name: string) -> bool return false; } -get_attribute_completion :: proc (ast_context: ^AstContext, postition_context: ^DocumentPositionContext, list: ^CompletionList) { - +get_attribute_completion :: proc(ast_context: ^AstContext, postition_context: ^DocumentPositionContext, list: ^CompletionList) { } -get_directive_completion :: proc (ast_context: ^AstContext, postition_context: ^DocumentPositionContext, list: ^CompletionList) { +get_directive_completion :: proc(ast_context: ^AstContext, postition_context: ^DocumentPositionContext, list: ^CompletionList) { list.isIncomplete = false; @@ -181,7 +177,7 @@ get_directive_completion :: proc (ast_context: ^AstContext, postition_context: ^ list.items = items[:]; } -get_comp_lit_completion :: proc (ast_context: ^AstContext, position_context: ^DocumentPositionContext, list: ^CompletionList) { +get_comp_lit_completion :: proc(ast_context: ^AstContext, position_context: ^DocumentPositionContext, list: ^CompletionList) { items := make([dynamic]CompletionItem, context.temp_allocator); @@ -196,7 +192,6 @@ get_comp_lit_completion :: proc (ast_context: ^AstContext, position_context: ^Do #partial switch v in comp_symbol.value { case index.SymbolStructValue: for name, i in v.names { - //ERROR no completion on name and hover if resolved, ok := resolve_type_expression(ast_context, v.types[i]); ok { @@ -226,7 +221,7 @@ get_comp_lit_completion :: proc (ast_context: ^AstContext, position_context: ^Do list.items = items[:]; } -get_selector_completion :: proc (ast_context: ^AstContext, position_context: ^DocumentPositionContext, list: ^CompletionList) { +get_selector_completion :: proc(ast_context: ^AstContext, position_context: ^DocumentPositionContext, list: ^CompletionList) { items := make([dynamic]CompletionItem, context.temp_allocator); @@ -287,9 +282,7 @@ get_selector_completion :: proc (ast_context: ^AstContext, position_context: ^Do if symbol.pkg == ast_context.document_package { symbol.name = fmt.aprintf("(%v)", name); - } - - else { + } else { symbol.name = fmt.aprintf("(%v.%v)", path.base(symbol.pkg, false, context.temp_allocator), name); } @@ -378,7 +371,7 @@ get_selector_completion :: proc (ast_context: ^AstContext, position_context: ^Do list.items = items[:]; } -unwrap_enum :: proc (ast_context: ^AstContext, node: ^ast.Expr) -> (index.SymbolEnumValue, bool) { +unwrap_enum :: proc(ast_context: ^AstContext, node: ^ast.Expr) -> (index.SymbolEnumValue, bool) { if enum_symbol, ok := resolve_type_expression(ast_context, node); ok { @@ -390,7 +383,7 @@ unwrap_enum :: proc (ast_context: ^AstContext, node: ^ast.Expr) -> (index.Symbol return {}, false; } -unwrap_union :: proc (ast_context: ^AstContext, node: ^ast.Expr) -> (index.SymbolUnionValue, bool) { +unwrap_union :: proc(ast_context: ^AstContext, node: ^ast.Expr) -> (index.SymbolUnionValue, bool) { if union_symbol, ok := resolve_type_expression(ast_context, node); ok { @@ -402,7 +395,7 @@ unwrap_union :: proc (ast_context: ^AstContext, node: ^ast.Expr) -> (index.Symbo return {}, false; } -unwrap_bitset :: proc (ast_context: ^AstContext, bitset_symbol: index.Symbol) -> (index.SymbolEnumValue, bool) { +unwrap_bitset :: proc(ast_context: ^AstContext, bitset_symbol: index.Symbol) -> (index.SymbolEnumValue, bool) { if bitset_value, ok := bitset_symbol.value.(index.SymbolBitSetValue); ok { if enum_symbol, ok := resolve_type_expression(ast_context, bitset_value.expr); ok { @@ -415,7 +408,7 @@ unwrap_bitset :: proc (ast_context: ^AstContext, bitset_symbol: index.Symbol) -> return {}, false; } -get_implicit_completion :: proc (ast_context: ^AstContext, position_context: ^DocumentPositionContext, list: ^CompletionList) { +get_implicit_completion :: proc(ast_context: ^AstContext, position_context: ^DocumentPositionContext, list: ^CompletionList) { items := make([dynamic]CompletionItem, context.temp_allocator); @@ -488,7 +481,7 @@ get_implicit_completion :: proc (ast_context: ^AstContext, position_context: ^Do } } } - } else if position_context.comp_lit != nil && position_context.assign != nil && position_context.assign.lhs != nil && len(position_context.assign.lhs) == 1 && is_bitset_assignment_operator(position_context.assign.op.text) { + } else if position_context.comp_lit != nil && position_context.assign != nil && position_context.assign.lhs != nil && len(position_context.assign.lhs) == 1 && is_bitset_assignment_operator(position_context.assign.op.text) { if symbol, ok := resolve_type_expression(ast_context, position_context.assign.lhs[0]); ok { @@ -505,10 +498,7 @@ get_implicit_completion :: proc (ast_context: ^AstContext, position_context: ^Do append(&items, item); } } - } - - } else if position_context.comp_lit != nil { if position_context.parent_comp_lit.type == nil { @@ -678,7 +668,7 @@ get_implicit_completion :: proc (ast_context: ^AstContext, position_context: ^Do list.items = items[:]; } -get_identifier_completion :: proc (ast_context: ^AstContext, position_context: ^DocumentPositionContext, list: ^CompletionList) { +get_identifier_completion :: proc(ast_context: ^AstContext, position_context: ^DocumentPositionContext, list: ^CompletionList) { items := make([dynamic]CompletionItem, context.temp_allocator); @@ -690,18 +680,18 @@ get_identifier_completion :: proc (ast_context: ^AstContext, position_context: ^ variable: ^ast.Ident, }; - combined_sort_interface :: proc (s: ^[dynamic]CombinedResult) -> sort.Interface { + combined_sort_interface :: proc(s: ^[dynamic]CombinedResult) -> sort.Interface { return sort.Interface { collection = rawptr(s), - len = proc (it: sort.Interface) -> int { + len = proc(it: sort.Interface) -> int { s := (^[dynamic]CombinedResult)(it.collection); return len(s^); }, - less = proc (it: sort.Interface, i, j: int) -> bool { + less = proc(it: sort.Interface, i, j: int) -> bool { s := (^[dynamic]CombinedResult)(it.collection); return s[i].score > s[j].score; }, - swap = proc (it: sort.Interface, i, j: int) { + swap = proc(it: sort.Interface, i, j: int) { s := (^[dynamic]CombinedResult)(it.collection); s[i], s[j] = s[j], s[i]; }, @@ -822,10 +812,10 @@ get_identifier_completion :: proc (ast_context: ^AstContext, position_context: ^ list.items = items[:]; } -get_package_completion :: proc (ast_context: ^AstContext, position_context: ^DocumentPositionContext, list: ^CompletionList) { +get_package_completion :: proc(ast_context: ^AstContext, position_context: ^DocumentPositionContext, list: ^CompletionList) { } -get_type_switch_Completion :: proc (ast_context: ^AstContext, position_context: ^DocumentPositionContext, list: ^CompletionList) { +get_type_switch_Completion :: proc(ast_context: ^AstContext, position_context: ^DocumentPositionContext, list: ^CompletionList) { items := make([dynamic]CompletionItem, context.temp_allocator); list.isIncomplete = false; @@ -865,12 +855,10 @@ get_type_switch_Completion :: proc (ast_context: ^AstContext, position_context: }; if symbol.pkg == ast_context.document_package { - item.label = fmt.aprintf("%v", name); + item.label = fmt.aprintf("%v", name); item.detail = item.label; - } - - else { - item.label = fmt.aprintf("%v.%v", path.base(symbol.pkg, false, context.temp_allocator), name); + } else { + item.label = fmt.aprintf("%v.%v", path.base(symbol.pkg, false, context.temp_allocator), name); item.detail = item.label; } @@ -900,10 +888,10 @@ bitset_assignment_operators: map[string]bool = { "=" = true, }; -is_bitset_binary_operator :: proc (op: string) -> bool { +is_bitset_binary_operator :: proc(op: string) -> bool { return op in bitset_operators; } -is_bitset_assignment_operator :: proc (op: string) -> bool { +is_bitset_assignment_operator :: proc(op: string) -> bool { return op in bitset_assignment_operators; -}
\ No newline at end of file +} diff --git a/src/server/documents.odin b/src/server/documents.odin index 7f92cb0..92cab27 100644 --- a/src/server/documents.odin +++ b/src/server/documents.odin @@ -47,7 +47,7 @@ DocumentStorage :: struct { document_storage: DocumentStorage; -document_storage_shutdown :: proc () { +document_storage_shutdown :: proc() { for k, v in document_storage.documents { delete(k); @@ -62,7 +62,7 @@ document_storage_shutdown :: proc () { delete(document_storage.documents); } -document_get_allocator :: proc () -> ^common.Scratch_Allocator { +document_get_allocator :: proc() -> ^common.Scratch_Allocator { if len(document_storage.free_allocators) > 0 { return pop(&document_storage.free_allocators); @@ -73,11 +73,11 @@ document_get_allocator :: proc () -> ^common.Scratch_Allocator { } } -document_free_allocator :: proc (allocator: ^common.Scratch_Allocator) { +document_free_allocator :: proc(allocator: ^common.Scratch_Allocator) { append(&document_storage.free_allocators, allocator); } -document_get :: proc (uri_string: string) -> ^Document { +document_get :: proc(uri_string: string) -> ^Document { uri, parsed_ok := common.parse_uri(uri_string, context.temp_allocator); @@ -96,7 +96,7 @@ document_get :: proc (uri_string: string) -> ^Document { return document; } -document_release :: proc (document: ^Document) { +document_release :: proc(document: ^Document) { if document != nil { intrinsics.atomic_sub(&document.operating_on, 1); @@ -107,7 +107,7 @@ document_release :: proc (document: ^Document) { Client opens a document with transferred text */ -document_open :: proc (uri_string: string, text: string, config: ^common.Config, writer: ^Writer) -> common.Error { +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); @@ -160,7 +160,7 @@ 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 { +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); @@ -236,7 +236,7 @@ document_apply_changes :: proc (uri_string: string, changes: [dynamic]TextDocume return document_refresh(document, config, writer); } -document_close :: proc (uri_string: string) -> common.Error { +document_close :: proc(uri_string: string) -> common.Error { log.infof("document_close: %v", uri_string); @@ -268,7 +268,7 @@ document_close :: proc (uri_string: string) -> common.Error { return .None; } -document_refresh :: proc (document: ^Document, config: ^common.Config, writer: ^Writer) -> common.Error { +document_refresh :: proc(document: ^Document, config: ^common.Config, writer: ^Writer) -> common.Error { errors, ok := parse_document(document, config); @@ -287,20 +287,20 @@ document_refresh :: proc (document: ^Document, config: ^common.Config, writer: ^ for error, i in errors { params.diagnostics[i] = Diagnostic { - range = common.Range { - start = common.Position { - line = error.line - 1, - character = 0, - }, - end = common.Position { - line = error.line, - character = 0, - }, + range = common.Range { + start = common.Position { + line = error.line - 1, + character = 0, }, - severity = DiagnosticSeverity.Error, - code = "test", - message = error.message, - }; + end = common.Position { + line = error.line, + character = 0, + }, + }, + severity = DiagnosticSeverity.Error, + code = "test", + message = error.message, + }; } notifaction := Notification { @@ -337,7 +337,7 @@ document_refresh :: proc (document: ^Document, config: ^common.Config, writer: ^ current_errors: [dynamic]ParserError; -parser_error_handler :: proc (pos: tokenizer.Pos, msg: string, args: ..any) { +parser_error_handler :: proc(pos: tokenizer.Pos, msg: string, args: ..any) { error := ParserError { line = pos.line,column = pos.column,file = pos.file, offset = pos.offset,message = fmt.tprintf(msg, ..args), @@ -345,10 +345,10 @@ parser_error_handler :: proc (pos: tokenizer.Pos, msg: string, args: ..any) { append(¤t_errors, error); } -parser_warning_handler :: proc (pos: tokenizer.Pos, msg: string, args: ..any) { +parser_warning_handler :: proc(pos: tokenizer.Pos, msg: string, args: ..any) { } -parse_document :: proc (document: ^Document, config: ^common.Config) -> ([]ParserError, bool) { +parse_document :: proc(document: ^Document, config: ^common.Config) -> ([]ParserError, bool) { p := parser.Parser { err = parser_error_handler, @@ -367,10 +367,10 @@ parse_document :: proc (document: ^Document, config: ^common.Config) -> ([]Parse pkg.fullpath = document.uri.path; document.ast = ast.File { - fullpath = document.uri.path, - src = document.text[:document.used_text], - pkg = pkg, - }; + fullpath = document.uri.path, + src = document.text[:document.used_text], + pkg = pkg, + }; parser.parse_file(&p, &document.ast); @@ -409,7 +409,7 @@ parse_document :: proc (document: ^Document, config: ^common.Config) -> ([]Parse } append(&imports, import_); - } else + } else //relative { diff --git a/src/server/format.odin b/src/server/format.odin index 180d0d2..791bab8 100644 --- a/src/server/format.odin +++ b/src/server/format.odin @@ -3,7 +3,7 @@ package server import "shared:common" -//import "core:odin/printer" +import "core:odin/printer" FormattingOptions :: struct { tabSize: uint, @@ -25,7 +25,6 @@ TextEdit :: struct { get_complete_format :: proc (document: ^Document) -> ([]TextEdit, bool) { - /* prnt := printer.make_printer(printer.default_style, context.temp_allocator); printer.print_file(&prnt, &document.ast); @@ -51,6 +50,4 @@ get_complete_format :: proc (document: ^Document) -> ([]TextEdit, bool) { append(&edits, edit); return edits[:], true; - */ - return {}, true; } diff --git a/src/server/hover.odin b/src/server/hover.odin index 30a8fb0..b8cd5bc 100644 --- a/src/server/hover.odin +++ b/src/server/hover.odin @@ -16,12 +16,12 @@ import "core:slice" import "shared:common" import "shared:index" -get_hover_information :: proc (document: ^Document, position: common.Position) -> (Hover, bool) { +get_hover_information :: proc(document: ^Document, position: common.Position) -> (Hover, bool) { hover := Hover { contents = { - kind = "plaintext" - } + kind = "plaintext", + }, }; ast_context := make_ast_context(document.ast, document.imports, document.package_name); diff --git a/src/server/log.odin b/src/server/log.odin index 1527fa2..cf83979 100644 --- a/src/server/log.odin +++ b/src/server/log.odin @@ -18,17 +18,17 @@ Lsp_Logger_Data :: struct { writer: ^Writer, } -create_lsp_logger :: proc (writer: ^Writer, lowest := log.Level.Debug, opt := Default_Console_Logger_Opts) -> log.Logger { +create_lsp_logger :: proc(writer: ^Writer, lowest := log.Level.Debug, opt := Default_Console_Logger_Opts) -> log.Logger { data := new(Lsp_Logger_Data); data.writer = writer; return log.Logger {lsp_logger_proc, data, lowest, opt}; } -destroy_lsp_logger :: proc (log: ^log.Logger) { +destroy_lsp_logger :: proc(log: ^log.Logger) { free(log.data); } -lsp_logger_proc :: proc (logger_data: rawptr, level: log.Level, text: string, options: log.Options, location := #caller_location) { +lsp_logger_proc :: proc(logger_data: rawptr, level: log.Level, text: string, options: log.Options, location := #caller_location) { data := cast(^Lsp_Logger_Data)logger_data; diff --git a/src/server/reader.odin b/src/server/reader.odin index 7679db7..b8843de 100644 --- a/src/server/reader.odin +++ b/src/server/reader.odin @@ -4,18 +4,18 @@ import "core:os" import "core:mem" import "core:strings" -ReaderFn :: proc (_: rawptr, _: []byte) -> (int, int); +ReaderFn :: proc(_: rawptr, _: []byte) -> (int, int); Reader :: struct { reader_fn: ReaderFn, reader_context: rawptr, } -make_reader :: proc (reader_fn: ReaderFn, reader_context: rawptr) -> Reader { +make_reader :: proc(reader_fn: ReaderFn, reader_context: rawptr) -> Reader { return Reader {reader_context = reader_context, reader_fn = reader_fn}; } -read_u8 :: proc (reader: ^Reader) -> (u8, bool) { +read_u8 :: proc(reader: ^Reader) -> (u8, bool) { value: [1]byte; @@ -28,7 +28,7 @@ read_u8 :: proc (reader: ^Reader) -> (u8, bool) { return value[0], true; } -read_until_delimiter :: proc (reader: ^Reader, delimiter: u8, builder: ^strings.Builder) -> bool { +read_until_delimiter :: proc(reader: ^Reader, delimiter: u8, builder: ^strings.Builder) -> bool { for true { @@ -48,7 +48,7 @@ read_until_delimiter :: proc (reader: ^Reader, delimiter: u8, builder: ^strings. return true; } -read_sized :: proc (reader: ^Reader, data: []u8) -> bool { +read_sized :: proc(reader: ^Reader, data: []u8) -> bool { read, err := reader.reader_fn(reader.reader_context, data); diff --git a/src/server/requests.odin b/src/server/requests.odin index 0dc9b7c..6085115 100644 --- a/src/server/requests.odin +++ b/src/server/requests.odin @@ -193,7 +193,7 @@ handle_error :: proc (err: common.Error, id: RequestId, writer: ^Writer) { if err != .None { response := make_response_message_error( - id = id, + id = id, error = ResponseError {code = err, message = ""}); send_error(response, writer); @@ -232,7 +232,7 @@ handle_request :: proc (request: json.Value, config: ^common.Config, writer: ^Wr if !ok { response := make_response_message_error( - id = id, + id = id, error = ResponseError {code = .MethodNotFound, message = ""}); send_error(response, writer); @@ -502,7 +502,7 @@ request_initialize :: proc (task: ^common.Task) { hoverProvider = enable_hover, documentFormattingProvider = enable_format, } - }, + }, id = id); send_response(response, writer); @@ -546,7 +546,7 @@ request_shutdown :: proc (task: ^common.Task) { defer free(info); response := make_response_message( - params = nil, + params = nil, id = id); send_response(response, writer); @@ -583,7 +583,7 @@ request_definition :: proc (task: ^common.Task) { } response := make_response_message( - params = location, + params = location, id = id); send_response(response, writer); @@ -623,7 +623,7 @@ request_completion :: proc (task: ^common.Task) { } response := make_response_message( - params = list, + params = list, id = id); send_response(response, writer); @@ -662,7 +662,7 @@ request_signature_help :: proc (task: ^common.Task) { } response := make_response_message( - params = help, + params = help, id = id); send_response(response, writer); @@ -701,7 +701,7 @@ request_format_document :: proc (task: ^common.Task) { } response := make_response_message( - params = edit, + params = edit, id = id); send_response(response, writer); @@ -917,7 +917,7 @@ request_semantic_token_full :: proc (task: ^common.Task) { } response := make_response_message( - params = symbols, + params = symbols, id = id); send_response(response, writer); @@ -954,7 +954,7 @@ request_semantic_token_range :: proc (task: ^common.Task) { } response := make_response_message( - params = symbols, + params = symbols, id = id); send_response(response, writer); @@ -987,7 +987,7 @@ request_document_symbols :: proc (task: ^common.Task) { symbols := get_document_symbols(document); response := make_response_message( - params = symbols, + params = symbols, id = id); send_response(response, writer); @@ -1026,7 +1026,7 @@ request_hover :: proc (task: ^common.Task) { } response := make_response_message( - params = hover, + params = hover, id = id); send_response(response, writer); diff --git a/src/server/response.odin b/src/server/response.odin index d5d3e7b..4e5b680 100644 --- a/src/server/response.odin +++ b/src/server/response.odin @@ -13,11 +13,11 @@ send_notification :: proc (notification: Notification, writer: ^Writer) -> bool return false; } - if (!write_sized(writer, transmute([]u8)header)) { + if !write_sized(writer, transmute([]u8)header) { return false; } - if (!write_sized(writer, data)) { + if !write_sized(writer, data) { return false; } @@ -34,11 +34,11 @@ send_response :: proc (response: ResponseMessage, writer: ^Writer) -> bool { return false; } - if (!write_sized(writer, transmute([]u8)header)) { + if !write_sized(writer, transmute([]u8)header) { return false; } - if (!write_sized(writer, data)) { + if !write_sized(writer, data) { return false; } @@ -55,11 +55,11 @@ send_error :: proc (response: ResponseMessageError, writer: ^Writer) -> bool { return false; } - if (!write_sized(writer, transmute([]u8)header)) { + if !write_sized(writer, transmute([]u8)header) { return false; } - if (!write_sized(writer, data)) { + if !write_sized(writer, data) { return false; } diff --git a/src/server/semantic_tokens.odin b/src/server/semantic_tokens.odin index 4db13ca..9b2e669 100644 --- a/src/server/semantic_tokens.odin +++ b/src/server/semantic_tokens.odin @@ -81,20 +81,20 @@ SemanticTokenBuilder :: struct { tokens: [dynamic]u32, } -make_token_builder :: proc (allocator := context.temp_allocator) -> SemanticTokenBuilder { +make_token_builder :: proc(allocator := context.temp_allocator) -> SemanticTokenBuilder { return { - tokens = make([dynamic]u32, context.temp_allocator) + tokens = make([dynamic]u32, context.temp_allocator), }; } -get_tokens :: proc (builder: SemanticTokenBuilder) -> SemanticTokens { +get_tokens :: proc(builder: SemanticTokenBuilder) -> SemanticTokens { return { - data = builder.tokens[:] + data = builder.tokens[:], }; } -get_semantic_tokens :: proc (document: ^Document, range: common.Range) -> SemanticTokens { +get_semantic_tokens :: proc(document: ^Document, range: common.Range) -> SemanticTokens { ast_context := make_ast_context(document.ast, document.imports, document.package_name, context.temp_allocator); builder := make_token_builder(); @@ -110,7 +110,7 @@ get_semantic_tokens :: proc (document: ^Document, range: common.Range) -> Semant return get_tokens(builder); } -write_semantic_node :: proc (builder: ^SemanticTokenBuilder, node: ^ast.Node, src: []byte, type: SemanticTokenTypes, modifier: SemanticTokenModifiers) { +write_semantic_node :: proc(builder: ^SemanticTokenBuilder, node: ^ast.Node, src: []byte, type: SemanticTokenTypes, modifier: SemanticTokenModifiers) { position := common.get_relative_token_position(node.pos.offset, src, builder.current_start); @@ -121,7 +121,7 @@ write_semantic_node :: proc (builder: ^SemanticTokenBuilder, node: ^ast.Node, sr builder.current_start = node.pos.offset; } -write_semantic_token :: proc (builder: ^SemanticTokenBuilder, token: tokenizer.Token, src: []byte, type: SemanticTokenTypes, modifier: SemanticTokenModifiers) { +write_semantic_token :: proc(builder: ^SemanticTokenBuilder, token: tokenizer.Token, src: []byte, type: SemanticTokenTypes, modifier: SemanticTokenModifiers) { position := common.get_relative_token_position(token.pos.offset, src, builder.current_start); @@ -130,7 +130,7 @@ write_semantic_token :: proc (builder: ^SemanticTokenBuilder, token: tokenizer.T builder.current_start = token.pos.offset; } -write_semantic_token_pos :: proc (builder: ^SemanticTokenBuilder, pos: tokenizer.Pos, name: string, src: []byte, type: SemanticTokenTypes, modifier: SemanticTokenModifiers) { +write_semantic_token_pos :: proc(builder: ^SemanticTokenBuilder, pos: tokenizer.Pos, name: string, src: []byte, type: SemanticTokenTypes, modifier: SemanticTokenModifiers) { position := common.get_relative_token_position(pos.offset, src, builder.current_start); @@ -139,11 +139,11 @@ write_semantic_token_pos :: proc (builder: ^SemanticTokenBuilder, pos: tokenizer builder.current_start = pos.offset; } -resolve_and_write_ident :: proc (node: ^ast.Node, builder: ^SemanticTokenBuilder, ast_context: ^AstContext) -> (is_member: bool, is_package: bool, package_name: string) { +resolve_and_write_ident :: proc(node: ^ast.Node, builder: ^SemanticTokenBuilder, ast_context: ^AstContext) -> (is_member: bool, is_package: bool, package_name: string) { n := node.derived.(ast.Ident); - package_name = ast_context.document_package; + package_name = ast_context.document_package; ast_context.current_package = ast_context.document_package; ast_context.use_globals = true; ast_context.use_locals = true; @@ -155,7 +155,7 @@ resolve_and_write_ident :: proc (node: ^ast.Node, builder: ^SemanticTokenBuilder #partial switch v in symbol.value { case index.SymbolPackageValue: write_semantic_node(builder, node, ast_context.file.src, .Namespace, .None); - is_package = true; + is_package = true; package_name = symbol.pkg; case index.SymbolStructValue: write_semantic_node(builder, node, ast_context.file.src, .Struct, .None); @@ -178,28 +178,28 @@ resolve_and_write_ident :: proc (node: ^ast.Node, builder: ^SemanticTokenBuilder return; } -write_semantic_tokens :: proc { +write_semantic_tokens :: proc{ write_semantic_tokens_node, write_semantic_tokens_dynamic_array, write_semantic_tokens_array, write_semantic_tokens_stmt, }; -write_semantic_tokens_array :: proc (array: $A/[]^$T, builder: ^SemanticTokenBuilder, ast_context: ^AstContext) { +write_semantic_tokens_array :: proc(array: $A/[]^$T, builder: ^SemanticTokenBuilder, ast_context: ^AstContext) { for elem, i in array { write_semantic_tokens(elem, builder, ast_context); } } -write_semantic_tokens_dynamic_array :: proc (array: $A/[dynamic]^$T, builder: ^SemanticTokenBuilder, ast_context: ^AstContext) { +write_semantic_tokens_dynamic_array :: proc(array: $A/[dynamic]^$T, builder: ^SemanticTokenBuilder, ast_context: ^AstContext) { for elem, i in array { write_semantic_tokens(elem, builder, ast_context); } } -write_semantic_tokens_stmt :: proc (node: ^ast.Stmt, builder: ^SemanticTokenBuilder, ast_context: ^AstContext) { +write_semantic_tokens_stmt :: proc(node: ^ast.Stmt, builder: ^SemanticTokenBuilder, ast_context: ^AstContext) { ast_context.current_package = ast_context.document_package; ast_context.use_globals = true; ast_context.use_locals = true; @@ -208,7 +208,7 @@ write_semantic_tokens_stmt :: proc (node: ^ast.Stmt, builder: ^SemanticTokenBuil write_semantic_tokens_node(node, builder, ast_context); } -write_semantic_tokens_node :: proc (node: ^ast.Node, builder: ^SemanticTokenBuilder, ast_context: ^AstContext) { +write_semantic_tokens_node :: proc(node: ^ast.Node, builder: ^SemanticTokenBuilder, ast_context: ^AstContext) { using ast; @@ -365,7 +365,7 @@ write_semantic_tokens_node :: proc (node: ^ast.Node, builder: ^SemanticTokenBuil } } -write_semantic_token_basic_lit :: proc (basic_lit: ast.Basic_Lit, builder: ^SemanticTokenBuilder, ast_context: ^AstContext) { +write_semantic_token_basic_lit :: proc(basic_lit: ast.Basic_Lit, builder: ^SemanticTokenBuilder, ast_context: ^AstContext) { if symbol, ok := resolve_basic_lit(ast_context, basic_lit); ok { @@ -383,7 +383,7 @@ write_semantic_token_basic_lit :: proc (basic_lit: ast.Basic_Lit, builder: ^Sema } } -write_semantic_tokens_value_decl :: proc (value_decl: ast.Value_Decl, builder: ^SemanticTokenBuilder, ast_context: ^AstContext) { +write_semantic_tokens_value_decl :: proc(value_decl: ast.Value_Decl, builder: ^SemanticTokenBuilder, ast_context: ^AstContext) { using ast; @@ -445,7 +445,7 @@ write_semantic_tokens_value_decl :: proc (value_decl: ast.Value_Decl, builder: ^ } } -write_semantic_token_op :: proc (builder: ^SemanticTokenBuilder, token: tokenizer.Token, src: []byte) { +write_semantic_token_op :: proc(builder: ^SemanticTokenBuilder, token: tokenizer.Token, src: []byte) { if token.text == "=" { write_semantic_token_pos(builder, token.pos, token.text, src, .Operator, .None); @@ -454,7 +454,7 @@ write_semantic_token_op :: proc (builder: ^SemanticTokenBuilder, token: tokenize } } -write_semantic_proc_type :: proc (node: ^ast.Proc_Type, builder: ^SemanticTokenBuilder, ast_context: ^AstContext) { +write_semantic_proc_type :: proc(node: ^ast.Proc_Type, builder: ^SemanticTokenBuilder, ast_context: ^AstContext) { using ast; @@ -493,7 +493,7 @@ write_semantic_proc_type :: proc (node: ^ast.Proc_Type, builder: ^SemanticTokenB } } -write_semantic_enum_fields :: proc (node: ast.Enum_Type, builder: ^SemanticTokenBuilder, ast_context: ^AstContext) { +write_semantic_enum_fields :: proc(node: ast.Enum_Type, builder: ^SemanticTokenBuilder, ast_context: ^AstContext) { using ast; @@ -509,7 +509,7 @@ write_semantic_enum_fields :: proc (node: ast.Enum_Type, builder: ^SemanticToken } } -write_semantic_struct_fields :: proc (node: ast.Struct_Type, builder: ^SemanticTokenBuilder, ast_context: ^AstContext) { +write_semantic_struct_fields :: proc(node: ast.Struct_Type, builder: ^SemanticTokenBuilder, ast_context: ^AstContext) { using ast; @@ -529,7 +529,7 @@ write_semantic_struct_fields :: proc (node: ast.Struct_Type, builder: ^SemanticT } } -write_semantic_selector :: proc (selector: ^ast.Selector_Expr, builder: ^SemanticTokenBuilder, ast_context: ^AstContext) { +write_semantic_selector :: proc(selector: ^ast.Selector_Expr, builder: ^SemanticTokenBuilder, ast_context: ^AstContext) { using ast; @@ -568,7 +568,7 @@ write_semantic_selector :: proc (selector: ^ast.Selector_Expr, builder: ^Semanti } } -get_locals_at :: proc (function: ^ast.Node, position: ^ast.Node, ast_context: ^AstContext) { +get_locals_at :: proc(function: ^ast.Node, position: ^ast.Node, ast_context: ^AstContext) { clear_locals(ast_context); @@ -581,7 +581,7 @@ get_locals_at :: proc (function: ^ast.Node, position: ^ast.Node, ast_context: ^A } document_position := DocumentPositionContext { - position = position.end.offset + position = position.end.offset, }; get_locals(ast_context.file, function, ast_context, &document_position); diff --git a/src/server/types.odin b/src/server/types.odin index 22a8451..0efbd39 100644 --- a/src/server/types.odin +++ b/src/server/types.odin @@ -147,7 +147,7 @@ ClientCapabilities :: struct { } RangeOptional :: union { - common.Range + common.Range, } TextDocumentContentChangeEvent :: struct { diff --git a/src/server/unmarshal.odin b/src/server/unmarshal.odin index c61b7c8..ba37497 100644 --- a/src/server/unmarshal.odin +++ b/src/server/unmarshal.odin @@ -12,7 +12,7 @@ import "core:fmt" Right now union handling is type specific so you can only have one struct type, int type, etc. */ -unmarshal :: proc (json_value: json.Value, v: any, allocator: mem.Allocator) -> json.Marshal_Error { +unmarshal :: proc(json_value: json.Value, v: any, allocator: mem.Allocator) -> json.Marshal_Error { using runtime; diff --git a/src/server/writer.odin b/src/server/writer.odin index 4e9ebae..46a340e 100644 --- a/src/server/writer.odin +++ b/src/server/writer.odin @@ -6,7 +6,7 @@ import "core:fmt" import "core:strings" import "core:sync" -WriterFn :: proc (_: rawptr, _: []byte) -> (int, int); +WriterFn :: proc(_: rawptr, _: []byte) -> (int, int); Writer :: struct { writer_fn: WriterFn, @@ -14,13 +14,13 @@ Writer :: struct { writer_mutex: sync.Mutex, } -make_writer :: proc (writer_fn: WriterFn, writer_context: rawptr) -> Writer { +make_writer :: proc(writer_fn: WriterFn, writer_context: rawptr) -> Writer { writer := Writer {writer_context = writer_context, writer_fn = writer_fn}; sync.mutex_init(&writer.writer_mutex); return writer; } -write_sized :: proc (writer: ^Writer, data: []byte) -> bool { +write_sized :: proc(writer: ^Writer, data: []byte) -> bool { sync.mutex_lock(&writer.writer_mutex); defer sync.mutex_unlock(&writer.writer_mutex); |