aboutsummaryrefslogtreecommitdiff
path: root/src/server
diff options
context:
space:
mode:
authorDanielGavin <danielgavin5@hotmail.com>2024-08-12 00:42:55 +0200
committerDanielGavin <danielgavin5@hotmail.com>2024-08-12 00:42:55 +0200
commit4bbb629241db3cf79d1509eb391b7e3143f34242 (patch)
treef0791d2c9f3480ccf9de1ad72964fc29a8480ef9 /src/server
parent95f580cf5d57862d8dbf116e43da3a87c8dda58b (diff)
Better handling of local globals.
Diffstat (limited to 'src/server')
-rw-r--r--src/server/analysis.odin14
1 files changed, 8 insertions, 6 deletions
diff --git a/src/server/analysis.odin b/src/server/analysis.odin
index da4e921..2b69bc7 100644
--- a/src/server/analysis.odin
+++ b/src/server/analysis.odin
@@ -100,7 +100,7 @@ AstContext :: struct {
field_name: ast.Ident,
uri: string,
fullpath: string,
- non_mutable_only: bool,
+ non_mutable_only: bool, //Only store local value declarations that are non mutable.
overloading: bool,
}
@@ -1111,7 +1111,7 @@ get_local :: proc(ast_context: AstContext, ident: ast.Ident) -> (DocumentLocal,
get_local_offset :: proc(ast_context: ^AstContext, offset: int, name: string) -> int {
for _, locals in &ast_context.locals {
if local_stack, ok := locals[name]; ok {
- for i := len(local_stack) - 1; i >= 0; i -= 1 {
+ #reverse for local, i in local_stack {
if local_stack[i].offset <= offset || local_stack[i].local_global {
if i < 0 {
return -1
@@ -3407,10 +3407,6 @@ get_locals :: proc(
return
}
- for stmt in block.stmts {
- get_locals_stmt(file, stmt, ast_context, document_position)
- }
-
old_position := document_position.position
for function in document_position.functions {
@@ -3420,6 +3416,12 @@ get_locals :: proc(
}
document_position.position = old_position
+ ast_context.non_mutable_only = false
+
+ for stmt in block.stmts {
+ get_locals_stmt(file, stmt, ast_context, document_position)
+ }
+
}
clear_locals :: proc(ast_context: ^AstContext) {