mirror of
https://github.com/MaskRay/ccls.git
synced 2025-01-19 03:55:49 +00:00
Format
This commit is contained in:
parent
5605dfbb00
commit
54394ed868
@ -125,13 +125,13 @@ lsCompletionItemKind GetCompletionKind(CXCursorKind cursor_kind) {
|
|||||||
case CXCursor_ObjCClassRef:
|
case CXCursor_ObjCClassRef:
|
||||||
return lsCompletionItemKind::Reference;
|
return lsCompletionItemKind::Reference;
|
||||||
|
|
||||||
// return lsCompletionItemKind::Property;
|
// return lsCompletionItemKind::Property;
|
||||||
// return lsCompletionItemKind::Unit;
|
// return lsCompletionItemKind::Unit;
|
||||||
// return lsCompletionItemKind::Value;
|
// return lsCompletionItemKind::Value;
|
||||||
// return lsCompletionItemKind::Keyword;
|
// return lsCompletionItemKind::Keyword;
|
||||||
// return lsCompletionItemKind::Snippet;
|
// return lsCompletionItemKind::Snippet;
|
||||||
// return lsCompletionItemKind::Color;
|
// return lsCompletionItemKind::Color;
|
||||||
// return lsCompletionItemKind::File;
|
// return lsCompletionItemKind::File;
|
||||||
|
|
||||||
case CXCursor_NotImplemented:
|
case CXCursor_NotImplemented:
|
||||||
return lsCompletionItemKind::Text;
|
return lsCompletionItemKind::Text;
|
||||||
@ -389,7 +389,8 @@ void CompletionQueryMain(ClangCompleteManager* completion_manager) {
|
|||||||
if (!session->tu)
|
if (!session->tu)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
WorkingFilesSnapshot snapshot = completion_manager->working_files_->AsSnapshot();
|
WorkingFilesSnapshot snapshot =
|
||||||
|
completion_manager->working_files_->AsSnapshot();
|
||||||
std::vector<CXUnsavedFile> unsaved = snapshot.AsUnsavedFiles();
|
std::vector<CXUnsavedFile> unsaved = snapshot.AsUnsavedFiles();
|
||||||
|
|
||||||
// Emit code completion data.
|
// Emit code completion data.
|
||||||
@ -450,9 +451,9 @@ void CompletionQueryMain(ClangCompleteManager* completion_manager) {
|
|||||||
ls_completion_item.documentation = ToString(
|
ls_completion_item.documentation = ToString(
|
||||||
clang_getCompletionBriefComment(result.CompletionString));
|
clang_getCompletionBriefComment(result.CompletionString));
|
||||||
|
|
||||||
ls_completion_item.priority_ =
|
ls_completion_item.priority_ = GetCompletionPriority(
|
||||||
GetCompletionPriority(result.CompletionString, result.CursorKind,
|
result.CompletionString, result.CursorKind,
|
||||||
ls_completion_item.label);
|
ls_completion_item.label);
|
||||||
|
|
||||||
ls_result.push_back(ls_completion_item);
|
ls_result.push_back(ls_completion_item);
|
||||||
}
|
}
|
||||||
|
@ -19,8 +19,8 @@ void EmitDiagnostics(std::string path,
|
|||||||
CXTranslationUnit tu) {
|
CXTranslationUnit tu) {
|
||||||
std::string output = "Fatal errors while trying to parse " + path + "\n";
|
std::string output = "Fatal errors while trying to parse " + path + "\n";
|
||||||
output +=
|
output +=
|
||||||
"Args: " + StringJoinMap(
|
"Args: " +
|
||||||
args, [](const char* arg) { return std::string(arg); }) +
|
StringJoinMap(args, [](const char* arg) { return std::string(arg); }) +
|
||||||
"\n";
|
"\n";
|
||||||
|
|
||||||
size_t num_diagnostics = clang_getNumDiagnostics(tu);
|
size_t num_diagnostics = clang_getNumDiagnostics(tu);
|
||||||
|
@ -25,6 +25,6 @@ std::string ToString(CXCursorKind cursor_kind);
|
|||||||
// Converts Clang formatting replacement operations into LSP text edits.
|
// Converts Clang formatting replacement operations into LSP text edits.
|
||||||
#if USE_CLANG_CXX
|
#if USE_CLANG_CXX
|
||||||
std::vector<lsTextEdit> ConvertClangReplacementsIntoTextEdits(
|
std::vector<lsTextEdit> ConvertClangReplacementsIntoTextEdits(
|
||||||
llvm::StringRef document,
|
llvm::StringRef document,
|
||||||
const std::vector<clang::tooling::Replacement>& clang_replacements);
|
const std::vector<clang::tooling::Replacement>& clang_replacements);
|
||||||
#endif
|
#endif
|
||||||
|
@ -30,8 +30,8 @@
|
|||||||
#include "working_files.h"
|
#include "working_files.h"
|
||||||
|
|
||||||
#include <doctest/doctest.h>
|
#include <doctest/doctest.h>
|
||||||
#include <loguru.hpp>
|
|
||||||
#include <rapidjson/error/en.h>
|
#include <rapidjson/error/en.h>
|
||||||
|
#include <loguru.hpp>
|
||||||
|
|
||||||
#include <climits>
|
#include <climits>
|
||||||
#include <functional>
|
#include <functional>
|
||||||
|
@ -138,8 +138,7 @@ MAKE_REFLECT_STRUCT(Config,
|
|||||||
|
|
||||||
enableComments,
|
enableComments,
|
||||||
|
|
||||||
dumpAST
|
dumpAST);
|
||||||
);
|
|
||||||
|
|
||||||
// Expected client version. We show an error if this doesn't match.
|
// Expected client version. We show an error if this doesn't match.
|
||||||
constexpr const int kExpectedClientVersion = 3;
|
constexpr const int kExpectedClientVersion = 3;
|
||||||
|
@ -106,7 +106,6 @@ ClangSymbolKind GetSymbolKind(CXIdxEntityKind kind) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Caches all instances of constructors, regardless if they are indexed or not.
|
// Caches all instances of constructors, regardless if they are indexed or not.
|
||||||
// The constructor may have a make_unique call associated with it that we need
|
// The constructor may have a make_unique call associated with it that we need
|
||||||
// to export. If we do not capture the parameter type description for the
|
// to export. If we do not capture the parameter type description for the
|
||||||
@ -339,7 +338,8 @@ std::string GetDocumentContentInRange(CXTranslationUnit cx_tu,
|
|||||||
|
|
||||||
for (unsigned i = 0; i < num_tokens; ++i) {
|
for (unsigned i = 0; i < num_tokens; ++i) {
|
||||||
// Add whitespace between the previous token and this one.
|
// Add whitespace between the previous token and this one.
|
||||||
Range token_range = ResolveCXSourceRange(clang_getTokenExtent(cx_tu, tokens[i]));
|
Range token_range =
|
||||||
|
ResolveCXSourceRange(clang_getTokenExtent(cx_tu, tokens[i]));
|
||||||
if (previous_token_range) {
|
if (previous_token_range) {
|
||||||
// Insert newlines.
|
// Insert newlines.
|
||||||
int16_t line_delta =
|
int16_t line_delta =
|
||||||
@ -419,9 +419,9 @@ void SetVarDetail(IndexVar* var,
|
|||||||
def.comments = cursor.get_comments();
|
def.comments = cursor.get_comments();
|
||||||
|
|
||||||
std::string qualified_name =
|
std::string qualified_name =
|
||||||
semanticContainer
|
semanticContainer
|
||||||
? param->ns.QualifiedName(semanticContainer, def.short_name)
|
? param->ns.QualifiedName(semanticContainer, def.short_name)
|
||||||
: def.short_name;
|
: def.short_name;
|
||||||
if (semanticContainer && semanticContainer->cursor.kind == CXCursor_EnumDecl)
|
if (semanticContainer && semanticContainer->cursor.kind == CXCursor_EnumDecl)
|
||||||
def.detailed_name = std::move(qualified_name);
|
def.detailed_name = std::move(qualified_name);
|
||||||
else {
|
else {
|
||||||
@ -463,8 +463,7 @@ void OnIndexReference_Function(IndexFile* db,
|
|||||||
|
|
||||||
AddFuncRef(&caller->def.callees,
|
AddFuncRef(&caller->def.callees,
|
||||||
IndexFuncRef(called->id, loc, is_implicit));
|
IndexFuncRef(called->id, loc, is_implicit));
|
||||||
AddFuncRef(&called->callers,
|
AddFuncRef(&called->callers, IndexFuncRef(caller->id, loc, is_implicit));
|
||||||
IndexFuncRef(caller->id, loc, is_implicit));
|
|
||||||
} else {
|
} else {
|
||||||
AddFuncRef(&called->callers, IndexFuncRef(loc, is_implicit));
|
AddFuncRef(&called->callers, IndexFuncRef(loc, is_implicit));
|
||||||
}
|
}
|
||||||
@ -594,8 +593,8 @@ void OnIndexDiagnostic(CXClientData client_data,
|
|||||||
unsigned int line, column;
|
unsigned int line, column;
|
||||||
clang_getSpellingLocation(diag_loc, &file, &line, &column, nullptr);
|
clang_getSpellingLocation(diag_loc, &file, &line, &column, nullptr);
|
||||||
// Skip empty diagnostic.
|
// Skip empty diagnostic.
|
||||||
if(!line && !column)
|
if (!line && !column)
|
||||||
continue;
|
continue;
|
||||||
IndexFile* db = ConsumeFile(param, file);
|
IndexFile* db = ConsumeFile(param, file);
|
||||||
if (!db)
|
if (!db)
|
||||||
continue;
|
continue;
|
||||||
@ -1036,7 +1035,8 @@ ClangCursor::VisitResult VisitMacroDefinitionAndExpansions(ClangCursor cursor,
|
|||||||
var_def->def.kind = ClangSymbolKind::Macro;
|
var_def->def.kind = ClangSymbolKind::Macro;
|
||||||
var_def->def.comments = cursor.get_comments();
|
var_def->def.comments = cursor.get_comments();
|
||||||
var_def->def.definition_spelling = decl_loc_spelling;
|
var_def->def.definition_spelling = decl_loc_spelling;
|
||||||
var_def->def.definition_extent = ResolveCXSourceRange(cx_extent, nullptr);
|
var_def->def.definition_extent =
|
||||||
|
ResolveCXSourceRange(cx_extent, nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
@ -1312,9 +1312,9 @@ void OnIndexDeclaration(CXClientData client_data, const CXIdxDeclInfo* decl) {
|
|||||||
// We don't need to assign declaring type multiple times if this variable
|
// We don't need to assign declaring type multiple times if this variable
|
||||||
// has already been seen.
|
// has already been seen.
|
||||||
if (!decl->isRedeclaration) {
|
if (!decl->isRedeclaration) {
|
||||||
//optional<IndexTypeId> var_type =
|
// optional<IndexTypeId> var_type =
|
||||||
// ResolveToDeclarationType(db, decl_cursor);
|
// ResolveToDeclarationType(db, decl_cursor);
|
||||||
//if (var_type.has_value()) {
|
// if (var_type.has_value()) {
|
||||||
// // Don't treat enum definition variables as instantiations.
|
// // Don't treat enum definition variables as instantiations.
|
||||||
// bool is_enum_member =
|
// bool is_enum_member =
|
||||||
// decl->semanticContainer &&
|
// decl->semanticContainer &&
|
||||||
@ -1597,7 +1597,8 @@ void OnIndexDeclaration(CXClientData client_data, const CXIdxDeclInfo* decl) {
|
|||||||
decl->lexicalContainer);
|
decl->lexicalContainer);
|
||||||
optional<IndexTypeId> parent_type_id =
|
optional<IndexTypeId> parent_type_id =
|
||||||
ResolveToDeclarationType(db, base_class->cursor);
|
ResolveToDeclarationType(db, base_class->cursor);
|
||||||
// type_def ptr could be invalidated by ResolveToDeclarationType and TemplateVisitor.
|
// type_def ptr could be invalidated by ResolveToDeclarationType and
|
||||||
|
// TemplateVisitor.
|
||||||
type = db->Resolve(type_id);
|
type = db->Resolve(type_id);
|
||||||
if (parent_type_id) {
|
if (parent_type_id) {
|
||||||
IndexType* parent_type_def = db->Resolve(parent_type_id.value());
|
IndexType* parent_type_def = db->Resolve(parent_type_id.value());
|
||||||
@ -1675,7 +1676,8 @@ void OnIndexReference(CXClientData client_data, const CXIdxEntityRefInfo* ref) {
|
|||||||
// definition, We use cursor extent (larger than spelling range) `e.x`. It
|
// definition, We use cursor extent (larger than spelling range) `e.x`. It
|
||||||
// would be better if we could restrict the ranges to `.x` or just `x`.
|
// would be better if we could restrict the ranges to `.x` or just `x`.
|
||||||
// Nevertheless, larger ranges are less specific, and should do no harm
|
// Nevertheless, larger ranges are less specific, and should do no harm
|
||||||
// because they will be overriden by more specific variable references `e`.
|
// because they will be overriden by more specific variable references
|
||||||
|
// `e`.
|
||||||
Range loc = ref->cursor.kind == CXCursor_MemberRefExpr &&
|
Range loc = ref->cursor.kind == CXCursor_MemberRefExpr &&
|
||||||
ref_cursor.get_spelling().empty()
|
ref_cursor.get_spelling().empty()
|
||||||
? ref_cursor.get_extent()
|
? ref_cursor.get_extent()
|
||||||
@ -1750,17 +1752,17 @@ void OnIndexReference(CXClientData client_data, const CXIdxEntityRefInfo* ref) {
|
|||||||
!CursorSpellingContainsString(ref->cursor, param->tu->cx_tu,
|
!CursorSpellingContainsString(ref->cursor, param->tu->cx_tu,
|
||||||
called->def.short_name)));
|
called->def.short_name)));
|
||||||
|
|
||||||
// Extents have larger ranges and thus less specific, and will be overriden
|
// Extents have larger ranges and thus less specific, and will be
|
||||||
// by other functions if exist.
|
// overriden by other functions if exist.
|
||||||
//
|
//
|
||||||
// Members of non-concrete template types do not have useful spelling ranges.
|
// Members of non-concrete template types do not have useful spelling
|
||||||
// See the comment above for the CXIdxEntity_Field case.
|
// ranges. See the comment above for the CXIdxEntity_Field case.
|
||||||
if (is_implicit || (ref->cursor.kind == CXCursor_MemberRefExpr &&
|
if (is_implicit || (ref->cursor.kind == CXCursor_MemberRefExpr &&
|
||||||
ref_cursor.get_spelling().empty()))
|
ref_cursor.get_spelling().empty()))
|
||||||
loc = ref_cursor.get_extent();
|
loc = ref_cursor.get_extent();
|
||||||
|
|
||||||
OnIndexReference_Function(db, loc, ref->container->cursor,
|
OnIndexReference_Function(db, loc, ref->container->cursor, called_id,
|
||||||
called_id, called, is_implicit);
|
called, is_implicit);
|
||||||
|
|
||||||
// Checks if |str| starts with |start|. Ignores case.
|
// Checks if |str| starts with |start|. Ignores case.
|
||||||
auto str_begin = [](const char* start, const char* str) {
|
auto str_begin = [](const char* start, const char* str) {
|
||||||
@ -1800,8 +1802,7 @@ void OnIndexReference(CXClientData client_data, const CXIdxEntityRefInfo* ref) {
|
|||||||
param->ctors.TryFindConstructorUsr(ctor_type_usr, call_type_desc);
|
param->ctors.TryFindConstructorUsr(ctor_type_usr, call_type_desc);
|
||||||
if (ctor_usr) {
|
if (ctor_usr) {
|
||||||
IndexFunc* ctor = db->Resolve(db->ToFuncId(*ctor_usr));
|
IndexFunc* ctor = db->Resolve(db->ToFuncId(*ctor_usr));
|
||||||
AddFuncRef(&ctor->callers,
|
AddFuncRef(&ctor->callers, IndexFuncRef(loc, true /*is_implicit*/));
|
||||||
IndexFuncRef(loc, true /*is_implicit*/));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1837,21 +1838,26 @@ void OnIndexReference(CXClientData client_data, const CXIdxEntityRefInfo* ref) {
|
|||||||
// Foo f;
|
// Foo f;
|
||||||
// }
|
// }
|
||||||
//
|
//
|
||||||
UniqueAdd(referenced->uses, ClangCursor(ref->cursor).get_spelling_range());
|
UniqueAdd(referenced->uses,
|
||||||
|
ClangCursor(ref->cursor).get_spelling_range());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
default:
|
default:
|
||||||
std::cerr << "!! Unhandled indexEntityReference: " << cursor.ToString()
|
std::cerr
|
||||||
<< " at " << ClangCursor(ref->cursor).get_spelling_range().start.ToString()
|
<< "!! Unhandled indexEntityReference: " << cursor.ToString()
|
||||||
<< std::endl;
|
<< " at "
|
||||||
|
<< ClangCursor(ref->cursor).get_spelling_range().start.ToString()
|
||||||
|
<< std::endl;
|
||||||
std::cerr << " ref->referencedEntity->kind = "
|
std::cerr << " ref->referencedEntity->kind = "
|
||||||
<< ref->referencedEntity->kind << std::endl;
|
<< ref->referencedEntity->kind << std::endl;
|
||||||
if (ref->parentEntity)
|
if (ref->parentEntity)
|
||||||
std::cerr << " ref->parentEntity->kind = "
|
std::cerr << " ref->parentEntity->kind = "
|
||||||
<< ref->parentEntity->kind << std::endl;
|
<< ref->parentEntity->kind << std::endl;
|
||||||
std::cerr << " ref->loc = "
|
std::cerr
|
||||||
<< ClangCursor(ref->cursor).get_spelling_range().start.ToString() << std::endl;
|
<< " ref->loc = "
|
||||||
|
<< ClangCursor(ref->cursor).get_spelling_range().start.ToString()
|
||||||
|
<< std::endl;
|
||||||
std::cerr << " ref->kind = " << ref->kind << std::endl;
|
std::cerr << " ref->kind = " << ref->kind << std::endl;
|
||||||
if (ref->parentEntity)
|
if (ref->parentEntity)
|
||||||
std::cerr << " parentEntity = "
|
std::cerr << " parentEntity = "
|
||||||
@ -2003,7 +2009,7 @@ std::vector<std::unique_ptr<IndexFile>> ParseWithTu(
|
|||||||
std::unordered_map<std::string, int> inc_to_line;
|
std::unordered_map<std::string, int> inc_to_line;
|
||||||
// TODO
|
// TODO
|
||||||
if (param.primary_file)
|
if (param.primary_file)
|
||||||
for (auto &inc : param.primary_file->includes)
|
for (auto& inc : param.primary_file->includes)
|
||||||
inc_to_line[inc.resolved_path] = inc.line;
|
inc_to_line[inc.resolved_path] = inc.line;
|
||||||
|
|
||||||
auto result = param.file_consumer->TakeLocalState();
|
auto result = param.file_consumer->TakeLocalState();
|
||||||
@ -2080,12 +2086,14 @@ void ClangSanityCheck() {
|
|||||||
void* reserved) -> CXIdxClientFile {
|
void* reserved) -> CXIdxClientFile {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
};
|
};
|
||||||
callback.ppIncludedFile = [](
|
callback.ppIncludedFile =
|
||||||
CXClientData client_data,
|
[](CXClientData client_data,
|
||||||
const CXIdxIncludedFileInfo* file) -> CXIdxClientFile { return nullptr; };
|
const CXIdxIncludedFileInfo* file) -> CXIdxClientFile {
|
||||||
callback.importedASTFile = [](
|
return nullptr;
|
||||||
CXClientData client_data,
|
};
|
||||||
const CXIdxImportedASTFileInfo*) -> CXIdxClientASTFile {
|
callback.importedASTFile =
|
||||||
|
[](CXClientData client_data,
|
||||||
|
const CXIdxImportedASTFileInfo*) -> CXIdxClientASTFile {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
};
|
};
|
||||||
callback.startedTranslationUnit = [](CXClientData client_data,
|
callback.startedTranslationUnit = [](CXClientData client_data,
|
||||||
|
@ -112,7 +112,8 @@ enum class ClangSymbolKind : uint8_t {
|
|||||||
Parameter = 25,
|
Parameter = 25,
|
||||||
Using,
|
Using,
|
||||||
};
|
};
|
||||||
MAKE_REFLECT_TYPE_PROXY(ClangSymbolKind, std::underlying_type<ClangSymbolKind>::type);
|
MAKE_REFLECT_TYPE_PROXY(ClangSymbolKind,
|
||||||
|
std::underlying_type<ClangSymbolKind>::type);
|
||||||
|
|
||||||
struct IndexFuncRef {
|
struct IndexFuncRef {
|
||||||
// NOTE: id can be -1 if the function call is not coming from a function.
|
// NOTE: id can be -1 if the function call is not coming from a function.
|
||||||
|
@ -458,7 +458,6 @@ enum class lsDocumentHighlightKind {
|
|||||||
};
|
};
|
||||||
MAKE_REFLECT_TYPE_PROXY(lsDocumentHighlightKind, int);
|
MAKE_REFLECT_TYPE_PROXY(lsDocumentHighlightKind, int);
|
||||||
|
|
||||||
|
|
||||||
struct lsFormattingOptions {
|
struct lsFormattingOptions {
|
||||||
// Size of a tab in spaces.
|
// Size of a tab in spaces.
|
||||||
int tabSize;
|
int tabSize;
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#include "match.h"
|
#include "match.h"
|
||||||
|
|
||||||
#include "queue_manager.h"
|
|
||||||
#include "language_server_api.h"
|
#include "language_server_api.h"
|
||||||
|
#include "queue_manager.h"
|
||||||
|
|
||||||
#include <doctest/doctest.h>
|
#include <doctest/doctest.h>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
@ -22,11 +22,10 @@ optional<Matcher> Matcher::Create(const std::string& search) {
|
|||||||
Matcher m;
|
Matcher m;
|
||||||
m.regex_string = search;
|
m.regex_string = search;
|
||||||
m.regex = std::regex(
|
m.regex = std::regex(
|
||||||
search,
|
search, std::regex_constants::ECMAScript | std::regex_constants::icase |
|
||||||
std::regex_constants::ECMAScript | std::regex_constants::icase |
|
std::regex_constants::optimize
|
||||||
std::regex_constants::optimize
|
|
||||||
// std::regex_constants::nosubs
|
// std::regex_constants::nosubs
|
||||||
);
|
);
|
||||||
return m;
|
return m;
|
||||||
} catch (std::exception e) {
|
} catch (std::exception e) {
|
||||||
Out_ShowLogMessage out;
|
Out_ShowLogMessage out;
|
||||||
|
@ -21,7 +21,7 @@ struct ScanLineEvent {
|
|||||||
return !(pos == other.pos) ? pos < other.pos : other.end_pos < end_pos;
|
return !(pos == other.pos) ? pos < other.pos : other.end_pos < end_pos;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
} // namespace
|
||||||
|
|
||||||
MessageHandler::MessageHandler() {
|
MessageHandler::MessageHandler() {
|
||||||
// Dynamically allocate |message_handlers|, otherwise there will be static
|
// Dynamically allocate |message_handlers|, otherwise there will be static
|
||||||
@ -35,7 +35,7 @@ MessageHandler::MessageHandler() {
|
|||||||
std::vector<MessageHandler*>* MessageHandler::message_handlers = nullptr;
|
std::vector<MessageHandler*>* MessageHandler::message_handlers = nullptr;
|
||||||
|
|
||||||
bool FindFileOrFail(QueryDatabase* db,
|
bool FindFileOrFail(QueryDatabase* db,
|
||||||
const Project *project,
|
const Project* project,
|
||||||
optional<lsRequestId> id,
|
optional<lsRequestId> id,
|
||||||
const std::string& absolute_path,
|
const std::string& absolute_path,
|
||||||
QueryFile** out_query_file,
|
QueryFile** out_query_file,
|
||||||
@ -143,14 +143,14 @@ void EmitSemanticHighlighting(QueryDatabase* db,
|
|||||||
auto concise_name = detailed_name.substr(0, detailed_name.find('<'));
|
auto concise_name = detailed_name.substr(0, detailed_name.find('<'));
|
||||||
if (sym.loc.range.start.line <= working_file->index_lines.size()) {
|
if (sym.loc.range.start.line <= working_file->index_lines.size()) {
|
||||||
std::string& line =
|
std::string& line =
|
||||||
working_file->index_lines[sym.loc.range.start.line - 1];
|
working_file->index_lines[sym.loc.range.start.line - 1];
|
||||||
auto pos = line.find(concise_name);
|
auto pos = line.find(concise_name);
|
||||||
sym.loc.range.end.line = sym.loc.range.start.line;
|
sym.loc.range.end.line = sym.loc.range.start.line;
|
||||||
if (pos == std::string::npos)
|
if (pos == std::string::npos)
|
||||||
sym.loc.range.end.column = sym.loc.range.start.column;
|
sym.loc.range.end.column = sym.loc.range.start.column;
|
||||||
else
|
else
|
||||||
sym.loc.range.end.column =
|
sym.loc.range.end.column =
|
||||||
sym.loc.range.start.column + concise_name.size();
|
sym.loc.range.start.column + concise_name.size();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -209,8 +209,8 @@ void EmitSemanticHighlighting(QueryDatabase* db,
|
|||||||
for (auto& entry : grouped_symbols) {
|
for (auto& entry : grouped_symbols) {
|
||||||
Out_CqueryPublishSemanticHighlighting::Symbol& symbol = entry.second;
|
Out_CqueryPublishSemanticHighlighting::Symbol& symbol = entry.second;
|
||||||
for (auto& loc : symbol.ranges) {
|
for (auto& loc : symbol.ranges) {
|
||||||
// For ranges sharing the same start point, the one with leftmost end point
|
// For ranges sharing the same start point, the one with leftmost end
|
||||||
// comes first.
|
// point comes first.
|
||||||
events.push_back({loc.start, loc.end, id, &symbol});
|
events.push_back({loc.start, loc.end, id, &symbol});
|
||||||
// For ranges sharing the same end point, their relative order does not
|
// For ranges sharing the same end point, their relative order does not
|
||||||
// matter, therefore we arbitrarily assign loc.end to them. We use
|
// matter, therefore we arbitrarily assign loc.end to them. We use
|
||||||
@ -231,9 +231,11 @@ void EmitSemanticHighlighting(QueryDatabase* db,
|
|||||||
// the ealier. The order of [a0, b) [a1, b) does not matter.
|
// the ealier. The order of [a0, b) [a1, b) does not matter.
|
||||||
// The order of [a, b) [b, c) does not as long as we do not emit empty
|
// The order of [a, b) [b, c) does not as long as we do not emit empty
|
||||||
// ranges.
|
// ranges.
|
||||||
// Attribute range [events[i-1].pos, events[i].pos) to events[top-1].symbol .
|
// Attribute range [events[i-1].pos, events[i].pos) to events[top-1].symbol
|
||||||
|
// .
|
||||||
if (top && !(events[i - 1].pos == events[i].pos))
|
if (top && !(events[i - 1].pos == events[i].pos))
|
||||||
events[top - 1].symbol->ranges.emplace_back(events[i - 1].pos, events[i].pos);
|
events[top - 1].symbol->ranges.emplace_back(events[i - 1].pos,
|
||||||
|
events[i].pos);
|
||||||
if (events[i].id >= 0)
|
if (events[i].id >= 0)
|
||||||
events[top++] = events[i];
|
events[top++] = events[i];
|
||||||
else
|
else
|
||||||
|
@ -178,8 +178,7 @@ struct InitializeHandler : BaseMessageHandler<Ipc_InitializeRequest> {
|
|||||||
Timer time;
|
Timer time;
|
||||||
|
|
||||||
// Open up / load the project.
|
// Open up / load the project.
|
||||||
project->Load(config,
|
project->Load(config, config->extraClangArguments,
|
||||||
config->extraClangArguments,
|
|
||||||
config->compilationDatabaseDirectory, project_path,
|
config->compilationDatabaseDirectory, project_path,
|
||||||
config->resourceDirectory);
|
config->resourceDirectory);
|
||||||
time.ResetAndPrint("[perf] Loaded compilation entries (" +
|
time.ResetAndPrint("[perf] Loaded compilation entries (" +
|
||||||
|
@ -8,9 +8,8 @@ struct Ipc_Shutdown : public IpcMessage<Ipc_Shutdown> {
|
|||||||
MAKE_REFLECT_EMPTY_STRUCT(Ipc_Shutdown);
|
MAKE_REFLECT_EMPTY_STRUCT(Ipc_Shutdown);
|
||||||
REGISTER_IPC_MESSAGE(Ipc_Shutdown);
|
REGISTER_IPC_MESSAGE(Ipc_Shutdown);
|
||||||
|
|
||||||
struct Out_Shutdown
|
struct Out_Shutdown : public lsOutMessage<Out_Shutdown> {
|
||||||
: public lsOutMessage<Out_Shutdown> {
|
lsRequestId id; // defaults to std::monostate (null)
|
||||||
lsRequestId id; // defaults to std::monostate (null)
|
|
||||||
std::monostate result; // null
|
std::monostate result; // null
|
||||||
};
|
};
|
||||||
MAKE_REFLECT_STRUCT(Out_Shutdown, jsonrpc, id, result);
|
MAKE_REFLECT_STRUCT(Out_Shutdown, jsonrpc, id, result);
|
||||||
|
@ -249,7 +249,8 @@ struct WorkspaceSymbolHandler : BaseMessageHandler<Ipc_WorkspaceSymbol> {
|
|||||||
longest = std::max(longest, int(db->short_names[i].size()));
|
longest = std::max(longest, int(db->short_names[i].size()));
|
||||||
|
|
||||||
std::vector<int> score(longest); // score for each position
|
std::vector<int> score(longest); // score for each position
|
||||||
std::vector<int> dp(longest); // dp[i]: maximum value by aligning pattern to str[0..i]
|
std::vector<int> dp(
|
||||||
|
longest); // dp[i]: maximum value by aligning pattern to str[0..i]
|
||||||
std::vector<std::pair<int, int>> permutation(result_indices.size());
|
std::vector<std::pair<int, int>> permutation(result_indices.size());
|
||||||
for (int i = 0; i < int(result_indices.size()); i++) {
|
for (int i = 0; i < int(result_indices.size()); i++) {
|
||||||
permutation[i] = {
|
permutation[i] = {
|
||||||
@ -260,15 +261,14 @@ struct WorkspaceSymbolHandler : BaseMessageHandler<Ipc_WorkspaceSymbol> {
|
|||||||
std::greater<std::pair<int, int>>());
|
std::greater<std::pair<int, int>>());
|
||||||
out.result.reserve(result_indices.size());
|
out.result.reserve(result_indices.size());
|
||||||
for (int i = 0; i < int(result_indices.size()); i++)
|
for (int i = 0; i < int(result_indices.size()); i++)
|
||||||
out.result.push_back(std::move(unsorted_results[permutation[i].second]));
|
out.result.push_back(
|
||||||
}
|
std::move(unsorted_results[permutation[i].second]));
|
||||||
else {
|
} else {
|
||||||
out.result.reserve(unsorted_results.size());
|
out.result.reserve(unsorted_results.size());
|
||||||
for (const auto& entry : unsorted_results)
|
for (const auto& entry : unsorted_results)
|
||||||
out.result.push_back(std::move(entry));
|
out.result.push_back(std::move(entry));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
LOG_S(INFO) << "[querydb] Found " << out.result.size()
|
LOG_S(INFO) << "[querydb] Found " << out.result.size()
|
||||||
<< " results for query " << query;
|
<< " results for query " << query;
|
||||||
QueueManager::WriteStdout(IpcId::WorkspaceSymbol, out);
|
QueueManager::WriteStdout(IpcId::WorkspaceSymbol, out);
|
||||||
|
@ -7,10 +7,10 @@
|
|||||||
|
|
||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
#if defined(__FreeBSD__)
|
#if defined(__FreeBSD__)
|
||||||
# include <pthread_np.h>
|
#include <pthread_np.h>
|
||||||
# include <sys/thr.h>
|
#include <sys/thr.h>
|
||||||
#elif defined(__OpenBSD__)
|
#elif defined(__OpenBSD__)
|
||||||
# include <pthread_np.h>
|
#include <pthread_np.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
@ -130,7 +130,10 @@ std::string GetExecutablePath() {
|
|||||||
return result;
|
return result;
|
||||||
#elif defined(__FreeBSD__)
|
#elif defined(__FreeBSD__)
|
||||||
static const int name[] = {
|
static const int name[] = {
|
||||||
CTL_KERN, KERN_PROC, KERN_PROC_PATHNAME, -1,
|
CTL_KERN,
|
||||||
|
KERN_PROC,
|
||||||
|
KERN_PROC_PATHNAME,
|
||||||
|
-1,
|
||||||
};
|
};
|
||||||
char path[MAXPATHLEN];
|
char path[MAXPATHLEN];
|
||||||
size_t len = sizeof(path);
|
size_t len = sizeof(path);
|
||||||
@ -139,7 +142,7 @@ std::string GetExecutablePath() {
|
|||||||
return std::string(path);
|
return std::string(path);
|
||||||
#else
|
#else
|
||||||
char buffer[PATH_MAX] = {0};
|
char buffer[PATH_MAX] = {0};
|
||||||
if(-1 == readlink("/proc/self/exe", buffer, PATH_MAX))
|
if (-1 == readlink("/proc/self/exe", buffer, PATH_MAX))
|
||||||
return "";
|
return "";
|
||||||
return buffer;
|
return buffer;
|
||||||
#endif
|
#endif
|
||||||
|
@ -147,7 +147,6 @@ bool RunObjectiveCIndexTests() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// TODO Wait for debugger to attach
|
// TODO Wait for debugger to attach
|
||||||
void TraceMe() {
|
void TraceMe() {}
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -95,7 +95,6 @@ Project::Entry GetCompilationEntryFromCompileCommandEntry(
|
|||||||
Config* init_opts,
|
Config* init_opts,
|
||||||
ProjectConfig* config,
|
ProjectConfig* config,
|
||||||
const CompileCommandsEntry& entry) {
|
const CompileCommandsEntry& entry) {
|
||||||
|
|
||||||
auto cleanup_maybe_relative_path = [&](const std::string& path) {
|
auto cleanup_maybe_relative_path = [&](const std::string& path) {
|
||||||
// TODO/FIXME: Normalization will fail for paths that do not exist. Should
|
// TODO/FIXME: Normalization will fail for paths that do not exist. Should
|
||||||
// it return an optional<std::string>?
|
// it return an optional<std::string>?
|
||||||
@ -246,14 +245,16 @@ Project::Entry GetCompilationEntryFromCompileCommandEntry(
|
|||||||
|
|
||||||
// Using -fparse-all-comments enables documententation in the indexer and in
|
// Using -fparse-all-comments enables documententation in the indexer and in
|
||||||
// code completion.
|
// code completion.
|
||||||
if (init_opts->enableComments > 1 && !AnyStartsWith(result.args, "-fparse-all-comments")) {
|
if (init_opts->enableComments > 1 &&
|
||||||
|
!AnyStartsWith(result.args, "-fparse-all-comments")) {
|
||||||
result.args.push_back("-fparse-all-comments");
|
result.args.push_back("-fparse-all-comments");
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<Project::Entry> LoadFromDirectoryListing(Config* init_opts, ProjectConfig* config) {
|
std::vector<Project::Entry> LoadFromDirectoryListing(Config* init_opts,
|
||||||
|
ProjectConfig* config) {
|
||||||
std::vector<Project::Entry> result;
|
std::vector<Project::Entry> result;
|
||||||
|
|
||||||
std::vector<std::string> args;
|
std::vector<std::string> args;
|
||||||
@ -281,7 +282,8 @@ std::vector<Project::Entry> LoadFromDirectoryListing(Config* init_opts, ProjectC
|
|||||||
e.file = file;
|
e.file = file;
|
||||||
e.args = args;
|
e.args = args;
|
||||||
e.args.push_back(e.file);
|
e.args.push_back(e.file);
|
||||||
result.push_back(GetCompilationEntryFromCompileCommandEntry(init_opts, config, e));
|
result.push_back(
|
||||||
|
GetCompilationEntryFromCompileCommandEntry(init_opts, config, e));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -351,7 +353,8 @@ std::vector<Project::Entry> LoadCompilationEntriesFromDirectory(
|
|||||||
absolute_filename = directory + "/" + relative_filename;
|
absolute_filename = directory + "/" + relative_filename;
|
||||||
entry.file = NormalizePathWithTestOptOut(absolute_filename);
|
entry.file = NormalizePathWithTestOptOut(absolute_filename);
|
||||||
|
|
||||||
result.push_back(GetCompilationEntryFromCompileCommandEntry(init_opts, config, entry));
|
result.push_back(
|
||||||
|
GetCompilationEntryFromCompileCommandEntry(init_opts, config, entry));
|
||||||
our_time.Pause();
|
our_time.Pause();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -416,8 +419,8 @@ void Project::Load(Config* init_opts,
|
|||||||
config.extra_flags = extra_flags;
|
config.extra_flags = extra_flags;
|
||||||
config.project_dir = root_directory;
|
config.project_dir = root_directory;
|
||||||
config.resource_dir = resource_directory;
|
config.resource_dir = resource_directory;
|
||||||
entries =
|
entries = LoadCompilationEntriesFromDirectory(init_opts, &config,
|
||||||
LoadCompilationEntriesFromDirectory(init_opts, &config, opt_compilation_db_dir);
|
opt_compilation_db_dir);
|
||||||
|
|
||||||
// Cleanup / postprocess include directories.
|
// Cleanup / postprocess include directories.
|
||||||
quote_include_directories.assign(config.quote_dirs.begin(),
|
quote_include_directories.assign(config.quote_dirs.begin(),
|
||||||
@ -545,12 +548,13 @@ TEST_SUITE("Project") {
|
|||||||
|
|
||||||
// FIXME: Fix this test.
|
// FIXME: Fix this test.
|
||||||
TEST_CASE("Path in args") {
|
TEST_CASE("Path in args") {
|
||||||
CheckFlags("/home/user", "/home/user/foo/bar.c",
|
CheckFlags(
|
||||||
/* raw */ {"cc", "-O0", "foo/bar.c"},
|
"/home/user", "/home/user/foo/bar.c",
|
||||||
/* expected */
|
/* raw */ {"cc", "-O0", "foo/bar.c"},
|
||||||
{"cc", "-working-directory", "/home/user", "-xc", "-std=gnu11",
|
/* expected */
|
||||||
"-O0", "&/home/user/foo/bar.c", "-resource-dir=/w/resource_dir/",
|
{"cc", "-working-directory", "/home/user", "-xc", "-std=gnu11", "-O0",
|
||||||
"-Wno-unknown-warning-option"});
|
"&/home/user/foo/bar.c", "-resource-dir=/w/resource_dir/",
|
||||||
|
"-Wno-unknown-warning-option"});
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_CASE("Implied binary") {
|
TEST_CASE("Implied binary") {
|
||||||
@ -907,7 +911,8 @@ TEST_SUITE("Project") {
|
|||||||
"debian_jessie_amd64-sysroot",
|
"debian_jessie_amd64-sysroot",
|
||||||
"-fno-exceptions",
|
"-fno-exceptions",
|
||||||
"-fvisibility-inlines-hidden",
|
"-fvisibility-inlines-hidden",
|
||||||
"&/w/c/s/out/Release/../../ash/login/ui/lock_screen_sanity_unittest.cc",
|
"&/w/c/s/out/Release/../../ash/login/ui/"
|
||||||
|
"lock_screen_sanity_unittest.cc",
|
||||||
"-resource-dir=/w/resource_dir/",
|
"-resource-dir=/w/resource_dir/",
|
||||||
"-Wno-unknown-warning-option"});
|
"-Wno-unknown-warning-option"});
|
||||||
}
|
}
|
||||||
|
@ -233,8 +233,8 @@ QueryFile::Def BuildFileDef(const IdMap& id_map, const IndexFile& indexed) {
|
|||||||
for (const IndexFuncRef& caller : func.callers) {
|
for (const IndexFuncRef& caller : func.callers) {
|
||||||
// Make ranges of implicit function calls larger (spanning one more column
|
// Make ranges of implicit function calls larger (spanning one more column
|
||||||
// to the left/right). This is hacky but useful. e.g.
|
// to the left/right). This is hacky but useful. e.g.
|
||||||
// textDocument/definition on the space/semicolon in `A a;` or `return 42;`
|
// textDocument/definition on the space/semicolon in `A a;` or `return
|
||||||
// will take you to the constructor.
|
// 42;` will take you to the constructor.
|
||||||
Range range = caller.loc;
|
Range range = caller.loc;
|
||||||
if (caller.is_implicit) {
|
if (caller.is_implicit) {
|
||||||
if (range.start.column > 1)
|
if (range.start.column > 1)
|
||||||
|
@ -503,16 +503,17 @@ std::vector<SymbolRef> FindSymbolsAtLocation(WorkingFile* working_file,
|
|||||||
//
|
//
|
||||||
// Then order functions before other types, which makes goto definition work
|
// Then order functions before other types, which makes goto definition work
|
||||||
// better on constructors.
|
// better on constructors.
|
||||||
std::sort(symbols.begin(), symbols.end(), [](const SymbolRef& a,
|
std::sort(symbols.begin(), symbols.end(),
|
||||||
const SymbolRef& b) {
|
[](const SymbolRef& a, const SymbolRef& b) {
|
||||||
int a_size = ComputeRangeSize(a.loc.range);
|
int a_size = ComputeRangeSize(a.loc.range);
|
||||||
int b_size = ComputeRangeSize(b.loc.range);
|
int b_size = ComputeRangeSize(b.loc.range);
|
||||||
|
|
||||||
if (a_size != b_size)
|
if (a_size != b_size)
|
||||||
return a_size < b_size;
|
return a_size < b_size;
|
||||||
// operator> orders Var/Func in front of orders.
|
// operator> orders Var/Func in front of orders.
|
||||||
return static_cast<int>(a.idx.kind) > static_cast<int>(b.idx.kind);
|
return static_cast<int>(a.idx.kind) >
|
||||||
});
|
static_cast<int>(b.idx.kind);
|
||||||
|
});
|
||||||
|
|
||||||
return symbols;
|
return symbols;
|
||||||
}
|
}
|
||||||
|
@ -226,7 +226,6 @@ void Reflect(Writer& visitor, SerializeFormat& value) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
std::string Serialize(SerializeFormat format, IndexFile& file) {
|
std::string Serialize(SerializeFormat format, IndexFile& file) {
|
||||||
|
|
||||||
switch (format) {
|
switch (format) {
|
||||||
case SerializeFormat::Json: {
|
case SerializeFormat::Json: {
|
||||||
rapidjson::StringBuffer output;
|
rapidjson::StringBuffer output;
|
||||||
@ -261,8 +260,8 @@ std::unique_ptr<IndexFile> Deserialize(SerializeFormat format,
|
|||||||
if (reader.HasParseError())
|
if (reader.HasParseError())
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
||||||
// Do not deserialize a document with a bad version. Doing so could cause a
|
// Do not deserialize a document with a bad version. Doing so could cause
|
||||||
// crash because the file format may have changed.
|
// a crash because the file format may have changed.
|
||||||
if (expected_version) {
|
if (expected_version) {
|
||||||
auto actual_version = reader.FindMember("version");
|
auto actual_version = reader.FindMember("version");
|
||||||
if (actual_version == reader.MemberEnd() ||
|
if (actual_version == reader.MemberEnd() ||
|
||||||
@ -291,7 +290,8 @@ std::unique_ptr<IndexFile> Deserialize(SerializeFormat format,
|
|||||||
if (file->version != expected_version)
|
if (file->version != expected_version)
|
||||||
return nullptr;
|
return nullptr;
|
||||||
} catch (msgpack::unpack_error& ex) {
|
} catch (msgpack::unpack_error& ex) {
|
||||||
LOG_S(ERROR) << "msgpack::unpack_err for '" << path << "' " << ex.what();
|
LOG_S(ERROR) << "msgpack::unpack_err for '" << path << "' "
|
||||||
|
<< ex.what();
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -15,12 +15,12 @@ class Reader {
|
|||||||
virtual ~Reader() {}
|
virtual ~Reader() {}
|
||||||
virtual SerializeFormat Format() const = 0;
|
virtual SerializeFormat Format() const = 0;
|
||||||
|
|
||||||
//virtual bool IsBool() = 0;
|
// virtual bool IsBool() = 0;
|
||||||
virtual bool IsNull() = 0;
|
virtual bool IsNull() = 0;
|
||||||
virtual bool IsArray() = 0;
|
virtual bool IsArray() = 0;
|
||||||
virtual bool IsInt() = 0;
|
virtual bool IsInt() = 0;
|
||||||
//virtual bool IsInt64() = 0;
|
// virtual bool IsInt64() = 0;
|
||||||
//virtual bool IsUint64() = 0;
|
// virtual bool IsUint64() = 0;
|
||||||
virtual bool IsString() = 0;
|
virtual bool IsString() = 0;
|
||||||
|
|
||||||
virtual void GetNull() = 0;
|
virtual void GetNull() = 0;
|
||||||
@ -60,12 +60,12 @@ class Writer {
|
|||||||
|
|
||||||
struct IndexFile;
|
struct IndexFile;
|
||||||
|
|
||||||
#define REFLECT_MEMBER_START() \
|
#define REFLECT_MEMBER_START() \
|
||||||
if (!ReflectMemberStart(visitor, value)) \
|
if (!ReflectMemberStart(visitor, value)) \
|
||||||
return
|
return
|
||||||
#define REFLECT_MEMBER_START1(value) \
|
#define REFLECT_MEMBER_START1(value) \
|
||||||
if (!ReflectMemberStart(visitor, value)) \
|
if (!ReflectMemberStart(visitor, value)) \
|
||||||
return
|
return
|
||||||
#define REFLECT_MEMBER_END() ReflectMemberEnd(visitor, value);
|
#define REFLECT_MEMBER_END() ReflectMemberEnd(visitor, value);
|
||||||
#define REFLECT_MEMBER_END1(value) ReflectMemberEnd(visitor, value);
|
#define REFLECT_MEMBER_END1(value) ReflectMemberEnd(visitor, value);
|
||||||
#define REFLECT_MEMBER(name) ReflectMember(visitor, #name, value.name)
|
#define REFLECT_MEMBER(name) ReflectMember(visitor, #name, value.name)
|
||||||
@ -106,11 +106,11 @@ struct IndexFile;
|
|||||||
|
|
||||||
// Reflects the struct so it is serialized as an array instead of an object.
|
// Reflects the struct so it is serialized as an array instead of an object.
|
||||||
// This currently only supports writers.
|
// This currently only supports writers.
|
||||||
#define MAKE_REFLECT_STRUCT_WRITER_AS_ARRAY(type, ...) \
|
#define MAKE_REFLECT_STRUCT_WRITER_AS_ARRAY(type, ...) \
|
||||||
inline void Reflect(Writer& visitor, type& value) { \
|
inline void Reflect(Writer& visitor, type& value) { \
|
||||||
visitor.StartArray(NUM_VA_ARGS(__VA_ARGS__)); \
|
visitor.StartArray(NUM_VA_ARGS(__VA_ARGS__)); \
|
||||||
MACRO_MAP(_MAPPABLE_REFLECT_ARRAY, __VA_ARGS__) \
|
MACRO_MAP(_MAPPABLE_REFLECT_ARRAY, __VA_ARGS__) \
|
||||||
visitor.EndArray(); \
|
visitor.EndArray(); \
|
||||||
}
|
}
|
||||||
|
|
||||||
// API:
|
// API:
|
||||||
@ -265,7 +265,6 @@ void ReflectMember(Writer& visitor, const char* name, std::string& value);
|
|||||||
|
|
||||||
// Reader:
|
// Reader:
|
||||||
|
|
||||||
|
|
||||||
inline void DefaultReflectMemberStart(Reader& visitor) {}
|
inline void DefaultReflectMemberStart(Reader& visitor) {}
|
||||||
template <typename T>
|
template <typename T>
|
||||||
bool ReflectMemberStart(Reader& visitor, T& value) {
|
bool ReflectMemberStart(Reader& visitor, T& value) {
|
||||||
|
@ -12,12 +12,12 @@ class JsonReader : public Reader {
|
|||||||
JsonReader(rapidjson::GenericValue<rapidjson::UTF8<>>* m) : m_(m) {}
|
JsonReader(rapidjson::GenericValue<rapidjson::UTF8<>>* m) : m_(m) {}
|
||||||
SerializeFormat Format() const override { return SerializeFormat::Json; }
|
SerializeFormat Format() const override { return SerializeFormat::Json; }
|
||||||
|
|
||||||
//bool IsBool() override { return m_->IsBool(); }
|
// bool IsBool() override { return m_->IsBool(); }
|
||||||
bool IsNull() override { return m_->IsNull(); }
|
bool IsNull() override { return m_->IsNull(); }
|
||||||
bool IsArray() override { return m_->IsArray(); }
|
bool IsArray() override { return m_->IsArray(); }
|
||||||
bool IsInt() override { return m_->IsInt(); }
|
bool IsInt() override { return m_->IsInt(); }
|
||||||
//bool IsInt64() override { return m_->IsInt64(); }
|
// bool IsInt64() override { return m_->IsInt64(); }
|
||||||
//bool IsUint64() override { return m_->IsUint64(); }
|
// bool IsUint64() override { return m_->IsUint64(); }
|
||||||
bool IsString() override { return m_->IsString(); }
|
bool IsString() override { return m_->IsString(); }
|
||||||
|
|
||||||
void GetNull() override {}
|
void GetNull() override {}
|
||||||
@ -43,7 +43,8 @@ class JsonReader : public Reader {
|
|||||||
|
|
||||||
void DoMember(const char* name, std::function<void(Reader&)> fn) override {
|
void DoMember(const char* name, std::function<void(Reader&)> fn) override {
|
||||||
if (m_->GetType() != rapidjson::Type::kObjectType)
|
if (m_->GetType() != rapidjson::Type::kObjectType)
|
||||||
return; // FIXME: signal an error that object was not deserialized correctly?
|
return; // FIXME: signal an error that object was not deserialized
|
||||||
|
// correctly?
|
||||||
|
|
||||||
auto it = m_->FindMember(name);
|
auto it = m_->FindMember(name);
|
||||||
if (it != m_->MemberEnd()) {
|
if (it != m_->MemberEnd()) {
|
||||||
|
@ -17,7 +17,9 @@ class MessagePackReader : public Reader {
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
MessagePackReader(msgpack::unpacker* pk) : pk_(pk) { pk->next(oh_); }
|
MessagePackReader(msgpack::unpacker* pk) : pk_(pk) { pk->next(oh_); }
|
||||||
SerializeFormat Format() const override { return SerializeFormat::MessagePack; }
|
SerializeFormat Format() const override {
|
||||||
|
return SerializeFormat::MessagePack;
|
||||||
|
}
|
||||||
|
|
||||||
bool IsNull() override { return oh_.get().is_nil(); }
|
bool IsNull() override { return oh_.get().is_nil(); }
|
||||||
bool IsArray() override { return oh_.get().type == msgpack::type::ARRAY; }
|
bool IsArray() override { return oh_.get().type == msgpack::type::ARRAY; }
|
||||||
@ -36,9 +38,7 @@ class MessagePackReader : public Reader {
|
|||||||
std::string GetString() override { return Get<std::string>(); }
|
std::string GetString() override { return Get<std::string>(); }
|
||||||
|
|
||||||
bool HasMember(const char* x) override { return true; }
|
bool HasMember(const char* x) override { return true; }
|
||||||
std::unique_ptr<Reader> operator[](const char* x) override {
|
std::unique_ptr<Reader> operator[](const char* x) override { return {}; }
|
||||||
return {};
|
|
||||||
}
|
|
||||||
|
|
||||||
void IterArray(std::function<void(Reader&)> fn) override {
|
void IterArray(std::function<void(Reader&)> fn) override {
|
||||||
size_t n = Get<size_t>();
|
size_t n = Get<size_t>();
|
||||||
@ -56,7 +56,9 @@ class MessagePackWriter : public Writer {
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
MessagePackWriter(msgpack::packer<msgpack::sbuffer>* m) : m_(m) {}
|
MessagePackWriter(msgpack::packer<msgpack::sbuffer>* m) : m_(m) {}
|
||||||
SerializeFormat Format() const override { return SerializeFormat::MessagePack; }
|
SerializeFormat Format() const override {
|
||||||
|
return SerializeFormat::MessagePack;
|
||||||
|
}
|
||||||
|
|
||||||
void Null() override { m_->pack_nil(); }
|
void Null() override { m_->pack_nil(); }
|
||||||
void Bool(bool x) override { m_->pack(x); }
|
void Bool(bool x) override { m_->pack(x); }
|
||||||
@ -66,7 +68,9 @@ class MessagePackWriter : public Writer {
|
|||||||
void Double(double x) override { m_->pack(x); }
|
void Double(double x) override { m_->pack(x); }
|
||||||
void String(const char* x) override { m_->pack(x); }
|
void String(const char* x) override { m_->pack(x); }
|
||||||
// TODO Remove std::string
|
// TODO Remove std::string
|
||||||
void String(const char* x, size_t len) override { m_->pack(std::string(x, len)); }
|
void String(const char* x, size_t len) override {
|
||||||
|
m_->pack(std::string(x, len));
|
||||||
|
}
|
||||||
void StartArray(size_t n) override { m_->pack(n); }
|
void StartArray(size_t n) override { m_->pack(n); }
|
||||||
void EndArray() override {}
|
void EndArray() override {}
|
||||||
void StartObject() override {}
|
void StartObject() override {}
|
||||||
|
@ -240,7 +240,7 @@ bool RunIndexTests(const std::string& filter_path, bool enable_update) {
|
|||||||
std::cout << std::endl;
|
std::cout << std::endl;
|
||||||
if (enable_update) {
|
if (enable_update) {
|
||||||
std::cout
|
std::cout
|
||||||
<< "[Enter to continue - type u to update test, a to update all]";
|
<< "[Enter to continue - type u to update test, a to update all]";
|
||||||
char c = 'u';
|
char c = 'u';
|
||||||
if (!update_all) {
|
if (!update_all) {
|
||||||
c = (char)std::cin.get();
|
c = (char)std::cin.get();
|
||||||
|
@ -27,7 +27,7 @@ struct index_sequence {};
|
|||||||
|
|
||||||
template <size_t I, size_t... Is>
|
template <size_t I, size_t... Is>
|
||||||
struct make_index_sequence {
|
struct make_index_sequence {
|
||||||
using type = typename make_index_sequence<I-1, I-1, Is...>::type;
|
using type = typename make_index_sequence<I - 1, I - 1, Is...>::type;
|
||||||
};
|
};
|
||||||
|
|
||||||
template <size_t... Is>
|
template <size_t... Is>
|
||||||
@ -35,7 +35,7 @@ struct make_index_sequence<0, Is...> {
|
|||||||
using type = index_sequence<Is...>;
|
using type = index_sequence<Is...>;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
} // namespace
|
||||||
|
|
||||||
// std::lock accepts two or more arguments. We define an overload for one
|
// std::lock accepts two or more arguments. We define an overload for one
|
||||||
// argument.
|
// argument.
|
||||||
@ -44,16 +44,12 @@ template <typename Lockable>
|
|||||||
void lock(Lockable& l) {
|
void lock(Lockable& l) {
|
||||||
l.lock();
|
l.lock();
|
||||||
}
|
}
|
||||||
}
|
} // namespace std
|
||||||
|
|
||||||
template <typename... Queue>
|
template <typename... Queue>
|
||||||
struct MultiQueueLock {
|
struct MultiQueueLock {
|
||||||
MultiQueueLock(Queue... lockable) : tuple_{lockable...} {
|
MultiQueueLock(Queue... lockable) : tuple_{lockable...} { lock(); }
|
||||||
lock();
|
~MultiQueueLock() { unlock(); }
|
||||||
}
|
|
||||||
~MultiQueueLock() {
|
|
||||||
unlock();
|
|
||||||
}
|
|
||||||
void lock() {
|
void lock() {
|
||||||
lock_impl(typename make_index_sequence<sizeof...(Queue)>::type{});
|
lock_impl(typename make_index_sequence<sizeof...(Queue)>::type{});
|
||||||
}
|
}
|
||||||
|
@ -75,8 +75,7 @@ std::string GetFunctionSignature(IndexFile* db,
|
|||||||
|
|
||||||
// Second pass: insert argument names before each comma and closing paren.
|
// Second pass: insert argument names before each comma and closing paren.
|
||||||
int i = function_name_offset;
|
int i = function_name_offset;
|
||||||
std::string type_desc_with_names(type_desc.begin(),
|
std::string type_desc_with_names(type_desc.begin(), type_desc.begin() + i);
|
||||||
type_desc.begin() + i);
|
|
||||||
type_desc_with_names.append(function_name);
|
type_desc_with_names.append(function_name);
|
||||||
for (auto& arg : args) {
|
for (auto& arg : args) {
|
||||||
if (arg.first < 0) {
|
if (arg.first < 0) {
|
||||||
|
@ -149,7 +149,7 @@ static void GetFilesInFolderHelper(
|
|||||||
const std::function<void(const std::string&)>& handler) {
|
const std::function<void(const std::string&)>& handler) {
|
||||||
std::queue<std::pair<std::string, std::string>> q;
|
std::queue<std::pair<std::string, std::string>> q;
|
||||||
q.push(make_pair(folder, output_prefix));
|
q.push(make_pair(folder, output_prefix));
|
||||||
while(!q.empty()) {
|
while (!q.empty()) {
|
||||||
tinydir_dir dir;
|
tinydir_dir dir;
|
||||||
if (tinydir_open(&dir, q.front().first.c_str()) == -1) {
|
if (tinydir_open(&dir, q.front().first.c_str()) == -1) {
|
||||||
LOG_S(WARNING) << "Unable to open directory " << folder;
|
LOG_S(WARNING) << "Unable to open directory " << folder;
|
||||||
|
Loading…
Reference in New Issue
Block a user