Skip to content

Commit f1214b9

Browse files
committed
Avoid completion on base struct constants, creation methods and static methods. Which cannot be used in derived structs.
1 parent 1dc8c5a commit f1214b9

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

src/codehelp/completionengine.vala

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1033,6 +1033,11 @@ namespace Vls.CompletionEngine {
10331033
in_oce,
10341034
is_cm_this_or_base_access))
10351035
continue;
1036+
// Avoid base struct creation and static methods
1037+
if (((method_sym is Vala.CreationMethod) || method_sym.binding == Vala.MemberBinding.STATIC)) {
1038+
if (current_scope.owner.name != null && current_scope.owner.name != struct_sym.scope.owner.name)
1039+
continue;
1040+
}
10361041
var completion = new CompletionItem.from_symbol (type, method_sym, current_scope, CompletionItemKind.Method, lang_serv.get_symbol_documentation (project, method_sym));
10371042
completion.insertText = generate_insert_text_for_callable (type, method_sym, current_scope, method_spaces);
10381043
completion.insertTextFormat = InsertTextFormat.Snippet;
@@ -1050,14 +1055,17 @@ namespace Vls.CompletionEngine {
10501055
foreach (var constant_sym in struct_sym.get_constants ()) {
10511056
if (!CodeHelp.is_symbol_accessible (constant_sym, current_scope))
10521057
continue;
1058+
// Avoid base struct constants
1059+
if (current_scope.owner.name != null && current_scope.owner.name != struct_sym.scope.owner.name)
1060+
continue;
10531061
completions.add (new CompletionItem.from_symbol (type, constant_sym, current_scope, CompletionItemKind.Constant, lang_serv.get_symbol_documentation (project, constant_sym)));
10541062
}
10551063
}
10561064

10571065
// get instance members of base_struct
1058-
if (struct_sym.base_type != null) {
1066+
if (struct_sym.base_struct != null) {
10591067
add_completions_for_type (lang_serv, project, code_style, type, struct_sym.base_struct,
1060-
completions, current_scope, in_oce, false, seen_props, seen_type_symbols);
1068+
completions, struct_sym.scope, in_oce, false, seen_props, seen_type_symbols);
10611069
}
10621070
} else if (type_symbol is Vala.TypeParameter) {
10631071
var typeparam_sym = (Vala.TypeParameter) type_symbol;

0 commit comments

Comments
 (0)