mirror of
https://github.com/MaskRay/ccls.git
synced 2025-01-19 12:05:50 +00:00
Format using clang format 4.0.0
This commit is contained in:
parent
4aeb6acf04
commit
fb491e6c6d
@ -142,13 +142,13 @@ lsCompletionItemKind GetCompletionKind(CXCursorKind cursor_kind) {
|
||||
case CXCursor_ObjCClassRef:
|
||||
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;
|
||||
|
@ -93,4 +93,4 @@ struct hash<ClangCursor> {
|
||||
return clang_hashCursor(x.cx_cursor);
|
||||
}
|
||||
};
|
||||
}
|
||||
} // namespace std
|
||||
|
@ -19,8 +19,8 @@ void EmitDiagnostics(std::string path,
|
||||
CXTranslationUnit tu) {
|
||||
std::string output = "Fatal errors while trying to parse " + path + "\n";
|
||||
output +=
|
||||
"Args: " +
|
||||
StringJoinMap(args, [](const char* arg) { return std::string(arg); }) +
|
||||
"Args: " + StringJoinMap(
|
||||
args, [](const char* arg) { return std::string(arg); }) +
|
||||
"\n";
|
||||
|
||||
size_t num_diagnostics = clang_getNumDiagnostics(tu);
|
||||
|
@ -1051,7 +1051,8 @@ int main(int argc, char** argv) {
|
||||
}
|
||||
|
||||
if (print_help) {
|
||||
std::cout << R"help(cquery is a low-latency C/C++/Objective-C language server.
|
||||
std::cout
|
||||
<< R"help(cquery is a low-latency C/C++/Objective-C language server.
|
||||
|
||||
Command line options:
|
||||
--language-server
|
||||
|
@ -76,8 +76,7 @@ struct NamespaceHelper {
|
||||
|
||||
void RegisterQualifiedName(std::string usr,
|
||||
const CXIdxContainerInfo* container,
|
||||
std::string qualified_name) {
|
||||
}
|
||||
std::string qualified_name) {}
|
||||
|
||||
std::string QualifiedName(const CXIdxContainerInfo* container,
|
||||
std::string unqualified_name) {
|
||||
@ -100,7 +99,7 @@ struct NamespaceHelper {
|
||||
namespaces.push_back(cursor);
|
||||
cursor = clang_getCursorSemanticParent(cursor.cx_cursor);
|
||||
}
|
||||
for (size_t i = namespaces.size(); i > 0; ) {
|
||||
for (size_t i = namespaces.size(); i > 0;) {
|
||||
i--;
|
||||
std::string name = namespaces[i].get_spelling();
|
||||
// Empty name indicates unnamed namespace, anonymous struct, anonymous
|
||||
@ -266,8 +265,7 @@ IndexFile* ConsumeFile(IndexParam* param, CXFile file) {
|
||||
|
||||
// Capture file contents in |param->file_contents| if it was not specified
|
||||
// at the start of indexing.
|
||||
if (db &&
|
||||
!param->file_contents.count(file_name)) {
|
||||
if (db && !param->file_contents.count(file_name)) {
|
||||
optional<std::string> content = ReadContent(file_name);
|
||||
if (content)
|
||||
param->file_contents.emplace(file_name, *content);
|
||||
@ -601,16 +599,16 @@ optional<ClangCursor> FindType(ClangCursor cursor) {
|
||||
}
|
||||
|
||||
bool IsGlobalContainer(const CXIdxContainerInfo* container) {
|
||||
if (!container)
|
||||
return false;
|
||||
if (!container)
|
||||
return false;
|
||||
|
||||
switch (container->cursor.kind) {
|
||||
switch (container->cursor.kind) {
|
||||
case CXCursor_Namespace:
|
||||
case CXCursor_TranslationUnit:
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool IsTypeDefinition(const CXIdxContainerInfo* container) {
|
||||
@ -1060,12 +1058,13 @@ void OnIndexDeclaration(CXClientData client_data, const CXIdxDeclInfo* decl) {
|
||||
}
|
||||
|
||||
bool is_system = clang_Location_isInSystemHeader(
|
||||
clang_indexLoc_getCXSourceLocation(decl->loc));
|
||||
clang_indexLoc_getCXSourceLocation(decl->loc));
|
||||
var->def.is_global =
|
||||
!is_system && IsGlobalContainer(decl->semanticContainer);
|
||||
var->def.is_member =
|
||||
!is_system && IsTypeDefinition(decl->semanticContainer);
|
||||
var->def.is_local = !is_system && !var->def.is_global && !var->def.is_member;
|
||||
var->def.is_local =
|
||||
!is_system && !var->def.is_global && !var->def.is_member;
|
||||
|
||||
//}
|
||||
|
||||
@ -1207,7 +1206,7 @@ void OnIndexDeclaration(CXClientData client_data, const CXIdxDeclInfo* decl) {
|
||||
size_t offset = 0;
|
||||
if (type_desc.back() == ')') {
|
||||
size_t balance = 0;
|
||||
for (offset = type_desc.size(); offset; ) {
|
||||
for (offset = type_desc.size(); offset;) {
|
||||
offset--;
|
||||
if (type_desc[offset] == ')')
|
||||
balance++;
|
||||
@ -1296,10 +1295,10 @@ void OnIndexDeclaration(CXClientData client_data, const CXIdxDeclInfo* decl) {
|
||||
type->def.detailed_name =
|
||||
ns->QualifiedName(decl->semanticContainer, type->def.short_name);
|
||||
|
||||
// For Typedef/CXXTypeAlias spanning a few lines, display the declaration line,
|
||||
// with spelling name replaced with qualified name.
|
||||
// TODO Think how to display multi-line declaration like `typedef struct { ... } foo;`
|
||||
// https://github.com/jacobdufault/cquery/issues/29
|
||||
// For Typedef/CXXTypeAlias spanning a few lines, display the declaration
|
||||
// line, with spelling name replaced with qualified name.
|
||||
// TODO Think how to display multi-line declaration like `typedef struct {
|
||||
// ... } foo;` https://github.com/jacobdufault/cquery/issues/29
|
||||
if (extent.end.line - extent.start.line <
|
||||
kMaxLinesDisplayTypeAliasDeclarations) {
|
||||
FileContentsWithOffsets& fc = param->file_contents[db->path];
|
||||
@ -1468,15 +1467,15 @@ void OnIndexReference(CXClientData client_data, const CXIdxEntityRefInfo* ref) {
|
||||
// as lambdas cannot be split across files.
|
||||
if (var->def.short_name.empty()) {
|
||||
CXFile referenced_file;
|
||||
Range spelling = ResolveSpelling(referenced.cx_cursor, &referenced_file);
|
||||
Range spelling =
|
||||
ResolveSpelling(referenced.cx_cursor, &referenced_file);
|
||||
if (file == referenced_file) {
|
||||
var->def.definition_spelling = spelling;
|
||||
var->def.definition_extent = ResolveExtent(referenced.cx_cursor);
|
||||
|
||||
// TODO Some of the logic here duplicates CXIdxEntity_Variable branch of
|
||||
// OnIndexDeclaration.
|
||||
// But there `decl` is of type CXIdxDeclInfo and has more information,
|
||||
// thus not easy to reuse the code.
|
||||
// TODO Some of the logic here duplicates CXIdxEntity_Variable branch
|
||||
// of OnIndexDeclaration. But there `decl` is of type CXIdxDeclInfo
|
||||
// and has more information, thus not easy to reuse the code.
|
||||
var->def.short_name = referenced.get_spelling();
|
||||
std::string type_name = ToString(
|
||||
clang_getTypeSpelling(clang_getCursorType(referenced.cx_cursor)));
|
||||
@ -1679,7 +1678,8 @@ optional<int> FileContentsWithOffsets::ToOffset(Position p) const {
|
||||
return nullopt;
|
||||
}
|
||||
|
||||
optional<std::string> FileContentsWithOffsets::ContentsInRange(Range range) const {
|
||||
optional<std::string> FileContentsWithOffsets::ContentsInRange(
|
||||
Range range) const {
|
||||
optional<int> start_offset = ToOffset(range.start),
|
||||
end_offset = ToOffset(range.end);
|
||||
if (start_offset && end_offset && *start_offset < *end_offset)
|
||||
@ -1838,14 +1838,12 @@ void ClangSanityCheck() {
|
||||
void* reserved) -> CXIdxClientFile {
|
||||
return nullptr;
|
||||
};
|
||||
callback.ppIncludedFile =
|
||||
[](CXClientData client_data,
|
||||
const CXIdxIncludedFileInfo* file) -> CXIdxClientFile {
|
||||
return nullptr;
|
||||
};
|
||||
callback.importedASTFile =
|
||||
[](CXClientData client_data,
|
||||
const CXIdxImportedASTFileInfo*) -> CXIdxClientASTFile {
|
||||
callback.ppIncludedFile = [](
|
||||
CXClientData client_data,
|
||||
const CXIdxIncludedFileInfo* file) -> CXIdxClientFile { return nullptr; };
|
||||
callback.importedASTFile = [](
|
||||
CXClientData client_data,
|
||||
const CXIdxImportedASTFileInfo*) -> CXIdxClientASTFile {
|
||||
return nullptr;
|
||||
};
|
||||
callback.startedTranslationUnit = [](CXClientData client_data,
|
||||
|
@ -178,8 +178,7 @@ struct TypeDefDefinitionData {
|
||||
bool operator==(
|
||||
const TypeDefDefinitionData<TypeId, FuncId, VarId, Range>& other) const {
|
||||
return short_name == other.short_name &&
|
||||
detailed_name == other.detailed_name &&
|
||||
hover == other.hover &&
|
||||
detailed_name == other.detailed_name && hover == other.hover &&
|
||||
definition_spelling == other.definition_spelling &&
|
||||
definition_extent == other.definition_extent &&
|
||||
alias_of == other.alias_of && parents == other.parents &&
|
||||
@ -270,8 +269,7 @@ struct FuncDefDefinitionData {
|
||||
const FuncDefDefinitionData<TypeId, FuncId, VarId, FuncRef, Range>& other)
|
||||
const {
|
||||
return short_name == other.short_name &&
|
||||
detailed_name == other.detailed_name &&
|
||||
hover == other.hover &&
|
||||
detailed_name == other.detailed_name && hover == other.hover &&
|
||||
definition_spelling == other.definition_spelling &&
|
||||
definition_extent == other.definition_extent &&
|
||||
declaring_type == other.declaring_type && base == other.base &&
|
||||
@ -387,8 +385,7 @@ struct VarDefDefinitionData {
|
||||
bool operator==(
|
||||
const VarDefDefinitionData<TypeId, FuncId, VarId, Range>& other) const {
|
||||
return short_name == other.short_name &&
|
||||
detailed_name == other.detailed_name &&
|
||||
hover == other.hover &&
|
||||
detailed_name == other.detailed_name && hover == other.hover &&
|
||||
declaration == other.declaration &&
|
||||
definition_spelling == other.definition_spelling &&
|
||||
definition_extent == other.definition_extent &&
|
||||
|
@ -22,10 +22,11 @@ optional<Matcher> Matcher::Create(const std::string& search) {
|
||||
Matcher m;
|
||||
m.regex_string = search;
|
||||
m.regex = std::regex(
|
||||
search, std::regex_constants::ECMAScript | std::regex_constants::icase |
|
||||
std::regex_constants::optimize
|
||||
search,
|
||||
std::regex_constants::ECMAScript | std::regex_constants::icase |
|
||||
std::regex_constants::optimize
|
||||
// std::regex_constants::nosubs
|
||||
);
|
||||
);
|
||||
return m;
|
||||
} catch (std::exception e) {
|
||||
Out_ShowLogMessage out;
|
||||
|
@ -75,9 +75,9 @@ std::vector<Out_CqueryCallTree::CallEntry> BuildExpandCallTree(
|
||||
if (!root_func.def)
|
||||
return {};
|
||||
|
||||
auto format_location =
|
||||
[&](const lsLocation& location,
|
||||
optional<QueryTypeId> declaring_type) -> std::string {
|
||||
auto format_location = [&](
|
||||
const lsLocation& location,
|
||||
optional<QueryTypeId> declaring_type) -> std::string {
|
||||
std::string base;
|
||||
|
||||
if (declaring_type) {
|
||||
|
@ -113,10 +113,10 @@ BuildParentInheritanceHierarchyForFunc(QueryDatabase* db,
|
||||
Out_CqueryTypeHierarchyTree::TypeEntry parent_entry;
|
||||
parent_entry.name = parent_func.def->detailed_name;
|
||||
if (parent_func.def->definition_spelling)
|
||||
parent_entry.location =
|
||||
GetLsLocation(db, working_files, *parent_func.def->definition_spelling);
|
||||
parent_entry.children = BuildParentInheritanceHierarchyForFunc(
|
||||
db, working_files, parent_id);
|
||||
parent_entry.location = GetLsLocation(
|
||||
db, working_files, *parent_func.def->definition_spelling);
|
||||
parent_entry.children =
|
||||
BuildParentInheritanceHierarchyForFunc(db, working_files, parent_id);
|
||||
|
||||
entries.push_back(parent_entry);
|
||||
}
|
||||
|
@ -165,8 +165,8 @@ struct InitializeHandler : BaseMessageHandler<Ipc_InitializeRequest> {
|
||||
// If the user has not specified how many indexers to run, try to
|
||||
// guess an appropriate value. Default to 80% utilization.
|
||||
const float kDefaultTargetUtilization = 0.8f;
|
||||
config->indexerCount = (int)(
|
||||
std::thread::hardware_concurrency() * kDefaultTargetUtilization);
|
||||
config->indexerCount = (int)(std::thread::hardware_concurrency() *
|
||||
kDefaultTargetUtilization);
|
||||
if (config->indexerCount <= 0)
|
||||
config->indexerCount = 1;
|
||||
}
|
||||
|
@ -202,13 +202,14 @@ struct TextDocumentCodeLensHandler
|
||||
|
||||
// "Base"
|
||||
if (func.def->base.size() == 1) {
|
||||
optional<QueryLocation> base_loc = GetDefinitionSpellingOfSymbol(db, func.def->base[0]);
|
||||
optional<QueryLocation> base_loc =
|
||||
GetDefinitionSpellingOfSymbol(db, func.def->base[0]);
|
||||
if (base_loc) {
|
||||
optional<lsLocation> ls_base =
|
||||
GetLsLocation(db, working_files, *base_loc);
|
||||
GetLsLocation(db, working_files, *base_loc);
|
||||
if (ls_base) {
|
||||
optional<lsRange> range =
|
||||
GetLsRange(common.working_file, ref.loc.range);
|
||||
GetLsRange(common.working_file, ref.loc.range);
|
||||
if (range) {
|
||||
TCodeLens code_lens;
|
||||
code_lens.range = *range;
|
||||
@ -223,10 +224,9 @@ struct TextDocumentCodeLensHandler
|
||||
}
|
||||
}
|
||||
} else {
|
||||
AddCodeLens("base", "base", &common,
|
||||
ref.loc.OffsetStartColumn(1),
|
||||
ToQueryLocation(db, func.def->base), nullopt,
|
||||
false /*force_display*/);
|
||||
AddCodeLens("base", "base", &common, ref.loc.OffsetStartColumn(1),
|
||||
ToQueryLocation(db, func.def->base), nullopt,
|
||||
false /*force_display*/);
|
||||
}
|
||||
|
||||
break;
|
||||
|
@ -194,16 +194,14 @@ struct TextDocumentCompletionHandler : MessageHandler {
|
||||
!global_code_complete_cache->cached_results_.empty();
|
||||
});
|
||||
if (is_cache_match) {
|
||||
ClangCompleteManager::OnComplete freshen_global =
|
||||
[this](std::vector<lsCompletionItem> results,
|
||||
bool is_cached_result) {
|
||||
assert(!is_cached_result);
|
||||
ClangCompleteManager::OnComplete freshen_global = [this](
|
||||
std::vector<lsCompletionItem> results, bool is_cached_result) {
|
||||
assert(!is_cached_result);
|
||||
|
||||
// note: path is updated in the normal completion handler.
|
||||
global_code_complete_cache->WithLock([&]() {
|
||||
global_code_complete_cache->cached_results_ = results;
|
||||
});
|
||||
};
|
||||
// note: path is updated in the normal completion handler.
|
||||
global_code_complete_cache->WithLock(
|
||||
[&]() { global_code_complete_cache->cached_results_ = results; });
|
||||
};
|
||||
|
||||
global_code_complete_cache->WithLock([&]() {
|
||||
callback(global_code_complete_cache->cached_results_,
|
||||
|
@ -24,9 +24,8 @@ struct Out_TextDocumentDefinition
|
||||
};
|
||||
MAKE_REFLECT_STRUCT(Out_TextDocumentDefinition, jsonrpc, id, result);
|
||||
|
||||
std::vector<QueryLocation> GetGotoDefinitionTargets(
|
||||
QueryDatabase* db,
|
||||
const SymbolIdx& symbol) {
|
||||
std::vector<QueryLocation> GetGotoDefinitionTargets(QueryDatabase* db,
|
||||
const SymbolIdx& symbol) {
|
||||
switch (symbol.kind) {
|
||||
// Returns GetDeclarationsOfSymbolForGotoDefinition and
|
||||
// variable type definition.
|
||||
|
@ -2,7 +2,7 @@
|
||||
#include "query_utils.h"
|
||||
|
||||
namespace {
|
||||
|
||||
|
||||
std::string GetHoverForSymbol(QueryDatabase* db, const SymbolIdx& symbol) {
|
||||
switch (symbol.kind) {
|
||||
case SymbolKind::Type: {
|
||||
@ -60,7 +60,7 @@ struct Out_TextDocumentHover : public lsOutMessage<Out_TextDocumentHover> {
|
||||
optional<Result> result;
|
||||
};
|
||||
MAKE_REFLECT_STRUCT(Out_TextDocumentHover::Result, contents, range);
|
||||
void Reflect(Writer& visitor, Out_TextDocumentHover& value) {
|
||||
void Reflect(Writer& visitor, Out_TextDocumentHover& value) {
|
||||
REFLECT_MEMBER_START();
|
||||
REFLECT_MEMBER(jsonrpc);
|
||||
REFLECT_MEMBER(id);
|
||||
|
@ -11,7 +11,8 @@ void InsertSymbolIntoResult(QueryDatabase* db,
|
||||
WorkingFiles* working_files,
|
||||
SymbolIdx symbol,
|
||||
std::vector<lsSymbolInformation>* result) {
|
||||
optional<lsSymbolInformation> info = GetSymbolInfo(db, working_files, symbol, false /*use_short_name*/);
|
||||
optional<lsSymbolInformation> info =
|
||||
GetSymbolInfo(db, working_files, symbol, false /*use_short_name*/);
|
||||
if (!info)
|
||||
return;
|
||||
|
||||
|
@ -33,11 +33,11 @@
|
||||
#include <sys/mman.h>
|
||||
|
||||
#if defined(__FreeBSD__)
|
||||
# include <sys/param.h> // MAXPATHLEN
|
||||
# include <sys/sysctl.h> // sysctl
|
||||
#include <sys/param.h> // MAXPATHLEN
|
||||
#include <sys/sysctl.h> // sysctl
|
||||
#elif defined(__linux__)
|
||||
# include <malloc.h>
|
||||
# include <sys/prctl.h>
|
||||
#include <malloc.h>
|
||||
#include <sys/prctl.h>
|
||||
#endif
|
||||
|
||||
namespace {
|
||||
@ -211,22 +211,23 @@ std::unique_ptr<PlatformSharedMemory> CreatePlatformSharedMemory(
|
||||
void PlatformInit() {}
|
||||
|
||||
#ifdef __APPLE__
|
||||
extern "C" int _NSGetExecutablePath(char* buf,uint32_t* bufsize);
|
||||
extern "C" int _NSGetExecutablePath(char* buf, uint32_t* bufsize);
|
||||
#endif
|
||||
|
||||
// See https://stackoverflow.com/questions/143174/how-do-i-get-the-directory-that-a-program-is-running-from
|
||||
// See
|
||||
// https://stackoverflow.com/questions/143174/how-do-i-get-the-directory-that-a-program-is-running-from
|
||||
std::string GetExecutablePath() {
|
||||
#ifdef __APPLE__
|
||||
uint32_t size = 0;
|
||||
_NSGetExecutablePath(nullptr, &size);
|
||||
char *buffer = new char[size];
|
||||
char* buffer = new char[size];
|
||||
_NSGetExecutablePath(buffer, &size);
|
||||
std::string result(buffer);
|
||||
delete[] buffer;
|
||||
return result;
|
||||
#elif defined(__FreeBSD__)
|
||||
static const int name[] = {
|
||||
CTL_KERN, KERN_PROC, KERN_PROC_PATHNAME, -1,
|
||||
CTL_KERN, KERN_PROC, KERN_PROC_PATHNAME, -1,
|
||||
};
|
||||
char path[MAXPATHLEN];
|
||||
size_t len = sizeof(path);
|
||||
|
@ -127,7 +127,8 @@ void PlatformInit() {
|
||||
_setmode(_fileno(stdin), O_BINARY);
|
||||
}
|
||||
|
||||
// See https://stackoverflow.com/questions/143174/how-do-i-get-the-directory-that-a-program-is-running-from
|
||||
// See
|
||||
// https://stackoverflow.com/questions/143174/how-do-i-get-the-directory-that-a-program-is-running-from
|
||||
std::string GetExecutablePath() {
|
||||
char result[MAX_PATH] = {0};
|
||||
GetModuleFileName(NULL, result, MAX_PATH);
|
||||
@ -233,6 +234,7 @@ std::vector<std::string> GetPlatformClangArguments() {
|
||||
// $ clang++ -E -x c++ - -v
|
||||
//
|
||||
|
||||
// clang-format off
|
||||
return {
|
||||
"-isystem","C:/Program Files/Microsoft Visual Studio 10.0/VC/include",
|
||||
"-isystem","C:/Program Files/Microsoft Visual Studio 9.0/VC/include",
|
||||
@ -244,6 +246,7 @@ std::vector<std::string> GetPlatformClangArguments() {
|
||||
"-isystem","C:/Program Files/LLVM/lib/clang/4.0.0/include",
|
||||
"-fms-extensions", "-fms-compatibility", "-fms-compatibility-version=18", "-fdelayed-template-parsing"
|
||||
};
|
||||
// clang-format on
|
||||
}
|
||||
|
||||
void FreeUnusedMemory() {}
|
||||
|
@ -52,15 +52,10 @@ static std::vector<std::string> kBlacklistMulti = {
|
||||
|
||||
// Blacklisted flags which are always removed from the command line.
|
||||
static std::vector<std::string> kBlacklist = {
|
||||
"-c",
|
||||
"-MP",
|
||||
"-MD",
|
||||
"-MMD",
|
||||
"--fcolor-diagnostics",
|
||||
"-c", "-MP", "-MD", "-MMD", "--fcolor-diagnostics",
|
||||
|
||||
// This strips path-like args but is a bit hacky.
|
||||
"/",
|
||||
"..",
|
||||
"/", "..",
|
||||
};
|
||||
|
||||
// Arguments which are followed by a potentially relative path. We need to make
|
||||
@ -204,7 +199,6 @@ Project::Entry GetCompilationEntryFromCompileCommandEntry(
|
||||
else if (*source_file_type == "c++")
|
||||
result.args.push_back("-std=c++11");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Add -resource-dir so clang can correctly resolve system includes like
|
||||
@ -486,19 +480,21 @@ TEST_SUITE("Project") {
|
||||
TEST_CASE("strip meta-compiler invocations") {
|
||||
CheckFlags(
|
||||
/* raw */ {"clang", "-lstdc++", "myfile.cc"},
|
||||
/* expected */ {"clang", "-lstdc++", "myfile.cc", "-xc++", "-std=c++11",
|
||||
"-resource-dir=/w/resource_dir/",
|
||||
"-Wno-unknown-warning-option"});
|
||||
/* expected */
|
||||
{"clang", "-lstdc++", "myfile.cc", "-xc++", "-std=c++11",
|
||||
"-resource-dir=/w/resource_dir/", "-Wno-unknown-warning-option"});
|
||||
|
||||
CheckFlags(/* raw */ {"goma", "clang"},
|
||||
/* expected */ {"clang", "-xc++", "-std=c++11",
|
||||
"-resource-dir=/w/resource_dir/",
|
||||
"-Wno-unknown-warning-option"});
|
||||
CheckFlags(
|
||||
/* raw */ {"goma", "clang"},
|
||||
/* expected */
|
||||
{"clang", "-xc++", "-std=c++11", "-resource-dir=/w/resource_dir/",
|
||||
"-Wno-unknown-warning-option"});
|
||||
|
||||
CheckFlags(/* raw */ {"goma", "clang", "--foo"},
|
||||
/* expected */ {"clang", "--foo", "-xc++", "-std=c++11",
|
||||
"-resource-dir=/w/resource_dir/",
|
||||
"-Wno-unknown-warning-option"});
|
||||
CheckFlags(
|
||||
/* raw */ {"goma", "clang", "--foo"},
|
||||
/* expected */
|
||||
{"clang", "--foo", "-xc++", "-std=c++11",
|
||||
"-resource-dir=/w/resource_dir/", "-Wno-unknown-warning-option"});
|
||||
}
|
||||
|
||||
// FIXME: Fix this test.
|
||||
@ -512,11 +508,12 @@ TEST_SUITE("Project") {
|
||||
}
|
||||
|
||||
TEST_CASE("Implied binary") {
|
||||
CheckFlags("/home/user", "/home/user/foo/bar.cc",
|
||||
CheckFlags(
|
||||
"/home/user", "/home/user/foo/bar.cc",
|
||||
/* raw */ {"-DDONT_IGNORE_ME"},
|
||||
/* expected */ {"clang++", "-DDONT_IGNORE_ME", "-xc++", "-std=c++11",
|
||||
"-resource-dir=/w/resource_dir/",
|
||||
"-Wno-unknown-warning-option"});
|
||||
/* expected */
|
||||
{"clang++", "-DDONT_IGNORE_ME", "-xc++", "-std=c++11",
|
||||
"-resource-dir=/w/resource_dir/", "-Wno-unknown-warning-option"});
|
||||
}
|
||||
|
||||
// Checks flag parsing for a random chromium file in comparison to what
|
||||
|
@ -51,7 +51,8 @@ struct QueryLocation {
|
||||
MAKE_REFLECT_STRUCT(QueryLocation, path, range);
|
||||
MAKE_HASHABLE(QueryLocation, t.path, t.range);
|
||||
|
||||
// The order matters. In FindSymbolsAtLocation, we want Var/Func ordered in front of others.
|
||||
// The order matters. In FindSymbolsAtLocation, we want Var/Func ordered in
|
||||
// front of others.
|
||||
enum class SymbolKind : int { Invalid, File, Type, Func, Var };
|
||||
MAKE_REFLECT_TYPE_PROXY(SymbolKind, int);
|
||||
|
||||
|
@ -425,7 +425,8 @@ optional<lsSymbolInformation> GetSymbolInfo(QueryDatabase* db,
|
||||
return nullopt;
|
||||
|
||||
lsSymbolInformation info;
|
||||
info.name = use_short_name ? type.def->short_name : type.def->detailed_name;
|
||||
info.name =
|
||||
use_short_name ? type.def->short_name : type.def->detailed_name;
|
||||
if (type.def->detailed_name != type.def->short_name)
|
||||
info.containerName = type.def->detailed_name;
|
||||
info.kind = lsSymbolKind::Class;
|
||||
@ -437,7 +438,8 @@ optional<lsSymbolInformation> GetSymbolInfo(QueryDatabase* db,
|
||||
return nullopt;
|
||||
|
||||
lsSymbolInformation info;
|
||||
info.name = use_short_name ? func.def->short_name : func.def->detailed_name;
|
||||
info.name =
|
||||
use_short_name ? func.def->short_name : func.def->detailed_name;
|
||||
info.containerName = func.def->detailed_name;
|
||||
info.kind = lsSymbolKind::Function;
|
||||
|
||||
@ -537,23 +539,23 @@ std::vector<SymbolRef> FindSymbolsAtLocation(WorkingFile* working_file,
|
||||
// important for macros which generate code so that we can resolving the
|
||||
// macro argument takes priority over the entire macro body.
|
||||
//
|
||||
// Order SymbolKind::Var before SymbolKind::Type. Macro calls are treated as Var
|
||||
// currently. If a macro expands to tokens led by a SymbolKind::Type, the
|
||||
// Order SymbolKind::Var before SymbolKind::Type. Macro calls are treated as
|
||||
// Var currently. If a macro expands to tokens led by a SymbolKind::Type, the
|
||||
// macro and the Type have the same range. We want to find the macro
|
||||
// definition instead of the Type definition.
|
||||
//
|
||||
// Then order functions before other types, which makes goto definition work
|
||||
// better on constructors.
|
||||
std::sort(symbols.begin(), symbols.end(),
|
||||
[](const SymbolRef& a, const SymbolRef& b) {
|
||||
int a_size = ComputeRangeSize(a.loc.range);
|
||||
int b_size = ComputeRangeSize(b.loc.range);
|
||||
std::sort(symbols.begin(), symbols.end(), [](const SymbolRef& a,
|
||||
const SymbolRef& b) {
|
||||
int a_size = ComputeRangeSize(a.loc.range);
|
||||
int b_size = ComputeRangeSize(b.loc.range);
|
||||
|
||||
if (a_size != b_size)
|
||||
return a_size < b_size;
|
||||
// operator> orders Var/Func in front of orders.
|
||||
return static_cast<int>(a.idx.kind) > static_cast<int>(b.idx.kind);
|
||||
});
|
||||
if (a_size != b_size)
|
||||
return a_size < b_size;
|
||||
// operator> orders Var/Func in front of orders.
|
||||
return static_cast<int>(a.idx.kind) > static_cast<int>(b.idx.kind);
|
||||
});
|
||||
|
||||
return symbols;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user