std::string getSymbol( const std::string &varName ) { SymbolMap::iterator sbmItr = _symbolMap.find( varName ); if ( sbmItr == _symbolMap.end() ) { SpecialSymbolMap::iterator ssmItr = _specialSymbolMap.find( varName ); return ssmItr == _specialSymbolMap.end() ? varName : ssmItr->second; } return sbmItr->second.back(); }
static inline void joinCursors(SymbolMap &symbols, const Set<Location> &locations) { for (Set<Location>::const_iterator it = locations.begin(); it != locations.end(); ++it) { SymbolMap::iterator c = symbols.find(*it); if (c != symbols.end()) { CursorInfo &cursorInfo = c->second; for (Set<Location>::const_iterator innerIt = locations.begin(); innerIt != locations.end(); ++innerIt) { if (innerIt != it) cursorInfo.targets.insert(*innerIt); } // ### this is filthy, we could likely think of something better } } }
static inline void writeCursors(SymbolMap &symbols, SymbolMap ¤t) { 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(); }
bool atTopLevel( const std::string &varName ) { SymbolMap::iterator sbmItr = _symbolMap.find( varName ); if ( sbmItr == _symbolMap.end() ) return true; return sbmItr->second.size() <= 1; }