aboutsummaryrefslogtreecommitdiff
path: root/src/server
diff options
context:
space:
mode:
authorDaniel Gavin <danielgavin5@hotmail.com>2022-06-11 22:50:18 +0200
committerDaniel Gavin <danielgavin5@hotmail.com>2022-06-11 22:50:18 +0200
commit4dcbd44dbf63f2b365c315f481b70ecc946e9f56 (patch)
treeab7bf9872e4b70490cbdf97e0edc5435e12aac91 /src/server
parent70d5bcf8eca474440020c31239cd827cf3bb3415 (diff)
Fix hover bug
Diffstat (limited to 'src/server')
-rw-r--r--src/server/analysis.odin6
-rw-r--r--src/server/completion.odin6
-rw-r--r--src/server/documents.odin56
-rw-r--r--src/server/hover.odin4
-rw-r--r--src/server/memory_index.odin8
-rw-r--r--src/server/semantic_tokens.odin4
6 files changed, 48 insertions, 36 deletions
diff --git a/src/server/analysis.odin b/src/server/analysis.odin
index a4ec13b..bd700fe 100644
--- a/src/server/analysis.odin
+++ b/src/server/analysis.odin
@@ -1204,9 +1204,6 @@ resolve_type_identifier :: proc(ast_context: ^AstContext, node: ast.Ident) -> (S
#partial switch v in local.derived {
case ^Ident:
- if v.name == node.name {
- return {}, false
- }
return_symbol, ok = resolve_type_identifier(ast_context, v^)
case ^Union_Type:
return_symbol, ok = make_symbol_union_from_ast(ast_context, v^, node.name), true
@@ -1273,9 +1270,6 @@ resolve_type_identifier :: proc(ast_context: ^AstContext, node: ast.Ident) -> (S
#partial switch v in global.expr.derived {
case ^Ident:
- if v.name == node.name {
- return {}, false
- }
return_symbol, ok = resolve_type_identifier(ast_context, v^)
case ^Struct_Type:
return_symbol, ok = make_symbol_struct_from_ast(ast_context, v^, node.name), true
diff --git a/src/server/completion.odin b/src/server/completion.odin
index 093c9e3..f42fbb3 100644
--- a/src/server/completion.odin
+++ b/src/server/completion.odin
@@ -354,10 +354,10 @@ get_selector_completion :: proc(ast_context: ^AstContext, position_context: ^Doc
documentation = symbol.doc,
}
- if symbol.pkg == ast_context.document_package || base == "runtime" {
- item.label = fmt.aprintf("(%v%v)", common.repeat("^", symbol.pointers, context.temp_allocator), symbol.name)
+ if symbol.pkg == ast_context.document_package || base == "runtime" || base == "$builtin" {
+ item.label = fmt.aprintf("(%v%v)", common.repeat("^", symbol.pointers, context.temp_allocator), common.node_to_string(type))
} else {
- item.label = fmt.aprintf("(%v%v.%v)", common.repeat("^", symbol.pointers, context.temp_allocator), path.base(symbol.pkg, false, context.temp_allocator), symbol.name)
+ item.label = fmt.aprintf("(%v%v.%v)", common.repeat("^", symbol.pointers, context.temp_allocator), path.base(symbol.pkg, false, context.temp_allocator), common.node_to_string(type))
}
append(&items, item)
diff --git a/src/server/documents.odin b/src/server/documents.odin
index 62cc1ba..8750720 100644
--- a/src/server/documents.odin
+++ b/src/server/documents.odin
@@ -108,6 +108,8 @@ document_open :: proc(uri_string: string, text: string, config: ^common.Config,
document.used_text = len(document.text)
document.allocator = document_get_allocator()
+ document_setup(document)
+
if err := document_refresh(document, config, writer); err != .None {
return err
}
@@ -120,6 +122,8 @@ document_open :: proc(uri_string: string, text: string, config: ^common.Config,
allocator = document_get_allocator(),
}
+ document_setup(&document)
+
if err := document_refresh(&document, config, writer); err != .None {
return err
}
@@ -132,6 +136,34 @@ document_open :: proc(uri_string: string, text: string, config: ^common.Config,
return .None
}
+document_setup :: proc(document: ^common.Document) {
+ //Right now not all clients return the case correct windows path, and that causes issues with indexing, so we ensure that it's case correct.
+ when ODIN_OS == .Windows {
+ package_name := path.dir(document.uri.path, context.temp_allocator)
+ forward, _ := filepath.to_slash(common.get_case_sensitive_path(package_name), context.temp_allocator)
+ if forward == "" {
+ document.package_name = package_name
+ } else {
+ document.package_name = strings.clone(forward)
+ }
+ } else {
+ document.package_name = path.dir(document.uri.path)
+ }
+
+ when ODIN_OS == .Windows {
+ correct := common.get_case_sensitive_path(document.uri.path)
+ fullpath: string
+ if correct == "" {
+ //This is basically here to handle the tests where the physical file doesn't actual exist.
+ document.fullpath, _ = filepath.to_slash(document.uri.path)
+ } else {
+ document.fullpath, _ = filepath.to_slash(correct)
+ }
+ } else {
+ document.fullpath = document.uri.path
+ }
+}
+
/*
Function that applies changes to the given document through incremental syncronization
*/
@@ -330,18 +362,12 @@ parse_document :: proc(document: ^common.Document, config: ^common.Config) -> ([
context.allocator = common.scratch_allocator(document.allocator)
- when ODIN_OS == .Windows {
- fullpath, _ := filepath.to_slash(common.get_case_sensitive_path(document.uri.path))
- } else {
- fullpath := document.uri.path
- }
-
pkg := new(ast.Package)
pkg.kind = .Normal
- pkg.fullpath = fullpath
+ pkg.fullpath = document.fullpath
document.ast = ast.File {
- fullpath = fullpath,
+ fullpath = document.fullpath,
src = string(document.text[:document.used_text]),
pkg = pkg,
}
@@ -352,7 +378,6 @@ parse_document :: proc(document: ^common.Document, config: ^common.Config) -> ([
log.error(document.ast.decls[0])
}
-
parse_imports(document, config)
return current_errors[:], true
@@ -360,19 +385,6 @@ parse_document :: proc(document: ^common.Document, config: ^common.Config) -> ([
parse_imports :: proc(document: ^common.Document, config: ^common.Config) {
imports := make([dynamic]common.Package)
-
- //Right now not all clients return the case correct windows path, and that causes issues with indexing, so we ensure that it's case correct.
- when ODIN_OS == .Windows {
- package_name := path.dir(document.uri.path, context.temp_allocator)
- forward, _ := filepath.to_slash(common.get_case_sensitive_path(package_name), context.temp_allocator)
- if forward == "" {
- document.package_name = package_name
- } else {
- document.package_name = strings.clone(forward)
- }
- } else {
- document.package_name = path.dir(document.uri.path)
- }
for imp, index in document.ast.imports {
if i := strings.index(imp.fullpath, "\""); i == -1 {
diff --git a/src/server/hover.odin b/src/server/hover.odin
index 1fdecd5..25975c0 100644
--- a/src/server/hover.odin
+++ b/src/server/hover.odin
@@ -73,7 +73,6 @@ get_hover_information :: proc(document: ^common.Document, position: common.Posit
if position_context.selector != nil && position_context.identifier != nil {
hover.range = common.get_token_range(position_context.identifier^, ast_context.file.src)
-
ast_context.use_locals = true
ast_context.use_globals = true
ast_context.current_package = ast_context.document_package
@@ -114,8 +113,7 @@ get_hover_information :: proc(document: ^common.Document, position: common.Posit
}
}
- hover.range = common.get_token_range(position_context.identifier^, document.ast.src)
-
+
#partial switch v in selector.value {
case SymbolStructValue:
for name, i in v.names {
diff --git a/src/server/memory_index.odin b/src/server/memory_index.odin
index 22b901f..a6866d1 100644
--- a/src/server/memory_index.odin
+++ b/src/server/memory_index.odin
@@ -41,6 +41,14 @@ memory_index_lookup :: proc(index: ^MemoryIndex, name: string, pkg: string) -> (
return {}, false
}
+memory_reference_lookup :: proc(index: ^MemoryIndex, name: string, pkg: string) -> (Reference, bool) {
+ if pkg, ok := &index.collection.references[pkg]; ok {
+ return pkg[name]
+ }
+
+ return {}, false
+}
+
memory_index_fuzzy_search :: proc(index: ^MemoryIndex, name: string, pkgs: []string) -> ([]FuzzyResult, bool) {
symbols := make([dynamic]FuzzyResult, 0, context.temp_allocator)
diff --git a/src/server/semantic_tokens.odin b/src/server/semantic_tokens.odin
index be103a2..321858e 100644
--- a/src/server/semantic_tokens.odin
+++ b/src/server/semantic_tokens.odin
@@ -170,10 +170,10 @@ visit_node :: proc(node: ^ast.Node, builder: ^SemanticTokenBuilder, ast_context:
visit(n.expr, builder, ast_context)
case ^Ident:
if symbol_and_node, ok := builder.symbols[cast(uintptr)node]; ok {
- if symbol_and_node.symbol.type == .Variable {
+ if symbol_and_node.symbol.type == .Variable || symbol_and_node.symbol.type == .Constant {
write_semantic_node(builder, node, ast_context.file.src, .Variable, .None)
return
- }
+ }
#partial switch v in symbol_and_node.symbol.value {
case SymbolPackageValue: