aboutsummaryrefslogtreecommitdiff
path: root/src/server
diff options
context:
space:
mode:
authorDaniel Gavin <danielgavin5@hotmail.com>2022-06-14 20:05:42 +0200
committerDaniel Gavin <danielgavin5@hotmail.com>2022-06-14 20:05:42 +0200
commit141bcd1d9e1857b38e25af38f218692b151b40ae (patch)
tree9469d84fe33766333cb83c0f31474ae3ab477f6b /src/server
parent7fcf6248a623170a7521f6f1b42e0fae2e3518da (diff)
Fix issue with parameter and type being the same causing stack overflow
Diffstat (limited to 'src/server')
-rw-r--r--src/server/analysis.odin10
-rw-r--r--src/server/format.odin1
-rw-r--r--src/server/memory_index.odin14
-rw-r--r--src/server/response.odin3
4 files changed, 18 insertions, 10 deletions
diff --git a/src/server/analysis.odin b/src/server/analysis.odin
index 0686743..5c40e7e 100644
--- a/src/server/analysis.odin
+++ b/src/server/analysis.odin
@@ -1093,7 +1093,17 @@ get_local :: proc(ast_context: ^AstContext, offset: int, name: string) -> ^ast.E
if i - previous < 0 {
return nil
} else {
+ ret := local_stack[i - previous].expr
+ if ident, ok := ret.derived.(^ast.Ident); ok && ident.name == name {
+ if i - previous - 1 < 0 {
+ return nil
+ }
+
+ if _, ok := ast_context.parameters[ident.name]; ok {
return local_stack[i - previous].expr
+ }
+ }
+ return ret;
}
}
}
diff --git a/src/server/format.odin b/src/server/format.odin
index 5829793..4c51943 100644
--- a/src/server/format.odin
+++ b/src/server/format.odin
@@ -18,7 +18,6 @@ DocumentFormattingParams :: struct {
}
get_complete_format :: proc(document: ^common.Document, config: ^common.Config) -> ([]TextEdit, bool) {
-
style := printer.default_style
style.max_characters = config.formatter.characters
style.tabs = config.formatter.tabs
diff --git a/src/server/memory_index.odin b/src/server/memory_index.odin
index a6866d1..480d9f2 100644
--- a/src/server/memory_index.odin
+++ b/src/server/memory_index.odin
@@ -31,12 +31,14 @@ memory_index_lookup :: proc(index: ^MemoryIndex, name: string, pkg: string) -> (
return index.last_package[name]
}
- index.last_package_name = pkg
-
- if pkg, ok := &index.collection.packages[pkg]; ok {
- index.last_package = pkg
- return pkg[name]
- }
+ if _pkg, ok := &index.collection.packages[pkg]; ok {
+ index.last_package = _pkg
+ index.last_package_name = pkg
+ return _pkg[name]
+ } else {
+ index.last_package = nil
+ index.last_package_name = ""
+ }
return {}, false
}
diff --git a/src/server/response.odin b/src/server/response.odin
index 8cbd410..ddf6486 100644
--- a/src/server/response.odin
+++ b/src/server/response.odin
@@ -4,7 +4,6 @@ import "core:fmt"
import "core:encoding/json"
send_notification :: proc (notification: Notification, writer: ^Writer) -> bool {
-
data, error := json.marshal(notification, context.temp_allocator)
header := fmt.tprintf("Content-Length: %v\r\n\r\n", len(data))
@@ -25,7 +24,6 @@ send_notification :: proc (notification: Notification, writer: ^Writer) -> bool
}
send_response :: proc (response: ResponseMessage, writer: ^Writer) -> bool {
-
data, error := json.marshal(response, context.temp_allocator)
header := fmt.tprintf("Content-Length: %v\r\n\r\n", len(data))
@@ -46,7 +44,6 @@ send_response :: proc (response: ResponseMessage, writer: ^Writer) -> bool {
}
send_error :: proc (response: ResponseMessageError, writer: ^Writer) -> bool {
-
data, error := json.marshal(response, context.temp_allocator)
header := fmt.tprintf("Content-Length: %v\r\n\r\n", len(data))