Browse Source

Fix Script editor completion doesn't suggest members of a script for type hints

(cherry picked from commit 7afbd5904e8cfccd8e87ddfca9f05359ca2df113)
ray90514 4 years ago
parent
commit
f1231a7c7e
2 changed files with 11 additions and 1 deletions
  1. 10 1
      modules/gdscript/gdscript_editor.cpp
  2. 1 0
      modules/gdscript/gdscript_parser.cpp

+ 10 - 1
modules/gdscript/gdscript_editor.cpp

@@ -2983,8 +2983,17 @@ Error GDScriptLanguage::complete_code(const String &p_code, const String &p_path
 							base_type.has_type = false;
 						}
 					} break;
-					case GDScriptParser::DataType::SCRIPT:
 					case GDScriptParser::DataType::GDSCRIPT: {
+						Ref<GDScript> scr = base_type.script_type;
+						if (scr.is_valid()) {
+							for (const Map<StringName, Ref<GDScript>>::Element *E = scr->get_subclasses().front(); E; E = E->next()) {
+								ScriptCodeCompletionOption option(E->key().operator String(), ScriptCodeCompletionOption::KIND_CLASS);
+								options.insert(option.display, option);
+							}
+						}
+						FALLTHROUGH;
+					}
+					case GDScriptParser::DataType::SCRIPT: {
 						Ref<Script> scr = base_type.script_type;
 						if (scr.is_valid()) {
 							Map<StringName, Variant> constants;

+ 1 - 0
modules/gdscript/gdscript_parser.cpp

@@ -5746,6 +5746,7 @@ bool GDScriptParser::_parse_type(DataType &r_type, bool p_can_be_void) {
 					can_index = false;
 					tokenizer->advance();
 				} break;
+				case GDScriptTokenizer::TK_CURSOR:
 				case GDScriptTokenizer::TK_IDENTIFIER: {
 					if (can_index) {
 						_set_error("Unexpected identifier.");