aboutsummaryrefslogtreecommitdiff
path: root/src/server
diff options
context:
space:
mode:
authorBrad Lewis <22850972+BradLewis@users.noreply.github.com>2025-08-12 11:29:12 -0400
committerBrad Lewis <22850972+BradLewis@users.noreply.github.com>2025-08-12 11:29:12 -0400
commit613c9e6d59dfcdc72dfb3fcc72e63f1ed277cbfc (patch)
tree754f21d9accf6ad7b9eecfd94870fd45ac062a54 /src/server
parent9e6c39fcd74edce577015d4c2a09cbad89adf958 (diff)
Use empty struct as map values when wanting a hashset
Diffstat (limited to 'src/server')
-rw-r--r--src/server/analysis.odin14
-rw-r--r--src/server/ast.odin124
-rw-r--r--src/server/build.odin28
-rw-r--r--src/server/completion.odin58
-rw-r--r--src/server/documentation.odin192
-rw-r--r--src/server/requests.odin16
6 files changed, 216 insertions, 216 deletions
diff --git a/src/server/analysis.odin b/src/server/analysis.odin
index 9fb6ad0..8b736c3 100644
--- a/src/server/analysis.odin
+++ b/src/server/analysis.odin
@@ -91,7 +91,7 @@ UsingStatement :: struct {
AstContext :: struct {
locals: [dynamic]LocalGroup, //locals all the way to the document position
globals: map[string]GlobalExpr,
- recursion_map: map[rawptr]bool,
+ recursion_map: map[rawptr]struct{},
usings: [dynamic]UsingStatement,
file: ast.File,
allocator: mem.Allocator,
@@ -123,7 +123,7 @@ make_ast_context :: proc(
locals = make([dynamic]map[string][dynamic]DocumentLocal, 0, allocator),
globals = make(map[string]GlobalExpr, 0, allocator),
usings = make([dynamic]UsingStatement, allocator),
- recursion_map = make(map[rawptr]bool, 0, allocator),
+ recursion_map = make(map[rawptr]struct{}, 0, allocator),
file = file,
imports = imports,
use_locals = true,
@@ -961,7 +961,7 @@ check_node_recursion :: proc(ast_context: ^AstContext, node: ^ast.Node) -> bool
return true
}
- ast_context.recursion_map[raw] = true
+ ast_context.recursion_map[raw] = {}
return false
}
@@ -3377,7 +3377,7 @@ get_generic_assignment :: proc(
value: ^ast.Expr,
ast_context: ^AstContext,
results: ^[dynamic]^ast.Expr,
- calls: ^map[int]bool,
+ calls: ^map[int]struct{},
flags: GetGenericAssignmentFlags,
is_mutable: bool,
) {
@@ -3462,7 +3462,7 @@ get_generic_assignment :: proc(
case SymbolProcedureValue:
return_types := get_proc_return_types(ast_context, symbol, v, is_mutable)
for ret in return_types {
- calls[len(results)] = true
+ calls[len(results)] = {}
append(results, ret)
}
case SymbolAggregateValue:
@@ -3567,7 +3567,7 @@ get_locals_value_decl :: proc(file: ast.File, value_decl: ast.Value_Decl, ast_co
}
results := make([dynamic]^Expr, context.temp_allocator)
- calls := make(map[int]bool, 0, context.temp_allocator) //Have to track the calls, since they disallow use of variables afterwards
+ calls := make(map[int]struct{}, 0, context.temp_allocator) //Have to track the calls, since they disallow use of variables afterwards
flags: GetGenericAssignmentFlags
@@ -3758,7 +3758,7 @@ get_locals_assign_stmt :: proc(file: ast.File, stmt: ast.Assign_Stmt, ast_contex
}
results := make([dynamic]^Expr, context.temp_allocator)
- calls := make(map[int]bool, 0, context.temp_allocator)
+ calls := make(map[int]struct{}, 0, context.temp_allocator)
for rhs in stmt.rhs {
get_generic_assignment(file, rhs, ast_context, &results, &calls, {}, true)
diff --git a/src/server/ast.odin b/src/server/ast.odin
index 7c0921c..2bb13d0 100644
--- a/src/server/ast.odin
+++ b/src/server/ast.odin
@@ -9,66 +9,66 @@ import "core:odin/parser"
import path "core:path/slashpath"
import "core:strings"
-keyword_map: map[string]bool = {
- "typeid" = true,
- "string" = true,
- "cstring" = true,
- "int" = true,
- "uint" = true,
- "u8" = true,
- "i8" = true,
- "u16" = true,
- "i16" = true,
- "u32" = true,
- "i32" = true,
- "u64" = true,
- "i64" = true,
- "u128" = true,
- "i128" = true,
- "f16" = true,
- "f32" = true,
- "f64" = true,
- "bool" = true,
- "rawptr" = true,
- "any" = true,
- "b8" = true,
- "b16" = true,
- "b32" = true,
- "b64" = true,
- "true" = true,
- "false" = true,
- "nil" = true,
- "byte" = true,
- "rune" = true,
- "f16be" = true,
- "f16le" = true,
- "f32be" = true,
- "f32le" = true,
- "f64be" = true,
- "f64le" = true,
- "i16be" = true,
- "i16le" = true,
- "i32be" = true,
- "i32le" = true,
- "i64be" = true,
- "i64le" = true,
- "u16be" = true,
- "u16le" = true,
- "u32be" = true,
- "u32le" = true,
- "u64be" = true,
- "u64le" = true,
- "i128be" = true,
- "i128le" = true,
- "u128be" = true,
- "u128le" = true,
- "complex32" = true,
- "complex64" = true,
- "complex128" = true,
- "quaternion64" = true,
- "quaternion128" = true,
- "quaternion256" = true,
- "uintptr" = true,
+keyword_map: map[string]struct{} = {
+ "typeid" = {},
+ "string" = {},
+ "cstring" = {},
+ "int" = {},
+ "uint" = {},
+ "u8" = {},
+ "i8" = {},
+ "u16" = {},
+ "i16" = {},
+ "u32" = {},
+ "i32" = {},
+ "u64" = {},
+ "i64" = {},
+ "u128" = {},
+ "i128" = {},
+ "f16" = {},
+ "f32" = {},
+ "f64" = {},
+ "bool" = {},
+ "rawptr" = {},
+ "any" = {},
+ "b8" = {},
+ "b16" = {},
+ "b32" = {},
+ "b64" = {},
+ "true" = {},
+ "false" = {},
+ "nil" = {},
+ "byte" = {},
+ "rune" = {},
+ "f16be" = {},
+ "f16le" = {},
+ "f32be" = {},
+ "f32le" = {},
+ "f64be" = {},
+ "f64le" = {},
+ "i16be" = {},
+ "i16le" = {},
+ "i32be" = {},
+ "i32le" = {},
+ "i64be" = {},
+ "i64le" = {},
+ "u16be" = {},
+ "u16le" = {},
+ "u32be" = {},
+ "u32le" = {},
+ "u64be" = {},
+ "u64le" = {},
+ "i128be" = {},
+ "i128le" = {},
+ "u128be" = {},
+ "u128le" = {},
+ "complex32" = {},
+ "complex64" = {},
+ "complex128" = {},
+ "quaternion64" = {},
+ "quaternion128" = {},
+ "quaternion256" = {},
+ "uintptr" = {},
}
are_keyword_aliases :: proc(a, b: string) -> bool {
@@ -314,12 +314,12 @@ merge_attributes :: proc(attrs: []^ast.Attribute, foreign_attrs: []^ast.Attribut
}
new_attrs := make([dynamic]^ast.Attribute, context.temp_allocator)
- attr_names := make(map[string]bool, context.temp_allocator)
+ attr_names := make(map[string]struct{}, context.temp_allocator)
for attr in attrs {
append(&new_attrs, attr)
for elem in attr.elems {
if ident, _, ok := unwrap_attr_elem(elem); ok {
- attr_names[ident.name] = true
+ attr_names[ident.name] = {}
}
}
}
diff --git a/src/server/build.odin b/src/server/build.odin
index 373b5d3..24e109d 100644
--- a/src/server/build.odin
+++ b/src/server/build.odin
@@ -17,20 +17,20 @@ import "core:time"
import "src:common"
-platform_os: map[string]bool = {
- "windows" = true,
- "linux" = true,
- "essence" = true,
- "js" = true,
- "freebsd" = true,
- "darwin" = true,
- "wasm32" = true,
- "openbsd" = true,
- "wasi" = true,
- "wasm" = true,
- "haiku" = true,
- "netbsd" = true,
- "freebsd" = true,
+platform_os: map[string]struct{} = {
+ "windows" = {},
+ "linux" = {},
+ "essence" = {},
+ "js" = {},
+ "freebsd" = {},
+ "darwin" = {},
+ "wasm32" = {},
+ "openbsd" = {},
+ "wasi" = {},
+ "wasm" = {},
+ "haiku" = {},
+ "netbsd" = {},
+ "freebsd" = {},
}
diff --git a/src/server/completion.odin b/src/server/completion.odin
index 3921958..ab583d6 100644
--- a/src/server/completion.odin
+++ b/src/server/completion.odin
@@ -933,14 +933,14 @@ get_implicit_completion :: proc(
if position_context.switch_stmt != nil &&
position_context.case_clause != nil &&
position_context.switch_stmt.cond != nil {
- used_enums := make(map[string]bool, 5, context.temp_allocator)
+ used_enums := make(map[string]struct{}, 5, context.temp_allocator)
if block, ok := position_context.switch_stmt.body.derived.(^ast.Block_Stmt); ok {
for stmt in block.stmts {
if case_clause, ok := stmt.derived.(^ast.Case_Clause); ok {
for name in case_clause.list {
if implicit, ok := name.derived.(^ast.Implicit_Selector_Expr); ok {
- used_enums[implicit.field.name] = true
+ used_enums[implicit.field.name] = {}
}
}
}
@@ -1602,14 +1602,14 @@ get_type_switch_completion :: proc(
) -> bool {
is_incomplete := false
- used_unions := make(map[string]bool, 5, context.temp_allocator)
+ used_unions := make(map[string]struct{}, 5, context.temp_allocator)
if block, ok := position_context.switch_type_stmt.body.derived.(^ast.Block_Stmt); ok {
for stmt in block.stmts {
if case_clause, ok := stmt.derived.(^ast.Case_Clause); ok {
for name in case_clause.list {
if n, ok := get_used_switch_name(name); ok {
- used_unions[n] = true
+ used_unions[n] = {}
}
}
}
@@ -2093,23 +2093,23 @@ append_magic_union_completion :: proc(
}
-bitset_operators: map[string]bool = {
- "|" = true,
- "&" = true,
- "~" = true,
- "<" = true,
- ">" = true,
- "==" = true,
+bitset_operators: map[string]struct{} = {
+ "|" = {},
+ "&" = {},
+ "~" = {},
+ "<" = {},
+ ">" = {},
+ "==" = {},
}
-bitset_assignment_operators: map[string]bool = {
- "|=" = true,
- "&=" = true,
- "~=" = true,
- "<=" = true,
- ">=" = true,
- "=" = true,
- "+=" = true,
+bitset_assignment_operators: map[string]struct{} = {
+ "|=" = {},
+ "&=" = {},
+ "~=" = {},
+ "<=" = {},
+ ">=" = {},
+ "=" = {},
+ "+=" = {},
}
is_bitset_binary_operator :: proc(op: string) -> bool {
@@ -2166,20 +2166,20 @@ language_keywords: []string = {
"or_break",
}
-swizzle_color_map: map[u8]bool = {
- 'r' = true,
- 'g' = true,
- 'b' = true,
- 'a' = true,
+swizzle_color_map: map[u8]struct{} = {
+ 'r' = {},
+ 'g' = {},
+ 'b' = {},
+ 'a' = {},
}
swizzle_color_components: []string = {"r", "g", "b", "a"}
-swizzle_coord_map: map[u8]bool = {
- 'x' = true,
- 'y' = true,
- 'z' = true,
- 'w' = true,
+swizzle_coord_map: map[u8]struct{} = {
+ 'x' = {},
+ 'y' = {},
+ 'z' = {},
+ 'w' = {},
}
swizzle_coord_components: []string = {"x", "y", "z", "w"}
diff --git a/src/server/documentation.odin b/src/server/documentation.odin
index cdc2112..6ec0e07 100644
--- a/src/server/documentation.odin
+++ b/src/server/documentation.odin
@@ -7,103 +7,103 @@ import "core:odin/ast"
import path "core:path/slashpath"
import "core:strings"
-keywords_docs: map[string]bool = {
- "typeid" = true,
- "string" = true,
- "cstring" = true,
- "int" = true,
- "uint" = true,
- "u8" = true,
- "i8" = true,
- "u16" = true,
- "i16" = true,
- "u32" = true,
- "i32" = true,
- "u64" = true,
- "i64" = true,
- "u128" = true,
- "i128" = true,
- "f16" = true,
- "f32" = true,
- "f64" = true,
- "bool" = true,
- "rawptr" = true,
- "any" = true,
- "b8" = true,
- "b16" = true,
- "b32" = true,
- "b64" = true,
- "true" = true,
- "false" = true,
- "nil" = true,
- "byte" = true,
- "rune" = true,
- "f16be" = true,
- "f16le" = true,
- "f32be" = true,
- "f32le" = true,
- "f64be" = true,
- "f64le" = true,
- "i16be" = true,
- "i16le" = true,
- "i32be" = true,
- "i32le" = true,
- "i64be" = true,
- "i64le" = true,
- "u16be" = true,
- "u16le" = true,
- "u32be" = true,
- "u32le" = true,
- "u64be" = true,
- "u64le" = true,
- "i128be" = true,
- "i128le" = true,
- "u128be" = true,
- "u128le" = true,
- "complex32" = true,
- "complex64" = true,
- "complex128" = true,
- "quaternion64" = true,
- "quaternion128" = true,
- "quaternion256" = true,
- "uintptr" = true,
+keywords_docs: map[string]struct{} = {
+ "typeid" = {},
+ "string" = {},
+ "cstring" = {},
+ "int" = {},
+ "uint" = {},
+ "u8" = {},
+ "i8" = {},
+ "u16" = {},
+ "i16" = {},
+ "u32" = {},
+ "i32" = {},
+ "u64" = {},
+ "i64" = {},
+ "u128" = {},
+ "i128" = {},
+ "f16" = {},
+ "f32" = {},
+ "f64" = {},
+ "bool" = {},
+ "rawptr" = {},
+ "any" = {},
+ "b8" = {},
+ "b16" = {},
+ "b32" = {},
+ "b64" = {},
+ "true" = {},
+ "false" = {},
+ "nil" = {},
+ "byte" = {},
+ "rune" = {},
+ "f16be" = {},
+ "f16le" = {},
+ "f32be" = {},
+ "f32le" = {},
+ "f64be" = {},
+ "f64le" = {},
+ "i16be" = {},
+ "i16le" = {},
+ "i32be" = {},
+ "i32le" = {},
+ "i64be" = {},
+ "i64le" = {},
+ "u16be" = {},
+ "u16le" = {},
+ "u32be" = {},
+ "u32le" = {},
+ "u64be" = {},
+ "u64le" = {},
+ "i128be" = {},
+ "i128le" = {},
+ "u128be" = {},
+ "u128le" = {},
+ "complex32" = {},
+ "complex64" = {},
+ "complex128" = {},
+ "quaternion64" = {},
+ "quaternion128" = {},
+ "quaternion256" = {},
+ "uintptr" = {},
// taken from https://github.com/odin-lang/Odin/wiki/Keywords-and-Operators
- "asm" = true,
- "auto_cast" = true,
- "bit_field" = true,
- "bit_set" = true,
- "break" = true,
- "case" = true,
- "cast" = true,
- "context" = true,
- "continue" = true,
- "defer" = true,
- "distinct" = true,
- "do" = true,
- "dynamic" = true,
- "else" = true,
- "enum" = true,
- "fallthrough" = true,
- "for" = true,
- "foreign" = true,
- "if" = true,
- "import" = true,
- "in" = true,
- "map" = true,
- "not_in" = true,
- "or_else" = true,
- "or_return" = true,
- "package" = true,
- "proc" = true,
- "return" = true,
- "struct" = true,
- "switch" = true,
- "transmute" = true,
- "typeid" = true,
- "union" = true,
- "using" = true,
- "when" = true,
- "where" = true,
+ "asm" = {},
+ "auto_cast" = {},
+ "bit_field" = {},
+ "bit_set" = {},
+ "break" = {},
+ "case" = {},
+ "cast" = {},
+ "context" = {},
+ "continue" = {},
+ "defer" = {},
+ "distinct" = {},
+ "do" = {},
+ "dynamic" = {},
+ "else" = {},
+ "enum" = {},
+ "fallthrough" = {},
+ "for" = {},
+ "foreign" = {},
+ "if" = {},
+ "import" = {},
+ "in" = {},
+ "map" = {},
+ "not_in" = {},
+ "or_else" = {},
+ "or_return" = {},
+ "package" = {},
+ "proc" = {},
+ "return" = {},
+ "struct" = {},
+ "switch" = {},
+ "transmute" = {},
+ "typeid" = {},
+ "union" = {},
+ "using" = {},
+ "when" = {},
+ "where" = {},
}
// Adds signature and docs information to the provided symbol
diff --git a/src/server/requests.odin b/src/server/requests.odin
index c34f7f5..aeda500 100644
--- a/src/server/requests.odin
+++ b/src/server/requests.odin
@@ -247,14 +247,14 @@ call_map: map[string]proc(_: json.Value, _: RequestId, _: ^common.Config, _: ^Wr
"workspace/didChangeWatchedFiles" = notification_did_change_watched_files,
}
-notification_map: map[string]bool = {
- "textDocument/didOpen" = true,
- "textDocument/didChange" = true,
- "textDocument/didClose" = true,
- "textDocument/didSave" = true,
- "initialized" = true,
- "window/progress" = true,
- "workspace/didChangeWatchedFiles" = true,
+notification_map: map[string]struct{} = {
+ "textDocument/didOpen" = {},
+ "textDocument/didChange" = {},
+ "textDocument/didClose" = {},
+ "textDocument/didSave" = {},
+ "initialized" = {},
+ "window/progress" = {},
+ "workspace/didChangeWatchedFiles" = {},
}
consume_requests :: proc(config: ^common.Config, writer: ^Writer) -> bool {