aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDanielGavin <danielgavin5@hotmail.com>2024-05-09 13:33:28 +0200
committerGitHub <noreply@github.com>2024-05-09 13:33:28 +0200
commit3a2b74f601cb1baeab192218daa7c79f33150396 (patch)
tree5bf563b2b45179d15ad5119001e25370c4f63490
parent5c646656e988ddcdaee09f1bea666dc00ea2ea4d (diff)
parentdcd50ee6cf5444dac3cca1b14ae59893afcd3ebf (diff)
Merge pull request #384 from thetarnav/generic-type-variant
Add a .Type SymbolType enum
-rw-r--r--src/server/analysis.odin10
-rw-r--r--src/server/semantic_tokens.odin20
-rw-r--r--src/server/symbol.odin3
3 files changed, 15 insertions, 18 deletions
diff --git a/src/server/analysis.odin b/src/server/analysis.odin
index a75b574..b52890b 100644
--- a/src/server/analysis.odin
+++ b/src/server/analysis.odin
@@ -2659,7 +2659,7 @@ make_symbol_array_from_ast :: proc(
) -> Symbol {
symbol := Symbol {
range = common.get_token_range(v.node, ast_context.file.src),
- type = .Constant,
+ type = .Type,
pkg = get_package_from_node(v.node),
name = name.name,
}
@@ -2685,7 +2685,7 @@ make_symbol_dynamic_array_from_ast :: proc(
) -> Symbol {
symbol := Symbol {
range = common.get_token_range(v.node, ast_context.file.src),
- type = .Constant,
+ type = .Type,
pkg = get_package_from_node(v.node),
name = name.name,
}
@@ -2704,7 +2704,7 @@ make_symbol_matrix_from_ast :: proc(
) -> Symbol {
symbol := Symbol {
range = common.get_token_range(v.node, ast_context.file.src),
- type = .Constant,
+ type = .Type,
pkg = get_package_from_node(v.node),
name = name.name,
}
@@ -2726,7 +2726,7 @@ make_symbol_multi_pointer_from_ast :: proc(
) -> Symbol {
symbol := Symbol {
range = common.get_token_range(v.node, ast_context.file.src),
- type = .Constant,
+ type = .Type,
pkg = get_package_from_node(v.node),
name = name.name,
}
@@ -2745,7 +2745,7 @@ make_symbol_map_from_ast :: proc(
) -> Symbol {
symbol := Symbol {
range = common.get_token_range(v.node, ast_context.file.src),
- type = .Constant,
+ type = .Type,
pkg = get_package_from_node(v.node),
name = name.name,
}
diff --git a/src/server/semantic_tokens.odin b/src/server/semantic_tokens.odin
index 5d55138..36e7c83 100644
--- a/src/server/semantic_tokens.odin
+++ b/src/server/semantic_tokens.odin
@@ -562,25 +562,20 @@ visit_ident :: proc(
modifiers += {.ReadOnly}
}
- if .Distinct in symbol.flags && symbol.type == .Constant {
- write_semantic_node(builder, ident, .Type)
- return
- }
-
+ /* variable idents */
#partial switch symbol.type {
- case .Variable, .Constant:
+ case .Variable, .Constant, .Function:
#partial switch _ in symbol.value {
- case SymbolProcedureValue:
+ case SymbolProcedureValue, SymbolProcedureGroupValue, SymbolAggregateValue:
write_semantic_node(builder, ident, .Function, modifiers)
case:
write_semantic_node(builder, ident, .Variable, modifiers)
}
- case .Type_Function:
- write_semantic_node(builder, ident, .Type, modifiers)
case .EnumMember:
write_semantic_node(builder, ident, .EnumMember, modifiers)
}
+ /* type idents */
switch v in symbol.value {
case SymbolPackageValue:
write_semantic_node(builder, ident, .Namespace, modifiers)
@@ -588,9 +583,8 @@ visit_ident :: proc(
write_semantic_node(builder, ident, .Struct, modifiers)
case SymbolEnumValue, SymbolUnionValue:
write_semantic_node(builder, ident, .Enum, modifiers)
- case SymbolProcedureValue, SymbolProcedureGroupValue, SymbolAggregateValue:
- write_semantic_node(builder, ident, .Function, modifiers)
- case SymbolMatrixValue,
+ case SymbolProcedureValue,
+ SymbolMatrixValue,
SymbolBitSetValue,
SymbolDynamicArrayValue,
SymbolFixedArrayValue,
@@ -601,7 +595,7 @@ visit_ident :: proc(
write_semantic_node(builder, ident, .Type, modifiers)
case SymbolUntypedValue:
// handled by static syntax highlighting
- case SymbolGenericValue:
+ case SymbolGenericValue, SymbolProcedureGroupValue, SymbolAggregateValue:
// unused
case:
// log.errorf("Unexpected symbol value: %v", symbol.value);
diff --git a/src/server/symbol.odin b/src/server/symbol.odin
index fefdb4d..39708d9 100644
--- a/src/server/symbol.odin
+++ b/src/server/symbol.odin
@@ -176,6 +176,7 @@ SymbolType :: enum {
Struct = 22,
Type_Function = 23,
Union = 7,
+ Type = 8, //For maps, arrays, slices, dyn arrays, matrixes, etc
Unresolved = 1, //Use text if not being able to resolve it.
}
@@ -279,6 +280,8 @@ symbol_type_to_completion_kind :: proc(
return .Enum
case .Unresolved:
return .Text
+ case .Type:
+ return .Constant
case:
return .Text
}