aboutsummaryrefslogtreecommitdiff
path: root/src/server
diff options
context:
space:
mode:
authorBrad Lewis <22850972+BradLewis@users.noreply.github.com>2025-10-29 00:08:24 -0400
committerBrad Lewis <22850972+BradLewis@users.noreply.github.com>2025-10-29 00:08:24 -0400
commit0f0d35c0b52ea666fc2adae7ecbcf0d013152ec7 (patch)
tree66df59b63754265076ebffa9bc42547f2acfff62 /src/server
parente8b2b18f24973c4bde9e235cb083043a896fb705 (diff)
Display hover information for untyped complex numbers and quaternions correctly
Diffstat (limited to 'src/server')
-rw-r--r--src/server/analysis.odin35
-rw-r--r--src/server/builtins.odin1
-rw-r--r--src/server/documentation.odin4
-rw-r--r--src/server/symbol.odin2
4 files changed, 31 insertions, 11 deletions
diff --git a/src/server/analysis.odin b/src/server/analysis.odin
index 8cd75d6..83aef98 100644
--- a/src/server/analysis.odin
+++ b/src/server/analysis.odin
@@ -302,14 +302,16 @@ resolve_type_comp_literal :: proc(
// odinfmt: disable
untyped_map: [SymbolUntypedValueType][]string = {
- .Integer = {
+ .Integer = {
"int", "uint", "u8", "i8", "u16", "i16", "u32", "i32", "u64", "i64", "u128", "i128", "byte",
"i16le", "i16be", "i32le", "i32be", "i64le", "i64be", "i128le", "i128be",
"u16le", "u16be", "u32le", "u32be", "u64le", "u64be", "u128le", "u128be",
},
- .Bool = {"bool", "b8", "b16", "b32", "b64"},
- .Float = {"f16", "f32", "f64", "f16le", "f16be", "f32le", "f32be", "f64le", "f64be"},
- .String = {"string", "cstring"},
+ .Bool = {"bool", "b8", "b16", "b32", "b64"},
+ .Float = {"f16", "f32", "f64", "f16le", "f16be", "f32le", "f32be", "f64le", "f64be"},
+ .String = {"string", "cstring"},
+ .Complex = {"complex32", "complex64", "complex128"},
+ .Quaternion = {"quaternion64", "quaternion128", "quaternion256"},
}
// odinfmt: enable
@@ -953,14 +955,27 @@ resolve_basic_lit :: proc(ast_context: ^AstContext, basic_lit: ast.Basic_Lit) ->
return {}, false
}
- if v, ok := strconv.parse_int(basic_lit.tok.text); ok {
+ #partial switch basic_lit.tok.kind {
+ case .Integer:
value.type = .Integer
- } else if v, ok := strconv.parse_bool(basic_lit.tok.text); ok {
- value.type = .Bool
- } else if v, ok := strconv.parse_f64(basic_lit.tok.text); ok {
+ case .Float:
value.type = .Float
- } else {
- value.type = .String
+ case .Imag:
+ if v, ok := strconv.parse_complex64(basic_lit.tok.text); ok {
+ value.type = .Complex
+ } else {
+ value.type = .Quaternion
+ }
+ case:
+ if v, ok := strconv.parse_int(basic_lit.tok.text); ok {
+ value.type = .Integer
+ } else if v, ok := strconv.parse_bool(basic_lit.tok.text); ok {
+ value.type = .Bool
+ } else if v, ok := strconv.parse_f64(basic_lit.tok.text); ok {
+ value.type = .Float
+ } else {
+ value.type = .String
+ }
}
symbol.pkg = ast_context.current_package
diff --git a/src/server/builtins.odin b/src/server/builtins.odin
index 7c5ce8e..37b80c3 100644
--- a/src/server/builtins.odin
+++ b/src/server/builtins.odin
@@ -1,7 +1,6 @@
package server
import "core:fmt"
-import "core:log"
import "core:odin/ast"
import "core:strconv"
diff --git a/src/server/documentation.odin b/src/server/documentation.odin
index 42afe6e..c190837 100644
--- a/src/server/documentation.odin
+++ b/src/server/documentation.odin
@@ -445,6 +445,10 @@ write_short_signature :: proc(sb: ^strings.Builder, ast_context: ^AstContext, sy
strings.write_string(sb, "bool")
case .Integer:
strings.write_string(sb, "int")
+ case .Complex:
+ strings.write_string(sb, "complex")
+ case .Quaternion:
+ strings.write_string(sb, "quaternion")
}
return
}
diff --git a/src/server/symbol.odin b/src/server/symbol.odin
index d4be282..4f9539d 100644
--- a/src/server/symbol.odin
+++ b/src/server/symbol.odin
@@ -138,6 +138,8 @@ SymbolBitSetValue :: struct {
SymbolUntypedValueType :: enum {
Integer,
Float,
+ Complex,
+ Quaternion,
String,
Bool,
}