use of org.python.pydev.core.IInfo in project Pydev by fabioz.
the class IOUtils method getWithFilter.
/**
* @param qualifier
* @param initialsToInfo this is where we are going to get the info from (currently: inner or top level list)
* @param toks (out) the tokens will be added to this list
* @return
*/
protected void getWithFilter(String qualifier, SortedMap<String, Set<IInfo>> initialsToInfo, Collection<IInfo> toks, Filter filter, boolean useLowerCaseQual) {
String initials = getInitials(qualifier);
String qualToCompare = qualifier;
if (useLowerCaseQual) {
qualToCompare = qualifier.toLowerCase();
}
// get until the end of the alphabet
SortedMap<String, Set<IInfo>> subMap = initialsToInfo.subMap(initials, initials + "\uffff\uffff\uffff\uffff");
for (Set<IInfo> listForInitials : subMap.values()) {
for (IInfo info : listForInitials) {
if (filter.doCompare(qualToCompare, info)) {
toks.add(info);
}
}
}
}
use of org.python.pydev.core.IInfo in project Pydev by fabioz.
the class IOUtils method getAllModulesWithTokens.
/**
* @return a set with the module names that have tokens.
*/
public Set<String> getAllModulesWithTokens() {
HashSet<String> ret = new HashSet<String>();
synchronized (lock) {
Set<Entry<String, Set<IInfo>>> entrySet = this.topLevelInitialsToInfo.entrySet();
for (Entry<String, Set<IInfo>> entry : entrySet) {
Set<IInfo> value = entry.getValue();
for (IInfo info : value) {
ret.add(info.getDeclaringModuleName());
}
}
entrySet = this.innerInitialsToInfo.entrySet();
for (Entry<String, Set<IInfo>> entry : entrySet) {
Set<IInfo> value = entry.getValue();
for (IInfo info : value) {
ret.add(info.getDeclaringModuleName());
}
}
}
return ret;
}
use of org.python.pydev.core.IInfo in project Pydev by fabioz.
the class AbstractInfo method equals.
@Override
public boolean equals(Object obj) {
if (!(obj instanceof IInfo)) {
return false;
}
IInfo otherInfo = (IInfo) obj;
if (otherInfo.getType() != getType()) {
return false;
}
if (!otherInfo.getDeclaringModuleName().equals(this.moduleDeclared)) {
return false;
}
if (!otherInfo.getName().equals(this.name)) {
return false;
}
// if one of them is null, the other must also be null...
String otherPath = otherInfo.getPath();
String myPath = getPath();
if ((otherPath == null || myPath == null)) {
if (otherPath != myPath) {
// one of them is not null
return false;
}
// both are null
return true;
}
// they're not null
if (!otherPath.equals(myPath)) {
return false;
}
return true;
}
use of org.python.pydev.core.IInfo in project Pydev by fabioz.
the class InfoStrFactory method infoToString.
/**
* @param iInfo
* @return
*/
public static String infoToString(List<IInfo> iInfo) {
HashMap<String, Integer> map = new HashMap<String, Integer>();
FastStringBuffer infos = new FastStringBuffer();
int next = 0;
map.put(null, next);
next++;
for (Iterator<IInfo> it = iInfo.iterator(); it.hasNext(); ) {
IInfo info = it.next();
infos.append("&&");
// 0
infos.append(info.getType());
// 1
next = add(map, infos, next, info.getName());
// 2
next = add(map, infos, next, info.getDeclaringModuleName());
// 3
next = add(map, infos, next, info.getPath());
// 4
next = add(map, infos, next, info.getFile());
infos.append('|');
// 5
infos.append(info.getLine());
infos.append('|');
// 6
infos.append(info.getCol());
}
FastStringBuffer header = new FastStringBuffer("INFOS:", map.size() * 30);
Set<Entry<String, Integer>> entrySet = map.entrySet();
// null is always 0 (not written to header)
header.append(infos);
header.append('\n');
map.remove(null);
for (Entry<String, Integer> entry : entrySet) {
header.append(entry.getKey());
header.append("=");
header.append(entry.getValue());
header.append("\n");
}
return header.toString();
}
use of org.python.pydev.core.IInfo in project Pydev by fabioz.
the class GlobalsTwoPanelElementSelector2 method fillContentProvider.
/**
* This is the place where we put all the info in the content provider. Note that here we must add
* ALL the info -- later, we'll filter it based on the active working set.
*/
@Override
protected void fillContentProvider(AbstractContentProvider contentProvider, ItemsFilter itemsFilter, IProgressMonitor progressMonitor) throws CoreException {
if (itemsFilter instanceof InfoFilter) {
if (progressMonitor != null) {
progressMonitor.beginTask("Searching...", this.additionalInfo.size());
}
for (AbstractAdditionalTokensInfo additionalInfo : this.additionalInfo) {
if (progressMonitor != null) {
if (progressMonitor.isCanceled()) {
return;
} else {
progressMonitor.worked(1);
}
}
// no duplicates
Collection<IInfo> allTokens = new HashSet<IInfo>(additionalInfo.getAllTokens());
for (IInfo iInfo : allTokens) {
contentProvider.add(new AdditionalInfoAndIInfo(additionalInfo, iInfo), itemsFilter);
}
// Also show to the user the modules available as globals (2.2.3)
IModulesManager modulesManager = null;
try {
if (additionalInfo instanceof AdditionalProjectInterpreterInfo) {
AdditionalProjectInterpreterInfo projectInterpreterInfo = (AdditionalProjectInterpreterInfo) additionalInfo;
IProject project = projectInterpreterInfo.getProject();
PythonNature nature = PythonNature.getPythonNature(project);
if (nature != null) {
ICodeCompletionASTManager astManager = nature.getAstManager();
if (astManager != null) {
modulesManager = astManager.getModulesManager();
}
}
} else if (additionalInfo instanceof AdditionalSystemInterpreterInfo) {
AdditionalSystemInterpreterInfo systemInterpreterInfo = (AdditionalSystemInterpreterInfo) additionalInfo;
IInterpreterInfo defaultInterpreterInfo = systemInterpreterInfo.getManager().getDefaultInterpreterInfo(false);
modulesManager = defaultInterpreterInfo.getModulesManager();
}
} catch (Throwable e) {
Log.log(e);
}
if (modulesManager != null) {
SortedMap<ModulesKey, ModulesKey> allDirectModulesStartingWith = modulesManager.getAllDirectModulesStartingWith("");
Collection<ModulesKey> values = allDirectModulesStartingWith.values();
for (ModulesKey modulesKey : values) {
contentProvider.add(new AdditionalInfoAndIInfo(additionalInfo, new ModInfo(modulesKey.name, modulesManager.getNature(), modulesKey.file != null ? modulesKey.file.toString() : null, 1, 1)), itemsFilter);
}
}
}
}
if (progressMonitor != null) {
progressMonitor.done();
}
}
Aggregations