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.cpp65
1 files changed, 0 insertions, 65 deletions
diff --git a/modules/gdscript/gdscript_editor.cpp b/modules/gdscript/gdscript_editor.cpp
index 56381e8af7..fc6f9b5419 100644
--- a/modules/gdscript/gdscript_editor.cpp
+++ b/modules/gdscript/gdscript_editor.cpp
@@ -41,19 +41,16 @@
#endif
void GDScriptLanguage::get_comment_delimiters(List<String> *p_delimiters) const {
-
p_delimiters->push_back("#");
}
void GDScriptLanguage::get_string_delimiters(List<String> *p_delimiters) const {
-
p_delimiters->push_back("\" \"");
p_delimiters->push_back("' '");
p_delimiters->push_back("\"\"\" \"\"\"");
}
String GDScriptLanguage::_get_processed_template(const String &p_template, const String &p_base_class_name) const {
-
String processed_template = p_template;
#ifdef TOOLS_ENABLED
@@ -109,18 +106,15 @@ Ref<Script> GDScriptLanguage::get_template(const String &p_class_name, const Str
}
bool GDScriptLanguage::is_using_templates() {
-
return true;
}
void GDScriptLanguage::make_template(const String &p_class_name, const String &p_base_class_name, Ref<Script> &p_script) {
-
String _template = _get_processed_template(p_script->get_source_code(), p_base_class_name);
p_script->set_source_code(_template);
}
bool GDScriptLanguage::validate(const String &p_script, int &r_line_error, int &r_col_error, String &r_test_error, const String &p_path, List<String> *r_functions, List<ScriptLanguage::Warning> *r_warnings, Set<int> *r_safe_lines) const {
-
GDScriptParser parser;
Error err = parser.parse(p_script, p_path.get_base_dir(), true, p_path, false, r_safe_lines);
@@ -143,35 +137,29 @@ bool GDScriptLanguage::validate(const String &p_script, int &r_line_error, int &
r_test_error = parser.get_error();
return false;
} else {
-
const GDScriptParser::Node *root = parser.get_parse_tree();
ERR_FAIL_COND_V(root->type != GDScriptParser::Node::TYPE_CLASS, false);
const GDScriptParser::ClassNode *cl = static_cast<const GDScriptParser::ClassNode *>(root);
Map<int, String> funcs;
for (int i = 0; i < cl->functions.size(); i++) {
-
funcs[cl->functions[i]->line] = cl->functions[i]->name;
}
for (int i = 0; i < cl->static_functions.size(); i++) {
-
funcs[cl->static_functions[i]->line] = cl->static_functions[i]->name;
}
for (int i = 0; i < cl->subclasses.size(); i++) {
for (int j = 0; j < cl->subclasses[i]->functions.size(); j++) {
-
funcs[cl->subclasses[i]->functions[j]->line] = String(cl->subclasses[i]->name) + "." + cl->subclasses[i]->functions[j]->name;
}
for (int j = 0; j < cl->subclasses[i]->static_functions.size(); j++) {
-
funcs[cl->subclasses[i]->static_functions[j]->line] = String(cl->subclasses[i]->name) + "." + cl->subclasses[i]->static_functions[j]->name;
}
}
for (Map<int, String>::Element *E = funcs.front(); E; E = E->next()) {
-
r_functions->push_back(E->get() + ":" + itos(E->key()));
}
}
@@ -180,27 +168,22 @@ bool GDScriptLanguage::validate(const String &p_script, int &r_line_error, int &
}
bool GDScriptLanguage::has_named_classes() const {
-
return false;
}
bool GDScriptLanguage::supports_builtin_mode() const {
-
return true;
}
int GDScriptLanguage::find_function(const String &p_function, const String &p_code) const {
-
GDScriptTokenizerText tokenizer;
tokenizer.set_code(p_code);
int indent = 0;
while (tokenizer.get_token() != GDScriptTokenizer::TK_EOF && tokenizer.get_token() != GDScriptTokenizer::TK_ERROR) {
-
if (tokenizer.get_token() == GDScriptTokenizer::TK_NEWLINE) {
indent = tokenizer.get_token_line_indent();
}
if (indent == 0 && tokenizer.get_token() == GDScriptTokenizer::TK_PR_FUNCTION && tokenizer.get_token(1) == GDScriptTokenizer::TK_IDENTIFIER) {
-
String identifier = tokenizer.get_token_identifier(1);
if (identifier == p_function) {
return tokenizer.get_token_line();
@@ -212,7 +195,6 @@ int GDScriptLanguage::find_function(const String &p_function, const String &p_co
}
Script *GDScriptLanguage::create_script() const {
-
return memnew(GDScript);
}
@@ -222,7 +204,6 @@ bool GDScriptLanguage::debug_break_parse(const String &p_file, int p_line, const
//break because of parse error
if (EngineDebugger::is_active() && Thread::get_caller_id() == Thread::get_main_id()) {
-
_debug_parse_err_line = p_line;
_debug_parse_err_file = p_file;
_debug_error = p_error;
@@ -234,9 +215,7 @@ bool GDScriptLanguage::debug_break_parse(const String &p_file, int p_line, const
}
bool GDScriptLanguage::debug_break(const String &p_error, bool p_allow_continue) {
-
if (EngineDebugger::is_active() && Thread::get_caller_id() == Thread::get_main_id()) {
-
_debug_parse_err_line = -1;
_debug_parse_err_file = "";
_debug_error = p_error;
@@ -249,19 +228,16 @@ bool GDScriptLanguage::debug_break(const String &p_error, bool p_allow_continue)
}
String GDScriptLanguage::debug_get_error() const {
-
return _debug_error;
}
int GDScriptLanguage::debug_get_stack_level_count() const {
-
if (_debug_parse_err_line >= 0)
return 1;
return _debug_call_stack_pos;
}
int GDScriptLanguage::debug_get_stack_level_line(int p_level) const {
-
if (_debug_parse_err_line >= 0)
return _debug_parse_err_line;
@@ -272,7 +248,6 @@ int GDScriptLanguage::debug_get_stack_level_line(int p_level) const {
return *(_call_stack[l].line);
}
String GDScriptLanguage::debug_get_stack_level_function(int p_level) const {
-
if (_debug_parse_err_line >= 0)
return "";
@@ -281,7 +256,6 @@ String GDScriptLanguage::debug_get_stack_level_function(int p_level) const {
return _call_stack[l].function->get_name();
}
String GDScriptLanguage::debug_get_stack_level_source(int p_level) const {
-
if (_debug_parse_err_line >= 0)
return _debug_parse_err_file;
@@ -290,7 +264,6 @@ String GDScriptLanguage::debug_get_stack_level_source(int p_level) const {
return _call_stack[l].function->get_source();
}
void GDScriptLanguage::debug_get_stack_level_locals(int p_level, List<String> *p_locals, List<Variant> *p_values, int p_max_subitems, int p_max_depth) {
-
if (_debug_parse_err_line >= 0)
return;
@@ -303,13 +276,11 @@ void GDScriptLanguage::debug_get_stack_level_locals(int p_level, List<String> *p
f->debug_get_stack_member_state(*_call_stack[l].line, &locals);
for (List<Pair<StringName, int>>::Element *E = locals.front(); E; E = E->next()) {
-
p_locals->push_back(E->get().first);
p_values->push_back(_call_stack[l].stack[E->get().second]);
}
}
void GDScriptLanguage::debug_get_stack_level_members(int p_level, List<String> *p_members, List<Variant> *p_values, int p_max_subitems, int p_max_depth) {
-
if (_debug_parse_err_line >= 0)
return;
@@ -327,14 +298,12 @@ void GDScriptLanguage::debug_get_stack_level_members(int p_level, List<String> *
const Map<StringName, GDScript::MemberInfo> &mi = script->debug_get_member_indices();
for (const Map<StringName, GDScript::MemberInfo>::Element *E = mi.front(); E; E = E->next()) {
-
p_members->push_back(E->key());
p_values->push_back(instance->debug_get_member_by_index(E->get().index));
}
}
ScriptInstance *GDScriptLanguage::debug_get_stack_level_instance(int p_level) {
-
if (_debug_parse_err_line >= 0)
return nullptr;
@@ -347,7 +316,6 @@ ScriptInstance *GDScriptLanguage::debug_get_stack_level_instance(int p_level) {
}
void GDScriptLanguage::debug_get_globals(List<String> *p_globals, List<Variant> *p_values, int p_max_subitems, int p_max_depth) {
-
const Map<StringName, int> &name_idx = GDScriptLanguage::get_singleton()->get_global_map();
const Variant *globals = GDScriptLanguage::get_singleton()->get_global_array();
@@ -355,7 +323,6 @@ void GDScriptLanguage::debug_get_globals(List<String> *p_globals, List<Variant>
get_public_constants(&cinfo);
for (const Map<StringName, int>::Element *E = name_idx.front(); E; E = E->next()) {
-
if (ClassDB::class_exists(E->key()) || Engine::get_singleton()->has_singleton(E->key()))
continue;
@@ -391,19 +358,15 @@ void GDScriptLanguage::debug_get_globals(List<String> *p_globals, List<Variant>
}
String GDScriptLanguage::debug_parse_stack_level_expression(int p_level, const String &p_expression, int p_max_subitems, int p_max_depth) {
-
return "";
}
void GDScriptLanguage::get_recognized_extensions(List<String> *p_extensions) const {
-
p_extensions->push_back("gd");
}
void GDScriptLanguage::get_public_functions(List<MethodInfo> *p_functions) const {
-
for (int i = 0; i < GDScriptFunctions::FUNC_MAX; i++) {
-
p_functions->push_back(GDScriptFunctions::get_info(GDScriptFunctions::Function(i)));
}
@@ -437,7 +400,6 @@ void GDScriptLanguage::get_public_functions(List<MethodInfo> *p_functions) const
}
void GDScriptLanguage::get_public_constants(List<Pair<String, Variant>> *p_constants) const {
-
Pair<String, Variant> pi;
pi.first = "PI";
pi.second = Math_PI;
@@ -460,7 +422,6 @@ void GDScriptLanguage::get_public_constants(List<Pair<String, Variant>> *p_const
}
String GDScriptLanguage::make_function(const String &p_class, const String &p_name, const PackedStringArray &p_args) const {
-
#ifdef TOOLS_ENABLED
bool th = EditorSettings::get_singleton()->get_setting("text_editor/completion/add_type_hints");
#else
@@ -491,7 +452,6 @@ String GDScriptLanguage::make_function(const String &p_class, const String &p_na
#if defined(DEBUG_METHODS_ENABLED) && defined(TOOLS_ENABLED)
struct GDScriptCompletionContext {
-
const GDScriptParser::ClassNode *_class = nullptr;
const GDScriptParser::FunctionNode *function = nullptr;
const GDScriptParser::BlockNode *block = nullptr;
@@ -513,7 +473,6 @@ struct GDScriptCompletionIdentifier {
};
static void _get_directory_contents(EditorFileSystemDirectory *p_dir, Map<String, ScriptCodeCompletionOption> &r_list) {
-
const String quote_style = EDITOR_DEF("text_editor/completion/use_single_quotes", false) ? "'" : "\"";
for (int i = 0; i < p_dir->get_file_count(); i++) {
@@ -528,7 +487,6 @@ static void _get_directory_contents(EditorFileSystemDirectory *p_dir, Map<String
}
static String _get_visual_datatype(const PropertyInfo &p_info, bool p_isarg = true) {
-
if (p_info.usage & PROPERTY_USAGE_CLASS_IS_ENUM) {
String enum_name = p_info.class_name;
if (enum_name.find(".") == -1) {
@@ -828,7 +786,6 @@ static bool _guess_expression_type(GDScriptCompletionContext &p_context, const G
Object *baseptr = base.value;
if (all_is_const && String(id) == "get_node" && ClassDB::is_parent_class(native_type.native_type, "Node") && args.size()) {
-
String arg1 = args[0];
if (arg1.begins_with("/root/")) {
String which = arg1.get_slice("/", 2);
@@ -842,7 +799,6 @@ static bool _guess_expression_type(GDScriptCompletionContext &p_context, const G
ProjectSettings::get_singleton()->get_property_list(&props);
for (List<PropertyInfo>::Element *E = props.front(); E; E = E->next()) {
-
String s = E->get().name;
if (!s.begins_with("autoload/")) {
continue;
@@ -1184,7 +1140,6 @@ static bool _guess_expression_type(GDScriptCompletionContext &p_context, const G
}
static bool _guess_identifier_type(GDScriptCompletionContext &p_context, const StringName &p_identifier, GDScriptCompletionIdentifier &r_type) {
-
// Look in blocks first
const GDScriptParser::BlockNode *blk = p_context.block;
int last_assign_line = -1;
@@ -1746,7 +1701,6 @@ static bool _guess_method_return_type_from_base(GDScriptCompletionContext &p_con
}
static String _make_arguments_hint(const MethodInfo &p_info, int p_arg_idx) {
-
String arghint = _get_visual_datatype(p_info.return_val, false) + " " + p_info.name + "(";
int def_args = p_info.arguments.size() - p_info.default_arguments.size();
@@ -1791,7 +1745,6 @@ static String _make_arguments_hint(const MethodInfo &p_info, int p_arg_idx) {
}
static String _make_arguments_hint(const GDScriptParser::FunctionNode *p_function, int p_arg_idx) {
-
String arghint = p_function->return_type.to_string() + " " + p_function->name.operator String() + "(";
int def_args = p_function->arguments.size() - p_function->default_values.size();
@@ -1833,7 +1786,6 @@ static String _make_arguments_hint(const GDScriptParser::FunctionNode *p_functio
}
static void _find_enumeration_candidates(const String p_enum_hint, Map<String, ScriptCodeCompletionOption> &r_result) {
-
if (p_enum_hint.find(".") == -1) {
// Global constant
StringName current_enum = p_enum_hint;
@@ -2144,11 +2096,9 @@ static void _find_identifiers_in_base(const GDScriptCompletionContext &p_context
}
static void _find_identifiers(const GDScriptCompletionContext &p_context, bool p_only_functions, Map<String, ScriptCodeCompletionOption> &r_result) {
-
const GDScriptParser::BlockNode *block = p_context.block;
if (p_context.function) {
-
const GDScriptParser::FunctionNode *f = p_context.function;
for (int i = 0; i < f->arguments.size(); i++) {
@@ -2417,7 +2367,6 @@ static void _find_call_arguments(const GDScriptCompletionContext &p_context, con
}
static void _find_call_arguments(GDScriptCompletionContext &p_context, const GDScriptParser::Node *p_node, int p_argidx, Map<String, ScriptCodeCompletionOption> &r_result, bool &r_forced, String &r_arghint) {
-
const String quote_style = EDITOR_DEF("text_editor/completion/use_single_quotes", false) ? "'" : "\"";
if (!p_node || p_node->type != GDScriptParser::Node::TYPE_OPERATOR) {
@@ -2473,7 +2422,6 @@ static void _find_call_arguments(GDScriptCompletionContext &p_context, const GDS
}
return;
} else if (op->arguments[0]->type == GDScriptParser::Node::TYPE_SELF) {
-
if (op->arguments.size() < 2 || op->arguments[1]->type != GDScriptParser::Node::TYPE_IDENTIFIER) {
return;
}
@@ -2547,7 +2495,6 @@ static void _find_call_arguments(GDScriptCompletionContext &p_context, const GDS
}
Error GDScriptLanguage::complete_code(const String &p_code, const String &p_path, Object *p_owner, List<ScriptCodeCompletionOption> *r_options, bool &r_forced, String &r_call_hint) {
-
const String quote_style = EDITOR_DEF("text_editor/completion/use_single_quotes", false) ? "'" : "\"";
GDScriptParser parser;
@@ -2595,7 +2542,6 @@ Error GDScriptLanguage::complete_code(const String &p_code, const String &p_path
p_owner->get_argument_options("get_node", 0, &opts);
for (List<String>::Element *E = opts.front(); E; E = E->next()) {
-
String opt = E->get().strip_edges();
if (opt.is_quoted()) {
r_forced = true;
@@ -2703,7 +2649,6 @@ Error GDScriptLanguage::complete_code(const String &p_code, const String &p_path
List<MethodInfo> virtual_methods;
ClassDB::get_virtual_methods(class_name, &virtual_methods);
for (List<MethodInfo>::Element *E = virtual_methods.front(); E; E = E->next()) {
-
MethodInfo &mi = E->get();
String method_hint = mi.name;
if (method_hint.find(":") != -1) {
@@ -3027,19 +2972,16 @@ String GDScriptLanguage::_get_indentation() const {
}
void GDScriptLanguage::auto_indent_code(String &p_code, int p_from_line, int p_to_line) const {
-
String indent = _get_indentation();
Vector<String> lines = p_code.split("\n");
List<int> indent_stack;
for (int i = 0; i < lines.size(); i++) {
-
String l = lines[i];
int tc = 0;
for (int j = 0; j < l.length(); j++) {
if (l[j] == ' ' || l[j] == '\t') {
-
tc++;
} else {
break;
@@ -3067,7 +3009,6 @@ void GDScriptLanguage::auto_indent_code(String &p_code, int p_from_line, int p_t
}
if (i >= p_from_line) {
-
l = "";
for (int j = 0; j < indent_stack.size(); j++) {
l += indent;
@@ -3271,7 +3212,6 @@ static Error _lookup_symbol_from_base(const GDScriptParser::DataType &p_base, co
}
Error GDScriptLanguage::lookup_code(const String &p_code, const String &p_symbol, const String &p_path, Object *p_owner, LookupResult &r_result) {
-
//before parsing, try the usual stuff
if (ClassDB::class_exists(p_symbol)) {
r_result.type = ScriptLanguage::LookupResult::RESULT_CLASS;
@@ -3352,7 +3292,6 @@ Error GDScriptLanguage::lookup_code(const String &p_code, const String &p_symbol
[[fallthrough]];
}
case GDScriptParser::COMPLETION_IDENTIFIER: {
-
if (!is_function) {
is_function = parser.get_completion_identifier_is_function();
}
@@ -3404,13 +3343,11 @@ Error GDScriptLanguage::lookup_code(const String &p_code, const String &p_symbol
ProjectSettings::get_singleton()->get_property_list(&props);
for (List<PropertyInfo>::Element *E = props.front(); E; E = E->next()) {
-
String s = E->get().name;
if (!s.begins_with("autoload/"))
continue;
String name = s.get_slice("/", 1);
if (name == String(p_symbol)) {
-
String path = ProjectSettings::get_singleton()->get(s);
if (path.begins_with("*")) {
String script = path.substr(1, path.length());
@@ -3422,7 +3359,6 @@ Error GDScriptLanguage::lookup_code(const String &p_code, const String &p_symbol
}
if (FileAccess::exists(script)) {
-
r_result.type = ScriptLanguage::LookupResult::RESULT_SCRIPT_LOCATION;
r_result.location = 0;
r_result.script = ResourceLoader::load(script);
@@ -3505,7 +3441,6 @@ Error GDScriptLanguage::lookup_code(const String &p_code, const String &p_symbol
}
} break;
case GDScriptParser::COMPLETION_TYPE_HINT: {
-
GDScriptParser::DataType base_type = context._class->base_type;
base_type.has_type = true;
base_type.kind = GDScriptParser::DataType::CLASS;