aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDaniel Gavin <danielgavin5@hotmail.com>2022-01-27 13:53:35 +0100
committerDaniel Gavin <danielgavin5@hotmail.com>2022-01-27 13:53:35 +0100
commitf72c31da801b526e2c0f15e84afee0fdb21ce381 (patch)
treed9f00d827e4c05ddc8440f5bee66266ef1491221 /src
parent7e39136c69e8d29b2f1f3f804aa72c6e655a5691 (diff)
document links work
Diffstat (limited to 'src')
-rw-r--r--src/analysis/analysis.odin7
-rw-r--r--src/server/document_links.odin16
-rw-r--r--src/server/requests.odin4
3 files changed, 21 insertions, 6 deletions
diff --git a/src/analysis/analysis.odin b/src/analysis/analysis.odin
index b5716e1..5a374a5 100644
--- a/src/analysis/analysis.odin
+++ b/src/analysis/analysis.odin
@@ -129,7 +129,6 @@ resolve_poly_spec :: proc {
};
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;
}
@@ -140,7 +139,6 @@ 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) {
-
if len(call_array) != len(spec_array) {
return;
}
@@ -151,7 +149,6 @@ resolve_poly_spec_dynamic_array :: proc(ast_context: ^AstContext, call_array: $A
}
get_poly_node_to_expr :: proc(node: ^ast.Node) -> ^ast.Expr {
-
using ast;
switch v in node.derived {
@@ -297,6 +294,10 @@ resolve_type_comp_literal :: proc(ast_context: ^AstContext, position_context: ^D
return current_symbol, current_comp_lit, true;
}
+ if current_comp_lit == nil {
+ return {}, nil, false;
+ }
+
element_index := 0;
for elem, i in current_comp_lit.elems {
diff --git a/src/server/document_links.odin b/src/server/document_links.odin
index 205e9bc..9295c33 100644
--- a/src/server/document_links.odin
+++ b/src/server/document_links.odin
@@ -25,6 +25,20 @@ get_document_links :: proc(document: ^common.Document) -> ([]DocumentLink, bool)
links := make([dynamic]DocumentLink, 0, context.temp_allocator);
for imp in document.ast.imports {
+ if len(imp.relpath.text) <= 1 {
+ continue;
+ }
+
+ e := strings.split(imp.relpath.text[1:len(imp.relpath.text)-1], ":", context.temp_allocator);
+
+ if len(e) != 2 {
+ continue;
+ }
+
+ if e[0] != "core" {
+ continue;
+ }
+
//Temporarly assuming non unicode
node := ast.Node {
pos = {
@@ -43,7 +57,7 @@ get_document_links :: proc(document: ^common.Document) -> ([]DocumentLink, bool)
link := DocumentLink {
range = range,
- target = "https://code.visualstudio.com/docs/extensions/overview#frag",
+ target = fmt.tprintf("https://pkg.odin-lang.org/%v/%v", e[0], e[1]),
tooltip = "Documentation",
};
diff --git a/src/server/requests.odin b/src/server/requests.odin
index 361c0cb..f2e481d 100644
--- a/src/server/requests.odin
+++ b/src/server/requests.odin
@@ -515,7 +515,7 @@ request_initialize :: proc (params: json.Value, id: RequestId, config: ^common.C
tokenModifiers = token_modifiers,
},
},
- inlayHintsProvider = true,
+ inlayHintsProvider = config.enable_inlay_hints,
documentSymbolProvider = config.enable_document_symbols,
hoverProvider = config.enable_hover,
documentFormattingProvider = config.enable_format,
@@ -989,7 +989,7 @@ request_inlay_hint :: proc (params: json.Value, id: RequestId, config: ^common.C
hints: []InlayHint;
- if cache_symbols, ok := file_resolve_cache.files[document.uri.uri]; ok && config.enable_inlay_hints {
+ if cache_symbols, ok := file_resolve_cache.files[document.uri.uri]; ok {
hints, ok = get_inlay_hints(document, cache_symbols);
}