aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDaniel Gavin <danielgavin5@hotmail.com>2022-06-14 21:55:46 +0200
committerDaniel Gavin <danielgavin5@hotmail.com>2022-06-14 21:55:46 +0200
commit09fdb88a25c3cc350bc1256b2f48c5d5a297807e (patch)
treeb1212e4043e3656c4e331118cfbdbfef84427e4a /src
parent141bcd1d9e1857b38e25af38f218692b151b40ae (diff)
Fix ternary expression semantic tokens
Diffstat (limited to 'src')
-rw-r--r--src/server/build.odin2
-rw-r--r--src/server/collector.odin4
-rw-r--r--src/server/semantic_tokens.odin14
3 files changed, 17 insertions, 3 deletions
diff --git a/src/server/build.odin b/src/server/build.odin
index ad186be..41690c6 100644
--- a/src/server/build.odin
+++ b/src/server/build.odin
@@ -153,7 +153,7 @@ build_static_index :: proc(allocator := context.allocator, config: ^common.Confi
}
//TODO(daniel): Implement path code to handle whether paths are contained in core
- if !config.enable_std_references && (strings.contains(fullpath, "Odin/core") || strings.contains(fullpath, "odin/core")) {
+ if !config.enable_std_references && (strings.contains(fullpath, "Odin/core") || strings.contains(fullpath, "odin/core") || strings.contains(fullpath, "Odin/vendor") || strings.contains(fullpath, "odin/vendor")) {
continue;
}
diff --git a/src/server/collector.odin b/src/server/collector.odin
index 47ebb98..fc40b11 100644
--- a/src/server/collector.odin
+++ b/src/server/collector.odin
@@ -468,8 +468,8 @@ collect_references :: proc(collection: ^SymbolCollection, file: ast.File, uri: s
if ref, ok = &pkg[v.symbol.name]; !ok {
pkg[get_index_unique_string(collection, v.symbol.name)] = {}
ref = &pkg[v.symbol.name]
- ref.identifiers = make([dynamic]common.Location, 100, collection.allocator)
- ref.selectors = make(map[string][dynamic]common.Range, 100, collection.allocator)
+ ref.identifiers = make([dynamic]common.Location, 2, collection.allocator)
+ ref.selectors = make(map[string][dynamic]common.Range, 2, collection.allocator)
}
assert(ref != nil)
diff --git a/src/server/semantic_tokens.odin b/src/server/semantic_tokens.odin
index 55d94d3..79d5dd8 100644
--- a/src/server/semantic_tokens.odin
+++ b/src/server/semantic_tokens.odin
@@ -350,6 +350,20 @@ visit_node :: proc(node: ^ast.Node, builder: ^SemanticTokenBuilder, ast_context:
visit(n.x, builder, ast_context)
write_semantic_token(builder, n.token, ast_context.file.src, .Keyword, .None)
visit(n.y, builder, ast_context)
+ case ^Ternary_If_Expr:
+ if n.op1.text == "if" {
+ visit(n.x, builder, ast_context)
+ visit(n.cond, builder, ast_context)
+ visit(n.y, builder, ast_context)
+ } else {
+ visit(n.cond, builder, ast_context)
+ visit(n.x, builder, ast_context)
+ visit(n.y, builder, ast_context)
+ }
+ case ^Ternary_When_Expr:
+ visit(n.cond, builder, ast_context)
+ visit(n.x, builder, ast_context)
+ visit(n.y, builder, ast_context)
case:
//log.errorf("unhandled semantic token node %v", n);
//panic(fmt.tprintf("Missed semantic token handling %v", n));