Skip to content
This repository has been archived by the owner on Jul 30, 2020. It is now read-only.

Commit

Permalink
Disable variable PrettyPrint #if CINDEX_VERSION >= 47 and allow trunk…
Browse files Browse the repository at this point in the history
… libclang in tests
  • Loading branch information
MaskRay committed Feb 13, 2018
1 parent ff4ff86 commit 5540eb1
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
16 changes: 10 additions & 6 deletions src/indexer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -309,9 +309,13 @@ struct IndexParam {
print_policy = clang_getCursorPrintingPolicy(cursor);
clang_PrintingPolicy_setProperty(print_policy,
CXPrintingPolicy_TerseOutput, 1);
clang_PrintingPolicy_setProperty(print_policy,
CXPrintingPolicy_FullyQualifiedName, 1);
clang_PrintingPolicy_setProperty(print_policy,
CXPrintingPolicy_SuppressInitializers, 1);
print_policy_more = clang_getCursorPrintingPolicy(cursor);
clang_PrintingPolicy_setProperty(print_policy_more,
CXPrintingPolicy_FullyQualifiedName, 1);
clang_PrintingPolicy_setProperty(print_policy_more,
CXPrintingPolicy_TerseOutput, 1);
}
Expand Down Expand Up @@ -566,8 +570,9 @@ void SetVarDetail(IndexVar* var,
def.comments = cursor.get_comments();
def.storage = GetStorageClass(clang_Cursor_getStorageClass(cursor.cx_cursor));

// TODO how to make PrettyPrint'ed variable name qualified?
std::string qualified_name =
#if CINDEX_HAVE_PRETTY
#if 0 && CINDEX_HAVE_PRETTY
cursor.get_kind() != CXCursor_EnumConstantDecl
? param->PrettyPrintCursor(cursor.cx_cursor)
:
Expand All @@ -587,9 +592,8 @@ void SetVarDetail(IndexVar* var,
def.detailed_name = std::move(qualified_name);
def.hover = hover;
} else {
#if CINDEX_HAVE_PRETTY
def.detailed_name = param->PrettyPrintCursor(cursor.cx_cursor, false);
def.hover = std::move(qualified_name);
#if 0 && CINDEX_HAVE_PRETTY
//def.detailed_name = param->PrettyPrintCursor(cursor.cx_cursor, false);
#else
ConcatTypeAndName(type_name, qualified_name);
def.detailed_name = type_name;
Expand Down Expand Up @@ -1349,7 +1353,7 @@ ClangCursor::VisitResult TemplateVisitor(ClangCursor cursor,
SetUse(db, &ref_index->def.spell, ref_cursor.get_spelling_range(), parent, Role::Definition);
SetUse(db, &ref_index->def.extent, ref_cursor.get_extent(), parent, Role::None);
#if CINDEX_HAVE_PRETTY
ref_index->def.detailed_name = param->PrettyPrintCursor(cursor.cx_cursor);
ref_index->def.detailed_name = param->PrettyPrintCursor(ref_cursor.cx_cursor);
#else
ref_index->def.detailed_name = ref_cursor.get_spelling();
#endif
Expand Down Expand Up @@ -1377,7 +1381,7 @@ ClangCursor::VisitResult TemplateVisitor(ClangCursor cursor,
SetUse(db, &ref_index->def.spell, ref_cursor.get_spelling_range(), parent, Role::Definition);
SetUse(db, &ref_index->def.extent, ref_cursor.get_extent(), parent, Role::None);
#if CINDEX_HAVE_PRETTY
ref_index->def.detailed_name = param->PrettyPrintCursor(cursor.cx_cursor);
ref_index->def.detailed_name = param->PrettyPrintCursor(ref_cursor.cx_cursor);
#else
ref_index->def.detailed_name = ref_cursor.get_spelling();
#endif
Expand Down
3 changes: 2 additions & 1 deletion src/test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,8 @@ bool RunIndexTests(const std::string& filter_path, bool enable_update) {
// Index tests change based on the version of clang used.
static constexpr const char* kRequiredClangVersion =
"clang version 5.0.1 (tags/RELEASE_501/final)";
if (GetClangVersion() != kRequiredClangVersion) {
if (GetClangVersion() != kRequiredClangVersion &&
GetClangVersion().find("trunk") == std::string::npos) {
std::cerr << "Index tests must be run using clang version \""
<< kRequiredClangVersion << "\" (cquery is running with \""
<< GetClangVersion() << "\")" << std::endl;
Expand Down

0 comments on commit 5540eb1

Please sign in to comment.