mirror of
https://github.com/MaskRay/ccls.git
synced 2024-11-22 07:35:08 +00:00
No more NonElidedVector
This commit is contained in:
parent
e535fab581
commit
12bfabf9c2
@ -319,7 +319,7 @@ void TryEnsureDocumentParsed(ClangCompleteManager* manager,
|
||||
return;
|
||||
}
|
||||
|
||||
NonElidedVector<lsDiagnostic> ls_diagnostics;
|
||||
std::vector<lsDiagnostic> ls_diagnostics;
|
||||
unsigned num_diagnostics = clang_getNumDiagnostics((*tu)->cx_tu);
|
||||
for (unsigned i = 0; i < num_diagnostics; ++i) {
|
||||
optional<lsDiagnostic> diagnostic = BuildAndDisposeDiagnostic(
|
||||
@ -412,7 +412,7 @@ void CompletionQueryMain(ClangCompleteManager* completion_manager) {
|
||||
|
||||
{
|
||||
if (request->on_complete) {
|
||||
NonElidedVector<lsCompletionItem> ls_result;
|
||||
std::vector<lsCompletionItem> 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<lsDiagnostic> ls_diagnostics;
|
||||
std::vector<lsDiagnostic> 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);
|
||||
|
@ -39,13 +39,13 @@ struct CompletionSession
|
||||
struct ClangCompleteManager {
|
||||
using OnDiagnostic =
|
||||
std::function<void(std::string path,
|
||||
NonElidedVector<lsDiagnostic> diagnostics)>;
|
||||
std::vector<lsDiagnostic> diagnostics)>;
|
||||
using OnIndex = std::function<void(ClangTranslationUnit* tu,
|
||||
const std::vector<CXUnsavedFile>& unsaved,
|
||||
const std::string& path,
|
||||
const std::vector<std::string>& args)>;
|
||||
using OnComplete =
|
||||
std::function<void(const NonElidedVector<lsCompletionItem>& results,
|
||||
std::function<void(const std::vector<lsCompletionItem>& results,
|
||||
bool is_cached_result)>;
|
||||
|
||||
struct ParseRequest {
|
||||
|
@ -16,7 +16,7 @@ struct CodeCompleteCache {
|
||||
// NOTE: Make sure to access these variables under |WithLock|.
|
||||
optional<std::string> cached_path_;
|
||||
optional<lsPosition> cached_completion_position_;
|
||||
NonElidedVector<lsCompletionItem> cached_results_;
|
||||
std::vector<lsCompletionItem> cached_results_;
|
||||
|
||||
std::mutex mutex_;
|
||||
|
||||
|
@ -71,7 +71,7 @@ bool ShouldDisplayIpcTiming(IpcId id) {
|
||||
|
||||
void EmitDiagnostics(WorkingFiles* working_files,
|
||||
std::string path,
|
||||
NonElidedVector<lsDiagnostic> diagnostics) {
|
||||
std::vector<lsDiagnostic> diagnostics) {
|
||||
// Emit diagnostics.
|
||||
Out_TextDocumentPublishDiagnostics out;
|
||||
out.params.uri = lsDocumentUri::FromPath(path);
|
||||
|
@ -501,7 +501,7 @@ struct IndexFile {
|
||||
std::vector<IndexVar> vars;
|
||||
|
||||
// Diagnostics found when indexing this file. Not serialized.
|
||||
NonElidedVector<lsDiagnostic> diagnostics_;
|
||||
std::vector<lsDiagnostic> diagnostics_;
|
||||
// File contents at the time of index. Not serialized.
|
||||
std::string file_contents_;
|
||||
|
||||
|
@ -493,7 +493,7 @@ struct lsDiagnostic {
|
||||
std::string message;
|
||||
|
||||
// Non-serialized set of fixits.
|
||||
NonElidedVector<lsTextEdit> fixits_;
|
||||
std::vector<lsTextEdit> fixits_;
|
||||
};
|
||||
MAKE_REFLECT_STRUCT(lsDiagnostic, range, severity, source, message);
|
||||
|
||||
@ -792,7 +792,7 @@ struct lsDocumentOnTypeFormattingOptions {
|
||||
std::string firstTriggerCharacter;
|
||||
|
||||
// More trigger characters.
|
||||
NonElidedVector<std::string> moreTriggerCharacter;
|
||||
std::vector<std::string> 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<std::string> commands;
|
||||
std::vector<std::string> commands;
|
||||
};
|
||||
MAKE_REFLECT_STRUCT(lsExecuteCommandOptions, commands);
|
||||
|
||||
@ -951,7 +951,7 @@ struct Out_TextDocumentPublishDiagnostics
|
||||
lsDocumentUri uri;
|
||||
|
||||
// An array of diagnostic information items.
|
||||
NonElidedVector<lsDiagnostic> diagnostics;
|
||||
std::vector<lsDiagnostic> diagnostics;
|
||||
};
|
||||
|
||||
Params params;
|
||||
@ -1054,7 +1054,7 @@ struct Out_CquerySetInactiveRegion
|
||||
: public lsOutMessage<Out_CquerySetInactiveRegion> {
|
||||
struct Params {
|
||||
lsDocumentUri uri;
|
||||
NonElidedVector<lsRange> inactiveRegions;
|
||||
std::vector<lsRange> 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<lsRange> ranges;
|
||||
std::vector<lsRange> ranges;
|
||||
};
|
||||
struct Params {
|
||||
lsDocumentUri uri;
|
||||
NonElidedVector<Symbol> symbols;
|
||||
std::vector<Symbol> symbols;
|
||||
};
|
||||
std::string method = "$cquery/publishSemanticHighlighting";
|
||||
Params params;
|
||||
@ -1094,6 +1094,6 @@ MAKE_REFLECT_STRUCT(Out_CqueryPublishSemanticHighlighting,
|
||||
|
||||
struct Out_LocationList : public lsOutMessage<Out_LocationList> {
|
||||
lsRequestId id;
|
||||
NonElidedVector<lsLocation> result;
|
||||
std::vector<lsLocation> result;
|
||||
};
|
||||
MAKE_REFLECT_STRUCT(Out_LocationList, jsonrpc, id, result);
|
||||
|
@ -34,7 +34,7 @@ struct Out_CqueryCallTree : public lsOutMessage<Out_CqueryCallTree> {
|
||||
};
|
||||
|
||||
lsRequestId id;
|
||||
NonElidedVector<CallEntry> result;
|
||||
std::vector<CallEntry> 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<Out_CqueryCallTree::CallEntry> BuildInitialCallTree(
|
||||
std::vector<Out_CqueryCallTree::CallEntry> BuildInitialCallTree(
|
||||
QueryDatabase* db,
|
||||
WorkingFiles* working_files,
|
||||
QueryFuncId root) {
|
||||
@ -62,12 +62,12 @@ NonElidedVector<Out_CqueryCallTree::CallEntry> BuildInitialCallTree(
|
||||
entry.usr = root_func.def->usr;
|
||||
entry.location = *def_loc;
|
||||
entry.hasCallers = HasCallersOnSelfOrBaseOrDerived(db, root_func);
|
||||
NonElidedVector<Out_CqueryCallTree::CallEntry> result;
|
||||
std::vector<Out_CqueryCallTree::CallEntry> result;
|
||||
result.push_back(entry);
|
||||
return result;
|
||||
}
|
||||
|
||||
NonElidedVector<Out_CqueryCallTree::CallEntry> BuildExpandCallTree(
|
||||
std::vector<Out_CqueryCallTree::CallEntry> BuildExpandCallTree(
|
||||
QueryDatabase* db,
|
||||
WorkingFiles* working_files,
|
||||
QueryFuncId root) {
|
||||
@ -96,7 +96,7 @@ NonElidedVector<Out_CqueryCallTree::CallEntry> BuildExpandCallTree(
|
||||
return base + ":" + std::to_string(location.range.start.line + 1);
|
||||
};
|
||||
|
||||
NonElidedVector<Out_CqueryCallTree::CallEntry> result;
|
||||
std::vector<Out_CqueryCallTree::CallEntry> result;
|
||||
std::unordered_set<QueryLocation> seen_locations;
|
||||
|
||||
auto handle_caller = [&](QueryFuncRef caller,
|
||||
|
@ -16,7 +16,7 @@ struct Out_CqueryTypeHierarchyTree
|
||||
struct TypeEntry {
|
||||
std::string name;
|
||||
optional<lsLocation> location;
|
||||
NonElidedVector<TypeEntry> children;
|
||||
std::vector<TypeEntry> children;
|
||||
};
|
||||
lsRequestId id;
|
||||
optional<TypeEntry> result;
|
||||
@ -27,7 +27,7 @@ MAKE_REFLECT_STRUCT(Out_CqueryTypeHierarchyTree::TypeEntry,
|
||||
children);
|
||||
MAKE_REFLECT_STRUCT(Out_CqueryTypeHierarchyTree, jsonrpc, id, result);
|
||||
|
||||
NonElidedVector<Out_CqueryTypeHierarchyTree::TypeEntry>
|
||||
std::vector<Out_CqueryTypeHierarchyTree::TypeEntry>
|
||||
BuildParentInheritanceHierarchyForType(QueryDatabase* db,
|
||||
WorkingFiles* working_files,
|
||||
QueryTypeId root) {
|
||||
@ -35,7 +35,7 @@ BuildParentInheritanceHierarchyForType(QueryDatabase* db,
|
||||
if (!root_type.def)
|
||||
return {};
|
||||
|
||||
NonElidedVector<Out_CqueryTypeHierarchyTree::TypeEntry> parent_entries;
|
||||
std::vector<Out_CqueryTypeHierarchyTree::TypeEntry> 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<Out_CqueryTypeHierarchyTree::TypeEntry>
|
||||
std::vector<Out_CqueryTypeHierarchyTree::TypeEntry>
|
||||
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<Out_CqueryTypeHierarchyTree::TypeEntry> entries;
|
||||
std::vector<Out_CqueryTypeHierarchyTree::TypeEntry> entries;
|
||||
entries.push_back(parent_entry);
|
||||
return entries;
|
||||
}
|
||||
|
@ -254,7 +254,7 @@ struct Ipc_TextDocumentCodeAction
|
||||
// a code action is run.
|
||||
struct lsCodeActionContext {
|
||||
// An array of diagnostics.
|
||||
NonElidedVector<lsDiagnostic> diagnostics;
|
||||
std::vector<lsDiagnostic> diagnostics;
|
||||
};
|
||||
// Params for the CodeActionRequest
|
||||
struct lsCodeActionParams {
|
||||
@ -282,12 +282,12 @@ struct Out_TextDocumentCodeAction
|
||||
: public lsOutMessage<Out_TextDocumentCodeAction> {
|
||||
struct CommandArgs {
|
||||
lsDocumentUri textDocumentUri;
|
||||
NonElidedVector<lsTextEdit> edits;
|
||||
std::vector<lsTextEdit> edits;
|
||||
};
|
||||
using Command = lsCommand<CommandArgs>;
|
||||
|
||||
lsRequestId id;
|
||||
NonElidedVector<Command> result;
|
||||
std::vector<Command> result;
|
||||
};
|
||||
MAKE_REFLECT_STRUCT_WRITER_AS_ARRAY(Out_TextDocumentCodeAction::CommandArgs,
|
||||
textDocumentUri,
|
||||
|
@ -13,7 +13,7 @@ MAKE_REFLECT_EMPTY_STRUCT(lsCodeLensUserData);
|
||||
struct lsCodeLensCommandArguments {
|
||||
lsDocumentUri uri;
|
||||
lsPosition position;
|
||||
NonElidedVector<lsLocation> locations;
|
||||
std::vector<lsLocation> locations;
|
||||
};
|
||||
void Reflect(Writer& visitor, lsCodeLensCommandArguments& value) {
|
||||
visitor.StartArray();
|
||||
@ -45,7 +45,7 @@ REGISTER_IPC_MESSAGE(Ipc_TextDocumentCodeLens);
|
||||
struct Out_TextDocumentCodeLens
|
||||
: public lsOutMessage<Out_TextDocumentCodeLens> {
|
||||
lsRequestId id;
|
||||
NonElidedVector<lsCodeLens<lsCodeLensUserData, lsCodeLensCommandArguments>>
|
||||
std::vector<lsCodeLens<lsCodeLensUserData, lsCodeLensCommandArguments>>
|
||||
result;
|
||||
};
|
||||
MAKE_REFLECT_STRUCT(Out_TextDocumentCodeLens, jsonrpc, id, result);
|
||||
|
@ -20,7 +20,7 @@ struct lsTextDocumentCompleteResult {
|
||||
// this list.
|
||||
bool isIncomplete = false;
|
||||
// The completion items.
|
||||
NonElidedVector<lsCompletionItem> items;
|
||||
std::vector<lsCompletionItem> 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<lsCompletionItem> filtered_result;
|
||||
std::vector<lsCompletionItem> filtered_result;
|
||||
filtered_result.reserve(kMaxResultSize);
|
||||
|
||||
std::unordered_set<std::string> inserted;
|
||||
@ -157,7 +157,7 @@ struct TextDocumentCompletionHandler : MessageHandler {
|
||||
|
||||
ClangCompleteManager::OnComplete callback = std::bind(
|
||||
[this, is_global_completion, existing_completion, request](
|
||||
const NonElidedVector<lsCompletionItem>& results,
|
||||
const std::vector<lsCompletionItem>& 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<lsCompletionItem> results,
|
||||
[this](std::vector<lsCompletionItem> results,
|
||||
bool is_cached_result) {
|
||||
assert(!is_cached_result);
|
||||
|
||||
|
@ -2,7 +2,7 @@
|
||||
#include "query_utils.h"
|
||||
|
||||
namespace {
|
||||
void PushBack(NonElidedVector<lsLocation>* result,
|
||||
void PushBack(std::vector<lsLocation>* result,
|
||||
optional<lsLocation> location) {
|
||||
if (location)
|
||||
result->push_back(*location);
|
||||
@ -21,7 +21,7 @@ REGISTER_IPC_MESSAGE(Ipc_TextDocumentDefinition);
|
||||
struct Out_TextDocumentDefinition
|
||||
: public lsOutMessage<Out_TextDocumentDefinition> {
|
||||
lsRequestId id;
|
||||
NonElidedVector<lsLocation> result;
|
||||
std::vector<lsLocation> result;
|
||||
};
|
||||
MAKE_REFLECT_STRUCT(Out_TextDocumentDefinition, jsonrpc, id, result);
|
||||
|
||||
|
@ -34,7 +34,7 @@ MAKE_REFLECT_STRUCT(lsDocumentLink, range, target);
|
||||
struct Out_TextDocumentDocumentLink
|
||||
: public lsOutMessage<Out_TextDocumentDocumentLink> {
|
||||
lsRequestId id;
|
||||
NonElidedVector<lsDocumentLink> result;
|
||||
std::vector<lsDocumentLink> result;
|
||||
};
|
||||
MAKE_REFLECT_STRUCT(Out_TextDocumentDocumentLink, jsonrpc, id, result);
|
||||
|
||||
|
@ -20,7 +20,7 @@ REGISTER_IPC_MESSAGE(Ipc_TextDocumentDocumentSymbol);
|
||||
struct Out_TextDocumentDocumentSymbol
|
||||
: public lsOutMessage<Out_TextDocumentDocumentSymbol> {
|
||||
lsRequestId id;
|
||||
NonElidedVector<lsSymbolInformation> result;
|
||||
std::vector<lsSymbolInformation> result;
|
||||
};
|
||||
MAKE_REFLECT_STRUCT(Out_TextDocumentDocumentSymbol, jsonrpc, id, result);
|
||||
|
||||
|
@ -15,7 +15,7 @@ REGISTER_IPC_MESSAGE(Ipc_TextDocumentDocumentHighlight);
|
||||
struct Out_TextDocumentDocumentHighlight
|
||||
: public lsOutMessage<Out_TextDocumentDocumentHighlight> {
|
||||
lsRequestId id;
|
||||
NonElidedVector<lsDocumentHighlight> result;
|
||||
std::vector<lsDocumentHighlight> result;
|
||||
};
|
||||
MAKE_REFLECT_STRUCT(Out_TextDocumentDocumentHighlight, jsonrpc, id, result);
|
||||
|
||||
|
@ -33,7 +33,7 @@ REGISTER_IPC_MESSAGE(Ipc_TextDocumentReferences);
|
||||
struct Out_TextDocumentReferences
|
||||
: public lsOutMessage<Out_TextDocumentReferences> {
|
||||
lsRequestId id;
|
||||
NonElidedVector<lsLocation> result;
|
||||
std::vector<lsLocation> result;
|
||||
};
|
||||
MAKE_REFLECT_STRUCT(Out_TextDocumentReferences, jsonrpc, id, result);
|
||||
|
||||
|
@ -47,7 +47,7 @@ MAKE_REFLECT_STRUCT(lsSignatureInformation, label, documentation, parameters);
|
||||
// active and only one active parameter.
|
||||
struct lsSignatureHelp {
|
||||
// One or more signatures.
|
||||
NonElidedVector<lsSignatureInformation> signatures;
|
||||
std::vector<lsSignatureInformation> 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<lsCompletionItem>& results,
|
||||
const std::vector<lsCompletionItem>& results,
|
||||
bool is_cached_result) {
|
||||
auto msg = message->As<Ipc_TextDocumentSignatureHelp>();
|
||||
|
||||
|
@ -20,7 +20,7 @@ REGISTER_IPC_MESSAGE(Ipc_WorkspaceSymbol);
|
||||
|
||||
struct Out_WorkspaceSymbol : public lsOutMessage<Out_WorkspaceSymbol> {
|
||||
lsRequestId id;
|
||||
NonElidedVector<lsSymbolInformation> result;
|
||||
std::vector<lsSymbolInformation> result;
|
||||
};
|
||||
MAKE_REFLECT_STRUCT(Out_WorkspaceSymbol, jsonrpc, id, result);
|
||||
|
||||
|
@ -427,7 +427,7 @@ optional<lsLocation> GetLsLocation(QueryDatabase* db,
|
||||
return lsLocation(uri, *range);
|
||||
}
|
||||
|
||||
NonElidedVector<lsLocation> GetLsLocations(
|
||||
std::vector<lsLocation> GetLsLocations(
|
||||
QueryDatabase* db,
|
||||
WorkingFiles* working_files,
|
||||
const std::vector<QueryLocation>& locations) {
|
||||
@ -440,7 +440,7 @@ NonElidedVector<lsLocation> GetLsLocations(
|
||||
unique_locations.insert(*location);
|
||||
}
|
||||
|
||||
NonElidedVector<lsLocation> result;
|
||||
std::vector<lsLocation> result;
|
||||
result.reserve(unique_locations.size());
|
||||
result.assign(unique_locations.begin(), unique_locations.end());
|
||||
return result;
|
||||
|
@ -52,7 +52,7 @@ lsDocumentUri GetLsDocumentUri(QueryDatabase* db, QueryFileId file_id);
|
||||
optional<lsLocation> GetLsLocation(QueryDatabase* db,
|
||||
WorkingFiles* working_files,
|
||||
const QueryLocation& location);
|
||||
NonElidedVector<lsLocation> GetLsLocations(
|
||||
std::vector<lsLocation> GetLsLocations(
|
||||
QueryDatabase* db,
|
||||
WorkingFiles* working_files,
|
||||
const std::vector<QueryLocation>& locations);
|
||||
|
@ -63,9 +63,6 @@ struct IndexFile;
|
||||
visitor.EndArray(); \
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
struct NonElidedVector : public std::vector<T> {};
|
||||
|
||||
// API:
|
||||
/*
|
||||
template<typename TVisitor, typename T>
|
||||
@ -145,16 +142,6 @@ void ReflectMember(Writer& visitor, const char* name, std::vector<T>& values) {
|
||||
visitor.EndArray();
|
||||
}
|
||||
template <typename T>
|
||||
void ReflectMember(Writer& visitor,
|
||||
const char* name,
|
||||
NonElidedVector<T>& values) {
|
||||
visitor.Key(name);
|
||||
visitor.StartArray();
|
||||
for (auto& value : values)
|
||||
Reflect(visitor, value);
|
||||
visitor.EndArray();
|
||||
}
|
||||
template <typename T>
|
||||
void ReflectMember(Writer& visitor, const char* name, optional<T>& value) {
|
||||
if (!value)
|
||||
return;
|
||||
|
Loading…
Reference in New Issue
Block a user