Skip to content

Commit 25dcf7d

Browse files
committed
Merge pull request #108306 from Chaosus/gds_fix_super_completion
Fix lookup symbol for `super()`
2 parents ca374f9 + c232b7c commit 25dcf7d

File tree

4 files changed

+30
-1
lines changed

4 files changed

+30
-1
lines changed

modules/gdscript/gdscript_editor.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3807,6 +3807,8 @@ ::Error GDScriptLanguage::complete_code(const String &p_code, const String &p_pa
38073807
}
38083808
}
38093809
} break;
3810+
case GDScriptParser::COMPLETION_SUPER:
3811+
break;
38103812
case GDScriptParser::COMPLETION_SUPER_METHOD: {
38113813
if (!completion_context.current_class) {
38123814
break;
@@ -4367,6 +4369,13 @@ ::Error GDScriptLanguage::lookup_code(const String &p_code, const String &p_symb
43674369
return OK;
43684370
}
43694371
} break;
4372+
case GDScriptParser::COMPLETION_SUPER: {
4373+
if (context.current_class && context.current_function) {
4374+
if (_lookup_symbol_from_base(context.current_class->base_type, context.current_function->info.name, r_result) == OK) {
4375+
return OK;
4376+
}
4377+
}
4378+
} break;
43704379
case GDScriptParser::COMPLETION_SUPER_METHOD:
43714380
case GDScriptParser::COMPLETION_METHOD:
43724381
case GDScriptParser::COMPLETION_ASSIGN:

modules/gdscript/gdscript_parser.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3371,6 +3371,9 @@ GDScriptParser::ExpressionNode *GDScriptParser::parse_call(ExpressionNode *p_pre
33713371
if (previous.type == GDScriptTokenizer::Token::SUPER) {
33723372
// Super call.
33733373
call->is_super = true;
3374+
if (!check(GDScriptTokenizer::Token::PERIOD)) {
3375+
make_completion_context(COMPLETION_SUPER, call);
3376+
}
33743377
push_multiline(true);
33753378
if (match(GDScriptTokenizer::Token::PARENTHESIS_OPEN)) {
33763379
// Implicit call to the parent method of the same name.
@@ -3387,7 +3390,7 @@ GDScriptParser::ExpressionNode *GDScriptParser::parse_call(ExpressionNode *p_pre
33873390
}
33883391
} else {
33893392
consume(GDScriptTokenizer::Token::PERIOD, R"(Expected "." or "(" after "super".)");
3390-
make_completion_context(COMPLETION_SUPER_METHOD, call, true);
3393+
make_completion_context(COMPLETION_SUPER_METHOD, call);
33913394
if (!consume(GDScriptTokenizer::Token::IDENTIFIER, R"(Expected function name after ".".)")) {
33923395
pop_multiline();
33933396
complete_extents(call);

modules/gdscript/gdscript_parser.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1300,6 +1300,7 @@ class GDScriptParser {
13001300
COMPLETION_PROPERTY_METHOD, // Property setter or getter (list available methods).
13011301
COMPLETION_RESOURCE_PATH, // For load/preload.
13021302
COMPLETION_SUBSCRIPT, // Inside id[|].
1303+
COMPLETION_SUPER, // super(), used for lookup.
13031304
COMPLETION_SUPER_METHOD, // After super.
13041305
COMPLETION_TYPE_ATTRIBUTE, // Attribute in type name (Type.|).
13051306
COMPLETION_TYPE_NAME, // Name of type (after :).
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
extends Node
2+
3+
class Inner1:
4+
# ^^^^^^ class1 -> class1
5+
func _init():
6+
# ^^^^^ class1:init
7+
pass
8+
9+
class Inner2 extends Inner1:
10+
# | | ^^^^^^ -> class1
11+
# ^^^^^^ class2 -> class2
12+
func _init():
13+
# ^^^^^ class2:init
14+
super ()
15+
# ^^^^^ -> class1:init
16+
pass

0 commit comments

Comments
 (0)