Use C++ iterators for Lists in many situations
This commit is contained in:
@@ -39,8 +39,7 @@ void ExtendGDScriptParser::update_diagnostics() {
|
||||
diagnostics.clear();
|
||||
|
||||
const List<ParserError> &errors = get_errors();
|
||||
for (const List<ParserError>::Element *E = errors.front(); E != nullptr; E = E->next()) {
|
||||
const ParserError &error = E->get();
|
||||
for (const ParserError &error : errors) {
|
||||
lsp::Diagnostic diagnostic;
|
||||
diagnostic.severity = lsp::DiagnosticSeverity::Error;
|
||||
diagnostic.message = error.message;
|
||||
@@ -61,8 +60,7 @@ void ExtendGDScriptParser::update_diagnostics() {
|
||||
}
|
||||
|
||||
const List<GDScriptWarning> &warnings = get_warnings();
|
||||
for (const List<GDScriptWarning>::Element *E = warnings.front(); E; E = E->next()) {
|
||||
const GDScriptWarning &warning = E->get();
|
||||
for (const GDScriptWarning &warning : warnings) {
|
||||
lsp::Diagnostic diagnostic;
|
||||
diagnostic.severity = lsp::DiagnosticSeverity::Warning;
|
||||
diagnostic.message = "(" + warning.get_name() + "): " + warning.get_message();
|
||||
@@ -467,8 +465,8 @@ String ExtendGDScriptParser::parse_documentation(int p_line, bool p_docs_down) {
|
||||
}
|
||||
|
||||
String doc;
|
||||
for (List<String>::Element *E = doc_lines.front(); E; E = E->next()) {
|
||||
doc += E->get() + "\n";
|
||||
for (String &E : doc_lines) {
|
||||
doc += E + "\n";
|
||||
}
|
||||
return doc;
|
||||
}
|
||||
|
||||
@@ -157,8 +157,7 @@ Array GDScriptTextDocument::completion(const Dictionary &p_params) {
|
||||
int i = 0;
|
||||
arr.resize(options.size());
|
||||
|
||||
for (const List<ScriptCodeCompletionOption>::Element *E = options.front(); E; E = E->next()) {
|
||||
const ScriptCodeCompletionOption &option = E->get();
|
||||
for (const ScriptCodeCompletionOption &option : options) {
|
||||
lsp::CompletionItem item;
|
||||
item.label = option.display;
|
||||
item.data = request_data;
|
||||
@@ -294,8 +293,8 @@ Array GDScriptTextDocument::documentLink(const Dictionary &p_params) {
|
||||
|
||||
List<lsp::DocumentLink> links;
|
||||
GDScriptLanguageProtocol::get_singleton()->get_workspace()->resolve_document_links(params.textDocument.uri, links);
|
||||
for (const List<lsp::DocumentLink>::Element *E = links.front(); E; E = E->next()) {
|
||||
ret.push_back(E->get().to_json());
|
||||
for (const lsp::DocumentLink &E : links) {
|
||||
ret.push_back(E.to_json());
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
@@ -322,8 +321,8 @@ Variant GDScriptTextDocument::hover(const Dictionary &p_params) {
|
||||
Array contents;
|
||||
List<const lsp::DocumentSymbol *> list;
|
||||
GDScriptLanguageProtocol::get_singleton()->get_workspace()->resolve_related_symbols(params, list);
|
||||
for (List<const lsp::DocumentSymbol *>::Element *E = list.front(); E; E = E->next()) {
|
||||
if (const lsp::DocumentSymbol *s = E->get()) {
|
||||
for (const lsp::DocumentSymbol *&E : list) {
|
||||
if (const lsp::DocumentSymbol *s = E) {
|
||||
contents.push_back(s->render().value);
|
||||
}
|
||||
}
|
||||
@@ -430,8 +429,8 @@ Array GDScriptTextDocument::find_symbols(const lsp::TextDocumentPositionParams &
|
||||
} else if (GDScriptLanguageProtocol::get_singleton()->is_smart_resolve_enabled()) {
|
||||
List<const lsp::DocumentSymbol *> list;
|
||||
GDScriptLanguageProtocol::get_singleton()->get_workspace()->resolve_related_symbols(p_location, list);
|
||||
for (List<const lsp::DocumentSymbol *>::Element *E = list.front(); E; E = E->next()) {
|
||||
if (const lsp::DocumentSymbol *s = E->get()) {
|
||||
for (const lsp::DocumentSymbol *&E : list) {
|
||||
if (const lsp::DocumentSymbol *s = E) {
|
||||
if (!s->uri.is_empty()) {
|
||||
lsp::Location location;
|
||||
location.uri = s->uri;
|
||||
|
||||
@@ -119,8 +119,7 @@ const lsp::DocumentSymbol *GDScriptWorkspace::get_script_symbol(const String &p_
|
||||
void GDScriptWorkspace::reload_all_workspace_scripts() {
|
||||
List<String> paths;
|
||||
list_script_files("res://", paths);
|
||||
for (List<String>::Element *E = paths.front(); E; E = E->next()) {
|
||||
const String &path = E->get();
|
||||
for (String &path : paths) {
|
||||
Error err;
|
||||
String content = FileAccess::get_file_as_string(path, &err);
|
||||
ERR_CONTINUE(err != OK);
|
||||
@@ -559,8 +558,8 @@ const lsp::DocumentSymbol *GDScriptWorkspace::resolve_native_symbol(const lsp::N
|
||||
void GDScriptWorkspace::resolve_document_links(const String &p_uri, List<lsp::DocumentLink> &r_list) {
|
||||
if (const ExtendGDScriptParser *parser = get_parse_successed_script(get_file_path(p_uri))) {
|
||||
const List<lsp::DocumentLink> &links = parser->get_document_links();
|
||||
for (const List<lsp::DocumentLink>::Element *E = links.front(); E; E = E->next()) {
|
||||
r_list.push_back(E->get());
|
||||
for (const lsp::DocumentLink &E : links) {
|
||||
r_list.push_back(E);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -587,8 +586,7 @@ Error GDScriptWorkspace::resolve_signature(const lsp::TextDocumentPositionParams
|
||||
GDScriptLanguageProtocol::get_singleton()->get_workspace()->resolve_related_symbols(text_pos, symbols);
|
||||
}
|
||||
|
||||
for (List<const lsp::DocumentSymbol *>::Element *E = symbols.front(); E; E = E->next()) {
|
||||
const lsp::DocumentSymbol *symbol = E->get();
|
||||
for (const lsp::DocumentSymbol *symbol : symbols) {
|
||||
if (symbol->kind == lsp::SymbolKind::Method || symbol->kind == lsp::SymbolKind::Function) {
|
||||
lsp::SignatureInformation signature_info;
|
||||
signature_info.label = symbol->detail;
|
||||
|
||||
Reference in New Issue
Block a user