mirror of
https://github.com/MaskRay/ccls.git
synced 2025-01-19 12:05:50 +00:00
Run ./format.sh
This commit is contained in:
parent
066166ba40
commit
9b44bf7901
@ -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;
|
||||
|
@ -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<lsCompletionItem>& 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<lsCompletionItem> results,
|
||||
bool is_cached_result) {
|
||||
|
||||
assert(!is_cached_result);
|
||||
|
||||
// note: path is updated in the normal completion handler.
|
||||
|
@ -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 '('.
|
||||
|
@ -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<LanguageId>::type);
|
||||
|
||||
struct IndexFile {
|
||||
|
@ -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;
|
||||
|
@ -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<std::string> RealPathNotExpandSymlink(std::string path) {
|
||||
if (path.empty()) {
|
||||
|
@ -202,8 +202,7 @@ std::vector<Project::Entry> LoadFromDirectoryListing(ProjectConfig* config) {
|
||||
|
||||
std::vector<std::string> 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<Project::Entry> 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<std::string>& 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(),
|
||||
|
@ -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<std::string>& extra_flags,
|
||||
const std::string& opt_compilation_db_dir,
|
||||
|
10
src/query.cc
10
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);
|
||||
|
@ -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();
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user