use of com.python.pydev.analysis.additionalinfo.ModInfo 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