diff --git a/src/clang_complete.cc b/src/clang_complete.cc index 0c432d1a..15992604 100644 --- a/src/clang_complete.cc +++ b/src/clang_complete.cc @@ -114,13 +114,13 @@ lsCompletionItemKind GetCompletionKind(CXCursorKind cursor_kind) { case CXCursor_TypeRef: return lsCompletionItemKind::Reference; - // return lsCompletionItemKind::Property; - // return lsCompletionItemKind::Unit; - // return lsCompletionItemKind::Value; - // return lsCompletionItemKind::Keyword; - // return lsCompletionItemKind::Snippet; - // return lsCompletionItemKind::Color; - // return lsCompletionItemKind::File; + // return lsCompletionItemKind::Property; + // return lsCompletionItemKind::Unit; + // return lsCompletionItemKind::Value; + // return lsCompletionItemKind::Keyword; + // return lsCompletionItemKind::Snippet; + // return lsCompletionItemKind::Color; + // return lsCompletionItemKind::File; case CXCursor_NotImplemented: return lsCompletionItemKind::Text; diff --git a/src/command_line.cc b/src/command_line.cc index e65f5af9..86559aee 100644 --- a/src/command_line.cc +++ b/src/command_line.cc @@ -172,7 +172,7 @@ void EmitSemanticHighlighting(QueryDatabase* db, if (!func->def) continue; // applies to for loop if (func->def->is_operator) - continue; // applies to for loop + continue; // applies to for loop is_type_member = func->def->declaring_type.has_value(); break; } @@ -805,7 +805,7 @@ struct IndexManager { }; // Send indexing progress to client if reporting is enabled. -void EmitProgress(Config *config, QueueManager* queue) { +void EmitProgress(Config* config, QueueManager* queue) { if (config->enableProgressReports) { Out_Progress out; out.params.indexRequestCount = queue->index_request.Size(); @@ -1578,8 +1578,8 @@ bool QueryDbMainLoop(Config* config, // Open up / load the project. project->Load(config->extraClangArguments, - config->compilationDatabaseDirectory, - project_path, config->resourceDirectory); + config->compilationDatabaseDirectory, project_path, + config->resourceDirectory); time.ResetAndPrint("[perf] Loaded compilation entries (" + std::to_string(project->entries.size()) + " files)"); @@ -2027,7 +2027,6 @@ bool QueryDbMainLoop(Config* config, is_global_completion, existing_completion, msg](const NonElidedVector& results, bool is_cached_result) { - Out_TextDocumentComplete complete_response; complete_response.id = msg->id; complete_response.result.items = results; @@ -2070,7 +2069,6 @@ bool QueryDbMainLoop(Config* config, [global_code_complete_cache]( NonElidedVector results, bool is_cached_result) { - assert(!is_cached_result); // note: path is updated in the normal completion handler. diff --git a/src/indexer.cc b/src/indexer.cc index cd88ab0a..3f2938e6 100644 --- a/src/indexer.cc +++ b/src/indexer.cc @@ -996,8 +996,8 @@ void indexDeclaration(CXClientData client_data, const CXIdxDeclInfo* decl) { return; // The language of this declaration - LanguageId decl_lang = [decl] () { - switch (clang_getCursorLanguage(decl->cursor)) { + LanguageId decl_lang = [decl]() { + switch (clang_getCursorLanguage(decl->cursor)) { case CXLanguage_C: return LanguageId::C; case CXLanguage_CPlusPlus: @@ -1006,8 +1006,8 @@ void indexDeclaration(CXClientData client_data, const CXIdxDeclInfo* decl) { return LanguageId::ObjC; default: return LanguageId::Unknown; - }; - } (); + }; + }(); // Only update the file language if the new language is "greater" than the old if (decl_lang > db->language) { @@ -1188,8 +1188,10 @@ void indexDeclaration(CXClientData client_data, const CXIdxDeclInfo* decl) { if (!is_template_specialization) { func->def.short_name = decl->entityInfo->name; - // Set the |is_operator| flag to true if the function name starts with "operator" - func->def.is_operator = func->def.short_name.compare(0, 8, "operator") == 0; + // Set the |is_operator| flag to true if the function name starts with + // "operator" + func->def.is_operator = + func->def.short_name.compare(0, 8, "operator") == 0; // Build detailed name. The type desc looks like void (void *). We // insert the qualified name before the first '('. diff --git a/src/indexer.h b/src/indexer.h index 66029ad3..d05dfd39 100644 --- a/src/indexer.h +++ b/src/indexer.h @@ -471,12 +471,7 @@ struct IndexInclude { // Used to identify the language at a file level. The ordering is important, as // a file previously identified as `C`, will be changed to `Cpp` if it // encounters a c++ declaration. -enum class LanguageId { - Unknown = 0, - C = 1, - Cpp = 2, - ObjC = 3 -}; +enum class LanguageId { Unknown = 0, C = 1, Cpp = 2, ObjC = 3 }; MAKE_REFLECT_TYPE_PROXY(LanguageId, std::underlying_type::type); struct IndexFile { diff --git a/src/language_server_api.h b/src/language_server_api.h index cc209849..73d09915 100644 --- a/src/language_server_api.h +++ b/src/language_server_api.h @@ -1180,17 +1180,19 @@ MAKE_REFLECT_STRUCT(lsSignatureHelp, activeSignature, activeParameter); -// MarkedString can be used to render human readable text. It is either a markdown string -// or a code-block that provides a language and a code snippet. The language identifier -// is sematically equal to the optional language identifier in fenced code blocks in GitHub -// issues. See https://help.github.com/articles/creating-and-highlighting-code-blocks/#syntax-highlighting +// MarkedString can be used to render human readable text. It is either a +// markdown string or a code-block that provides a language and a code snippet. +// The language identifier is sematically equal to the optional language +// identifier in fenced code blocks in GitHub issues. See +// https://help.github.com/articles/creating-and-highlighting-code-blocks/#syntax-highlighting // // The pair of a language and a value is an equivalent to markdown: // ```${language} // ${value} // ``` // -// Note that markdown strings will be sanitized - that means html will be escaped. +// Note that markdown strings will be sanitized - that means html will be +// escaped. struct lsMarkedString { std::string language; std::string value; diff --git a/src/platform_linux.cc b/src/platform_linux.cc index fa5e4b76..c84ff1eb 100644 --- a/src/platform_linux.cc +++ b/src/platform_linux.cc @@ -42,8 +42,8 @@ namespace { -// Returns the canonicalized absolute pathname, without expanding symbolic links. -// This is a variant of realpath(2), C++ rewrite of +// Returns the canonicalized absolute pathname, without expanding symbolic +// links. This is a variant of realpath(2), C++ rewrite of // https://github.com/freebsd/freebsd/blob/master/lib/libc/stdlib/realpath.c optional RealPathNotExpandSymlink(std::string path) { if (path.empty()) { diff --git a/src/project.cc b/src/project.cc index 7d553072..cc590b99 100644 --- a/src/project.cc +++ b/src/project.cc @@ -202,8 +202,7 @@ std::vector LoadFromDirectoryListing(ProjectConfig* config) { std::vector args; std::cerr << "Using arguments: "; - for (const std::string& line : - ReadLines(config->project_dir + "/.cquery")) { + for (const std::string& line : ReadLines(config->project_dir + "/.cquery")) { if (line.empty() || StartsWith(line, "#")) continue; if (!args.empty()) @@ -232,17 +231,16 @@ std::vector LoadCompilationEntriesFromDirectory( ProjectConfig* config, const std::string& opt_compilation_db_dir) { // Try to load compile_commands.json, but fallback to a project listing. - const auto& compilation_db_dir = opt_compilation_db_dir.empty() - ? config->project_dir - : opt_compilation_db_dir; + const auto& compilation_db_dir = opt_compilation_db_dir.empty() + ? config->project_dir + : opt_compilation_db_dir; LOG_S(INFO) << "Trying to load compile_commands.json"; CXCompilationDatabase_Error cx_db_load_error; CXCompilationDatabase cx_db = clang_CompilationDatabase_fromDirectory( compilation_db_dir.c_str(), &cx_db_load_error); if (cx_db_load_error == CXCompilationDatabase_CanNotLoadDatabase) { LOG_S(INFO) << "Unable to load compile_commands.json located at \"" - << compilation_db_dir - << "\"; using directory listing instead."; + << compilation_db_dir << "\"; using directory listing instead."; return LoadFromDirectoryListing(config); } @@ -351,8 +349,8 @@ void Project::Load(const std::vector& extra_flags, config.extra_flags = extra_flags; config.project_dir = root_directory; config.resource_dir = resource_directory; - entries = LoadCompilationEntriesFromDirectory(&config, - opt_compilation_db_dir); + entries = + LoadCompilationEntriesFromDirectory(&config, opt_compilation_db_dir); // Cleanup / postprocess include directories. quote_include_directories.assign(config.quote_dirs.begin(), diff --git a/src/project.h b/src/project.h index 039f184b..2619e435 100644 --- a/src/project.h +++ b/src/project.h @@ -33,9 +33,9 @@ struct Project { // // If |opt_compilation_db_dir| is not empty, the compile_commands.json // file in it will be used to discover all files and args. If it's empty and - // |root_directory| contains a compile_commands.json file, that one will be used - // instead. Otherwise, a recursive directory listing of all *.cpp, *.cc, *.h, - // and *.hpp files will be used. clang arguments can be specified in a + // |root_directory| contains a compile_commands.json file, that one will be + // used instead. Otherwise, a recursive directory listing of all *.cpp, *.cc, + // *.h, and *.hpp files will be used. clang arguments can be specified in a // .cquery file located inside of |root_directory|. void Load(const std::vector& extra_flags, const std::string& opt_compilation_db_dir, diff --git a/src/query.cc b/src/query.cc index 03d27477..c7ccfbe6 100644 --- a/src/query.cc +++ b/src/query.cc @@ -176,8 +176,8 @@ QueryFile::Def BuildFileDef(const IdMap& id_map, const IndexFile& indexed) { def.inactive_regions = indexed.skipped_by_preprocessor; // Convert enum to markdown compatible strings - def.language = [indexed] () { - switch (indexed.language) { + def.language = [indexed]() { + switch (indexed.language) { case LanguageId::C: return "c"; case LanguageId::Cpp: @@ -186,8 +186,8 @@ QueryFile::Def BuildFileDef(const IdMap& id_map, const IndexFile& indexed) { return "objectivec"; default: return ""; - } - } (); + } + }(); auto add_outline = [&def, &id_map](SymbolIdx idx, Range range) { def.outline.push_back(SymbolRef(idx, id_map.ToQuery(range))); @@ -618,7 +618,7 @@ IndexUpdate::IndexUpdate(const IdMap& previous_id_map, } void IndexUpdate::Merge(const IndexUpdate& update) { -// This function runs on an indexer thread. + // This function runs on an indexer thread. #define INDEX_UPDATE_APPEND(name) AddRange(&name, update.name); #define INDEX_UPDATE_MERGE(name) AddMergeableRange(&name, update.name); diff --git a/src/working_files.cc b/src/working_files.cc index 50e893e7..b23b0955 100644 --- a/src/working_files.cc +++ b/src/working_files.cc @@ -329,14 +329,17 @@ void WorkingFiles::OnChange(const Ipc_TextDocumentDidChange::Params& change) { // std::cerr << "|" << file->buffer_content << "|" << std::endl; // Per the spec replace everything if the rangeLength and range are not set. // See https://github.com/Microsoft/language-server-protocol/issues/9. - if (diff.rangeLength == -1 && diff.range.start == lsPosition::kZeroPosition - && diff.range.end == lsPosition::kZeroPosition) { + if (diff.rangeLength == -1 && + diff.range.start == lsPosition::kZeroPosition && + diff.range.end == lsPosition::kZeroPosition) { file->buffer_content = diff.text; file->OnBufferContentUpdated(); // std::cerr << "-> Replacing entire content"; } else { - int start_offset = GetOffsetForPosition(diff.range.start, file->buffer_content); - int end_offset = GetOffsetForPosition(diff.range.end, file->buffer_content); + int start_offset = + GetOffsetForPosition(diff.range.start, file->buffer_content); + int end_offset = + GetOffsetForPosition(diff.range.end, file->buffer_content); int length = diff.rangeLength; if (length == -1) { length = end_offset - start_offset; @@ -346,8 +349,7 @@ void WorkingFiles::OnChange(const Ipc_TextDocumentDidChange::Params& change) { // start_offset << std::endl; file->buffer_content.replace( file->buffer_content.begin() + start_offset, - file->buffer_content.begin() + start_offset + length, - diff.text); + file->buffer_content.begin() + start_offset + length, diff.text); file->OnBufferContentUpdated(); }