Skip to content

Commit

Permalink
This is a lot of work.
Browse files Browse the repository at this point in the history
  • Loading branch information
Andersbakken committed Jan 21, 2015
1 parent d7cc73f commit d4ea64b
Show file tree
Hide file tree
Showing 22 changed files with 127 additions and 677 deletions.
1 change: 0 additions & 1 deletion src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,6 @@ target_link_libraries(shared rct)
set(RTAGS_SOURCES
CompilerManager.cpp
CompletionThread.cpp
CursorInfo.cpp
CursorInfoJob.cpp
DependenciesJob.cpp
Diagnostic.cpp
Expand Down
45 changes: 45 additions & 0 deletions src/Cursor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,53 @@

#include "Cursor.h"
#include "RTags.h"
#include "RTagsClang.h"

uint16_t Cursor::targetsValue() const
{
return RTags::createTargetsValue(kind, isDefinition());
}


String Cursor::toString(unsigned cursorInfoFlags, unsigned keyFlags) const
{
String ret = String::format<1024>("SymbolName: %s\n"
"Kind: %s\n"
"Type: %s\n" // type
"SymbolLength: %u\n"
"%s" // range
"%s" // enumValue
"%s", // definition
symbolName.constData(),
kindSpelling().constData(),
RTags::eatString(clang_getTypeKindSpelling(type)).constData(),
symbolLength,
startLine != -1 ? String::format<32>("Range: %d:%d-%d:%d\n", startLine, startColumn, endLine, endColumn).constData() : "",
#if CINDEX_VERSION_MINOR > 1
kind == CXCursor_EnumConstantDecl ? String::format<32>("Enum Value: %lld\n", enumValue).constData() :
#endif
"",
isDefinition() ? "Definition\n" : "");

// if (!targets.isEmpty() && !(cursorInfoFlags & IgnoreTargets)) {
// ret.append("Targets:\n");
// for (auto tit = targets.begin(); tit != targets.end(); ++tit) {
// const Location &l = *tit;
// ret.append(String::format<128>(" %s\n", l.key(keyFlags).constData()));
// }
// }

// if (!references.isEmpty() && !(cursorInfoFlags & IgnoreReferences)) {
// ret.append("References:\n");
// for (auto rit = references.begin(); rit != references.end(); ++rit) {
// const Location &l = *rit;
// ret.append(String::format<128>(" %s\n", l.key(keyFlags).constData()));
// }
// }
return ret;
}

String Cursor::kindSpelling(uint16_t kind)
{
return RTags::eatString(clang_getCursorKindSpelling(static_cast<CXCursorKind>(kind)));
}
17 changes: 13 additions & 4 deletions src/Cursor.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#ifndef Cursor_h
#define Cursor_h
#ifndef RTagsCursor_h
#define RTagsCursor_h

/* This file is part of RTags.
Expand All @@ -26,7 +26,7 @@ struct Cursor
{
Cursor()
: symbolLength(0), kind(CXCursor_FirstInvalid), type(CXType_Invalid), enumValue(0),
startLine(0), startColumn(0), endLine(0), endColumn(0)
startLine(-1), startColumn(-1), endLine(-1), endColumn(-1)
{}

Location location;
Expand All @@ -38,7 +38,7 @@ struct Cursor
bool definition;
int64_t enumValue; // only used if type == CXCursor_EnumConstantDecl
};
unsigned startLine, startColumn, endLine, endColumn;
int startLine, startColumn, endLine, endColumn;

bool isNull() const { return !symbolLength; }

Expand All @@ -57,6 +57,15 @@ struct Cursor
}

inline bool isDefinition() const { return kind == CXCursor_EnumConstantDecl || definition; }

enum Flag {
IgnoreTargets = 0x1,
IgnoreReferences = 0x2,
DefaultFlags = 0x0
};
String toString(unsigned cursorInfoFlags = DefaultFlags, unsigned keyFlags = 0) const;
String kindSpelling() const { return kindSpelling(kind); }
static String kindSpelling(uint16_t kind);
};


Expand Down
285 changes: 0 additions & 285 deletions src/CursorInfo.cpp

This file was deleted.

Loading

0 comments on commit d4ea64b

Please sign in to comment.