aboutsummaryrefslogtreecommitdiff
path: root/src/server/completion.odin
diff options
context:
space:
mode:
authorDanielGavin <danielgavin5@hotmail.com>2020-12-31 02:01:41 +0100
committerDanielGavin <danielgavin5@hotmail.com>2020-12-31 02:01:41 +0100
commita7ef0c50bf3aaa697406f796c362795b03699b7b (patch)
treeb9b82bbf11278b60101357b11bfc105666f9a4e2 /src/server/completion.odin
parent71e2e51443688c42c677cbd5d39c968b7b7cd031 (diff)
support completion on enums with assignment
Diffstat (limited to 'src/server/completion.odin')
-rw-r--r--src/server/completion.odin64
1 files changed, 64 insertions, 0 deletions
diff --git a/src/server/completion.odin b/src/server/completion.odin
index c11633f..1b3733d 100644
--- a/src/server/completion.odin
+++ b/src/server/completion.odin
@@ -398,6 +398,70 @@ get_implicit_completion :: proc(ast_context: ^AstContext, position_context: ^Doc
}
+ else if position_context.assign != nil && position_context.assign.rhs != nil && position_context.assign.lhs != nil {
+
+ rhs_index: int;
+
+ for elem in position_context.assign.rhs {
+
+ if position_in_node(elem, position_context.position) {
+ break;
+ }
+
+ else {
+
+ //procedures are the only types that can return more than one value
+ if symbol, ok := resolve_type_expression(ast_context, elem); ok {
+
+ if procedure, ok := symbol.value.(index.SymbolProcedureValue); ok {
+
+ if procedure.return_types == nil {
+ return;
+ }
+
+ rhs_index += len(procedure.return_types);
+ }
+
+ else {
+ rhs_index += 1;
+ }
+
+ }
+
+ }
+
+ }
+
+ if len(position_context.assign.lhs) > rhs_index {
+
+ log.info("in lhs %v", position_context.assign.lhs[rhs_index].derived);
+
+ if lhs, ok := resolve_type_expression(ast_context, position_context.assign.lhs[rhs_index]); ok {
+
+ log.infof("lhs %v", lhs);
+
+ #partial switch v in lhs.value {
+ case index.SymbolEnumValue:
+ for name in v.names {
+
+ item := CompletionItem {
+ label = name,
+ kind = .EnumMember,
+ detail = name,
+ };
+
+ append(&items, item);
+
+ }
+
+ }
+
+ }
+
+ }
+
+ }
+
else if position_context.returns != nil && position_context.function != nil {
return_index: int;