aboutsummaryrefslogtreecommitdiff
path: root/src/server/analysis.odin
diff options
context:
space:
mode:
authorDanielGavin <danielgavin5@hotmail.com>2023-07-05 21:11:53 +0200
committerDanielGavin <danielgavin5@hotmail.com>2023-07-05 21:11:53 +0200
commit1c90907c871f3e572fd3cd98b8a7bd4afa76e17c (patch)
treea8683a25683faf154559a18725b28c60998d73cb /src/server/analysis.odin
parent0edbb7d32a1c37c83e22ed04857f9974001251f7 (diff)
Add hack for type_of
Diffstat (limited to 'src/server/analysis.odin')
-rw-r--r--src/server/analysis.odin29
1 files changed, 20 insertions, 9 deletions
diff --git a/src/server/analysis.odin b/src/server/analysis.odin
index a312d6a..9ae0f7a 100644
--- a/src/server/analysis.odin
+++ b/src/server/analysis.odin
@@ -1329,6 +1329,14 @@ internal_resolve_type_expression :: proc(
return symbol, ok
case ^Call_Expr:
ast_context.call = cast(^Call_Expr)node
+
+ if ident, ok := v.expr.derived.(^ast.Ident); ok && len(v.args) >= 1 {
+ switch ident.name {
+ case "type_of":
+ return internal_resolve_type_expression(ast_context, v.args[0])
+ }
+ }
+
return internal_resolve_type_expression(ast_context, v.expr)
case ^Selector_Call_Expr:
if selector, ok := internal_resolve_type_expression(
@@ -1847,14 +1855,18 @@ internal_resolve_type_identifier :: proc(
return_symbol.doc = common.get_doc(global.docs, ast_context.allocator)
return return_symbol, ok
- } else if node.name == "context" {
- for built in indexer.builtin_packages {
- if symbol, ok := lookup("Context", built); ok {
- symbol.type = .Variable
- return symbol, ok
+ } else {
+ switch node.name {
+ case "context":
+ for built in indexer.builtin_packages {
+ if symbol, ok := lookup("Context", built); ok {
+ symbol.type = .Variable
+ return symbol, ok
+ }
}
}
- } else {
+
+
//right now we replace the package ident with the absolute directory name, so it should have '/' which is not a valid ident character
if strings.contains(node.name, "/") {
symbol := Symbol {
@@ -4519,9 +4531,8 @@ position_in_proc_decl :: proc(
return true
}
- if proc_lit, ok := position_context.value_decl.values[
- 0 \
- ].derived.(^ast.Proc_Lit); ok {
+ if proc_lit, ok := position_context.value_decl.values[0].derived.(^ast.Proc_Lit);
+ ok {
if proc_lit.type != nil &&
position_in_node(proc_lit.type, position_context.position) {
return true