summaryrefslogtreecommitdiffstats
path: root/modules/gdscript
diff options
context:
space:
mode:
Diffstat (limited to 'modules/gdscript')
-rw-r--r--modules/gdscript/gd_editor.cpp4
-rw-r--r--modules/gdscript/gd_function.cpp18
-rw-r--r--modules/gdscript/gd_function.h2
-rw-r--r--modules/gdscript/gd_parser.cpp22
-rw-r--r--modules/gdscript/gd_parser.h2
-rw-r--r--modules/gdscript/gd_tokenizer.cpp1
6 files changed, 33 insertions, 16 deletions
diff --git a/modules/gdscript/gd_editor.cpp b/modules/gdscript/gd_editor.cpp
index 4667e541dd..7d5ba08d6c 100644
--- a/modules/gdscript/gd_editor.cpp
+++ b/modules/gdscript/gd_editor.cpp
@@ -1321,7 +1321,7 @@ static void _find_identifiers(GDCompletionContext &context, int p_line, bool p_o
static const char *_type_names[Variant::VARIANT_MAX] = {
"null", "bool", "int", "float", "String", "Vector2", "Rect2", "Vector3", "Transform2D", "Plane", "Quat", "AABB", "Basis", "Transform",
- "Color", "Image", "NodePath", "RID", "Object", "InputEvent", "Dictionary", "Array", "RawArray", "IntArray", "FloatArray", "StringArray",
+ "Color", "NodePath", "RID", "Object", "InputEvent", "Dictionary", "Array", "RawArray", "IntArray", "FloatArray", "StringArray",
"Vector2Array", "Vector3Array", "ColorArray"
};
@@ -2395,7 +2395,7 @@ Error GDScriptLanguage::complete_code(const String &p_code, const String &p_base
}
} break;
- case GDParser::COMPLETION_PRELOAD: {
+ case GDParser::COMPLETION_RESOURCE_PATH: {
if (EditorSettings::get_singleton()->get("text_editor/completion/complete_file_paths"))
get_directory_contents(EditorFileSystem::get_singleton()->get_filesystem(), options);
diff --git a/modules/gdscript/gd_function.cpp b/modules/gdscript/gd_function.cpp
index 608256c88a..fb32d23ad5 100644
--- a/modules/gdscript/gd_function.cpp
+++ b/modules/gdscript/gd_function.cpp
@@ -1433,9 +1433,21 @@ Variant GDFunctionState::_signal_callback(const Variant **p_args, int p_argcount
return ret;
}
-bool GDFunctionState::is_valid() const {
+bool GDFunctionState::is_valid(bool p_extended_check) const {
+
+ if (function == NULL)
+ return false;
+
+ if (p_extended_check) {
+ //class instance gone?
+ if (state.instance_id && !ObjectDB::get_instance(state.instance_id))
+ return false;
+ //script gone?
+ if (state.script_id && !ObjectDB::get_instance(state.script_id))
+ return false;
+ }
- return function != NULL;
+ return true;
}
Variant GDFunctionState::resume(const Variant &p_arg) {
@@ -1464,7 +1476,7 @@ Variant GDFunctionState::resume(const Variant &p_arg) {
void GDFunctionState::_bind_methods() {
ClassDB::bind_method(D_METHOD("resume:Variant", "arg"), &GDFunctionState::resume, DEFVAL(Variant()));
- ClassDB::bind_method(D_METHOD("is_valid"), &GDFunctionState::is_valid);
+ ClassDB::bind_method(D_METHOD("is_valid", "extended_check"), &GDFunctionState::is_valid, DEFVAL(false));
ClassDB::bind_vararg_method(METHOD_FLAGS_DEFAULT, "_signal_callback", &GDFunctionState::_signal_callback, MethodInfo("_signal_callback"));
}
diff --git a/modules/gdscript/gd_function.h b/modules/gdscript/gd_function.h
index f0bf33147b..6d20b19777 100644
--- a/modules/gdscript/gd_function.h
+++ b/modules/gdscript/gd_function.h
@@ -237,7 +237,7 @@ protected:
static void _bind_methods();
public:
- bool is_valid() const;
+ bool is_valid(bool p_extended_check = false) const;
Variant resume(const Variant &p_arg = Variant());
GDFunctionState();
~GDFunctionState();
diff --git a/modules/gdscript/gd_parser.cpp b/modules/gdscript/gd_parser.cpp
index b02d7f713b..4ae62eb1d0 100644
--- a/modules/gdscript/gd_parser.cpp
+++ b/modules/gdscript/gd_parser.cpp
@@ -387,15 +387,21 @@ GDParser::Node *GDParser::_parse_expression(Node *p_parent, bool p_static, bool
_set_error("Expected '(' after 'preload'");
return NULL;
}
- completion_cursor = StringName();
- completion_type = COMPLETION_PRELOAD;
- completion_class = current_class;
- completion_function = current_function;
- completion_line = tokenizer->get_token_line();
- completion_block = current_block;
- completion_found = true;
tokenizer->advance();
+ if (tokenizer->get_token() == GDTokenizer::TK_CURSOR) {
+ completion_cursor = StringName();
+ completion_node = p_parent;
+ completion_type = COMPLETION_RESOURCE_PATH;
+ completion_class = current_class;
+ completion_function = current_function;
+ completion_line = tokenizer->get_token_line();
+ completion_block = current_block;
+ completion_argument = 0;
+ completion_found = true;
+ tokenizer->advance();
+ }
+
String path;
bool found_constant = false;
bool valid = false;
@@ -467,10 +473,10 @@ GDParser::Node *GDParser::_parse_expression(Node *p_parent, bool p_static, bool
_set_error("Expected ')' after 'preload' path");
return NULL;
}
+ tokenizer->advance();
ConstantNode *constant = alloc_node<ConstantNode>();
constant->value = res;
- tokenizer->advance();
expr = constant;
} else if (tokenizer->get_token() == GDTokenizer::TK_PR_YIELD) {
diff --git a/modules/gdscript/gd_parser.h b/modules/gdscript/gd_parser.h
index 4f3ca0dc5f..7e7e19de1b 100644
--- a/modules/gdscript/gd_parser.h
+++ b/modules/gdscript/gd_parser.h
@@ -437,7 +437,7 @@ public:
COMPLETION_PARENT_FUNCTION,
COMPLETION_METHOD,
COMPLETION_CALL_ARGUMENTS,
- COMPLETION_PRELOAD,
+ COMPLETION_RESOURCE_PATH,
COMPLETION_INDEX,
COMPLETION_VIRTUAL_FUNC,
COMPLETION_YIELD,
diff --git a/modules/gdscript/gd_tokenizer.cpp b/modules/gdscript/gd_tokenizer.cpp
index 13674f1f9a..c26ba03a64 100644
--- a/modules/gdscript/gd_tokenizer.cpp
+++ b/modules/gdscript/gd_tokenizer.cpp
@@ -800,7 +800,6 @@ void GDTokenizerText::_advance() {
{ Variant::BASIS, "Basis" },
{ Variant::TRANSFORM, "Transform" },
{ Variant::COLOR, "Color" },
- { Variant::IMAGE, "Image" },
{ Variant::_RID, "RID" },
{ Variant::OBJECT, "Object" },
{ Variant::INPUT_EVENT, "InputEvent" },