Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 15 additions & 14 deletions src/server/analysis.odin
Original file line number Diff line number Diff line change
Expand Up @@ -344,6 +344,8 @@ is_symbol_same_typed :: proc(
case:
return false
}
case .Nil:
return false
}
}
}
Expand Down Expand Up @@ -1304,24 +1306,21 @@ internal_resolve_type_identifier :: proc(
ident := new_type(Ident, node.pos, node.end, ast_context.allocator)
ident.name = node.name

symbol: Symbol
symbol: Symbol = {
type = .Keyword,
signature = node.name,
name = ident.name,
pkg = ast_context.current_package,
}

switch ident.name {
case "true", "false":
symbol = Symbol {
type = .Keyword,
signature = node.name,
pkg = ast_context.current_package,
value = SymbolUntypedValue{type = .Bool},
}
symbol.value = SymbolUntypedValue{type = .Bool}
case "nil":
// TODO get the type of nil from the context and remove .Nil from SymbolUntypedValue
symbol.value = SymbolUntypedValue{type = .Nil}
case:
symbol = Symbol {
type = .Keyword,
signature = node.name,
name = ident.name,
pkg = ast_context.current_package,
value = SymbolBasicValue{ident = ident},
}
symbol.value = SymbolBasicValue{ident = ident}
}

return symbol, true
Expand Down Expand Up @@ -4386,6 +4385,8 @@ get_signature :: proc(
return "bool"
case .Integer:
return "int"
case .Nil:
return "" // no obvious type for nil
}
}

Expand Down
2 changes: 2 additions & 0 deletions src/server/hover.odin
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ write_hover_content :: proc(
symbol.signature = "float"
case .Integer:
symbol.signature = "int"
case .Nil:
// no obvious signature for nil
}
}

Expand Down
7 changes: 4 additions & 3 deletions src/server/semantic_tokens.odin
Original file line number Diff line number Diff line change
Expand Up @@ -609,10 +609,11 @@ visit_ident :: proc(
SymbolFixedArrayValue,
SymbolSliceValue,
SymbolMapValue,
SymbolMultiPointer:
SymbolMultiPointer,
SymbolBasicValue:
write_semantic_node(builder, ident, .Type, modifiers)
case SymbolBasicValue, SymbolUntypedValue:
// handled by static syntax analysis
case SymbolUntypedValue:
// handled by static syntax highlighting
case SymbolGenericValue:
// unused
case:
Expand Down
1 change: 1 addition & 0 deletions src/server/symbol.odin
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ SymbolUntypedValue :: struct {
Float,
String,
Bool,
Nil,
},
tok: tokenizer.Token,
}
Expand Down