Exemple #1
0
SymbolMap::const_iterator findCursorInfo(const SymbolMap &map, const Location &location, const String &context,
                                         const SymbolMap *errors, bool *foundInErrors)
{
    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;
    }
}
Exemple #2
0
static inline void writeCursors(SymbolMap &symbols, SymbolMap &current)
{
    if (!symbols.isEmpty()) {
        if (current.isEmpty()) {
            current = symbols;
        } else {
            SymbolMap::iterator it = symbols.begin();
            const SymbolMap::iterator end = symbols.end();
            while (it != end) {
                SymbolMap::iterator cur = current.find(it->first);
                if (cur == current.end()) {
                    current[it->first] = it->second;
                } else {
                    cur->second.unite(it->second);
                }
                ++it;
            }
        }
    }
}
SymbolMap::const_iterator findCursorInfo(const SymbolMap &map, const Location &location)
{
    if (map.isEmpty())
        return map.end();

    SymbolMap::const_iterator it = map.find(location);
    if (it != map.end())
        return it;
    it = map.lower_bound(location);
    if (it == map.end()) {
        --it;
    } else {
        const int cmp = it->first.compare(location);
        if (!cmp)
            return it;
        --it;
    }
    if (location.fileId() != it->first.fileId())
        return map.end();
    const int off = location.offset() - it->first.offset();
    if (it->second.symbolLength > off)
        return it;
    return map.end();
}