Skip to content

Commit

Permalink
Introduce rdm --test
Browse files Browse the repository at this point in the history
  • Loading branch information
Andersbakken committed Nov 4, 2014
1 parent c79a790 commit f574c18
Show file tree
Hide file tree
Showing 12 changed files with 372 additions and 29 deletions.
3 changes: 3 additions & 0 deletions src/FileManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ void FileManager::init(const std::shared_ptr<Project> &proj, Mode mode)

void FileManager::reload(Mode mode)
{
if (!Server::instance()->options().tests.isEmpty())
mode = Synchronous;

mLastReloadTime = Rct::monoMs();
std::shared_ptr<Project> project = mProject.lock();
assert(project);
Expand Down
3 changes: 2 additions & 1 deletion src/FollowLocationJob.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,9 @@ int FollowLocationJob::execute()
const SymbolMap &map = project()->symbols();
SymbolMap::const_iterator it = RTags::findCursorInfo(map, location);

if (it == map.end())
if (it == map.end()) {
return 1;
}

const std::shared_ptr<CursorInfo> &cursorInfo = it->second;
if (cursorInfo && cursorInfo->isClass() && cursorInfo->isDefinition()) {
Expand Down
8 changes: 4 additions & 4 deletions src/Location.h
Original file line number Diff line number Diff line change
Expand Up @@ -162,14 +162,14 @@ class Location
error("Failed to make location from [%s:%d:%d]", path.constData(), line, col);
return Location();
}
static String encode(const String &key)
static String encode(const String &key, const Path &pwd = Path())
{
char path[PATH_MAX];
uint32_t line, col;
if (sscanf(key.constData(), "%[^':']:%d:%d", path, &line, &col) != 3)
return String();

Path resolved = Path::resolved(path, Path::MakeAbsolute);
Path resolved = Path::resolved(path, Path::MakeAbsolute, pwd);
{
char buf[8];
memcpy(buf, &line, sizeof(line));
Expand All @@ -180,14 +180,14 @@ class Location
return resolved;
}

static Location fromPathLineAndColumn(const String &str)
static Location fromPathLineAndColumn(const String &str, const Path &pwd = Path())
{
char path[PATH_MAX];
uint32_t line, col;
if (sscanf(str.constData(), "%[^':']:%d:%d", path, &line, &col) != 3)
return Location();

const Path resolved = Path::resolved(path);
const Path resolved = Path::resolved(path, Path::RealPath, pwd);
return Location(Location::insertFile(resolved), line, col);
}
static Hash<uint32_t, Path> idsToPaths()
Expand Down
8 changes: 5 additions & 3 deletions src/Project.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -529,10 +529,10 @@ void Project::onJobFinished(const std::shared_ptr<IndexerJob> &job, const std::s
Location::path(fileId).toTilde().constData());
}

if (mActiveJobs.isEmpty()) {
mSyncTimer.restart(indexData->flags & IndexerJob::Dirty ? 0 : SyncTimeout, Timer::SingleShot);
} else if (options.syncThreshold && mIndexData.size() >= options.syncThreshold) {
if (options.syncThreshold && mIndexData.size() >= options.syncThreshold) {
startSync(Sync_Asynchronous);
} else if (mActiveJobs.isEmpty()) {
mSyncTimer.restart(indexData->flags & IndexerJob::Dirty ? 0 : SyncTimeout, Timer::SingleShot);
}
}

Expand Down Expand Up @@ -1015,6 +1015,8 @@ String Project::fixIts(uint32_t fileId) const

bool Project::startSync(SyncMode mode)
{
if (!Server::instance()->options().tests.isEmpty())
mode = Sync_Synchronous;
if (mState != Loaded) {
if (mode == Sync_Asynchronous)
mSyncTimer.restart(SyncTimeout, Timer::SingleShot);
Expand Down
64 changes: 64 additions & 0 deletions src/QueryMessage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,3 +52,67 @@ Match QueryMessage::match() const

return Match(mQuery, flags);
}

QueryMessage::Flag QueryMessage::flagFromString(const String &string)
{
if (string == "no-context") {
return NoContext;
} else if (string == "filter-system-includes") {
return FilterSystemIncludes;
} else if (string == "strip-parentheses") {
return StripParentheses;
} else if (string == "all-references") {
return AllReferences;
} else if (string == "reverse-sort") {
return ReverseSort;
} else if (string == "elisp-list") {
return ElispList;
} else if (string == "imenu") {
return IMenu;
} else if (string == "match-regexp") {
return MatchRegexp;
} else if (string == "match-case-insensitive") {
return MatchCaseInsensitive;
} else if (string == "find-virtuals") {
return FindVirtuals;
} else if (string == "silent") {
return Silent;
} else if (string == "absolute-path") {
return AbsolutePath;
} else if (string == "find-file-prefer-exact") {
return FindFilePreferExact;
} else if (string == "cursor-info-include-parents") {
return CursorInfoIncludeParents;
} else if (string == "cursor-info-include-targets") {
return CursorInfoIncludeTargets;
} else if (string == "cursor-info-include-references") {
return CursorInfoIncludeReferences;
} else if (string == "declaration-only") {
return DeclarationOnly;
} else if (string == "containing-function") {
return ContainingFunction;
} else if (string == "wait-for-load-project") {
return WaitForLoadProject;
} else if (string == "cursor-kind") {
return CursorKind;
} else if (string == "display-name") {
return DisplayName;
} else if (string == "compilation-flags-only") {
return CompilationFlagsOnly;
} else if (string == "compilation-flags-split-line") {
return CompilationFlagsSplitLine;
} else if (string == "dump-include-headers") {
return DumpIncludeHeaders;
} else if (string == "silent-query") {
return SilentQuery;
} else if (string == "synchronous-completions") {
return SynchronousCompletions;
} else if (string == "no-sort-references-by-input") {
return NoSortReferencesByInput;
} else if (string == "has-location") {
return HasLocation;
} else if (string == "wildcard-symbol-names") {
return WildcardSymbolNames;
}
return NoFlag;
}
11 changes: 11 additions & 0 deletions src/QueryMessage.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ class QueryMessage : public RTagsMessage
};

enum Flag {
NoFlag = 0x00000000,
NoContext = 0x00000001,
FilterSystemIncludes = 0x00000004,
StripParentheses = 0x00000008,
Expand Down Expand Up @@ -150,6 +151,16 @@ class QueryMessage : public RTagsMessage
}
}

void setFlag(Flag flag, bool on = true)
{
if (on) {
mFlags |= flag;
} else {
mFlags &= ~flag;
}
}

static Flag flagFromString(const String &string);
static unsigned keyFlags(unsigned queryFlags);
inline unsigned keyFlags() const { return keyFlags(mFlags); }

Expand Down
Loading

0 comments on commit f574c18

Please sign in to comment.