Skip to content

Commit

Permalink
More work. It's getting close. References don't entirely work yet.
Browse files Browse the repository at this point in the history
  • Loading branch information
Andersbakken committed Jan 24, 2015
1 parent f798020 commit 1fcd3bf
Show file tree
Hide file tree
Showing 27 changed files with 385 additions and 282 deletions.
2 changes: 1 addition & 1 deletion src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ target_link_libraries(shared rct)
set(RTAGS_SOURCES
CompilerManager.cpp
CompletionThread.cpp
CursorInfoJob.cpp
SymbolInfoJob.cpp
DependenciesJob.cpp
Diagnostic.cpp
DumpThread.cpp
Expand Down
26 changes: 13 additions & 13 deletions src/ClangIndexer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -170,11 +170,11 @@ bool ClangIndexer::exec(const String &data)
int cursorCount = 0;
int symbolNameCount = 0;
for (const auto &unit : mUnits) {
cursorCount += unit.second->cursors.size();
cursorCount += unit.second->symbols.size();
symbolNameCount += unit.second->symbolNames.size();
}
if (mClangUnit) {
const char *format = "(%d syms, %d symNames, %d deps, %d of %d files, cursors: %d of %d, %d queried) (%d/%d/%dms)";
const char *format = "(%d syms, %d symNames, %d deps, %d of %d files, symbols: %d of %d, %d queried) (%d/%d/%dms)";
mData->message += String::format<128>(format, cursorCount, symbolNameCount,
mData->dependencies.size(), mIndexed, mData->visited.size(), mAllowed,
mAllowed + mBlocked, mFileIdsQueried,
Expand Down Expand Up @@ -450,7 +450,7 @@ String ClangIndexer::addNamePermutations(const CXCursor &cursor, const Location
}

if (i == 0) {
// create actual symbol name that will go into CursorInfo. This doesn't include namespaces etc
// create actual symbol name that will go into SymbolInfo. This doesn't include namespaces etc
if (!type.isEmpty()) {
ret = type;
ret.append(buf + cutoff, sizeof(buf) - cutoff - 1);
Expand Down Expand Up @@ -708,7 +708,7 @@ bool ClangIndexer::superclassTemplateMemberFunctionUgleHack(const CXCursor &curs
case 0:
break;
default:
warning() << "Can't decide which of these cursors are right for me"
warning() << "Can't decide which of these symbols are right for me"
<< cursor << alternatives
<< "Need to parse types";
break;
Expand Down Expand Up @@ -791,7 +791,7 @@ bool ClangIndexer::handleReference(const CXCursor &cursor, CXCursorKind kind,
refTargetValue = RTags::createTargetsValue(refKind, clang_isCursorDefinition(ref));
}
targets[reffedLoc] = refTargetValue;
Symbol &c = unit(location)->cursors[location];
Symbol &c = unit(location)->symbols[location];
if (cursorPtr)
*cursorPtr = &c;

Expand Down Expand Up @@ -849,7 +849,7 @@ bool ClangIndexer::handleReference(const CXCursor &cursor, CXCursorKind kind,
c.symbolLength = reffedCursorFound ? reffedCursor.symbolLength : symbolLength(refKind, ref);
}
if (!c.symbolLength) {
unit(location)->cursors.remove(location);
unit(location)->symbols.remove(location);
if (cursorPtr)
*cursorPtr = 0;
return false;
Expand Down Expand Up @@ -894,7 +894,7 @@ void ClangIndexer::handleInclude(const CXCursor &cursor, CXCursorKind kind, cons
if (includedFile) {
const Location refLoc = createLocation(includedFile, 1, 1);
if (!refLoc.isNull()) {
Symbol &c = unit(location)->cursors[location];
Symbol &c = unit(location)->symbols[location];
if (!c.isNull())
return;

Expand All @@ -918,7 +918,7 @@ void ClangIndexer::handleInclude(const CXCursor &cursor, CXCursorKind kind, cons
bool ClangIndexer::handleCursor(const CXCursor &cursor, CXCursorKind kind, const Location &location, Symbol **cursorPtr)
{
// error() << "Got a cursor" << cursor;
Symbol &c = unit(location)->cursors[location];
Symbol &c = unit(location)->symbols[location];
if (cursorPtr)
*cursorPtr = &c;
if (!c.isNull())
Expand Down Expand Up @@ -957,7 +957,7 @@ bool ClangIndexer::handleCursor(const CXCursor &cursor, CXCursorKind kind, const
c.symbolName = "struct";
break;
default:
unit(location)->cursors.remove(location);
unit(location)->symbols.remove(location);
if (cursorPtr)
*cursorPtr = 0;
return false;
Expand Down Expand Up @@ -1088,8 +1088,8 @@ bool ClangIndexer::writeFiles(const Path &root, String &error)
String unitRoot = root;
unitRoot << unit.first;
Path::mkdir(unitRoot, Path::Recursive);
if (!FileMap<Location, Symbol>::write(unitRoot + "/symbols", unit.second->cursors)) {
error = "Failed to write cursors";
if (!FileMap<Location, Symbol>::write(unitRoot + "/symbols", unit.second->symbols)) {
error = "Failed to write symbols";
return false;
}
if (!FileMap<Location, Map<Location, uint16_t> >::write(unitRoot + "/targets", unit.second->targets)) {
Expand Down Expand Up @@ -1314,7 +1314,7 @@ CXChildVisitResult ClangIndexer::verboseVisitor(CXCursor cursor, CXCursor, CXCli
}

if (loc.fileId() && u->indexer->mData->visited.value(loc.fileId())) {
if (u->indexer->unit(loc)->cursors.contains(loc)) {
if (u->indexer->unit(loc)->symbols.contains(loc)) {
u->out += " used as cursor\n";
} else {
u->out += " not used\n";
Expand Down Expand Up @@ -1482,7 +1482,7 @@ Symbol ClangIndexer::findSymbol(const Location &location, bool *ok) const
Symbol ret;
auto it = mUnits.find(location.fileId());
if (it != mUnits.end()) {
ret = it->second->cursors.value(location, Symbol(), ok);
ret = it->second->symbols.value(location, Symbol(), ok);
} else if (ok) {
*ok = false;
}
Expand Down
2 changes: 1 addition & 1 deletion src/ClangIndexer.h
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ class ClangIndexer
void onMessage(const std::shared_ptr<Message> &msg, Connection *conn);

struct Unit {
Map<Location, Symbol> cursors;
Map<Location, Symbol> symbols;
Map<Location, Map<Location, uint16_t> > targets;
Map<String, Set<Location> > usrs;
Map<String, Set<Location> > symbolNames;
Expand Down
76 changes: 0 additions & 76 deletions src/CursorInfoJob.cpp

This file was deleted.

2 changes: 1 addition & 1 deletion src/FindSymbolsJob.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ int FindSymbolsJob::execute()
if (queryFlags() & QueryMessage::ReverseSort)
sortFlags |= Project::Sort_Reverse;

const List<RTags::SortedCursor> sorted = proj->sort(locations, sortFlags);
const List<RTags::SortedSymbol> sorted = proj->sort(locations, sortFlags);
const unsigned int writeFlags = filter ? Unfiltered : NoWriteFlags;
const int count = sorted.size();
ret = count ? 0 : 1;
Expand Down
8 changes: 4 additions & 4 deletions src/FollowLocationJob.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,16 @@ FollowLocationJob::FollowLocationJob(const Location &loc,

int FollowLocationJob::execute()
{
const Symbol cursor = project()->findSymbol(location);
if (cursor.isNull())
const Symbol symbol = project()->findSymbol(location);
if (symbol.isNull())
return 1;

const Location targetLocation = project()->findTarget(cursor);
const Location targetLocation = project()->findTarget(symbol);
if (targetLocation.isNull())
return 1;
const Symbol target = project()->findSymbol(targetLocation);

if (cursor.usr == target.usr) {
if (symbol.usr == target.usr) {
write(target.location);
return 0;
}
Expand Down
4 changes: 2 additions & 2 deletions src/JSONJob.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ You should have received a copy of the GNU General Public License
along with RTags. If not, see <http://www.gnu.org/licenses/>. */

#include "JSONJob.h"
#include "CursorInfo.h"
#include "SymbolInfo.h"
#include "Project.h"
#include "RTags.h"
#include "Server.h"
Expand Down Expand Up @@ -60,7 +60,7 @@ void JSONJob::execute()
SymbolMap::const_iterator sit = map.lower_bound(loc);
while (sit != map.end() && sit->first.fileId() == it->first) {
Location targetLocation;
CursorInfo target = sit->second.bestTarget(map, 0, &targetLocation);
SymbolInfo target = sit->second.bestTarget(map, 0, &targetLocation);
const String type = sit->second.kindSpelling();
if (firstSymbol) {
firstSymbol = false;
Expand Down
16 changes: 8 additions & 8 deletions src/ListSymbolsJob.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,15 +82,15 @@ Set<String> ListSymbolsJob::imenu(const std::shared_ptr<Project> &project)
const uint32_t fileId = Location::fileId(file);
if (!fileId)
continue;
auto cursors = project->openSymbols(fileId);
if (!cursors)
auto symbols = project->openSymbols(fileId);
if (!symbols)
continue;
const int count = cursors->count();
const int count = symbols->count();
for (int j=0; j<count; ++j) {
const Symbol &cursor = cursors->valueAt(j);
if (RTags::isReference(cursor.kind))
const Symbol &symbol = symbols->valueAt(j);
if (RTags::isReference(symbol.kind))
continue;
switch (cursor.kind) {
switch (symbol.kind) {
case CXCursor_VarDecl:
case CXCursor_ParmDecl:
case CXCursor_InclusionDirective:
Expand All @@ -99,11 +99,11 @@ Set<String> ListSymbolsJob::imenu(const std::shared_ptr<Project> &project)
case CXCursor_ClassDecl:
case CXCursor_StructDecl:
case CXCursor_ClassTemplate:
if (!cursor.isDefinition())
if (!symbol.isDefinition())
break;
// fall through
default: {
const String &symbolName = cursor.symbolName;
const String &symbolName = symbol.symbolName;
if (!string.isEmpty() && !symbolName.contains(string))
continue;
out.insert(symbolName);
Expand Down
Loading

0 comments on commit 1fcd3bf

Please sign in to comment.