summaryrefslogtreecommitdiff
path: root/modules/gdscript/gdscript_editor.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'modules/gdscript/gdscript_editor.cpp')
-rw-r--r--modules/gdscript/gdscript_editor.cpp37
1 files changed, 19 insertions, 18 deletions
diff --git a/modules/gdscript/gdscript_editor.cpp b/modules/gdscript/gdscript_editor.cpp
index 280bc37dc0..65c61cb57c 100644
--- a/modules/gdscript/gdscript_editor.cpp
+++ b/modules/gdscript/gdscript_editor.cpp
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md) */
+/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -335,7 +335,9 @@ void GDScriptLanguage::debug_get_stack_level_members(int p_level, List<String> *
ScriptInstance *GDScriptLanguage::debug_get_stack_level_instance(int p_level) {
- ERR_FAIL_COND_V(_debug_parse_err_line >= 0, NULL);
+ if (_debug_parse_err_line >= 0)
+ return NULL;
+
ERR_FAIL_INDEX_V(p_level, _debug_call_stack_pos, NULL);
int l = _debug_call_stack_pos - p_level - 1;
@@ -555,7 +557,7 @@ static String _get_visual_datatype(const PropertyInfo &p_info, bool p_isarg = tr
}
if (p_info.type == Variant::NIL) {
if (p_isarg || (p_info.usage & PROPERTY_USAGE_NIL_IS_VARIANT)) {
- return "var";
+ return "Variant";
} else {
return "void";
}
@@ -744,6 +746,14 @@ static bool _guess_expression_type(GDScriptCompletionContext &p_context, const G
r_type.type.kind = GDScriptParser::DataType::BUILTIN;
r_type.type.builtin_type = Variant::ARRAY;
} break;
+ case GDScriptParser::Node::TYPE_CAST: {
+ const GDScriptParser::CastNode *cn = static_cast<const GDScriptParser::CastNode *>(p_expression);
+ GDScriptCompletionIdentifier value;
+ if (_guess_expression_type(p_context, cn->source_node, r_type)) {
+ r_type.type = cn->get_datatype();
+ found = true;
+ }
+ } break;
case GDScriptParser::Node::TYPE_OPERATOR: {
const GDScriptParser::OperatorNode *op = static_cast<const GDScriptParser::OperatorNode *>(p_expression);
switch (op->op) {
@@ -1232,6 +1242,9 @@ static bool _guess_identifier_type(GDScriptCompletionContext &p_context, const S
c.line = last_assign_line;
r_type.assigned_expression = last_assigned_expression;
if (_guess_expression_type(c, last_assigned_expression, r_type)) {
+ if (var_type.has_type) {
+ r_type.type = var_type;
+ }
return true;
}
}
@@ -1725,14 +1738,12 @@ static String _make_arguments_hint(const MethodInfo &p_info, int p_arg_idx) {
for (const List<PropertyInfo>::Element *E = p_info.arguments.front(); E; E = E->next()) {
if (i > 0) {
arghint += ", ";
- } else {
- arghint += " ";
}
if (i == p_arg_idx) {
arghint += String::chr(0xFFFF);
}
- arghint += _get_visual_datatype(E->get(), true) + " " + E->get().name;
+ arghint += E->get().name + ": " + _get_visual_datatype(E->get(), true);
if (i - def_args >= 0) {
arghint += String(" = ") + p_info.default_arguments[i - def_args].get_construct_string();
@@ -1748,8 +1759,6 @@ static String _make_arguments_hint(const MethodInfo &p_info, int p_arg_idx) {
if (p_info.flags & METHOD_FLAG_VARARG) {
if (p_info.arguments.size() > 0) {
arghint += ", ";
- } else {
- arghint += " ";
}
if (p_arg_idx >= p_info.arguments.size()) {
arghint += String::chr(0xFFFF);
@@ -1759,9 +1768,6 @@ static String _make_arguments_hint(const MethodInfo &p_info, int p_arg_idx) {
arghint += String::chr(0xFFFF);
}
}
- if (p_info.arguments.size() > 0 || (p_info.flags & METHOD_FLAG_VARARG)) {
- arghint += " ";
- }
arghint += ")";
@@ -1776,14 +1782,12 @@ static String _make_arguments_hint(const GDScriptParser::FunctionNode *p_functio
for (int i = 0; i < p_function->arguments.size(); i++) {
if (i > 0) {
arghint += ", ";
- } else {
- arghint += " ";
}
if (i == p_arg_idx) {
arghint += String::chr(0xFFFF);
}
- arghint += p_function->argument_types[i].to_string() + " " + p_function->arguments[i].operator String();
+ arghint += p_function->arguments[i].operator String() + ": " + p_function->argument_types[i].to_string();
if (i - def_args >= 0) {
String def_val = "<unknown>";
@@ -1807,9 +1811,6 @@ static String _make_arguments_hint(const GDScriptParser::FunctionNode *p_functio
}
}
- if (p_function->arguments.size() > 0) {
- arghint += " ";
- }
arghint += ")";
return arghint;