aboutsummaryrefslogtreecommitdiff
path: root/src/server/analysis.odin
diff options
context:
space:
mode:
authorDaniel Gavin <danielgavin5@hotmail.com>2021-05-05 23:43:12 +0200
committerDaniel Gavin <danielgavin5@hotmail.com>2021-05-05 23:43:12 +0200
commit28ce0ddfebfd671094e8da231923ff96fb72dd47 (patch)
tree62505e3c9959b3c41ef9f1580702679d92f668a7 /src/server/analysis.odin
parentd25e7a8dfd64e492e4fe23876f2ccc646ed18c57 (diff)
begun argument underlining
Diffstat (limited to 'src/server/analysis.odin')
-rw-r--r--src/server/analysis.odin28
1 files changed, 28 insertions, 0 deletions
diff --git a/src/server/analysis.odin b/src/server/analysis.odin
index cd505ce..d7ac8ef 100644
--- a/src/server/analysis.odin
+++ b/src/server/analysis.odin
@@ -57,6 +57,7 @@ DocumentPositionContext :: struct {
hint: DocumentPositionContextHint,
global_lhs_stmt: bool,
import_stmt: ^ast.Import_Decl,
+ call_commas: []int,
}
DocumentLocal :: struct {
@@ -2285,6 +2286,29 @@ get_document_symbols :: proc(document: ^Document) -> []DocumentSymbol {
}
/*
+ Parser gives ranges of expression, but not actually where the commas are placed.
+*/
+get_call_commas :: proc(position_context: ^DocumentPositionContext, document: ^Document) {
+
+ if position_context.call == nil {
+ return;
+ }
+
+ commas := make([dynamic]int, 0, 10, context.temp_allocator);
+
+ if call, ok := position_context.call.derived.(ast.Call_Expr); ok {
+ for i := call.open.offset; i < call.close.offset; i += 1 {
+
+ if document.text[i] == ',' {
+ append(&commas, i);
+ }
+ }
+ }
+
+ position_context.call_commas = commas[:];
+}
+
+/*
Figure out what exactly is at the given position and whether it is in a function, struct, etc.
*/
get_document_position_context :: proc(document: ^Document, position: common.Position, hint: DocumentPositionContextHint) -> (DocumentPositionContext, bool) {
@@ -2357,6 +2381,10 @@ get_document_position_context :: proc(document: ^Document, position: common.Posi
fallback_position_context_signature(document, position, &position_context);
}
+ if hint == .SignatureHelp {
+ get_call_commas(&position_context, document);
+ }
+
return position_context, true;
}