Browse Source

Merge pull request #102698 from HolonProduction/no-null-safety

Autocompletion: Account for invalid annotations when making arghint
Rémi Verschelde 6 months ago
parent
commit
172fc62c80
2 changed files with 6 additions and 1 deletions
  1. 5 1
      modules/gdscript/gdscript_editor.cpp
  2. 1 0
      modules/gdscript/gdscript_parser.h

+ 5 - 1
modules/gdscript/gdscript_editor.cpp

@@ -889,7 +889,11 @@ static void _get_directory_contents(EditorFileSystemDirectory *p_dir, HashMap<St
 }
 
 static void _find_annotation_arguments(const GDScriptParser::AnnotationNode *p_annotation, int p_argument, const String p_quote_style, HashMap<String, ScriptLanguage::CodeCompletionOption> &r_result, String &r_arghint) {
-	r_arghint = _make_arguments_hint(p_annotation->info->info, p_argument, true);
+	ERR_FAIL_NULL(p_annotation);
+
+	if (p_annotation->info != nullptr) {
+		r_arghint = _make_arguments_hint(p_annotation->info->info, p_argument, true);
+	}
 	if (p_annotation->name == SNAME("@export_range")) {
 		if (p_argument == 3 || p_argument == 4 || p_argument == 5) {
 			// Slider hint.

+ 1 - 0
modules/gdscript/gdscript_parser.h

@@ -372,6 +372,7 @@ public:
 		Vector<ExpressionNode *> arguments;
 		Vector<Variant> resolved_arguments;
 
+		/** Information of the annotation. Might be null for unknown annotations. */
 		AnnotationInfo *info = nullptr;
 		PropertyInfo export_info;
 		bool is_resolved = false;