Fix MSVC warnings, rename shadowed variables, fix uninitialized values, change warnings=all to use /W4.
This commit is contained in:
@ -38,8 +38,8 @@
|
||||
void ExtendGDScriptParser::update_diagnostics() {
|
||||
diagnostics.clear();
|
||||
|
||||
const List<ParserError> &errors = get_errors();
|
||||
for (const ParserError &error : errors) {
|
||||
const List<ParserError> &parser_errors = get_errors();
|
||||
for (const ParserError &error : parser_errors) {
|
||||
lsp::Diagnostic diagnostic;
|
||||
diagnostic.severity = lsp::DiagnosticSeverity::Error;
|
||||
diagnostic.message = error.message;
|
||||
@ -47,9 +47,9 @@ void ExtendGDScriptParser::update_diagnostics() {
|
||||
diagnostic.code = -1;
|
||||
lsp::Range range;
|
||||
lsp::Position pos;
|
||||
const PackedStringArray lines = get_lines();
|
||||
int line = CLAMP(LINE_NUMBER_TO_INDEX(error.line), 0, lines.size() - 1);
|
||||
const String &line_text = lines[line];
|
||||
const PackedStringArray line_array = get_lines();
|
||||
int line = CLAMP(LINE_NUMBER_TO_INDEX(error.line), 0, line_array.size() - 1);
|
||||
const String &line_text = line_array[line];
|
||||
pos.line = line;
|
||||
pos.character = line_text.length() - line_text.strip_edges(true, false).length();
|
||||
range.start = pos;
|
||||
@ -59,8 +59,8 @@ void ExtendGDScriptParser::update_diagnostics() {
|
||||
diagnostics.push_back(diagnostic);
|
||||
}
|
||||
|
||||
const List<GDScriptWarning> &warnings = get_warnings();
|
||||
for (const GDScriptWarning &warning : warnings) {
|
||||
const List<GDScriptWarning> &parser_warnings = get_warnings();
|
||||
for (const GDScriptWarning &warning : parser_warnings) {
|
||||
lsp::Diagnostic diagnostic;
|
||||
diagnostic.severity = lsp::DiagnosticSeverity::Warning;
|
||||
diagnostic.message = "(" + warning.get_name() + "): " + warning.get_message();
|
||||
@ -83,8 +83,7 @@ void ExtendGDScriptParser::update_diagnostics() {
|
||||
void ExtendGDScriptParser::update_symbols() {
|
||||
members.clear();
|
||||
|
||||
const GDScriptParser::Node *head = get_tree();
|
||||
if (const GDScriptParser::ClassNode *gdclass = dynamic_cast<const GDScriptParser::ClassNode *>(head)) {
|
||||
if (const GDScriptParser::ClassNode *gdclass = dynamic_cast<const GDScriptParser::ClassNode *>(get_tree())) {
|
||||
parse_class_symbol(gdclass, class_symbol);
|
||||
|
||||
for (int i = 0; i < class_symbol.children.size(); i++) {
|
||||
@ -107,26 +106,26 @@ void ExtendGDScriptParser::update_symbols() {
|
||||
void ExtendGDScriptParser::update_document_links(const String &p_code) {
|
||||
document_links.clear();
|
||||
|
||||
GDScriptTokenizer tokenizer;
|
||||
GDScriptTokenizer scr_tokenizer;
|
||||
Ref<FileAccess> fs = FileAccess::create(FileAccess::ACCESS_RESOURCES);
|
||||
tokenizer.set_source_code(p_code);
|
||||
scr_tokenizer.set_source_code(p_code);
|
||||
while (true) {
|
||||
GDScriptTokenizer::Token token = tokenizer.scan();
|
||||
GDScriptTokenizer::Token token = scr_tokenizer.scan();
|
||||
if (token.type == GDScriptTokenizer::Token::TK_EOF) {
|
||||
break;
|
||||
} else if (token.type == GDScriptTokenizer::Token::LITERAL) {
|
||||
const Variant &const_val = token.literal;
|
||||
if (const_val.get_type() == Variant::STRING) {
|
||||
String path = const_val;
|
||||
bool exists = fs->file_exists(path);
|
||||
String scr_path = const_val;
|
||||
bool exists = fs->file_exists(scr_path);
|
||||
if (!exists) {
|
||||
path = get_path().get_base_dir() + "/" + path;
|
||||
exists = fs->file_exists(path);
|
||||
scr_path = get_path().get_base_dir() + "/" + scr_path;
|
||||
exists = fs->file_exists(scr_path);
|
||||
}
|
||||
if (exists) {
|
||||
String value = const_val;
|
||||
lsp::DocumentLink link;
|
||||
link.target = GDScriptLanguageProtocol::get_singleton()->get_workspace()->get_file_uri(path);
|
||||
link.target = GDScriptLanguageProtocol::get_singleton()->get_workspace()->get_file_uri(scr_path);
|
||||
link.range.start.line = LINE_NUMBER_TO_INDEX(token.start_line);
|
||||
link.range.end.line = LINE_NUMBER_TO_INDEX(token.end_line);
|
||||
link.range.start.character = LINE_NUMBER_TO_INDEX(token.start_column);
|
||||
@ -731,7 +730,7 @@ Dictionary ExtendGDScriptParser::dump_class_api(const GDScriptParser::ClassNode
|
||||
|
||||
Array nested_classes;
|
||||
Array constants;
|
||||
Array members;
|
||||
Array class_members;
|
||||
Array signals;
|
||||
Array methods;
|
||||
Array static_functions;
|
||||
@ -792,7 +791,7 @@ Dictionary ExtendGDScriptParser::dump_class_api(const GDScriptParser::ClassNode
|
||||
api["signature"] = symbol->detail;
|
||||
api["description"] = symbol->documentation;
|
||||
}
|
||||
members.push_back(api);
|
||||
class_members.push_back(api);
|
||||
} break;
|
||||
case ClassNode::Member::SIGNAL: {
|
||||
Dictionary api;
|
||||
@ -824,7 +823,7 @@ Dictionary ExtendGDScriptParser::dump_class_api(const GDScriptParser::ClassNode
|
||||
|
||||
class_api["sub_classes"] = nested_classes;
|
||||
class_api["constants"] = constants;
|
||||
class_api["members"] = members;
|
||||
class_api["members"] = class_members;
|
||||
class_api["signals"] = signals;
|
||||
class_api["methods"] = methods;
|
||||
class_api["static_functions"] = static_functions;
|
||||
@ -834,8 +833,7 @@ Dictionary ExtendGDScriptParser::dump_class_api(const GDScriptParser::ClassNode
|
||||
|
||||
Dictionary ExtendGDScriptParser::generate_api() const {
|
||||
Dictionary api;
|
||||
const GDScriptParser::Node *head = get_tree();
|
||||
if (const GDScriptParser::ClassNode *gdclass = dynamic_cast<const GDScriptParser::ClassNode *>(head)) {
|
||||
if (const GDScriptParser::ClassNode *gdclass = dynamic_cast<const GDScriptParser::ClassNode *>(get_tree())) {
|
||||
api = dump_class_api(gdclass);
|
||||
}
|
||||
return api;
|
||||
|
||||
@ -61,12 +61,12 @@ void GDScriptLanguageServer::_notification(int p_what) {
|
||||
} break;
|
||||
|
||||
case EditorSettings::NOTIFICATION_EDITOR_SETTINGS_CHANGED: {
|
||||
String host = String(_EDITOR_GET("network/language_server/remote_host"));
|
||||
int port = (int)_EDITOR_GET("network/language_server/remote_port");
|
||||
bool use_thread = (bool)_EDITOR_GET("network/language_server/use_thread");
|
||||
if (host != this->host || port != this->port || use_thread != this->use_thread) {
|
||||
this->stop();
|
||||
this->start();
|
||||
String remote_host = String(_EDITOR_GET("network/language_server/remote_host"));
|
||||
int remote_port = (int)_EDITOR_GET("network/language_server/remote_port");
|
||||
bool remote_use_thread = (bool)_EDITOR_GET("network/language_server/use_thread");
|
||||
if (remote_host != host || remote_port != port || remote_use_thread != use_thread) {
|
||||
stop();
|
||||
start();
|
||||
}
|
||||
} break;
|
||||
}
|
||||
|
||||
@ -86,9 +86,9 @@ void GDScriptTextDocument::willSaveWaitUntil(const Variant &p_param) {
|
||||
lsp::TextDocumentItem doc = load_document_item(p_param);
|
||||
|
||||
String path = GDScriptLanguageProtocol::get_singleton()->get_workspace()->get_file_path(doc.uri);
|
||||
Ref<Script> script = ResourceLoader::load(path);
|
||||
if (script.is_valid()) {
|
||||
ScriptEditor::get_singleton()->clear_docs_from_script(script);
|
||||
Ref<Script> scr = ResourceLoader::load(path);
|
||||
if (scr.is_valid()) {
|
||||
ScriptEditor::get_singleton()->clear_docs_from_script(scr);
|
||||
}
|
||||
}
|
||||
|
||||
@ -100,14 +100,14 @@ void GDScriptTextDocument::didSave(const Variant &p_param) {
|
||||
sync_script_content(doc.uri, text);
|
||||
|
||||
String path = GDScriptLanguageProtocol::get_singleton()->get_workspace()->get_file_path(doc.uri);
|
||||
Ref<GDScript> script = ResourceLoader::load(path);
|
||||
if (script.is_valid() && (script->load_source_code(path) == OK)) {
|
||||
if (script->is_tool()) {
|
||||
script->get_language()->reload_tool_script(script, true);
|
||||
Ref<GDScript> scr = ResourceLoader::load(path);
|
||||
if (scr.is_valid() && (scr->load_source_code(path) == OK)) {
|
||||
if (scr->is_tool()) {
|
||||
scr->get_language()->reload_tool_script(scr, true);
|
||||
} else {
|
||||
script->reload(true);
|
||||
scr->reload(true);
|
||||
}
|
||||
ScriptEditor::get_singleton()->update_docs_from_script(script);
|
||||
ScriptEditor::get_singleton()->update_docs_from_script(scr);
|
||||
}
|
||||
}
|
||||
|
||||
@ -229,8 +229,8 @@ Array GDScriptTextDocument::completion(const Dictionary &p_params) {
|
||||
arr = native_member_completions.duplicate();
|
||||
|
||||
for (KeyValue<String, ExtendGDScriptParser *> &E : GDScriptLanguageProtocol::get_singleton()->get_workspace()->scripts) {
|
||||
ExtendGDScriptParser *script = E.value;
|
||||
const Array &items = script->get_member_completions();
|
||||
ExtendGDScriptParser *scr = E.value;
|
||||
const Array &items = scr->get_member_completions();
|
||||
|
||||
const int start_size = arr.size();
|
||||
arr.resize(start_size + items.size());
|
||||
|
||||
@ -55,14 +55,14 @@ void GDScriptWorkspace::_bind_methods() {
|
||||
}
|
||||
|
||||
void GDScriptWorkspace::apply_new_signal(Object *obj, String function, PackedStringArray args) {
|
||||
Ref<Script> script = obj->get_script();
|
||||
Ref<Script> scr = obj->get_script();
|
||||
|
||||
if (script->get_language()->get_name() != "GDScript") {
|
||||
if (scr->get_language()->get_name() != "GDScript") {
|
||||
return;
|
||||
}
|
||||
|
||||
String function_signature = "func " + function;
|
||||
String source = script->get_source_code();
|
||||
String source = scr->get_source_code();
|
||||
|
||||
if (source.contains(function_signature)) {
|
||||
return;
|
||||
@ -98,7 +98,7 @@ void GDScriptWorkspace::apply_new_signal(Object *obj, String function, PackedStr
|
||||
|
||||
text_edit.newText = function_body;
|
||||
|
||||
String uri = get_file_uri(script->get_path());
|
||||
String uri = get_file_uri(scr->get_path());
|
||||
|
||||
lsp::ApplyWorkspaceEditParams params;
|
||||
params.edit.add_edit(uri, text_edit);
|
||||
@ -118,12 +118,12 @@ void GDScriptWorkspace::did_delete_files(const Dictionary &p_params) {
|
||||
|
||||
void GDScriptWorkspace::remove_cache_parser(const String &p_path) {
|
||||
HashMap<String, ExtendGDScriptParser *>::Iterator parser = parse_results.find(p_path);
|
||||
HashMap<String, ExtendGDScriptParser *>::Iterator script = scripts.find(p_path);
|
||||
if (parser && script) {
|
||||
if (script->value && script->value == parser->value) {
|
||||
memdelete(script->value);
|
||||
HashMap<String, ExtendGDScriptParser *>::Iterator scr = scripts.find(p_path);
|
||||
if (parser && scr) {
|
||||
if (scr->value && scr->value == parser->value) {
|
||||
memdelete(scr->value);
|
||||
} else {
|
||||
memdelete(script->value);
|
||||
memdelete(scr->value);
|
||||
memdelete(parser->value);
|
||||
}
|
||||
parse_results.erase(p_path);
|
||||
@ -131,8 +131,8 @@ void GDScriptWorkspace::remove_cache_parser(const String &p_path) {
|
||||
} else if (parser) {
|
||||
memdelete(parser->value);
|
||||
parse_results.erase(p_path);
|
||||
} else if (script) {
|
||||
memdelete(script->value);
|
||||
} else if (scr) {
|
||||
memdelete(scr->value);
|
||||
scripts.erase(p_path);
|
||||
}
|
||||
}
|
||||
@ -587,8 +587,8 @@ void GDScriptWorkspace::completion(const lsp::CompletionParams &p_params, List<S
|
||||
|
||||
while (!stack.is_empty()) {
|
||||
current = Object::cast_to<Node>(stack.pop_back());
|
||||
Ref<GDScript> script = current->get_script();
|
||||
if (script.is_valid() && script->get_path() == path) {
|
||||
Ref<GDScript> scr = current->get_script();
|
||||
if (scr.is_valid() && scr->get_path() == path) {
|
||||
break;
|
||||
}
|
||||
for (int i = 0; i < current->get_child_count(); ++i) {
|
||||
@ -596,8 +596,8 @@ void GDScriptWorkspace::completion(const lsp::CompletionParams &p_params, List<S
|
||||
}
|
||||
}
|
||||
|
||||
Ref<GDScript> script = current->get_script();
|
||||
if (!script.is_valid() || script->get_path() != path) {
|
||||
Ref<GDScript> scr = current->get_script();
|
||||
if (!scr.is_valid() || scr->get_path() != path) {
|
||||
current = owner_scene_node;
|
||||
}
|
||||
}
|
||||
@ -691,13 +691,13 @@ void GDScriptWorkspace::resolve_related_symbols(const lsp::TextDocumentPositionP
|
||||
}
|
||||
|
||||
for (const KeyValue<String, ExtendGDScriptParser *> &E : scripts) {
|
||||
const ExtendGDScriptParser *script = E.value;
|
||||
const ClassMembers &members = script->get_members();
|
||||
const ExtendGDScriptParser *scr = E.value;
|
||||
const ClassMembers &members = scr->get_members();
|
||||
if (const lsp::DocumentSymbol *const *symbol = members.getptr(symbol_identifier)) {
|
||||
r_list.push_back(*symbol);
|
||||
}
|
||||
|
||||
for (const KeyValue<String, ClassMembers> &F : script->get_inner_classes()) {
|
||||
for (const KeyValue<String, ClassMembers> &F : scr->get_inner_classes()) {
|
||||
const ClassMembers *inner_class = &F.value;
|
||||
if (const lsp::DocumentSymbol *const *symbol = inner_class->getptr(symbol_identifier)) {
|
||||
r_list.push_back(*symbol);
|
||||
|
||||
Reference in New Issue
Block a user