Skip to content

Commit

Permalink
Include symbol name for references
Browse files Browse the repository at this point in the history
  • Loading branch information
jhanssen committed Feb 26, 2015
1 parent 53c8027 commit e1c04f3
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 4 deletions.
17 changes: 15 additions & 2 deletions src/ClangIndexer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,8 @@ static inline void tokenize(const char *buf, int start,
}
}

String ClangIndexer::addNamePermutations(const CXCursor &cursor, const Location &location, String type)
String ClangIndexer::addNamePermutations(const CXCursor &cursor, const Location &location,
String type, RTags::CursorType cursorType)
{
CXCursorKind kind = clang_getCursorKind(cursor);
const CXCursorKind originalKind = kind;
Expand Down Expand Up @@ -425,6 +426,16 @@ String ClangIndexer::addNamePermutations(const CXCursor &cursor, const Location
cutoff = pos;

String ret;
if (cursorType == RTags::Type_Reference) {
if (!type.isEmpty()) {
ret = type;
ret.append(buf + cutoff, sizeof(buf) - cutoff - 1);
} else {
ret.assign(buf + cutoff, sizeof(buf) - cutoff - 1);
}
return ret;
}

int templateStart, templateEnd, colonColonCount;
int colonColons[512];
::tokenize(buf, pos,
Expand Down Expand Up @@ -866,6 +877,8 @@ bool ClangIndexer::handleReference(const CXCursor &cursor, CXCursorKind kind,
c.definition = false;
c.kind = kind;
c.location = location;
c.symbolName = reffedCursorFound ? reffedCursor.symbolName : addNamePermutations(ref, refLoc, String(), RTags::Type_Reference);

if (isOperator) {
unsigned int start, end;
clang_getSpellingLocation(rangeStart, 0, 0, 0, &start);
Expand Down Expand Up @@ -1012,7 +1025,7 @@ bool ClangIndexer::handleCursor(const CXCursor &cursor, CXCursorKind kind, const
}
}

c.symbolName = addNamePermutations(cursor, location, typeOverride);
c.symbolName = addNamePermutations(cursor, location, typeOverride, RTags::Type_Cursor);
}

const CXSourceRange range = clang_getCursorExtent(cursor);
Expand Down
3 changes: 2 additions & 1 deletion src/ClangIndexer.h
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,8 @@ class ClangIndexer
return createLocation(clang_getRangeStart(range), blocked);
}
Location createLocation(const Path &file, unsigned int line, unsigned int col, bool *blocked = 0);
String addNamePermutations(const CXCursor &cursor, const Location &location, String typeOverride);
String addNamePermutations(const CXCursor &cursor, const Location &location,
String typeOverride, RTags::CursorType cursorType);

bool handleCursor(const CXCursor &cursor, CXCursorKind kind,
const Location &location, Symbol **cursorPtr = 0);
Expand Down
2 changes: 1 addition & 1 deletion src/RTags.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class Database;
class Project;
namespace RTags {

enum { DatabaseVersion = 56 };
enum { DatabaseVersion = 57 };

enum {
CompilationError = -1,
Expand Down

0 comments on commit e1c04f3

Please sign in to comment.