From 3b95ae1c5b0399def09426c021ac3cf30818bd60 Mon Sep 17 00:00:00 2001 From: Anders Bakken Date: Wed, 30 Oct 2013 01:33:21 -0700 Subject: [PATCH] Kill unused errorsymbols rubbish. --- src/CursorInfo.cpp | 42 +++++++++++++++++++-------------------- src/CursorInfo.h | 14 ++++++------- src/FollowLocationJob.cpp | 20 ++++--------------- src/Project.cpp | 25 ----------------------- src/Project.h | 4 ---- src/RTagsClang.cpp | 36 +++------------------------------ src/RTagsClang.h | 3 +-- src/ReferencesJob.cpp | 23 +++++++-------------- src/Server.h | 2 +- src/StatusJob.cpp | 24 ++-------------------- 10 files changed, 46 insertions(+), 147 deletions(-) diff --git a/src/CursorInfo.cpp b/src/CursorInfo.cpp index 78e399390..48267a90f 100644 --- a/src/CursorInfo.cpp +++ b/src/CursorInfo.cpp @@ -109,9 +109,9 @@ int CursorInfo::targetRank(const CursorInfo &target) const } } -CursorInfo CursorInfo::bestTarget(const SymbolMap &map, const SymbolMap *errors, Location *loc) const +CursorInfo CursorInfo::bestTarget(const SymbolMap &map, Location *loc) const { - const SymbolMap targets = targetInfos(map, errors); + const SymbolMap targets = targetInfos(map); SymbolMap::const_iterator best = targets.end(); int bestRank = -1; @@ -131,11 +131,11 @@ CursorInfo CursorInfo::bestTarget(const SymbolMap &map, const SymbolMap *errors, return CursorInfo(); } -SymbolMap CursorInfo::targetInfos(const SymbolMap &map, const SymbolMap *errors) const +SymbolMap CursorInfo::targetInfos(const SymbolMap &map) const { SymbolMap ret; for (Set::const_iterator it = targets.begin(); it != targets.end(); ++it) { - SymbolMap::const_iterator found = RTags::findCursorInfo(map, *it, String(), errors); + SymbolMap::const_iterator found = RTags::findCursorInfo(map, *it, String()); // ### could/should I pass symbolName as context here? if (found != map.end()) { ret[*it] = found->second; @@ -148,11 +148,11 @@ SymbolMap CursorInfo::targetInfos(const SymbolMap &map, const SymbolMap *errors) return ret; } -SymbolMap CursorInfo::referenceInfos(const SymbolMap &map, const SymbolMap *errors) const +SymbolMap CursorInfo::referenceInfos(const SymbolMap &map) const { SymbolMap ret; for (Set::const_iterator it = references.begin(); it != references.end(); ++it) { - SymbolMap::const_iterator found = RTags::findCursorInfo(map, *it, String(), errors); + SymbolMap::const_iterator found = RTags::findCursorInfo(map, *it, String()); if (found != map.end()) { ret[*it] = found->second; } @@ -160,13 +160,13 @@ SymbolMap CursorInfo::referenceInfos(const SymbolMap &map, const SymbolMap *erro return ret; } -SymbolMap CursorInfo::callers(const Location &loc, const SymbolMap &map, const SymbolMap *errors) const +SymbolMap CursorInfo::callers(const Location &loc, const SymbolMap &map) const { SymbolMap ret; - const SymbolMap cursors = virtuals(loc, map, errors); + const SymbolMap cursors = virtuals(loc, map); for (SymbolMap::const_iterator c = cursors.begin(); c != cursors.end(); ++c) { for (Set::const_iterator it = c->second.references.begin(); it != c->second.references.end(); ++it) { - const SymbolMap::const_iterator found = RTags::findCursorInfo(map, *it, String(), errors); + const SymbolMap::const_iterator found = RTags::findCursorInfo(map, *it, String()); if (found == map.end()) continue; if (RTags::isReference(found->second.kind)) { // is this always right? @@ -185,12 +185,12 @@ enum Mode { NormalRefs }; -static inline void allImpl(const SymbolMap &map, const SymbolMap *errors, const Location &loc, const CursorInfo &info, SymbolMap &out, Mode mode, unsigned kind) +static inline void allImpl(const SymbolMap &map, const Location &loc, const CursorInfo &info, SymbolMap &out, Mode mode, unsigned kind) { if (out.contains(loc)) return; out[loc] = info; - const SymbolMap targets = info.targetInfos(map, errors); + const SymbolMap targets = info.targetInfos(map); for (SymbolMap::const_iterator t = targets.begin(); t != targets.end(); ++t) { bool ok = false; switch (mode) { @@ -203,9 +203,9 @@ static inline void allImpl(const SymbolMap &map, const SymbolMap *errors, const break; } if (ok) - allImpl(map, errors, t->first, t->second, out, mode, kind); + allImpl(map, t->first, t->second, out, mode, kind); } - const SymbolMap refs = info.referenceInfos(map, errors); + const SymbolMap refs = info.referenceInfos(map); for (SymbolMap::const_iterator r = refs.begin(); r != refs.end(); ++r) { switch (mode) { case NormalRefs: @@ -213,7 +213,7 @@ static inline void allImpl(const SymbolMap &map, const SymbolMap *errors, const break; case VirtualRefs: if (r->second.kind == kind) { - allImpl(map, errors, r->first, r->second, out, mode, kind); + allImpl(map, r->first, r->second, out, mode, kind); } else { out[r->first] = r->second; } @@ -224,13 +224,13 @@ static inline void allImpl(const SymbolMap &map, const SymbolMap *errors, const if (r->second.isClass() || r->second.kind == CXCursor_Destructor || r->second.kind == CXCursor_Constructor) { // if is a constructor/destructor/class reference we want to recurse it - allImpl(map, errors, r->first, r->second, out, mode, kind); + allImpl(map, r->first, r->second, out, mode, kind); } } } } -SymbolMap CursorInfo::allReferences(const Location &loc, const SymbolMap &map, const SymbolMap *errors) const +SymbolMap CursorInfo::allReferences(const Location &loc, const SymbolMap &map) const { SymbolMap ret; Mode mode = NormalRefs; @@ -247,15 +247,15 @@ SymbolMap CursorInfo::allReferences(const Location &loc, const SymbolMap &map, c break; } - allImpl(map, errors, loc, *this, ret, mode, kind); + allImpl(map, loc, *this, ret, mode, kind); return ret; } -SymbolMap CursorInfo::virtuals(const Location &loc, const SymbolMap &map, const SymbolMap *errors) const +SymbolMap CursorInfo::virtuals(const Location &loc, const SymbolMap &map) const { SymbolMap ret; ret[loc] = *this; - const SymbolMap s = (kind == CXCursor_CXXMethod ? allReferences(loc, map, errors) : targetInfos(map, errors)); + const SymbolMap s = (kind == CXCursor_CXXMethod ? allReferences(loc, map) : targetInfos(map)); for (SymbolMap::const_iterator it = s.begin(); it != s.end(); ++it) { if (it->second.kind == kind) ret[it->first] = it->second; @@ -263,13 +263,13 @@ SymbolMap CursorInfo::virtuals(const Location &loc, const SymbolMap &map, const return ret; } -SymbolMap CursorInfo::declarationAndDefinition(const Location &loc, const SymbolMap &map, const SymbolMap *errors) const +SymbolMap CursorInfo::declarationAndDefinition(const Location &loc, const SymbolMap &map) const { SymbolMap cursors; cursors[loc] = *this; Location l; - const CursorInfo t = bestTarget(map, errors, &l); + const CursorInfo t = bestTarget(map, &l); if (t.kind == kind) cursors[l] = t; diff --git a/src/CursorInfo.h b/src/CursorInfo.h index 119a8e1ba..30b3039a7 100644 --- a/src/CursorInfo.h +++ b/src/CursorInfo.h @@ -99,13 +99,13 @@ class CursorInfo bool isValid(const Location &location) const; - CursorInfo bestTarget(const SymbolMap &map, const SymbolMap *errors = 0, Location *loc = 0) const; - SymbolMap targetInfos(const SymbolMap &map, const SymbolMap *errors = 0) const; - SymbolMap referenceInfos(const SymbolMap &map, const SymbolMap *errors = 0) const; - SymbolMap callers(const Location &loc, const SymbolMap &map, const SymbolMap *errors = 0) const; - SymbolMap allReferences(const Location &loc, const SymbolMap &map, const SymbolMap *errors = 0) const; - SymbolMap virtuals(const Location &loc, const SymbolMap &map, const SymbolMap *errors = 0) const; - SymbolMap declarationAndDefinition(const Location &loc, const SymbolMap &map, const SymbolMap *errors = 0) const; + CursorInfo bestTarget(const SymbolMap &map, Location *loc = 0) const; + SymbolMap targetInfos(const SymbolMap &map) const; + SymbolMap referenceInfos(const SymbolMap &map) const; + SymbolMap callers(const Location &loc, const SymbolMap &map) const; + SymbolMap allReferences(const Location &loc, const SymbolMap &map) const; + SymbolMap virtuals(const Location &loc, const SymbolMap &map) const; + SymbolMap declarationAndDefinition(const Location &loc, const SymbolMap &map) const; bool isClass() const { diff --git a/src/FollowLocationJob.cpp b/src/FollowLocationJob.cpp index cf28f6fbf..fe2247b8f 100644 --- a/src/FollowLocationJob.cpp +++ b/src/FollowLocationJob.cpp @@ -27,13 +27,7 @@ FollowLocationJob::FollowLocationJob(const Location &loc, const QueryMessage &qu void FollowLocationJob::execute() { const SymbolMap &map = project()->symbols(); - const ErrorSymbolMap &errorSymbols = project()->errorSymbols(); - - const ErrorSymbolMap::const_iterator e = errorSymbols.find(location.fileId()); - const SymbolMap *errors = e == errorSymbols.end() ? 0 : &e->second; - - bool foundInError = false; - SymbolMap::const_iterator it = RTags::findCursorInfo(map, location, context(), errors, &foundInError); + SymbolMap::const_iterator it = RTags::findCursorInfo(map, location, context()); if (it == map.end()) return; @@ -44,10 +38,7 @@ void FollowLocationJob::execute() } Location loc; - CursorInfo target = cursorInfo.bestTarget(map, errors, &loc); - if (target.isNull() && foundInError) { - target = cursorInfo.bestTarget(e->second, errors, &loc); - } + CursorInfo target = cursorInfo.bestTarget(map, &loc); if (!loc.isNull()) { // ### not respecting DeclarationOnly if (cursorInfo.kind != target.kind) { @@ -61,10 +52,7 @@ void FollowLocationJob::execute() case CXCursor_Destructor: case CXCursor_Constructor: case CXCursor_FunctionTemplate: - target = target.bestTarget(map, errors, &loc); - if (target.isNull() && foundInError) - target = cursorInfo.bestTarget(e->second, errors, &loc); - + target = target.bestTarget(map, &loc); break; default: break; @@ -74,7 +62,7 @@ void FollowLocationJob::execute() if (!loc.isNull()) { if (queryFlags() & QueryMessage::DeclarationOnly && target.isDefinition()) { Location declLoc; - const CursorInfo decl = target.bestTarget(map, errors, &declLoc); + const CursorInfo decl = target.bestTarget(map, &declLoc); if (!declLoc.isNull()) { write(declLoc); } diff --git a/src/Project.cpp b/src/Project.cpp index e1f3ecd6c..41b3c9975 100644 --- a/src/Project.cpp +++ b/src/Project.cpp @@ -99,7 +99,6 @@ class RestoreThread : public Thread std::weak_ptr mProject; SymbolMap mSymbols; - ErrorSymbolMap mErrorSymbols; SymbolNameMap mSymbolNames; UsrMap mUsr; FilesMap mFiles; @@ -139,7 +138,6 @@ void Project::restore(RestoreThread *thread) assert(state() == Loading); mSymbols = std::move(thread->mSymbols); - mErrorSymbols = std::move(thread->mErrorSymbols); mSymbolNames = std::move(thread->mSymbolNames); mUsr = std::move(thread->mUsr);; mFiles = std::move(thread->mFiles); @@ -238,7 +236,6 @@ void Project::unload() fileManager.reset(); mSymbols.clear(); - mErrorSymbols.clear(); mSymbolNames.clear(); mUsr.clear(); mFiles.clear(); @@ -642,25 +639,6 @@ static inline void writeUsr(const UsrMap &usr, UsrMap ¤t, SymbolMap &symbo } } -static inline void writeErrorSymbols(const SymbolMap &symbols, ErrorSymbolMap &errorSymbols, const Hash &errors) -{ - for (Hash::const_iterator it = errors.begin(); it != errors.end(); ++it) { - if (it->second) { - SymbolMap &symbolsForFile = errorSymbols[it->first]; - if (symbolsForFile.isEmpty()) { - const Location loc(it->first, 1, 0); - SymbolMap::const_iterator sit = symbols.lower_bound(loc); - while (sit != symbols.end() && sit->first.fileId() == it->first) { - symbolsForFile[sit->first] = sit->second; - ++sit; - } - } - } else { - errorSymbols.remove(it->first); - } - } -} - static inline void writeSymbols(SymbolMap &symbols, SymbolMap ¤t) { if (!symbols.isEmpty()) { @@ -702,9 +680,6 @@ void Project::syncDB(int *dirty, int *sync) *sync = 0; return; } - // for (Hash >::iterator it = mPendingData.begin(); it != mPendingData.end(); ++it) { - // writeErrorSymbols(mSymbols, mErrorSymbols, it->second->errors); - // } if (!mPendingDirtyFiles.isEmpty()) { RTags::dirtySymbols(mSymbols, mPendingDirtyFiles); diff --git a/src/Project.h b/src/Project.h index 8191bd0fc..614a3d1ee 100644 --- a/src/Project.h +++ b/src/Project.h @@ -62,9 +62,6 @@ class Project : public std::enable_shared_from_this const SymbolMap &symbols() const { return mSymbols; } SymbolMap &symbols() { return mSymbols; } - const ErrorSymbolMap &errorSymbols() const { return mErrorSymbols; } - ErrorSymbolMap &errorSymbols() { return mErrorSymbols; } - const SymbolNameMap &symbolNames() const { return mSymbolNames; } SymbolNameMap &symbolNames() { return mSymbolNames; } @@ -129,7 +126,6 @@ class Project : public std::enable_shared_from_this State mState; SymbolMap mSymbols; - ErrorSymbolMap mErrorSymbols; SymbolNameMap mSymbolNames; UsrMap mUsr; FilesMap mFiles; diff --git a/src/RTagsClang.cpp b/src/RTagsClang.cpp index 8c0baf421..78194d13b 100644 --- a/src/RTagsClang.cpp +++ b/src/RTagsClang.cpp @@ -180,40 +180,10 @@ static inline SymbolMap::const_iterator findCursorInfo(const SymbolMap &map, con return map.end(); } -SymbolMap::const_iterator findCursorInfo(const SymbolMap &map, const Location &location, const String &context, - const SymbolMap *errors, bool *foundInErrors) +SymbolMap::const_iterator findCursorInfo(const SymbolMap &map, const Location &location, const String &context) { - if (foundInErrors) - *foundInErrors = false; - if (map.isEmpty() && !errors) - return map.end(); - if (errors) { - SymbolMap::const_iterator ret = findCursorInfo(map, location, context, false); - if (ret != map.end()) { - return ret; - } - ret = findCursorInfo(*errors, location, context, false); - if (ret != errors->end()) { - if (foundInErrors) - *foundInErrors = true; - return ret; - } - // ret = findCursorInfo(*errors, location, context, true); - // if (ret != errors->end()) { - // if (foundInErrors) - // *foundInErrors = true; - // return ret; - // } - // ret = findCursorInfo(map, location, context, true); - // if (ret != map.end()) { - // return ret; - // } - - return map.end(); - } else { - const SymbolMap::const_iterator ret = findCursorInfo(map, location, context, true); - return ret; - } + const SymbolMap::const_iterator ret = findCursorInfo(map, location, context, true); + return ret; } void parseTranslationUnit(const Path &sourceFile, const List &args, diff --git a/src/RTagsClang.h b/src/RTagsClang.h index e58bdf1ca..d2805dca4 100644 --- a/src/RTagsClang.h +++ b/src/RTagsClang.h @@ -54,8 +54,7 @@ enum CursorToStringFlags { }; String cursorToString(CXCursor cursor, unsigned = DefaultCursorToStringFlags); SymbolMap::const_iterator findCursorInfo(const SymbolMap &map, const Location &location, - const String &context = String(), - const SymbolMap *errors = 0, bool *foundInErrors = 0); + const String &context = String()); void parseTranslationUnit(const Path &sourceFile, const List &args, const List &defaultArguments, diff --git a/src/ReferencesJob.cpp b/src/ReferencesJob.cpp index 993c67a9b..12b084ed3 100644 --- a/src/ReferencesJob.cpp +++ b/src/ReferencesJob.cpp @@ -40,30 +40,21 @@ void ReferencesJob::execute() locations = proj->locations(symbolName); if (!locations.isEmpty()) { const SymbolMap &map = proj->symbols(); - const ErrorSymbolMap &errorMap = proj->errorSymbols(); - const ErrorSymbolMap::const_iterator e = symbolName.isEmpty() ? errorMap.find(locations.begin()->fileId()) : errorMap.end(); - const SymbolMap *errors = e == errorMap.end() ? 0 : &e->second; - - // ### return if e != errorMap && queryFlags() & QueryMessage::AllReferences? for (Set::const_iterator it = locations.begin(); it != locations.end(); ++it) { Location pos; SymbolMap::const_iterator found; - bool foundInError = false; - found = RTags::findCursorInfo(map, *it, context(), errors, &foundInError); + found = RTags::findCursorInfo(map, *it, context()); if (found == map.end()) continue; pos = found->first; if (startLocation.isNull()) startLocation = pos; CursorInfo cursorInfo = found->second; - if (RTags::isReference(cursorInfo.kind)) { - cursorInfo = cursorInfo.bestTarget(map, errors, &pos); - if (cursorInfo.isNull() && foundInError) - cursorInfo = cursorInfo.bestTarget(e->second, errors, &pos); - } + if (RTags::isReference(cursorInfo.kind)) + cursorInfo = cursorInfo.bestTarget(map, &pos); if (queryFlags() & QueryMessage::AllReferences) { - const SymbolMap all = cursorInfo.allReferences(pos, map, errors); + const SymbolMap all = cursorInfo.allReferences(pos, map); bool classRename = false; switch (cursorInfo.kind) { @@ -86,7 +77,7 @@ void ReferencesJob::execute() FoundReferences = 0x4 }; unsigned state = 0; - const SymbolMap targets = a->second.targetInfos(map, errors); + const SymbolMap targets = a->second.targetInfos(map); for (SymbolMap::const_iterator t = targets.begin(); t != targets.end(); ++t) { if (t->second.kind != a->second.kind) state |= FoundReferences; @@ -103,7 +94,7 @@ void ReferencesJob::execute() } } else if (queryFlags() & QueryMessage::FindVirtuals) { // ### not supporting DeclarationOnly - const SymbolMap virtuals = cursorInfo.virtuals(pos, map, errors); + const SymbolMap virtuals = cursorInfo.virtuals(pos, map); for (SymbolMap::const_iterator v = virtuals.begin(); v != virtuals.end(); ++v) { references[v->first] = std::make_pair(v->second.isDefinition(), v->second.kind); } @@ -112,7 +103,7 @@ void ReferencesJob::execute() // doesn't work that well do the clever offset thing // underneath } else { - const SymbolMap callers = cursorInfo.callers(pos, map, errors); + const SymbolMap callers = cursorInfo.callers(pos, map); for (SymbolMap::const_iterator c = callers.begin(); c != callers.end(); ++c) { references[c->first] = std::make_pair(false, CXCursor_FirstInvalid); // For find callers we don't want to prefer definitions or do ranks on cursors diff --git a/src/Server.h b/src/Server.h index 2d1104304..e7b4f3a42 100644 --- a/src/Server.h +++ b/src/Server.h @@ -46,7 +46,7 @@ class VisitFileMessage; class Server { public: - enum { DatabaseVersion = 31 }; + enum { DatabaseVersion = 32 }; Server(); ~Server(); diff --git a/src/StatusJob.cpp b/src/StatusJob.cpp index 1c7cfe232..f9212804a 100644 --- a/src/StatusJob.cpp +++ b/src/StatusJob.cpp @@ -29,7 +29,8 @@ StatusJob::StatusJob(const QueryMessage &q, const std::shared_ptr &proj void StatusJob::execute() { bool matched = false; - const char *alternatives = "fileids|dependencies|fileinfos|symbols|symbolnames|errorsymbols|watchedpaths|compilers"; + const char *alternatives = "fileids|watchedpaths|dependencies|symbols|symbolnames|sources|jobs"; + if (!strcasecmp(query.constData(), "fileids")) { matched = true; if (!write(delimiter) || !write("fileids") || !write(delimiter)) @@ -121,27 +122,6 @@ void StatusJob::execute() } } - if (query.isEmpty() || !strcasecmp(query.constData(), "errorsymbols")) { - matched = true; - const ErrorSymbolMap &map = proj->errorSymbols(); - write(delimiter); - write("errorsymbols"); - write(delimiter); - for (ErrorSymbolMap::const_iterator it = map.begin(); it != map.end(); ++it) { - Path file = Location::path(it->first); - write<128>("---------------- %s ---------------", file.constData()); - const SymbolMap &symbols = it->second; - for (SymbolMap::const_iterator sit = symbols.begin(); sit != symbols.end(); ++sit) { - const Location loc = sit->first; - const CursorInfo ci = sit->second; - write(loc); - write(ci); - if (isAborted()) - return; - } - } - } - if (query.isEmpty() || !strcasecmp(query.constData(), "symbolnames")) { matched = true; const SymbolNameMap &map = proj->symbolNames();