Skip to content

Commit b94640a

Browse files
committed
Implemented CompletionType::COMPLETION_DECLARATION.
1 parent f42e612 commit b94640a

File tree

4 files changed

+8
-2
lines changed

4 files changed

+8
-2
lines changed

editor/plugins/script_text_editor.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -1206,7 +1206,7 @@ void ScriptTextEditor::_show_symbol_tooltip(const String &p_symbol, int p_row, i
12061206
} break;
12071207
}
12081208
}
1209-
1209+
12101210
// NOTE: See also `ScriptEditor::_get_debug_tooltip()` for documentation tooltips disabled.
12111211
String debug_value = EditorDebuggerNode::get_singleton()->get_var_value(p_symbol);
12121212
if (!debug_value.is_empty()) {

modules/gdscript/gdscript_editor.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -4138,6 +4138,7 @@ ::Error GDScriptLanguage::lookup_code(const String &p_code, const String &p_symb
41384138
case GDScriptParser::COMPLETION_METHOD:
41394139
case GDScriptParser::COMPLETION_ASSIGN:
41404140
case GDScriptParser::COMPLETION_CALL_ARGUMENTS:
4141+
case GDScriptParser::COMPLETION_DECLARATION:
41414142
case GDScriptParser::COMPLETION_IDENTIFIER:
41424143
case GDScriptParser::COMPLETION_PROPERTY_METHOD:
41434144
case GDScriptParser::COMPLETION_SUBSCRIPT: {

modules/gdscript/gdscript_parser.cpp

+5
Original file line numberDiff line numberDiff line change
@@ -1110,6 +1110,8 @@ GDScriptParser::VariableNode *GDScriptParser::parse_variable(bool p_is_static) {
11101110
GDScriptParser::VariableNode *GDScriptParser::parse_variable(bool p_is_static, bool p_allow_property) {
11111111
VariableNode *variable = alloc_node<VariableNode>();
11121112

1113+
make_completion_context(COMPLETION_DECLARATION, nullptr);
1114+
11131115
if (!consume(GDScriptTokenizer::Token::IDENTIFIER, R"(Expected variable name after "var".)")) {
11141116
complete_extents(variable);
11151117
return nullptr;
@@ -1346,6 +1348,8 @@ void GDScriptParser::parse_property_getter(VariableNode *p_variable) {
13461348
GDScriptParser::ConstantNode *GDScriptParser::parse_constant(bool p_is_static) {
13471349
ConstantNode *constant = alloc_node<ConstantNode>();
13481350

1351+
make_completion_context(COMPLETION_DECLARATION, nullptr);
1352+
13491353
if (!consume(GDScriptTokenizer::Token::IDENTIFIER, R"(Expected constant name after "const".)")) {
13501354
complete_extents(constant);
13511355
return nullptr;
@@ -1613,6 +1617,7 @@ GDScriptParser::FunctionNode *GDScriptParser::parse_function(bool p_is_static) {
16131617
FunctionNode *function = alloc_node<FunctionNode>();
16141618

16151619
make_completion_context(COMPLETION_OVERRIDE_METHOD, function);
1620+
make_completion_context(COMPLETION_DECLARATION, nullptr);
16161621

16171622
if (!consume(GDScriptTokenizer::Token::IDENTIFIER, R"(Expected function name after "func".)")) {
16181623
complete_extents(function);

modules/gdscript/gdscript_parser.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -1294,7 +1294,7 @@ class GDScriptParser {
12941294
COMPLETION_ATTRIBUTE_METHOD, // After id.| to look for methods.
12951295
COMPLETION_BUILT_IN_TYPE_CONSTANT_OR_STATIC_METHOD, // Constants inside a built-in type (e.g. Color.BLUE) or static methods (e.g. Color.html).
12961296
COMPLETION_CALL_ARGUMENTS, // Complete with nodes, input actions, enum values (or usual expressions).
1297-
// TODO: COMPLETION_DECLARATION, // Potential declaration (var, const, func).
1297+
COMPLETION_DECLARATION, // Potential declaration (var, const, func).
12981298
COMPLETION_GET_NODE, // Get node with $ notation.
12991299
COMPLETION_IDENTIFIER, // List available identifiers in scope.
13001300
COMPLETION_INHERIT_TYPE, // Type after extends. Exclude non-viable types (built-ins, enums, void). Includes subtypes using the argument index.

0 commit comments

Comments
 (0)