Example #1
0
bool IndexParseData::write(const std::function<bool(const String &)> &write, const Match &match) const
{
    auto process = [&write, &match](const String &str, const Sources &sss) {
        if (!sss.isEmpty()) {
            if (!write(str + ":"))
                return false;

            for (const auto &ss : sss) {
                const Path file = Location::path(ss.first);
                if (match.isEmpty() || match.match(file)) {
                    write("  " + file + ":");
                    for (const auto &s : ss.second) {
                        if (!write("    " + s.toString()))
                            return false;
                    }
                }
            }
        }
        return true;
    };
    if (!process("Sources", sources))
        return false;

    for (const auto &commands : compileCommands) {
        if (!process(Location::path(commands.first), commands.second.sources))
            return false;
    }
    return true;
}
Example #2
0
bool Project::match(const Match &p)
{
    Path paths[] = { p.pattern(), p.pattern() };
    paths[1].resolve();
    const int count = paths[1].compare(paths[0]) ? 2 : 1;
    Scope<const FilesMap&> files = lockFilesForRead();
    for (int i=0; i<count; ++i) {
        const Path &path = paths[i];
        if (files.data().contains(path) || p.match(mPath))
            return true;
        const uint32_t id = Location::fileId(path);
        if (isIndexed(id))
            return true;

    }
    return false;
}
Example #3
0
int Project::reindex(const Match &match)
{
    Set<uint32_t> dirty;
    {
        MutexLocker lock(&mMutex);

        const DependencyMap::const_iterator end = mDependencies.end();
        for (DependencyMap::const_iterator it = mDependencies.begin(); it != end; ++it) {
            if (match.isEmpty() || match.match(Location::path(it->first))) {
                dirty.insert(it->first);
            }
        }
        if (dirty.isEmpty())
            return 0;
        mModifiedFiles += dirty;
    }
    startDirtyJobs();
    return dirty.size();
}
Example #4
0
int Project::remove(const Match &match)
{
    int count = 0;
    {
        MutexLocker lock(&mMutex);
        SourceInformationMap::iterator it = mSources.begin();
        while (it != mSources.end()) {
            if (match.match(it->second.sourceFile)) {
                const uint32_t fileId = Location::insertFile(it->second.sourceFile);
                mSources.erase(it++);
                shared_ptr<IndexerJob> job = mJobs.value(fileId);
                if (job)
                    job->abort();
                mPendingData.remove(fileId);
                mPendingJobs.remove(fileId);
                ++count;
            } else {
                ++it;
            }
        }
    }
    return count;
}
Example #5
0
bool Project::match(const Match &p, bool *indexed) const
{
    Path paths[] = { p.pattern(), p.pattern() };
    paths[1].resolve();
    const int count = paths[1].compare(paths[0]) ? 2 : 1;
    bool ret = false;
    for (int i=0; i<count; ++i) {
        const Path &path = paths[i];
        const uint32_t id = Location::fileId(path);
        if (isIndexed(id)) {
            if (indexed)
                *indexed = true;
            return true;
        } else if (mFiles.contains(path) || p.match(mPath)) {
            if (!indexed)
                return true;
            ret = true;
        }
    }
    if (indexed)
        *indexed = false;
    return ret;
}