diff --git a/src/clang_complete.cc b/src/clang_complete.cc index 660b263f4..477575812 100644 --- a/src/clang_complete.cc +++ b/src/clang_complete.cc @@ -319,7 +319,7 @@ void TryEnsureDocumentParsed(ClangCompleteManager* manager, return; } - NonElidedVector ls_diagnostics; + std::vector ls_diagnostics; unsigned num_diagnostics = clang_getNumDiagnostics((*tu)->cx_tu); for (unsigned i = 0; i < num_diagnostics; ++i) { optional diagnostic = BuildAndDisposeDiagnostic( @@ -412,7 +412,7 @@ void CompletionQueryMain(ClangCompleteManager* completion_manager) { { if (request->on_complete) { - NonElidedVector ls_result; + std::vector ls_result; ls_result.reserve(cx_results->NumResults); timer.Reset(); @@ -487,7 +487,7 @@ void CompletionQueryMain(ClangCompleteManager* completion_manager) { } size_t num_diagnostics = clang_getNumDiagnostics(session->tu->cx_tu); - NonElidedVector ls_diagnostics; + std::vector ls_diagnostics; ls_diagnostics.reserve(num_diagnostics); for (unsigned i = 0; i < num_diagnostics; ++i) { CXDiagnostic cx_diag = clang_getDiagnostic(session->tu->cx_tu, i); diff --git a/src/clang_complete.h b/src/clang_complete.h index 936b26eb6..fda498d60 100644 --- a/src/clang_complete.h +++ b/src/clang_complete.h @@ -39,13 +39,13 @@ struct CompletionSession struct ClangCompleteManager { using OnDiagnostic = std::function diagnostics)>; + std::vector diagnostics)>; using OnIndex = std::function& unsaved, const std::string& path, const std::vector& args)>; using OnComplete = - std::function& results, + std::function& results, bool is_cached_result)>; struct ParseRequest { diff --git a/src/code_complete_cache.h b/src/code_complete_cache.h index 9c0e72311..fca4b1e60 100644 --- a/src/code_complete_cache.h +++ b/src/code_complete_cache.h @@ -16,7 +16,7 @@ struct CodeCompleteCache { // NOTE: Make sure to access these variables under |WithLock|. optional cached_path_; optional cached_completion_position_; - NonElidedVector cached_results_; + std::vector cached_results_; std::mutex mutex_; diff --git a/src/command_line.cc b/src/command_line.cc index 89d881b5b..4f87e93ac 100644 --- a/src/command_line.cc +++ b/src/command_line.cc @@ -71,7 +71,7 @@ bool ShouldDisplayIpcTiming(IpcId id) { void EmitDiagnostics(WorkingFiles* working_files, std::string path, - NonElidedVector diagnostics) { + std::vector diagnostics) { // Emit diagnostics. Out_TextDocumentPublishDiagnostics out; out.params.uri = lsDocumentUri::FromPath(path); diff --git a/src/indexer.h b/src/indexer.h index d05dfd39c..45a0e1964 100644 --- a/src/indexer.h +++ b/src/indexer.h @@ -501,7 +501,7 @@ struct IndexFile { std::vector vars; // Diagnostics found when indexing this file. Not serialized. - NonElidedVector diagnostics_; + std::vector diagnostics_; // File contents at the time of index. Not serialized. std::string file_contents_; diff --git a/src/language_server_api.h b/src/language_server_api.h index c55e80501..28e5877ac 100644 --- a/src/language_server_api.h +++ b/src/language_server_api.h @@ -493,7 +493,7 @@ struct lsDiagnostic { std::string message; // Non-serialized set of fixits. - NonElidedVector fixits_; + std::vector fixits_; }; MAKE_REFLECT_STRUCT(lsDiagnostic, range, severity, source, message); @@ -792,7 +792,7 @@ struct lsDocumentOnTypeFormattingOptions { std::string firstTriggerCharacter; // More trigger characters. - NonElidedVector moreTriggerCharacter; + std::vector moreTriggerCharacter; }; MAKE_REFLECT_STRUCT(lsDocumentOnTypeFormattingOptions, firstTriggerCharacter, @@ -808,7 +808,7 @@ MAKE_REFLECT_STRUCT(lsDocumentLinkOptions, resolveProvider); // Execute command options. struct lsExecuteCommandOptions { // The commands to be executed on the server - NonElidedVector commands; + std::vector commands; }; MAKE_REFLECT_STRUCT(lsExecuteCommandOptions, commands); @@ -951,7 +951,7 @@ struct Out_TextDocumentPublishDiagnostics lsDocumentUri uri; // An array of diagnostic information items. - NonElidedVector diagnostics; + std::vector diagnostics; }; Params params; @@ -1054,7 +1054,7 @@ struct Out_CquerySetInactiveRegion : public lsOutMessage { struct Params { lsDocumentUri uri; - NonElidedVector inactiveRegions; + std::vector inactiveRegions; }; std::string method = "$cquery/setInactiveRegions"; Params params; @@ -1069,11 +1069,11 @@ struct Out_CqueryPublishSemanticHighlighting int stableId = 0; SymbolType type = SymbolType::Type; bool isTypeMember = false; - NonElidedVector ranges; + std::vector ranges; }; struct Params { lsDocumentUri uri; - NonElidedVector symbols; + std::vector symbols; }; std::string method = "$cquery/publishSemanticHighlighting"; Params params; @@ -1094,6 +1094,6 @@ MAKE_REFLECT_STRUCT(Out_CqueryPublishSemanticHighlighting, struct Out_LocationList : public lsOutMessage { lsRequestId id; - NonElidedVector result; + std::vector result; }; MAKE_REFLECT_STRUCT(Out_LocationList, jsonrpc, id, result); diff --git a/src/messages/cquery_call_tree.cc b/src/messages/cquery_call_tree.cc index abf2f9205..d47effcee 100644 --- a/src/messages/cquery_call_tree.cc +++ b/src/messages/cquery_call_tree.cc @@ -34,7 +34,7 @@ struct Out_CqueryCallTree : public lsOutMessage { }; lsRequestId id; - NonElidedVector result; + std::vector result; }; MAKE_REFLECT_TYPE_PROXY(Out_CqueryCallTree::CallType, int); MAKE_REFLECT_STRUCT(Out_CqueryCallTree::CallEntry, @@ -45,7 +45,7 @@ MAKE_REFLECT_STRUCT(Out_CqueryCallTree::CallEntry, callType); MAKE_REFLECT_STRUCT(Out_CqueryCallTree, jsonrpc, id, result); -NonElidedVector BuildInitialCallTree( +std::vector BuildInitialCallTree( QueryDatabase* db, WorkingFiles* working_files, QueryFuncId root) { @@ -62,12 +62,12 @@ NonElidedVector BuildInitialCallTree( entry.usr = root_func.def->usr; entry.location = *def_loc; entry.hasCallers = HasCallersOnSelfOrBaseOrDerived(db, root_func); - NonElidedVector result; + std::vector result; result.push_back(entry); return result; } -NonElidedVector BuildExpandCallTree( +std::vector BuildExpandCallTree( QueryDatabase* db, WorkingFiles* working_files, QueryFuncId root) { @@ -96,7 +96,7 @@ NonElidedVector BuildExpandCallTree( return base + ":" + std::to_string(location.range.start.line + 1); }; - NonElidedVector result; + std::vector result; std::unordered_set seen_locations; auto handle_caller = [&](QueryFuncRef caller, diff --git a/src/messages/cquery_type_hierarchy_tree.cc b/src/messages/cquery_type_hierarchy_tree.cc index 43e632a2f..6144ec734 100644 --- a/src/messages/cquery_type_hierarchy_tree.cc +++ b/src/messages/cquery_type_hierarchy_tree.cc @@ -16,7 +16,7 @@ struct Out_CqueryTypeHierarchyTree struct TypeEntry { std::string name; optional location; - NonElidedVector children; + std::vector children; }; lsRequestId id; optional result; @@ -27,7 +27,7 @@ MAKE_REFLECT_STRUCT(Out_CqueryTypeHierarchyTree::TypeEntry, children); MAKE_REFLECT_STRUCT(Out_CqueryTypeHierarchyTree, jsonrpc, id, result); -NonElidedVector +std::vector BuildParentInheritanceHierarchyForType(QueryDatabase* db, WorkingFiles* working_files, QueryTypeId root) { @@ -35,7 +35,7 @@ BuildParentInheritanceHierarchyForType(QueryDatabase* db, if (!root_type.def) return {}; - NonElidedVector parent_entries; + std::vector parent_entries; parent_entries.reserve(root_type.def->parents.size()); for (QueryTypeId parent_id : root_type.def->parents) { @@ -95,7 +95,7 @@ BuildInheritanceHierarchyForType(QueryDatabase* db, return entry; } -NonElidedVector +std::vector BuildParentInheritanceHierarchyForFunc(QueryDatabase* db, WorkingFiles* working_files, QueryFuncId root) { @@ -115,7 +115,7 @@ BuildParentInheritanceHierarchyForFunc(QueryDatabase* db, parent_entry.children = BuildParentInheritanceHierarchyForFunc( db, working_files, *root_func.def->base); - NonElidedVector entries; + std::vector entries; entries.push_back(parent_entry); return entries; } diff --git a/src/messages/text_document_code_action.cc b/src/messages/text_document_code_action.cc index c1ce22748..5f31e494b 100644 --- a/src/messages/text_document_code_action.cc +++ b/src/messages/text_document_code_action.cc @@ -254,7 +254,7 @@ struct Ipc_TextDocumentCodeAction // a code action is run. struct lsCodeActionContext { // An array of diagnostics. - NonElidedVector diagnostics; + std::vector diagnostics; }; // Params for the CodeActionRequest struct lsCodeActionParams { @@ -282,12 +282,12 @@ struct Out_TextDocumentCodeAction : public lsOutMessage { struct CommandArgs { lsDocumentUri textDocumentUri; - NonElidedVector edits; + std::vector edits; }; using Command = lsCommand; lsRequestId id; - NonElidedVector result; + std::vector result; }; MAKE_REFLECT_STRUCT_WRITER_AS_ARRAY(Out_TextDocumentCodeAction::CommandArgs, textDocumentUri, diff --git a/src/messages/text_document_code_lens.cc b/src/messages/text_document_code_lens.cc index c77c905db..0b26a8d1c 100644 --- a/src/messages/text_document_code_lens.cc +++ b/src/messages/text_document_code_lens.cc @@ -13,7 +13,7 @@ MAKE_REFLECT_EMPTY_STRUCT(lsCodeLensUserData); struct lsCodeLensCommandArguments { lsDocumentUri uri; lsPosition position; - NonElidedVector locations; + std::vector locations; }; void Reflect(Writer& visitor, lsCodeLensCommandArguments& value) { visitor.StartArray(); @@ -45,7 +45,7 @@ REGISTER_IPC_MESSAGE(Ipc_TextDocumentCodeLens); struct Out_TextDocumentCodeLens : public lsOutMessage { lsRequestId id; - NonElidedVector> + std::vector> result; }; MAKE_REFLECT_STRUCT(Out_TextDocumentCodeLens, jsonrpc, id, result); diff --git a/src/messages/text_document_completion.cc b/src/messages/text_document_completion.cc index c1d5a7677..cae380bd9 100644 --- a/src/messages/text_document_completion.cc +++ b/src/messages/text_document_completion.cc @@ -20,7 +20,7 @@ struct lsTextDocumentCompleteResult { // this list. bool isIncomplete = false; // The completion items. - NonElidedVector items; + std::vector items; }; MAKE_REFLECT_STRUCT(lsTextDocumentCompleteResult, isIncomplete, items); @@ -55,7 +55,7 @@ void FilterCompletionResponse(Out_TextDocumentComplete* complete_response, if (complete_text.empty()) { complete_response->result.items.resize(kMaxResultSize); } else { - NonElidedVector filtered_result; + std::vector filtered_result; filtered_result.reserve(kMaxResultSize); std::unordered_set inserted; @@ -157,7 +157,7 @@ struct TextDocumentCompletionHandler : MessageHandler { ClangCompleteManager::OnComplete callback = std::bind( [this, is_global_completion, existing_completion, request]( - const NonElidedVector& results, + const std::vector& results, bool is_cached_result) { Out_TextDocumentComplete out; out.id = request->id; @@ -195,7 +195,7 @@ struct TextDocumentCompletionHandler : MessageHandler { }); if (is_cache_match) { ClangCompleteManager::OnComplete freshen_global = - [this](NonElidedVector results, + [this](std::vector results, bool is_cached_result) { assert(!is_cached_result); diff --git a/src/messages/text_document_definition.cc b/src/messages/text_document_definition.cc index d2303edaf..6dd2ae477 100644 --- a/src/messages/text_document_definition.cc +++ b/src/messages/text_document_definition.cc @@ -2,7 +2,7 @@ #include "query_utils.h" namespace { -void PushBack(NonElidedVector* result, +void PushBack(std::vector* result, optional location) { if (location) result->push_back(*location); @@ -21,7 +21,7 @@ REGISTER_IPC_MESSAGE(Ipc_TextDocumentDefinition); struct Out_TextDocumentDefinition : public lsOutMessage { lsRequestId id; - NonElidedVector result; + std::vector result; }; MAKE_REFLECT_STRUCT(Out_TextDocumentDefinition, jsonrpc, id, result); diff --git a/src/messages/text_document_document_link.cc b/src/messages/text_document_document_link.cc index 73467bbe8..918e6bd88 100644 --- a/src/messages/text_document_document_link.cc +++ b/src/messages/text_document_document_link.cc @@ -34,7 +34,7 @@ MAKE_REFLECT_STRUCT(lsDocumentLink, range, target); struct Out_TextDocumentDocumentLink : public lsOutMessage { lsRequestId id; - NonElidedVector result; + std::vector result; }; MAKE_REFLECT_STRUCT(Out_TextDocumentDocumentLink, jsonrpc, id, result); diff --git a/src/messages/text_document_document_symbol.cc b/src/messages/text_document_document_symbol.cc index 5aaad4f92..b27f0d4af 100644 --- a/src/messages/text_document_document_symbol.cc +++ b/src/messages/text_document_document_symbol.cc @@ -20,7 +20,7 @@ REGISTER_IPC_MESSAGE(Ipc_TextDocumentDocumentSymbol); struct Out_TextDocumentDocumentSymbol : public lsOutMessage { lsRequestId id; - NonElidedVector result; + std::vector result; }; MAKE_REFLECT_STRUCT(Out_TextDocumentDocumentSymbol, jsonrpc, id, result); diff --git a/src/messages/text_document_highlight.cc b/src/messages/text_document_highlight.cc index db435ff64..ed8c70947 100644 --- a/src/messages/text_document_highlight.cc +++ b/src/messages/text_document_highlight.cc @@ -15,7 +15,7 @@ REGISTER_IPC_MESSAGE(Ipc_TextDocumentDocumentHighlight); struct Out_TextDocumentDocumentHighlight : public lsOutMessage { lsRequestId id; - NonElidedVector result; + std::vector result; }; MAKE_REFLECT_STRUCT(Out_TextDocumentDocumentHighlight, jsonrpc, id, result); diff --git a/src/messages/text_document_references.cc b/src/messages/text_document_references.cc index 9cc5e1588..392ebaaa0 100644 --- a/src/messages/text_document_references.cc +++ b/src/messages/text_document_references.cc @@ -33,7 +33,7 @@ REGISTER_IPC_MESSAGE(Ipc_TextDocumentReferences); struct Out_TextDocumentReferences : public lsOutMessage { lsRequestId id; - NonElidedVector result; + std::vector result; }; MAKE_REFLECT_STRUCT(Out_TextDocumentReferences, jsonrpc, id, result); diff --git a/src/messages/text_document_signature_help.cc b/src/messages/text_document_signature_help.cc index 4945544bc..a80e06b0f 100644 --- a/src/messages/text_document_signature_help.cc +++ b/src/messages/text_document_signature_help.cc @@ -47,7 +47,7 @@ MAKE_REFLECT_STRUCT(lsSignatureInformation, label, documentation, parameters); // active and only one active parameter. struct lsSignatureHelp { // One or more signatures. - NonElidedVector signatures; + std::vector signatures; // The active signature. If omitted or the value lies outside the // range of `signatures` the value defaults to zero or is ignored if @@ -100,7 +100,7 @@ struct TextDocumentSignatureHelpHandler : MessageHandler { ClangCompleteManager::OnComplete callback = std::bind( [this](BaseIpcMessage* message, std::string search, int active_param, - const NonElidedVector& results, + const std::vector& results, bool is_cached_result) { auto msg = message->As(); diff --git a/src/messages/workspace_symbol.cc b/src/messages/workspace_symbol.cc index 7290e3d13..bdef766b8 100644 --- a/src/messages/workspace_symbol.cc +++ b/src/messages/workspace_symbol.cc @@ -20,7 +20,7 @@ REGISTER_IPC_MESSAGE(Ipc_WorkspaceSymbol); struct Out_WorkspaceSymbol : public lsOutMessage { lsRequestId id; - NonElidedVector result; + std::vector result; }; MAKE_REFLECT_STRUCT(Out_WorkspaceSymbol, jsonrpc, id, result); diff --git a/src/query_utils.cc b/src/query_utils.cc index 50f262127..99a5cceab 100644 --- a/src/query_utils.cc +++ b/src/query_utils.cc @@ -427,7 +427,7 @@ optional GetLsLocation(QueryDatabase* db, return lsLocation(uri, *range); } -NonElidedVector GetLsLocations( +std::vector GetLsLocations( QueryDatabase* db, WorkingFiles* working_files, const std::vector& locations) { @@ -440,7 +440,7 @@ NonElidedVector GetLsLocations( unique_locations.insert(*location); } - NonElidedVector result; + std::vector result; result.reserve(unique_locations.size()); result.assign(unique_locations.begin(), unique_locations.end()); return result; diff --git a/src/query_utils.h b/src/query_utils.h index e62a51ccc..ff08604bb 100644 --- a/src/query_utils.h +++ b/src/query_utils.h @@ -52,7 +52,7 @@ lsDocumentUri GetLsDocumentUri(QueryDatabase* db, QueryFileId file_id); optional GetLsLocation(QueryDatabase* db, WorkingFiles* working_files, const QueryLocation& location); -NonElidedVector GetLsLocations( +std::vector GetLsLocations( QueryDatabase* db, WorkingFiles* working_files, const std::vector& locations); diff --git a/src/serializer.h b/src/serializer.h index 98f137296..1dbc59811 100644 --- a/src/serializer.h +++ b/src/serializer.h @@ -63,9 +63,6 @@ struct IndexFile; visitor.EndArray(); \ } -template -struct NonElidedVector : public std::vector {}; - // API: /* template @@ -145,16 +142,6 @@ void ReflectMember(Writer& visitor, const char* name, std::vector& values) { visitor.EndArray(); } template -void ReflectMember(Writer& visitor, - const char* name, - NonElidedVector& values) { - visitor.Key(name); - visitor.StartArray(); - for (auto& value : values) - Reflect(visitor, value); - visitor.EndArray(); -} -template void ReflectMember(Writer& visitor, const char* name, optional& value) { if (!value) return;