diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/index/collector.odin | 10 | ||||
| -rw-r--r-- | src/index/symbol.odin | 2 | ||||
| -rw-r--r-- | src/server/action.odin | 19 | ||||
| -rw-r--r-- | src/server/analysis.odin | 74 | ||||
| -rw-r--r-- | src/server/completion.odin | 2 |
5 files changed, 88 insertions, 19 deletions
diff --git a/src/index/collector.odin b/src/index/collector.odin index e671cf4..438366a 100644 --- a/src/index/collector.odin +++ b/src/index/collector.odin @@ -100,7 +100,7 @@ collect_struct_fields :: proc(collection: ^SymbolCollection, struct_type: ast.St names := make([dynamic] string, 0, collection.allocator); types := make([dynamic] ^ast.Expr, 0, collection.allocator); - usings := make([dynamic] bool, 0, collection.allocator); + usings := make(map [string] bool, 0, collection.allocator); for field in struct_type.fields.list { @@ -113,11 +113,7 @@ collect_struct_fields :: proc(collection: ^SymbolCollection, struct_type: ast.St append(&types, cloned); if .Using in field.flags { - append(&usings, true); - } - - else { - append(&usings, false); + usings[names[len(names)-1]] = true; } } @@ -127,7 +123,7 @@ collect_struct_fields :: proc(collection: ^SymbolCollection, struct_type: ast.St value := SymbolStructValue { names = names[:], types = types[:], - usings = usings[:], + usings = usings, }; return value; diff --git a/src/index/symbol.odin b/src/index/symbol.odin index 1f902db..35cb323 100644 --- a/src/index/symbol.odin +++ b/src/index/symbol.odin @@ -20,7 +20,7 @@ import "shared:common" SymbolStructValue :: struct { names: [] string, types: [] ^ast.Expr, - usings: [] bool, //not memory efficient + usings: map [string] bool, }; diff --git a/src/server/action.odin b/src/server/action.odin index ad13e0b..f0b97ed 100644 --- a/src/server/action.odin +++ b/src/server/action.odin @@ -1,3 +1,22 @@ package server +CodeActionKind :: struct { + +}; + +CodeActionClientCapabilities :: struct { + + codeActionLiteralSupport: struct { + + codeActionKind: struct { + valueSet: [] CodeActionKind, + }, + }, + +}; + +CodeActionOptions :: struct { + codeActionKinds: [] CodeActionKind, + resolveProvider: bool, +}; diff --git a/src/server/analysis.odin b/src/server/analysis.odin index 1de7c54..edb282e 100644 --- a/src/server/analysis.odin +++ b/src/server/analysis.odin @@ -946,6 +946,54 @@ 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 { + + names := slice.to_dynamic(value.names, context.temp_allocator); + types := slice.to_dynamic(value.types, context.temp_allocator); + + //ERROR no hover on k and v(completion works) + for k, v in value.usings { + + ast_context.current_package = symbol.pkg; + + field_expr: ^ast.Expr; + + for name, i in value.names { + + if name == k && v { + field_expr = value.types[i]; + } + + } + + if field_expr == nil { + continue; + } + + if s, ok := resolve_type_expression(ast_context, field_expr); ok { + + if struct_value, ok := s.value.(index.SymbolStructValue); ok { + + for name in struct_value.names { + append(&names, name); + } + + for type in struct_value.types { + append(&types, type); + } + + } + + } + + } + + return { + names = names[:], + types = types[:], + }; + +} resolve_symbol_return :: proc(ast_context: ^AstContext, symbol: index.Symbol, ok := true) -> (index.Symbol, bool) { @@ -968,6 +1016,12 @@ resolve_symbol_return :: proc(ast_context: ^AstContext, symbol: index.Symbol, ok else { return symbol, true; } + case index.SymbolStructValue: + //expand the types and names from the using - can't be done while indexing without complicating everything(this also saves memory) + expanded := symbol; + expanded.value = expand_struct_usings(ast_context, symbol, v); + return expanded, true; + case index.SymbolGenericValue: return resolve_type_expression(ast_context, v.expr); } @@ -994,20 +1048,20 @@ resolve_location_identifier :: proc(ast_context: ^AstContext, node: 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 { - ident := index.new_type(ast.Ident, {}, {}, context.temp_allocator); - ident.name = int_lit; + return ident; +} +make_ident_ast :: proc(name: string) -> ^ast.Ident { + ident := index.new_type(ast.Ident, {}, {}, context.temp_allocator); + ident.name = name; return ident; } @@ -1164,7 +1218,7 @@ make_symbol_struct_from_ast :: proc(ast_context: ^AstContext, v: ast.Struct_Type names := make([dynamic] string, context.temp_allocator); types := make([dynamic] ^ast.Expr, context.temp_allocator); - usings := make([dynamic] bool, context.temp_allocator); + usings := make(map [string] bool, 0, context.temp_allocator); for field in v.fields.list { @@ -1174,11 +1228,9 @@ make_symbol_struct_from_ast :: proc(ast_context: ^AstContext, v: ast.Struct_Type append(&types, index.clone_type(field.type, context.temp_allocator, nil)); if .Using in field.flags { - append(&usings, true); - } - else { - append(&usings, false); + usings[identifier.name] = true; } + } } @@ -1187,7 +1239,7 @@ make_symbol_struct_from_ast :: proc(ast_context: ^AstContext, v: ast.Struct_Type symbol.value = index.SymbolStructValue { names = names[:], types = types[:], - usings = usings[:], + usings = usings, }; return symbol; diff --git a/src/server/completion.odin b/src/server/completion.odin index e518695..f4ceaee 100644 --- a/src/server/completion.odin +++ b/src/server/completion.odin @@ -147,6 +147,8 @@ get_directive_completion :: proc(ast_context: ^AstContext, postition_context: ^D item := CompletionItem { detail = elem, + label = elem, + kind = .EnumMember, }; append(&items, item); |