summaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
authorRĂ©mi Verschelde <remi@verschelde.fr>2023-04-26 17:57:45 +0200
committerGitHub <noreply@github.com>2023-04-26 17:57:45 +0200
commitba004ea1c3b00c5516548edde7bdfe2d72d51ea1 (patch)
tree534f23706b47017760b8d5e9395b00ef3ebd385a /modules
parentd78691d44fe6e4f38dce3a89164cdae688772031 (diff)
parente7f4af091331ef10dd2088d82bc552a097d3d4ce (diff)
Merge pull request #76476 from YuriSizov/4.0-cherrypicks
Cherry-picks for the 4.0 branch (future 4.0.3) - 3rd batch
Diffstat (limited to 'modules')
-rw-r--r--modules/gdscript/gdscript_editor.cpp1
-rw-r--r--modules/gdscript/gdscript_tokenizer.cpp2
-rw-r--r--modules/gdscript/gdscript_vm.cpp7
-rw-r--r--modules/gdscript/language_server/gdscript_extend_parser.cpp14
-rw-r--r--modules/gdscript/language_server/gdscript_workspace.cpp40
-rw-r--r--modules/gdscript/language_server/godot_lsp.h10
-rw-r--r--modules/navigation/navigation_mesh_generator.cpp8
7 files changed, 55 insertions, 27 deletions
diff --git a/modules/gdscript/gdscript_editor.cpp b/modules/gdscript/gdscript_editor.cpp
index 536cb344f4..a8c1f38486 100644
--- a/modules/gdscript/gdscript_editor.cpp
+++ b/modules/gdscript/gdscript_editor.cpp
@@ -54,6 +54,7 @@ void GDScriptLanguage::get_string_delimiters(List<String> *p_delimiters) const {
p_delimiters->push_back("\" \"");
p_delimiters->push_back("' '");
p_delimiters->push_back("\"\"\" \"\"\"");
+ p_delimiters->push_back("''' '''");
}
bool GDScriptLanguage::is_using_templates() {
diff --git a/modules/gdscript/gdscript_tokenizer.cpp b/modules/gdscript/gdscript_tokenizer.cpp
index d586380c41..a45a73a8d5 100644
--- a/modules/gdscript/gdscript_tokenizer.cpp
+++ b/modules/gdscript/gdscript_tokenizer.cpp
@@ -1099,7 +1099,7 @@ void GDScriptTokenizer::check_indent() {
_advance();
}
- if (mixed) {
+ if (mixed && !(line_continuation || multiline_mode)) {
Token error = make_error("Mixed use of tabs and spaces for indentation.");
error.start_line = line;
error.start_column = 1;
diff --git a/modules/gdscript/gdscript_vm.cpp b/modules/gdscript/gdscript_vm.cpp
index 83d2ed6010..7098e4cd40 100644
--- a/modules/gdscript/gdscript_vm.cpp
+++ b/modules/gdscript/gdscript_vm.cpp
@@ -3572,8 +3572,9 @@ Variant GDScriptFunction::call(GDScriptInstance *p_instance, const Variant **p_a
//error
// function, file, line, error, explanation
String err_file;
- if (p_instance && ObjectDB::get_instance(p_instance->owner_id) != nullptr && p_instance->script->is_valid() && !p_instance->script->path.is_empty()) {
- err_file = p_instance->script->path;
+ bool instance_valid_with_script = p_instance && ObjectDB::get_instance(p_instance->owner_id) != nullptr && p_instance->script->is_valid();
+ if (instance_valid_with_script && !get_script()->path.is_empty()) {
+ err_file = get_script()->path;
} else if (script) {
err_file = script->path;
}
@@ -3581,7 +3582,7 @@ Variant GDScriptFunction::call(GDScriptInstance *p_instance, const Variant **p_a
err_file = "<built-in>";
}
String err_func = name;
- if (p_instance && ObjectDB::get_instance(p_instance->owner_id) != nullptr && p_instance->script->is_valid() && !p_instance->script->name.is_empty()) {
+ if (instance_valid_with_script && !p_instance->script->name.is_empty()) {
err_func = p_instance->script->name + "." + err_func;
}
int err_line = line;
diff --git a/modules/gdscript/language_server/gdscript_extend_parser.cpp b/modules/gdscript/language_server/gdscript_extend_parser.cpp
index 1bf9f85831..deed90626f 100644
--- a/modules/gdscript/language_server/gdscript_extend_parser.cpp
+++ b/modules/gdscript/language_server/gdscript_extend_parser.cpp
@@ -400,6 +400,20 @@ void ExtendGDScriptParser::parse_function_symbol(const GDScriptParser::FunctionN
}
} break;
+ case GDScriptParser::TypeNode::VARIABLE: {
+ GDScriptParser::VariableNode *variable_node = (GDScriptParser::VariableNode *)(node);
+ lsp::DocumentSymbol symbol;
+ symbol.kind = lsp::SymbolKind::Variable;
+ symbol.name = variable_node->identifier->name;
+ symbol.range.start.line = LINE_NUMBER_TO_INDEX(variable_node->start_line);
+ symbol.range.start.character = LINE_NUMBER_TO_INDEX(variable_node->start_column);
+ symbol.range.end.line = LINE_NUMBER_TO_INDEX(variable_node->end_line);
+ symbol.range.end.character = LINE_NUMBER_TO_INDEX(variable_node->end_column);
+ symbol.uri = uri;
+ symbol.script_path = path;
+ r_symbol.children.push_back(symbol);
+ } break;
+
default:
continue;
}
diff --git a/modules/gdscript/language_server/gdscript_workspace.cpp b/modules/gdscript/language_server/gdscript_workspace.cpp
index b90c452346..7fc2962341 100644
--- a/modules/gdscript/language_server/gdscript_workspace.cpp
+++ b/modules/gdscript/language_server/gdscript_workspace.cpp
@@ -185,15 +185,27 @@ const lsp::DocumentSymbol *GDScriptWorkspace::get_local_symbol(const ExtendGDScr
const lsp::DocumentSymbol *class_symbol = &p_parser->get_symbols();
for (int i = 0; i < class_symbol->children.size(); ++i) {
- if (class_symbol->children[i].kind == lsp::SymbolKind::Function || class_symbol->children[i].kind == lsp::SymbolKind::Class) {
- const lsp::DocumentSymbol *function_symbol = &class_symbol->children[i];
+ int kind = class_symbol->children[i].kind;
+ switch (kind) {
+ case lsp::SymbolKind::Function:
+ case lsp::SymbolKind::Method:
+ case lsp::SymbolKind::Class: {
+ const lsp::DocumentSymbol *function_symbol = &class_symbol->children[i];
+
+ for (int l = 0; l < function_symbol->children.size(); ++l) {
+ const lsp::DocumentSymbol *local = &function_symbol->children[l];
+ if (!local->detail.is_empty() && local->name == p_symbol_identifier) {
+ return local;
+ }
+ }
+ } break;
- for (int l = 0; l < function_symbol->children.size(); ++l) {
- const lsp::DocumentSymbol *local = &function_symbol->children[l];
- if (!local->detail.is_empty() && local->name == p_symbol_identifier) {
- return local;
+ case lsp::SymbolKind::Variable: {
+ const lsp::DocumentSymbol *variable_symbol = &class_symbol->children[i];
+ if (variable_symbol->name == p_symbol_identifier) {
+ return variable_symbol;
}
- }
+ } break;
}
}
@@ -650,8 +662,18 @@ const lsp::DocumentSymbol *GDScriptWorkspace::resolve_symbol(const lsp::TextDocu
if (const ExtendGDScriptParser *target_parser = get_parse_result(target_script_path)) {
symbol = target_parser->get_symbol_defined_at_line(LINE_NUMBER_TO_INDEX(ret.location));
- if (symbol && symbol->kind == lsp::SymbolKind::Function && symbol->name != symbol_identifier) {
- symbol = get_parameter_symbol(symbol, symbol_identifier);
+ if (symbol) {
+ switch (symbol->kind) {
+ case lsp::SymbolKind::Function: {
+ if (symbol->name != symbol_identifier) {
+ symbol = get_parameter_symbol(symbol, symbol_identifier);
+ }
+ } break;
+
+ case lsp::SymbolKind::Variable: {
+ symbol = get_local_symbol(parser, symbol_identifier);
+ } break;
+ }
}
}
diff --git a/modules/gdscript/language_server/godot_lsp.h b/modules/gdscript/language_server/godot_lsp.h
index 8a033204da..5b5327bdb7 100644
--- a/modules/gdscript/language_server/godot_lsp.h
+++ b/modules/gdscript/language_server/godot_lsp.h
@@ -293,16 +293,6 @@ struct WorkspaceEdit {
}
_FORCE_INLINE_ void add_change(const String &uri, const int &line, const int &start_character, const int &end_character, const String &new_text) {
- if (HashMap<String, Vector<TextEdit>>::Iterator E = changes.find(uri)) {
- Vector<TextEdit> edit_list = E->value;
- for (int i = 0; i < edit_list.size(); ++i) {
- TextEdit edit = edit_list[i];
- if (edit.range.start.character == start_character) {
- return;
- }
- }
- }
-
TextEdit new_edit;
new_edit.newText = new_text;
new_edit.range.start.line = line;
diff --git a/modules/navigation/navigation_mesh_generator.cpp b/modules/navigation/navigation_mesh_generator.cpp
index 74ff9312fd..fe63d67aba 100644
--- a/modules/navigation/navigation_mesh_generator.cpp
+++ b/modules/navigation/navigation_mesh_generator.cpp
@@ -293,8 +293,8 @@ void NavigationMeshGenerator::_parse_geometry(const Transform3D &p_navmesh_trans
vertex_array.resize((heightmap_depth - 1) * (heightmap_width - 1) * 6);
int map_data_current_index = 0;
- for (int d = 0; d < heightmap_depth - 1; d++) {
- for (int w = 0; w < heightmap_width - 1; w++) {
+ for (int d = 0; d < heightmap_depth; d++) {
+ for (int w = 0; w < heightmap_width; w++) {
if (map_data_current_index + 1 + heightmap_depth < map_data.size()) {
float top_left_height = map_data[map_data_current_index];
float top_right_height = map_data[map_data_current_index + 1];
@@ -422,8 +422,8 @@ void NavigationMeshGenerator::_parse_geometry(const Transform3D &p_navmesh_trans
vertex_array.resize((heightmap_depth - 1) * (heightmap_width - 1) * 6);
int map_data_current_index = 0;
- for (int d = 0; d < heightmap_depth - 1; d++) {
- for (int w = 0; w < heightmap_width - 1; w++) {
+ for (int d = 0; d < heightmap_depth; d++) {
+ for (int w = 0; w < heightmap_width; w++) {
if (map_data_current_index + 1 + heightmap_depth < map_data.size()) {
float top_left_height = map_data[map_data_current_index];
float top_right_height = map_data[map_data_current_index + 1];