summaryrefslogtreecommitdiff
path: root/modules/gdscript
diff options
context:
space:
mode:
Diffstat (limited to 'modules/gdscript')
-rw-r--r--modules/gdscript/gd_editor.cpp2
-rw-r--r--modules/gdscript/gd_parser.cpp26
-rw-r--r--modules/gdscript/gd_parser.h3
3 files changed, 23 insertions, 8 deletions
diff --git a/modules/gdscript/gd_editor.cpp b/modules/gdscript/gd_editor.cpp
index 5f5de8b5db..a98b07ab92 100644
--- a/modules/gdscript/gd_editor.cpp
+++ b/modules/gdscript/gd_editor.cpp
@@ -65,7 +65,7 @@ bool GDScriptLanguage::validate(const String& p_script, int &r_line_error,int &r
GDParser parser;
- Error err = parser.parse(p_script,p_path.get_base_dir());
+ Error err = parser.parse(p_script,p_path.get_base_dir(),true);
if (err) {
r_line_error=parser.get_error_line();
r_col_error=parser.get_error_column();
diff --git a/modules/gdscript/gd_parser.cpp b/modules/gdscript/gd_parser.cpp
index 2829132d99..40c262c503 100644
--- a/modules/gdscript/gd_parser.cpp
+++ b/modules/gdscript/gd_parser.cpp
@@ -29,6 +29,7 @@
#include "gd_parser.h"
#include "print_string.h"
#include "io/resource_loader.h"
+#include "os/file_access.h"
/* TODO:
*Property reduce constant expressions
@@ -224,12 +225,23 @@ GDParser::Node* GDParser::_parse_expression(Node *p_parent,bool p_static,bool p_
String path = tokenizer->get_token_constant();
if (!path.is_abs_path() && base_path!="")
path=base_path+"/"+path;
- path = path.replace("///","//");
+ path = path.replace("///","//");
- Ref<Resource> res = ResourceLoader::load(path);
- if (!res.is_valid()) {
- _set_error("Can't preload resource at path: "+path);
- return NULL;
+ Ref<Resource> res;
+ if (!validating) {
+
+ //this can be too slow for just validating code
+ res = ResourceLoader::load(path);
+ if (!res.is_valid()) {
+ _set_error("Can't preload resource at path: "+path);
+ return NULL;
+ }
+ } else {
+
+ if (!FileAccess::exists(path)) {
+ _set_error("Can't preload resource at path: "+path);
+ return NULL;
+ }
}
tokenizer->advance();
@@ -2468,12 +2480,13 @@ Error GDParser::parse_bytecode(const Vector<uint8_t> &p_bytecode,const String& p
}
-Error GDParser::parse(const String& p_code,const String& p_base_path) {
+Error GDParser::parse(const String& p_code,const String& p_base_path,bool p_just_validate) {
GDTokenizerText *tt = memnew( GDTokenizerText );
tt->set_code(p_code);
+ validating=p_just_validate;
tokenizer=tt;
Error ret = _parse(p_base_path);
memdelete(tt);
@@ -2498,6 +2511,7 @@ void GDParser::clear() {
head=NULL;
list=NULL;
+ validating=false;
error_set=false;
tab_level.clear();
tab_level.push_back(0);
diff --git a/modules/gdscript/gd_parser.h b/modules/gdscript/gd_parser.h
index 825bd954d1..ae43a26f5a 100644
--- a/modules/gdscript/gd_parser.h
+++ b/modules/gdscript/gd_parser.h
@@ -356,6 +356,7 @@ private:
template<class T>
T* alloc_node();
+ bool validating;
int parenthesis;
bool error_set;
String error;
@@ -392,7 +393,7 @@ public:
String get_error() const;
int get_error_line() const;
int get_error_column() const;
- Error parse(const String& p_code,const String& p_base_path="");
+ Error parse(const String& p_code, const String& p_base_path="", bool p_just_validate=false);
Error parse_bytecode(const Vector<uint8_t> &p_bytecode,const String& p_base_path="");
const Node *get_parse_tree() const;