From 17cac3d30ac7a800aaf0046f1c784da707ad034f Mon Sep 17 00:00:00 2001 From: Fangrui Song Date: Wed, 13 Dec 2017 00:22:02 -0800 Subject: [PATCH] [indexer] Change macro's IndexVar::def::detail_name to its approximate definition For `#define foo 3`, Before this commit, `detail_name` was `foo` (displayed for textDocument/hover reqeusts). It is now shown as `#define foo 3` --- src/indexer.cc | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/indexer.cc b/src/indexer.cc index 125c405c..c5c1c08b 100644 --- a/src/indexer.cc +++ b/src/indexer.cc @@ -923,13 +923,14 @@ ClangCursor::VisitResult VisitMacroDefinitionAndExpansions(ClangCursor cursor, UniqueAdd(var_def->uses, decl_loc_spelling); if (cursor.get_kind() == CXCursor_MacroDefinition) { + CXSourceRange cx_extent = clang_getCursorExtent(cursor.cx_cursor); var_def->def.short_name = cursor.get_display_name(); - var_def->def.detailed_name = var_def->def.short_name; var_def->def.is_local = false; var_def->def.is_macro = true; var_def->def.definition_spelling = decl_loc_spelling; - var_def->def.definition_extent = ResolveExtent(cursor.cx_cursor); - ; + var_def->def.definition_extent = Resolve(cx_extent, nullptr); + var_def->def.detailed_name = + "#define " + GetDocumentContentInRange(param->tu->cx_tu, cx_extent); } break;