aboutsummaryrefslogtreecommitdiff
path: root/src/server
diff options
context:
space:
mode:
authorDaniel Gavin <danielgavin5@hotmail.com>2022-01-15 01:05:23 +0100
committerDaniel Gavin <danielgavin5@hotmail.com>2022-01-15 01:05:23 +0100
commitf3bfad6da8932b2d5c6a9cba430701b0a67e422c (patch)
treea7b0c3b8941c99b0081ec9f57fb670f8c79685a6 /src/server
parentbd3f707d8e0a717df49b7bf702a5b98d214b0381 (diff)
refractor + more tests
Diffstat (limited to 'src/server')
-rw-r--r--src/server/completion.odin52
1 files changed, 27 insertions, 25 deletions
diff --git a/src/server/completion.odin b/src/server/completion.odin
index 6eba90f..1d20cec 100644
--- a/src/server/completion.odin
+++ b/src/server/completion.odin
@@ -862,8 +862,8 @@ get_identifier_completion :: proc(ast_context: ^analysis.AstContext, position_co
}
}
- ast_context.use_locals = true;
- ast_context.use_globals = true;
+ ast_context.use_locals = true;
+ ast_context.use_globals = true;
ast_context.current_package = ast_context.document_package;
ident := index.new_type(ast.Ident, v.expr.pos, v.expr.end, context.temp_allocator);
@@ -888,35 +888,37 @@ get_identifier_completion :: proc(ast_context: ^analysis.AstContext, position_co
}
}
- for k, v in ast_context.locals {
- if position_context.global_lhs_stmt {
- break;
- }
+ for local in ast_context.locals {
+ for k, v in local {
+ if position_context.global_lhs_stmt {
+ break;
+ }
- local_offset := get_local_offset(ast_context, position_context.position, k);
+ local_offset := get_local_offset(ast_context, position_context.position, k);
- ast_context.use_locals = true;
- ast_context.use_globals = true;
- ast_context.current_package = ast_context.document_package;
+ ast_context.use_locals = true;
+ ast_context.use_globals = true;
+ ast_context.current_package = ast_context.document_package;
- ident := index.new_type(ast.Ident, {offset = local_offset}, {offset = local_offset}, context.temp_allocator);
- ident.name = k;
+ ident := index.new_type(ast.Ident, {offset = local_offset}, {offset = local_offset}, context.temp_allocator);
+ ident.name = k;
- if symbol, ok := resolve_type_identifier(ast_context, ident^); ok {
- symbol.signature = get_signature(ast_context, ident^, symbol);
+ if symbol, ok := resolve_type_identifier(ast_context, ident^); ok {
+ symbol.signature = get_signature(ast_context, ident^, symbol);
- build_procedure_symbol_signature(&symbol);
+ build_procedure_symbol_signature(&symbol);
- if score, ok := common.fuzzy_match(matcher, ident.name); ok == 1 {
- append(&combined, CombinedResult {
- score = score * 1.1,
- type = symbol.type,
- name = ident.name,
- doc = symbol.doc,
- flags = symbol.flags,
- pkg = symbol.pkg,
- signature = symbol.signature,
- });
+ if score, ok := common.fuzzy_match(matcher, ident.name); ok == 1 {
+ append(&combined, CombinedResult {
+ score = score * 1.1,
+ type = symbol.type,
+ name = ident.name,
+ doc = symbol.doc,
+ flags = symbol.flags,
+ pkg = symbol.pkg,
+ signature = symbol.signature,
+ });
+ }
}
}
}