diff options
Diffstat (limited to 'modules/gdscript')
| -rw-r--r-- | modules/gdscript/editor/gdscript_highlighter.cpp | 2 | ||||
| -rw-r--r-- | modules/gdscript/gdscript_analyzer.cpp | 14 | ||||
| -rw-r--r-- | modules/gdscript/gdscript_editor.cpp | 4 | ||||
| -rw-r--r-- | modules/gdscript/gdscript_parser.cpp | 16 | ||||
| -rw-r--r-- | modules/gdscript/gdscript_parser.h | 2 | 
5 files changed, 25 insertions, 13 deletions
diff --git a/modules/gdscript/editor/gdscript_highlighter.cpp b/modules/gdscript/editor/gdscript_highlighter.cpp index 996d323a7f..420401cb79 100644 --- a/modules/gdscript/editor/gdscript_highlighter.cpp +++ b/modules/gdscript/editor/gdscript_highlighter.cpp @@ -683,7 +683,7 @@ void GDScriptSyntaxHighlighter::_update_cache() {  		}  	} -	const String text_edit_color_theme = EditorSettings::get_singleton()->get("text_editor/theme/color_theme"); +	const String text_edit_color_theme = EDITOR_GET("text_editor/theme/color_theme");  	const bool godot_2_theme = text_edit_color_theme == "Godot 2";  	if (godot_2_theme || EditorSettings::get_singleton()->is_dark_theme()) { diff --git a/modules/gdscript/gdscript_analyzer.cpp b/modules/gdscript/gdscript_analyzer.cpp index 898e4eb1a6..1401e4b94b 100644 --- a/modules/gdscript/gdscript_analyzer.cpp +++ b/modules/gdscript/gdscript_analyzer.cpp @@ -1602,8 +1602,8 @@ void GDScriptAnalyzer::resolve_assert(GDScriptParser::AssertNode *p_assert) {  	reduce_expression(p_assert->condition);  	if (p_assert->message != nullptr) {  		reduce_expression(p_assert->message); -		if (!p_assert->message->is_constant || p_assert->message->reduced_value.get_type() != Variant::STRING) { -			push_error(R"(Expected constant string for assert error message.)", p_assert->message); +		if (!p_assert->message->get_datatype().has_no_type() && (p_assert->message->get_datatype().kind != GDScriptParser::DataType::BUILTIN || p_assert->message->get_datatype().builtin_type != Variant::STRING)) { +			push_error(R"(Expected string for assert error message.)", p_assert->message);  		}  	} @@ -2425,9 +2425,15 @@ void GDScriptAnalyzer::reduce_call(GDScriptParser::CallNode *p_call, bool p_is_a  				switch (err.error) {  					case Callable::CallError::CALL_ERROR_INVALID_ARGUMENT: { -						PropertyInfo wrong_arg = function_info.arguments[err.argument]; +						String expected_type_name; +						if (err.argument < function_info.arguments.size()) { +							expected_type_name = type_from_property(function_info.arguments[err.argument]).to_string(); +						} else { +							expected_type_name = Variant::get_type_name((Variant::Type)err.expected); +						} +  						push_error(vformat(R"*(Invalid argument for "%s()" function: argument %d should be %s but is %s.)*", function_name, err.argument + 1, -										   type_from_property(wrong_arg).to_string(), p_call->arguments[err.argument]->get_datatype().to_string()), +										   expected_type_name, p_call->arguments[err.argument]->get_datatype().to_string()),  								p_call->arguments[err.argument]);  					} break;  					case Callable::CallError::CALL_ERROR_INVALID_METHOD: diff --git a/modules/gdscript/gdscript_editor.cpp b/modules/gdscript/gdscript_editor.cpp index 3c68993b36..f33d1409bc 100644 --- a/modules/gdscript/gdscript_editor.cpp +++ b/modules/gdscript/gdscript_editor.cpp @@ -2513,7 +2513,7 @@ static void _find_call_arguments(GDScriptParser::CompletionContext &p_context, c  static void _find_call_arguments(GDScriptParser::CompletionContext &p_context, const GDScriptParser::Node *p_call, int p_argidx, HashMap<String, ScriptLanguage::CodeCompletionOption> &r_result, bool &r_forced, String &r_arghint) {  	if (p_call->type == GDScriptParser::Node::PRELOAD) { -		if (p_argidx == 0 && bool(EditorSettings::get_singleton()->get("text_editor/completion/complete_file_paths"))) { +		if (p_argidx == 0 && bool(EDITOR_GET("text_editor/completion/complete_file_paths"))) {  			_get_directory_contents(EditorFileSystem::get_singleton()->get_filesystem(), r_result);  		} @@ -2820,7 +2820,7 @@ static void _find_call_arguments(GDScriptParser::CompletionContext &p_context, c  			r_forced = true;  		} break;  		case GDScriptParser::COMPLETION_RESOURCE_PATH: { -			if (EditorSettings::get_singleton()->get("text_editor/completion/complete_file_paths")) { +			if (EDITOR_GET("text_editor/completion/complete_file_paths")) {  				_get_directory_contents(EditorFileSystem::get_singleton()->get_filesystem(), options);  				r_forced = true;  			} diff --git a/modules/gdscript/gdscript_parser.cpp b/modules/gdscript/gdscript_parser.cpp index bdf6fb35b6..4279edf394 100644 --- a/modules/gdscript/gdscript_parser.cpp +++ b/modules/gdscript/gdscript_parser.cpp @@ -3765,13 +3765,19 @@ bool GDScriptParser::export_annotations(const AnnotationNode *p_annotation, Node  				break;  			case GDScriptParser::DataType::CLASS:  				// Can assume type is a global GDScript class. -				if (!ClassDB::is_parent_class(export_type.native_type, SNAME("Resource"))) { -					push_error(R"(Exported script type must extend Resource.)"); +				if (ClassDB::is_parent_class(export_type.native_type, SNAME("Resource"))) { +					variable->export_info.type = Variant::OBJECT; +					variable->export_info.hint = PROPERTY_HINT_RESOURCE_TYPE; +					variable->export_info.hint_string = export_type.class_type->identifier->name; +				} else if (ClassDB::is_parent_class(export_type.native_type, SNAME("Node"))) { +					variable->export_info.type = Variant::OBJECT; +					variable->export_info.hint = PROPERTY_HINT_NODE_TYPE; +					variable->export_info.hint_string = export_type.class_type->identifier->name; +				} else { +					push_error(R"(Export type can only be built-in, a resource, a node or an enum.)", variable);  					return false;  				} -				variable->export_info.type = Variant::OBJECT; -				variable->export_info.hint = PROPERTY_HINT_RESOURCE_TYPE; -				variable->export_info.hint_string = export_type.class_type->identifier->name; +  				break;  			case GDScriptParser::DataType::SCRIPT: {  				StringName class_name; diff --git a/modules/gdscript/gdscript_parser.h b/modules/gdscript/gdscript_parser.h index 1850a44678..f40887ddb8 100644 --- a/modules/gdscript/gdscript_parser.h +++ b/modules/gdscript/gdscript_parser.h @@ -469,7 +469,7 @@ public:  			EnumNode *parent_enum = nullptr;  			int index = -1;  			bool resolved = false; -			int value = 0; +			int64_t value = 0;  			int line = 0;  			int leftmost_column = 0;  			int rightmost_column = 0;  |