diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/server/analysis.odin | 28 | ||||
| -rw-r--r-- | src/server/completion.odin | 2 | ||||
| -rw-r--r-- | src/server/hover.odin | 27 | ||||
| -rw-r--r-- | src/testing/testing.odin | 16 |
4 files changed, 54 insertions, 19 deletions
diff --git a/src/server/analysis.odin b/src/server/analysis.odin index 28a8249..035949e 100644 --- a/src/server/analysis.odin +++ b/src/server/analysis.odin @@ -2003,6 +2003,11 @@ get_locals :: proc(file: ast.File, function: ^ast.Node, ast_context: ^AstContext using_stmt.list[0] = arg.type; get_locals_using_stmt(using_stmt, ast_context); } + } else { + str := common.get_ast_node_string(name, file.src); + store_local(ast_context, arg.default_value, name.pos.offset, str); + ast_context.variables[str] = true; + ast_context.parameters[str] = true; } } } @@ -2184,21 +2189,6 @@ get_definition_location :: proc(document: ^Document, position: common.Position) return location, true; } -write_hover_content :: proc(ast_context: ^AstContext, symbol: index.Symbol) -> MarkupContent { - content: MarkupContent; - - cat := concatenate_symbols_information(ast_context, symbol, false); - - if cat != "" { - content.kind = "markdown"; - content.value = fmt.tprintf("```odin\n %v\n```\n%v", cat, symbol.doc); - } else { - content.kind = "plaintext"; - } - - return content; -} - get_signature :: proc(ast_context: ^AstContext, ident: ast.Ident, symbol: index.Symbol, was_variable := false) -> string { if symbol.type == .Function { @@ -2424,6 +2414,12 @@ fallback_position_context_completion :: proc(document: ^Document, position: comm continue; } + //ignore everything in the bracket + if bracket_count != 0 || paren_count != 0 { + i -= 1; + continue; + } + //yeah.. if c == ' ' || c == '{' || c == ',' || c == '}' || c == '^' || c == ':' || @@ -2442,8 +2438,6 @@ fallback_position_context_completion :: proc(document: ^Document, position: comm i -= 1; } - //log.error(u8(position_context.file.src[end])); - if i >= 0 && position_context.file.src[end] == '.' { empty_dot = true; end -= 1; diff --git a/src/server/completion.odin b/src/server/completion.odin index 25b8244..212dd9c 100644 --- a/src/server/completion.odin +++ b/src/server/completion.odin @@ -393,7 +393,7 @@ get_selector_completion :: proc(ast_context: ^AstContext, position_context: ^Doc item := CompletionItem { label = search.symbol.name, kind = .Field, - detail = fmt.tprintf("%v.%v: %v", search.symbol.pkg, search.symbol.name, search.symbol.signature), + detail = fmt.tprintf("%v.%v: %v", path.base(search.symbol.pkg, false, context.temp_allocator), search.symbol.name, search.symbol.signature), documentation = search.symbol.doc, }; diff --git a/src/server/hover.odin b/src/server/hover.odin index e22e539..d14cd34 100644 --- a/src/server/hover.odin +++ b/src/server/hover.odin @@ -16,6 +16,33 @@ import "core:slice" import "shared:common" import "shared:index" +write_hover_content :: proc(ast_context: ^AstContext, symbol: index.Symbol) -> MarkupContent { + content: MarkupContent; + + symbol := symbol; + + if untyped, ok := symbol.value.(index.SymbolUntypedValue); ok { + switch untyped.type { + case .String: symbol.signature = "string"; + case .Bool: symbol.signature = "bool"; + case .Float: symbol.signature = "float"; + case .Integer: symbol.signature = "int"; + } + } + + cat := concatenate_symbols_information(ast_context, symbol, false); + + if cat != "" { + content.kind = "markdown"; + content.value = fmt.tprintf("```odin\n %v\n```\n%v", cat, symbol.doc); + } else { + content.kind = "plaintext"; + } + + return content; +} + + get_hover_information :: proc(document: ^Document, position: common.Position) -> (Hover, bool) { hover := Hover { diff --git a/src/testing/testing.odin b/src/testing/testing.odin index 001b8cf..5bb8d63 100644 --- a/src/testing/testing.odin +++ b/src/testing/testing.odin @@ -134,7 +134,21 @@ expect_completion_details :: proc(t: ^testing.T, src: ^Source, trigger_character } -expect_hover :: proc(t: ^testing.T, src: ^Source, expect_hover_info: string) { +expect_hover :: proc(t: ^testing.T, src: ^Source, expect_hover_string: string) { setup(src); + hover, ok := server.get_hover_information(src.document, src.position); + + if !ok { + testing.error(t, "Failed get_hover_information"); + } + + if expect_hover_string == "" && hover.contents.value != "" { + testing.errorf(t, "Expected empty hover string, but received %v", hover.contents.value); + } + + if strings.contains(expect_hover_string, hover.contents.value) { + testing.errorf(t, "Expected hover string %v, but received %v", expect_hover_string, hover.contents.value); + } + } |