diff --git a/src/clang_complete.cc b/src/clang_complete.cc index 0eec9a71..734dcf30 100644 --- a/src/clang_complete.cc +++ b/src/clang_complete.cc @@ -94,7 +94,7 @@ lsCompletionItemKind GetCompletionKind(CXCursorKind cursor_kind) { return lsCompletionItemKind::Method; case CXCursor_FunctionTemplate: - return lsCompletionItemKind::Function; + return lsCompletionItemKind::Function; case CXCursor_Constructor: case CXCursor_Destructor: @@ -186,7 +186,7 @@ void BuildCompletionItemTexts(std::vector& out, case CXCompletionChunk_Equal: text = '='; break; case CXCompletionChunk_HorizontalSpace: text = ' '; break; case CXCompletionChunk_VerticalSpace: text = ' '; break; - // clang-format on + // clang-format on case CXCompletionChunk_ResultType: result_type = diff --git a/src/clang_complete.h b/src/clang_complete.h index cf752417..ef506005 100644 --- a/src/clang_complete.h +++ b/src/clang_complete.h @@ -2,9 +2,9 @@ #include "clang_index.h" #include "clang_translation_unit.h" +#include "lru_cache.h" #include "lsp_completion.h" #include "lsp_diagnostic.h" -#include "lru_cache.h" #include "project.h" #include "threaded_queue.h" #include "working_files.h" diff --git a/src/clang_cursor.h b/src/clang_cursor.h index f7129b9d..23eed1bb 100644 --- a/src/clang_cursor.h +++ b/src/clang_cursor.h @@ -29,7 +29,7 @@ class ClangType { // NOTE: This will return false for pointed types. Should we call // strip_qualifiers for the user? return cx_type.kind >= CXType_FirstBuiltin && - cx_type.kind <= CXType_LastBuiltin; + cx_type.kind <= CXType_LastBuiltin; } ClangCursor get_declaration() const; diff --git a/src/clang_indexer.cc b/src/clang_indexer.cc index e4596639..4e2b571b 100644 --- a/src/clang_indexer.cc +++ b/src/clang_indexer.cc @@ -493,16 +493,16 @@ Use SetUse(IndexFile* db, Range range, ClangCursor parent, Role role) { const char* GetAnonName(CXCursorKind kind) { switch (kind) { - case CXCursor_ClassDecl: - return "(anon class)"; - case CXCursor_EnumDecl: - return "(anon enum)"; - case CXCursor_StructDecl: - return "(anon struct)"; - case CXCursor_UnionDecl: - return "(anon union)"; - default: - return "(anon)"; + case CXCursor_ClassDecl: + return "(anon class)"; + case CXCursor_EnumDecl: + return "(anon enum)"; + case CXCursor_StructDecl: + return "(anon struct)"; + case CXCursor_UnionDecl: + return "(anon union)"; + default: + return "(anon)"; } } @@ -779,7 +779,7 @@ void Uniquify(std::vector& uses) { } // FIXME Reference: set id in call sites and remove this -//void AddUse(std::vector& values, Range value) { +// void AddUse(std::vector& values, Range value) { // values.push_back( // Use(value, Id(), SymbolKind::File, Role::Reference, {})); //} @@ -1811,8 +1811,8 @@ void OnIndexDeclaration(CXClientData client_data, const CXIdxDeclInfo* decl) { // TODO: For type section, verify if this ever runs for non definitions? // if (!decl->isRedeclaration) { - SetTypeName(type, cursor, decl->semanticContainer, - decl->entityInfo->name, param); + SetTypeName(type, cursor, decl->semanticContainer, decl->entityInfo->name, + param); type->def.kind = GetSymbolKind(decl->entityInfo->kind); if (param->config->index.comments) type->def.comments = cursor.get_comments(); diff --git a/src/clang_utils.cc b/src/clang_utils.cc index 8be4a15c..03a35d75 100644 --- a/src/clang_utils.cc +++ b/src/clang_utils.cc @@ -177,7 +177,7 @@ const char* ClangBuiltinTypeName(CXTypeKind kind) { #endif case CXType_NullPtr: return "nullptr"; default: return ""; - // clang-format on + // clang-format on } } diff --git a/src/command_line.cc b/src/command_line.cc index 717ba3af..8a58da02 100644 --- a/src/command_line.cc +++ b/src/command_line.cc @@ -8,9 +8,9 @@ #include "import_pipeline.h" #include "include_complete.h" #include "indexer.h" -#include "lsp_diagnostic.h" #include "lex_utils.h" #include "lru_cache.h" +#include "lsp_diagnostic.h" #include "match.h" #include "message_handler.h" #include "options.h" @@ -196,7 +196,8 @@ void RunQueryDbThread(const std::string& bin_name, Out_Error out; out.id = id; out.error.code = lsErrorCodes::InternalError; - out.error.message = "Dropping completion request; a newer request " + out.error.message = + "Dropping completion request; a newer request " "has come in that will be serviced instead."; QueueManager::WriteStdout(IpcId::Unknown, out); } diff --git a/src/config.h b/src/config.h index f06397a5..9ca7ab5b 100644 --- a/src/config.h +++ b/src/config.h @@ -238,9 +238,7 @@ MAKE_REFLECT_STRUCT(Config::Diagnostics, frequencyMs, onParse, whitelist) -MAKE_REFLECT_STRUCT(Config::Highlight, - blacklist, - whitelist) +MAKE_REFLECT_STRUCT(Config::Highlight, blacklist, whitelist) MAKE_REFLECT_STRUCT(Config::Index, attributeMakeCallsToCtor, blacklist, diff --git a/src/diagnostics_engine.cc b/src/diagnostics_engine.cc index 8d66325f..36453ea2 100644 --- a/src/diagnostics_engine.cc +++ b/src/diagnostics_engine.cc @@ -7,7 +7,7 @@ void DiagnosticsEngine::Init(Config* config) { frequencyMs_ = config->diagnostics.frequencyMs; match_ = std::make_unique(config->diagnostics.whitelist, - config->diagnostics.blacklist); + config->diagnostics.blacklist); } void DiagnosticsEngine::Publish(WorkingFiles* working_files, @@ -15,12 +15,14 @@ void DiagnosticsEngine::Publish(WorkingFiles* working_files, std::vector diagnostics) { // Cache diagnostics so we can show fixits. working_files->DoActionOnFile(path, [&](WorkingFile* working_file) { - if (working_file) - working_file->diagnostics_ = diagnostics; - }); + if (working_file) + working_file->diagnostics_ = diagnostics; + }); - int64_t now = std::chrono::duration_cast( - std::chrono::high_resolution_clock::now().time_since_epoch()).count(); + int64_t now = + std::chrono::duration_cast( + std::chrono::high_resolution_clock::now().time_since_epoch()) + .count(); if (frequencyMs_ >= 0 && (nextPublish_ <= now || diagnostics.empty()) && match_->IsMatch(path)) { nextPublish_ = now + frequencyMs_; diff --git a/src/fuzzy_match.cc b/src/fuzzy_match.cc index 968b5ab5..85930742 100644 --- a/src/fuzzy_match.cc +++ b/src/fuzzy_match.cc @@ -43,7 +43,7 @@ void CalculateRoles(std::string_view s, int roles[], int* class_set) { } roles[s.size() - 1] = fn(); } -} +} // namespace int FuzzyMatcher::MissScore(int j, bool last) { int s = last ? -20 : 0; @@ -152,7 +152,8 @@ TEST_SUITE("fuzzy_match") { Ranks("ab", {"ab", "aoo_boo", "acb"}); Ranks("CC", {"CamelCase", "camelCase", "camelcase"}); Ranks("cC", {"camelCase", "CamelCase", "camelcase"}); - Ranks("c c", {"camel case", "camelCase", "CamelCase", "camelcase", "camel ace"}); + Ranks("c c", + {"camel case", "camelCase", "CamelCase", "camelcase", "camel ace"}); Ranks("Da.Te", {"Data.Text", "Data.Text.Lazy", "Data.Aeson.Encoding.text"}); // prefix Ranks("is", {"isIEEE", "inSuf"}); diff --git a/src/fuzzy_match.h b/src/fuzzy_match.h index 79599857..336815b7 100644 --- a/src/fuzzy_match.h +++ b/src/fuzzy_match.h @@ -6,7 +6,7 @@ #include class FuzzyMatcher { -public: + public: constexpr static int kMaxPat = 100; constexpr static int kMaxText = 200; // Negative but far from INT_MIN so that intermediate results are hard to @@ -16,7 +16,7 @@ public: FuzzyMatcher(std::string_view pattern); int Match(std::string_view text); -private: + private: std::string pat; std::string_view text; int pat_set, text_set; diff --git a/src/import_pipeline.cc b/src/import_pipeline.cc index dc84f642..8052083f 100644 --- a/src/import_pipeline.cc +++ b/src/import_pipeline.cc @@ -679,7 +679,7 @@ void QueryDb_DoIdMap(QueueManager* queue, auto id_map = std::make_unique(db, file->id_cache); return std::make_unique(std::move(file), - std::move(id_map)); + std::move(id_map)); }; response.current = make_map(std::move(request->current)); response.previous = make_map(std::move(request->previous)); diff --git a/src/include_complete.cc b/src/include_complete.cc index 18d3e8f1..f063d6d6 100644 --- a/src/include_complete.cc +++ b/src/include_complete.cc @@ -113,7 +113,7 @@ void IncludeComplete::Rescan() { if (!match_ && (!config_->completion.includeWhitelist.empty() || !config_->completion.includeBlacklist.empty())) match_ = std::make_unique(config_->completion.includeWhitelist, - config_->completion.includeBlacklist); + config_->completion.includeBlacklist); is_scanning = true; WorkThread::StartThread("scan_includes", [this]() { @@ -140,7 +140,8 @@ void IncludeComplete::InsertCompletionItem(const std::string& absolute_path, auto it = absolute_path_to_completion_item.find(absolute_path); if (it == absolute_path_to_completion_item.end() || completion_items[it->second].detail.length() > item.detail.length()) { - absolute_path_to_completion_item[absolute_path] = completion_items.size() - 1; + absolute_path_to_completion_item[absolute_path] = + completion_items.size() - 1; } } else { lsCompletionItem& inserted_item = diff --git a/src/indexer.h b/src/indexer.h index c671fca3..922e7524 100644 --- a/src/indexer.h +++ b/src/indexer.h @@ -180,10 +180,9 @@ struct TypeDefDefinitionData { bool operator==(const TypeDefDefinitionData& o) const { return detailed_name == o.detailed_name && spell == o.spell && - extent == o.extent && alias_of == o.alias_of && - bases == o.bases && types == o.types && funcs == o.funcs && - vars == o.vars && kind == o.kind && hover == o.hover && - comments == o.comments; + extent == o.extent && alias_of == o.alias_of && bases == o.bases && + types == o.types && funcs == o.funcs && vars == o.vars && + kind == o.kind && hover == o.hover && comments == o.comments; } bool operator!=(const TypeDefDefinitionData& o) const { return !(*this == o); @@ -194,9 +193,7 @@ struct TypeDefDefinitionData { short_name_size); } // Used by cquery_inheritance_hierarchy.cc:Expand generic lambda - std::string_view DetailedName(bool) const { - return detailed_name; - } + std::string_view DetailedName(bool) const { return detailed_name; } }; template void Reflect(TVisitor& visitor, TypeDefDefinitionData& value) { diff --git a/src/ipc.cc b/src/ipc.cc index 27598672..90c75f9b 100644 --- a/src/ipc.cc +++ b/src/ipc.cc @@ -11,8 +11,10 @@ const char* IpcIdToString(IpcId id) { case IpcId::Exit: return "exit"; -#define CASE(name, method) case IpcId::name: return method; - #include "methods.inc" +#define CASE(name, method) \ + case IpcId::name: \ + return method; +#include "methods.inc" #undef CASE case IpcId::Unknown: diff --git a/src/ipc.h b/src/ipc.h index 55a1139a..3992e058 100644 --- a/src/ipc.h +++ b/src/ipc.h @@ -14,7 +14,7 @@ enum class IpcId : int { Exit, #define CASE(x, _) x, - #include "methods.inc" +#include "methods.inc" #undef CASE // Internal implementation detail. diff --git a/src/lex_utils.cc b/src/lex_utils.cc index c7e5700f..ebbe496a 100644 --- a/src/lex_utils.cc +++ b/src/lex_utils.cc @@ -355,7 +355,8 @@ TEST_SUITE("LexWordAroundPos") { std::string content = " file:ns::_my_t5ype7 "; REQUIRE(LexIdentifierAroundPos(CharPos(content, 'f'), content) == "file"); REQUIRE(LexIdentifierAroundPos(CharPos(content, 's'), content) == "ns"); - REQUIRE(LexIdentifierAroundPos(CharPos(content, 'y'), content) == "ns::_my_t5ype7"); + REQUIRE(LexIdentifierAroundPos(CharPos(content, 'y'), content) == + "ns::_my_t5ype7"); } TEST_CASE("dot, dash, colon are skipped") { diff --git a/src/lsp.cc b/src/lsp.cc index 47d869ea..38fdee6f 100644 --- a/src/lsp.cc +++ b/src/lsp.cc @@ -4,8 +4,8 @@ #include "serializers/json.h" #include -#include #include +#include #include #include diff --git a/src/message_handler.cc b/src/message_handler.cc index 35ceae77..a00bc859 100644 --- a/src/message_handler.cc +++ b/src/message_handler.cc @@ -145,7 +145,7 @@ void EmitSemanticHighlighting(QueryDatabase* db, if (def->spell) parent_kind = GetSymbolKind(db, *def->spell); if (parent_kind == lsSymbolKind::Unknown) { - for (Use use: func.declarations) { + for (Use use : func.declarations) { parent_kind = GetSymbolKind(db, use); break; } diff --git a/src/messages/cquery_base.cc b/src/messages/cquery_base.cc index 3c970e12..6a11a064 100644 --- a/src/messages/cquery_base.cc +++ b/src/messages/cquery_base.cc @@ -27,15 +27,15 @@ struct CqueryBaseHandler : BaseMessageHandler { FindSymbolsAtLocation(working_file, file, request->params.position)) { if (sym.kind == SymbolKind::Type) { if (const auto* def = db->GetType(sym).AnyDef()) - out.result = - GetLsLocationExs(db, working_files, GetDeclarations(db, def->bases), - config->xref.container, config->xref.maxNum); + out.result = GetLsLocationExs( + db, working_files, GetDeclarations(db, def->bases), + config->xref.container, config->xref.maxNum); break; } else if (sym.kind == SymbolKind::Func) { if (const auto* def = db->GetFunc(sym).AnyDef()) - out.result = - GetLsLocationExs(db, working_files, GetDeclarations(db, def->bases), - config->xref.container, config->xref.maxNum); + out.result = GetLsLocationExs( + db, working_files, GetDeclarations(db, def->bases), + config->xref.container, config->xref.maxNum); break; } } diff --git a/src/messages/cquery_call_hierarchy.cc b/src/messages/cquery_call_hierarchy.cc index aadac31b..594ce931 100644 --- a/src/messages/cquery_call_hierarchy.cc +++ b/src/messages/cquery_call_hierarchy.cc @@ -5,7 +5,12 @@ #include namespace { -enum class CallType : uint8_t { Direct = 0, Base = 1, Derived = 2, All = 1 | 2 }; +enum class CallType : uint8_t { + Direct = 0, + Base = 1, + Derived = 2, + All = 1 | 2 +}; MAKE_REFLECT_TYPE_PROXY(CallType); bool operator&(CallType lhs, CallType rhs) { @@ -96,7 +101,8 @@ bool Expand(MessageHandler* m, if (const auto* def = func.AnyDef()) for (SymbolRef ref : def->callees) if (ref.kind == SymbolKind::Func) - handle(Use(ref.range, ref.id, ref.kind, ref.role, def->file), call_type); + handle(Use(ref.range, ref.id, ref.kind, ref.role, def->file), + call_type); } else { for (Use use : func.uses) if (use.kind == SymbolKind::Func) @@ -165,7 +171,7 @@ struct CqueryCallHierarchyHandler entry.callType = CallType::Direct; if (def->spell) { if (optional loc = - GetLsLocation(db, working_files, *def->spell)) + GetLsLocation(db, working_files, *def->spell)) entry.location = *loc; } Expand(this, &entry, callee, call_type, detailed_name, levels); @@ -193,11 +199,11 @@ struct CqueryCallHierarchyHandler WorkingFile* working_file = working_files->GetFileByFilename(file->def->path); for (SymbolRef sym : - FindSymbolsAtLocation(working_file, file, params.position)) { + FindSymbolsAtLocation(working_file, file, params.position)) { if (sym.kind == SymbolKind::Func) { out.result = BuildInitial(QueryFuncId(sym.id), params.callee, params.callType, - params.detailedName, params.levels); + params.detailedName, params.levels); break; } } diff --git a/src/messages/cquery_derived.cc b/src/messages/cquery_derived.cc index 6e056584..08e7033f 100644 --- a/src/messages/cquery_derived.cc +++ b/src/messages/cquery_derived.cc @@ -27,15 +27,15 @@ struct CqueryDerivedHandler : BaseMessageHandler { FindSymbolsAtLocation(working_file, file, request->params.position)) { if (sym.kind == SymbolKind::Type) { QueryType& type = db->GetType(sym); - out.result = - GetLsLocationExs(db, working_files, GetDeclarations(db, type.derived), - config->xref.container, config->xref.maxNum); + out.result = GetLsLocationExs( + db, working_files, GetDeclarations(db, type.derived), + config->xref.container, config->xref.maxNum); break; } else if (sym.kind == SymbolKind::Func) { QueryFunc& func = db->GetFunc(sym); - out.result = - GetLsLocationExs(db, working_files, GetDeclarations(db, func.derived), - config->xref.container, config->xref.maxNum); + out.result = GetLsLocationExs( + db, working_files, GetDeclarations(db, func.derived), + config->xref.container, config->xref.maxNum); break; } } diff --git a/src/messages/cquery_inheritance_hierarchy.cc b/src/messages/cquery_inheritance_hierarchy.cc index 1d702a9c..d81df343 100644 --- a/src/messages/cquery_inheritance_hierarchy.cc +++ b/src/messages/cquery_inheritance_hierarchy.cc @@ -7,8 +7,8 @@ struct Ipc_CqueryInheritanceHierarchy : public RequestMessage { const static IpcId kIpcId = IpcId::CqueryInheritanceHierarchy; struct Params { - // If id+kind are specified, expand a node; otherwise textDocument+position should - // be specified for building the root and |levels| of nodes below. + // If id+kind are specified, expand a node; otherwise textDocument+position + // should be specified for building the root and |levels| of nodes below. lsTextDocumentIdentifier textDocument; lsPosition position; @@ -161,8 +161,8 @@ struct CqueryInheritanceHierarchyHandler WorkingFile* working_file = working_files->GetFileByFilename(file->def->path); - for (SymbolRef sym : - FindSymbolsAtLocation(working_file, file, request->params.position)) { + for (SymbolRef sym : FindSymbolsAtLocation(working_file, file, + request->params.position)) { if (sym.kind == SymbolKind::Func || sym.kind == SymbolKind::Type) { out.result = BuildInitial(sym, params.derived, params.detailedName, params.levels); diff --git a/src/messages/cquery_member_hierarchy.cc b/src/messages/cquery_member_hierarchy.cc index 0314a425..8245c857 100644 --- a/src/messages/cquery_member_hierarchy.cc +++ b/src/messages/cquery_member_hierarchy.cc @@ -75,7 +75,7 @@ void DoField(MessageHandler* m, entry1.fieldName = std::string(def1->ShortName()); if (def1->spell) { if (optional loc = - GetLsLocation(m->db, m->working_files, *def1->spell)) + GetLsLocation(m->db, m->working_files, *def1->spell)) entry1.location = *loc; } if (def1->type) { @@ -128,7 +128,7 @@ bool Expand(MessageHandler* m, if (def1 && def1->spell) { // The declaration of target type. if (optional loc = - GetLsLocation(m->db, m->working_files, *def1->spell)) + GetLsLocation(m->db, m->working_files, *def1->spell)) entry1.location = *loc; } else if (def->spell) { // Builtin types have no declaration but the typedef declaration @@ -175,7 +175,7 @@ struct CqueryMemberHierarchyHandler entry.name = std::string(def->ShortName()); if (def->spell) { if (optional loc = - GetLsLocation(db, working_files, *def->spell)) + GetLsLocation(db, working_files, *def->spell)) entry.location = *loc; } EachDefinedEntity(db->vars, def->vars, [&](QueryVar& var) { @@ -195,7 +195,7 @@ struct CqueryMemberHierarchyHandler entry.id = root_id; if (def->spell) { if (optional loc = - GetLsLocation(db, working_files, *def->spell)) + GetLsLocation(db, working_files, *def->spell)) entry.location = *loc; } Expand(this, &entry, detailed_name, levels); @@ -220,27 +220,27 @@ struct CqueryMemberHierarchyHandler params.textDocument.uri.GetPath(), &file)) return; WorkingFile* working_file = - working_files->GetFileByFilename(file->def->path); + working_files->GetFileByFilename(file->def->path); for (SymbolRef sym : - FindSymbolsAtLocation(working_file, file, params.position)) { + FindSymbolsAtLocation(working_file, file, params.position)) { switch (sym.kind) { - case SymbolKind::Func: - out.result = BuildInitial(QueryFuncId(sym.id), params.detailedName, - params.levels); - break; - case SymbolKind::Type: - out.result = BuildInitial(QueryTypeId(sym.id), params.detailedName, - params.levels); - break; - case SymbolKind::Var: { - const QueryVar::Def* def = db->GetVar(sym).AnyDef(); - if (def && def->type) - out.result = BuildInitial(QueryTypeId(*def->type), params.detailedName, + case SymbolKind::Func: + out.result = BuildInitial(QueryFuncId(sym.id), params.detailedName, params.levels); - break; - } - default: - continue; + break; + case SymbolKind::Type: + out.result = BuildInitial(QueryTypeId(sym.id), params.detailedName, + params.levels); + break; + case SymbolKind::Var: { + const QueryVar::Def* def = db->GetVar(sym).AnyDef(); + if (def && def->type) + out.result = BuildInitial(QueryTypeId(*def->type), + params.detailedName, params.levels); + break; + } + default: + continue; } break; } diff --git a/src/messages/text_document_code_action.cc b/src/messages/text_document_code_action.cc index df569e5c..559cae30 100644 --- a/src/messages/text_document_code_action.cc +++ b/src/messages/text_document_code_action.cc @@ -441,8 +441,8 @@ struct TextDocumentCodeActionHandler // For error diagnostics, provide an action to resolve an include. // TODO: find a way to index diagnostic contents so line numbers // don't get mismatched when actively editing a file. - std::string_view include_query = - LexIdentifierAroundPos(diag.range.start, working_file->buffer_content); + std::string_view include_query = LexIdentifierAroundPos( + diag.range.start, working_file->buffer_content); if (diag.severity == lsDiagnosticSeverity::Error && !include_query.empty()) { const size_t kMaxResults = 20; diff --git a/src/messages/text_document_code_lens.cc b/src/messages/text_document_code_lens.cc index 792c8426..239a543a 100644 --- a/src/messages/text_document_code_lens.cc +++ b/src/messages/text_document_code_lens.cc @@ -118,9 +118,11 @@ struct TextDocumentCodeLensHandler AddCodeLens("ref", "refs", &common, OffsetStartColumn(use, 0), type.uses, true /*force_display*/); AddCodeLens("derived", "derived", &common, OffsetStartColumn(use, 1), - GetDeclarations(db, type.derived), false /*force_display*/); + GetDeclarations(db, type.derived), + false /*force_display*/); AddCodeLens("var", "vars", &common, OffsetStartColumn(use, 2), - GetDeclarations(db, type.instances), false /*force_display*/); + GetDeclarations(db, type.instances), + false /*force_display*/); break; } case SymbolKind::Func: { @@ -164,9 +166,9 @@ struct TextDocumentCodeLensHandler false /*force_display*/); } - AddCodeLens("derived", "derived", &common, - OffsetStartColumn(use, offset++), - GetDeclarations(db, func.derived), false /*force_display*/); + AddCodeLens( + "derived", "derived", &common, OffsetStartColumn(use, offset++), + GetDeclarations(db, func.derived), false /*force_display*/); // "Base" if (def->bases.size() == 1) { @@ -193,7 +195,8 @@ struct TextDocumentCodeLensHandler } } else { AddCodeLens("base", "base", &common, OffsetStartColumn(use, 1), - GetDeclarations(db, def->bases), false /*force_display*/); + GetDeclarations(db, def->bases), + false /*force_display*/); } break; diff --git a/src/messages/text_document_completion.cc b/src/messages/text_document_completion.cc index c14e360f..aec06e27 100644 --- a/src/messages/text_document_completion.cc +++ b/src/messages/text_document_completion.cc @@ -197,10 +197,10 @@ void FilterAndSortCompletionResponse( : FuzzyMatcher::kMinScore; } items.erase(std::remove_if(items.begin(), items.end(), - [](const lsCompletionItem& item) { - return item.score_ <= FuzzyMatcher::kMinScore; - }), - items.end()); + [](const lsCompletionItem& item) { + return item.score_ <= FuzzyMatcher::kMinScore; + }), + items.end()); std::sort(items.begin(), items.end(), [](const lsCompletionItem& lhs, const lsCompletionItem& rhs) { if (lhs.score_ != rhs.score_) @@ -300,7 +300,7 @@ struct TextDocumentCompletionHandler : MessageHandler { { std::unique_lock lock( - include_complete->completion_items_mutex, std::defer_lock); + include_complete->completion_items_mutex, std::defer_lock); if (include_complete->is_scanning) lock.lock(); std::string quote = result.match[5]; @@ -314,7 +314,7 @@ struct TextDocumentCompletionHandler : MessageHandler { item.filterText = item.label; FilterAndSortCompletionResponse(&out, result.pattern, - config->completion.filterAndSort); + config->completion.filterAndSort); DecorateIncludePaths(result.match, &out.result.items); for (lsCompletionItem& item : out.result.items) { diff --git a/src/messages/text_document_definition.cc b/src/messages/text_document_definition.cc index 62f36585..e5823794 100644 --- a/src/messages/text_document_definition.cc +++ b/src/messages/text_document_definition.cc @@ -156,8 +156,7 @@ struct TextDocumentDefinitionHandler } } if (best_i != -1) { - Maybe use = - GetDefinitionSpell(db, db->symbols[best_i]); + Maybe use = GetDefinitionSpell(db, db->symbols[best_i]); assert(use); if (auto ls_loc = GetLsLocationEx(db, working_files, *use, config->xref.container)) diff --git a/src/messages/text_document_document_symbol.cc b/src/messages/text_document_document_symbol.cc index b6631bd1..54e5cf28 100644 --- a/src/messages/text_document_document_symbol.cc +++ b/src/messages/text_document_document_symbol.cc @@ -45,7 +45,8 @@ struct TextDocumentDocumentSymbolHandler if (sym.kind == SymbolKind::Var) { QueryVar& var = db->GetVar(sym); auto* def = var.AnyDef(); - if (!def || !def->spell) continue; + if (!def || !def->spell) + continue; // Ignore local variables. if (def->spell->kind == SymbolKind::Func && def->storage != StorageClass::Static && diff --git a/src/messages/text_document_type_definition.cc b/src/messages/text_document_type_definition.cc index 9745862b..dac467ae 100644 --- a/src/messages/text_document_type_definition.cc +++ b/src/messages/text_document_type_definition.cc @@ -22,21 +22,21 @@ MAKE_REFLECT_STRUCT(Out_TextDocumentTypeDefinition, jsonrpc, id, result); struct TextDocumentTypeDefinitionHandler : BaseMessageHandler { void Run(Ipc_TextDocumentTypeDefinition* request) override { - QueryFile* file; - if (!FindFileOrFail(db, project, request->id, - request->params.textDocument.uri.GetPath(), &file, - nullptr)) { - return; - } - WorkingFile* working_file = - working_files->GetFileByFilename(file->def->path); + QueryFile* file; + if (!FindFileOrFail(db, project, request->id, + request->params.textDocument.uri.GetPath(), &file, + nullptr)) { + return; + } + WorkingFile* working_file = + working_files->GetFileByFilename(file->def->path); - Out_TextDocumentTypeDefinition out; - out.id = request->id; - for (SymbolRef sym : - FindSymbolsAtLocation(working_file, file, request->params.position)) { - Id id = sym.id; - switch (sym.kind) { + Out_TextDocumentTypeDefinition out; + out.id = request->id; + for (SymbolRef sym : + FindSymbolsAtLocation(working_file, file, request->params.position)) { + Id id = sym.id; + switch (sym.kind) { case SymbolKind::Var: { const QueryVar::Def* def = db->GetVar(sym).AnyDef(); if (!def || !def->type) @@ -56,10 +56,10 @@ struct TextDocumentTypeDefinitionHandler } default: break; - } } + } - QueueManager::WriteStdout(IpcId::TextDocumentTypeDefinition, out); + QueueManager::WriteStdout(IpcId::TextDocumentTypeDefinition, out); } }; REGISTER_MESSAGE_HANDLER(TextDocumentTypeDefinitionHandler); diff --git a/src/messages/workspace_did_change_configuration.cc b/src/messages/workspace_did_change_configuration.cc index 29b5f57d..7b90fc8d 100644 --- a/src/messages/workspace_did_change_configuration.cc +++ b/src/messages/workspace_did_change_configuration.cc @@ -25,11 +25,11 @@ struct WorkspaceDidChangeConfigurationHandler Timer time; project->Load(config, config->projectRoot); time.ResetAndPrint("[perf] Loaded compilation entries (" + - std::to_string(project->entries.size()) + " files)"); + std::to_string(project->entries.size()) + " files)"); time.Reset(); project->Index(config, QueueManager::instance(), working_files, - std::monostate()); + std::monostate()); time.ResetAndPrint( "[perf] Dispatched workspace/didChangeConfiguration index requests"); } diff --git a/src/messages/workspace_symbol.cc b/src/messages/workspace_symbol.cc index 9595baf8..09216712 100644 --- a/src/messages/workspace_symbol.cc +++ b/src/messages/workspace_symbol.cc @@ -107,7 +107,8 @@ struct WorkspaceSymbolHandler : BaseMessageHandler { for (int i = 0; i < (int)db->symbols.size(); ++i) { std::string_view detailed_name = db->GetSymbolDetailedName(i); - if (CaseFoldingSubsequenceMatch(query_without_space, detailed_name).first) { + if (CaseFoldingSubsequenceMatch(query_without_space, detailed_name) + .first) { // Do not show the same entry twice. if (!inserted_results.insert(std::string(detailed_name)).second) continue; diff --git a/src/project.cc b/src/project.cc index 2568ab93..0c476a71 100644 --- a/src/project.cc +++ b/src/project.cc @@ -89,8 +89,7 @@ std::vector kPathArgs = { "-I", "-iquote", "-isystem", "--sysroot=", "-isysroot", "-gcc-toolchain", "-include-pch", "-iframework", "-F", "-imacros", "-include", "/I", - "-idirafter" -}; + "-idirafter"}; // Arguments which always require an absolute path, ie, clang -working-directory // does not work as expected. Argument processing assumes that this is a subset @@ -431,7 +430,7 @@ std::vector LoadCompilationEntriesFromDirectory( comp_db_dir.c_str(), &cx_db_load_error); if (!config->compilationDatabaseCommand.empty()) { #ifdef _WIN32 - // TODO + // TODO #else unlink((comp_db_dir + "/compile_commands.json").c_str()); rmdir(comp_db_dir.c_str()); diff --git a/src/project.h b/src/project.h index 17e41c59..db93f4b2 100644 --- a/src/project.h +++ b/src/project.h @@ -38,10 +38,10 @@ struct Project { // compile_commands.json in it, otherwise they are retrieved in // |root_directory|. // For .cquery, recursive directory listing is used and files with known - // suffixes are indexed. .cquery files can exist in subdirectories and they will affect - // flags in their subtrees (relative paths are relative to the project root, - // not subdirectories). - // For compile_commands.json, its entries are indexed. + // suffixes are indexed. .cquery files can exist in subdirectories and they + // will affect flags in their subtrees (relative paths are relative to the + // project root, not subdirectories). For compile_commands.json, its entries + // are indexed. void Load(Config* config, const std::string& root_directory); // Lookup the CompilationEntry for |filename|. If no entry was found this diff --git a/src/query_utils.cc b/src/query_utils.cc index 7377ad17..81bab28f 100644 --- a/src/query_utils.cc +++ b/src/query_utils.cc @@ -100,8 +100,7 @@ std::vector GetDeclarations(QueryDatabase* db, return GetDeclarations(db->vars, ids); } -std::vector GetNonDefDeclarations(QueryDatabase* db, - SymbolIdx sym) { +std::vector GetNonDefDeclarations(QueryDatabase* db, SymbolIdx sym) { switch (sym.kind) { case SymbolKind::Func: return db->GetFunc(sym).declarations; diff --git a/src/query_utils.h b/src/query_utils.h index f9a10a6a..f7f43a57 100644 --- a/src/query_utils.h +++ b/src/query_utils.h @@ -10,10 +10,14 @@ Maybe GetDefinitionExtent(QueryDatabase* db, SymbolIdx sym); Maybe GetDeclarationFileForSymbol(QueryDatabase* db, SymbolIdx sym); -// Get defining declaration (if exists) or an arbitrary declaration (otherwise) for each id. -std::vector GetDeclarations(QueryDatabase* db, const std::vector& ids); -std::vector GetDeclarations(QueryDatabase* db, const std::vector& ids); -std::vector GetDeclarations(QueryDatabase* db, const std::vector& ids); +// Get defining declaration (if exists) or an arbitrary declaration (otherwise) +// for each id. +std::vector GetDeclarations(QueryDatabase* db, + const std::vector& ids); +std::vector GetDeclarations(QueryDatabase* db, + const std::vector& ids); +std::vector GetDeclarations(QueryDatabase* db, + const std::vector& ids); // Get non-defining declarations. std::vector GetNonDefDeclarations(QueryDatabase* db, SymbolIdx sym); @@ -78,7 +82,10 @@ void EachEntityDef(QueryDatabase* db, SymbolIdx sym, Fn&& fn) { } template -void EachOccurrence(QueryDatabase* db, SymbolIdx sym, bool include_decl, Fn&& fn) { +void EachOccurrence(QueryDatabase* db, + SymbolIdx sym, + bool include_decl, + Fn&& fn) { WithEntity(db, sym, [&](const auto& entity) { for (Use use : entity.uses) fn(use); diff --git a/src/queue_manager.h b/src/queue_manager.h index 46312d54..61db1d23 100644 --- a/src/queue_manager.h +++ b/src/queue_manager.h @@ -81,7 +81,7 @@ struct Index_OnIndexed { class QueueManager { static std::unique_ptr instance_; -public: + public: static QueueManager* instance() { return instance_.get(); } static void Init(MultiQueueWaiter* querydb_waiter, MultiQueueWaiter* indexer_waiter, diff --git a/src/semantic_highlight_symbol_cache.cc b/src/semantic_highlight_symbol_cache.cc index 5992b5d4..10f8ebc4 100644 --- a/src/semantic_highlight_symbol_cache.cc +++ b/src/semantic_highlight_symbol_cache.cc @@ -62,7 +62,7 @@ SemanticHighlightSymbolCache::SemanticHighlightSymbolCache() void SemanticHighlightSymbolCache::Init(Config* config) { match_ = std::make_unique(config->highlight.whitelist, - config->highlight.blacklist); + config->highlight.blacklist); } std::shared_ptr diff --git a/src/test.cc b/src/test.cc index 429da329..925a82f4 100644 --- a/src/test.cc +++ b/src/test.cc @@ -6,11 +6,11 @@ #include "utils.h" #include -#include #include #include #include #include +#include #include #include diff --git a/src/threaded_queue.h b/src/threaded_queue.h index aeaab5d1..5f9404e0 100644 --- a/src/threaded_queue.h +++ b/src/threaded_queue.h @@ -32,12 +32,8 @@ template struct MultiQueueLock { MultiQueueLock(Queue... lockable) : tuple_{lockable...} { lock(); } ~MultiQueueLock() { unlock(); } - void lock() { - lock_impl(typename std::index_sequence_for{}); - } - void unlock() { - unlock_impl(typename std::index_sequence_for{}); - } + void lock() { lock_impl(typename std::index_sequence_for{}); } + void unlock() { unlock_impl(typename std::index_sequence_for{}); } private: template