use of org.python.pydev.ast.codecompletion.revisited.PyPublicTreeMap.Entry in project Pydev by fabioz.
the class ModulesManager method buildKeysForRegularEntries.
public static void buildKeysForRegularEntries(IProgressMonitor monitor, ModulesFoundStructure modulesFound, PyPublicTreeMap<ModulesKey, ModulesKey> keys, boolean includeOnlySourceModules) {
String[] dottedValidSourceFiles = FileTypesPreferences.getDottedValidSourceFiles();
int j = 0;
FastStringBuffer buffer = new FastStringBuffer();
Map<String, File> packages = new HashMap<String, File>();
String packageM;
File packageF;
// now, create in memory modules for all the loaded files (empty modules).
for (Iterator<Map.Entry<File, String>> iterator = modulesFound.regularModules.entrySet().iterator(); iterator.hasNext() && monitor.isCanceled() == false; j++) {
Map.Entry<File, String> entry = iterator.next();
String m = entry.getValue();
if (m != null) {
if (j % 20 == 0) {
// no need to report all the time (that's pretty fast now)
buffer.clear();
monitor.setTaskName(buffer.append("Module resolved: ").append(m).toString());
monitor.worked(1);
}
// we don't load them at this time.
File f = entry.getKey();
if (includeOnlySourceModules) {
// check if we should include only source modules
if (!PythonPathHelper.isValidSourceFile(f.getName())) {
continue;
}
}
packageM = FullRepIterable.getParentModule(m);
packageF = f.getParentFile();
while (!packageM.isEmpty()) {
packages.put(packageM, packageF);
packageM = FullRepIterable.getParentModule(packageM);
packageF = packageF.getParentFile();
}
ModulesKey modulesKey = new ModulesKey(m, f);
// no conflict (easy)
if (!keys.containsKey(modulesKey)) {
keys.put(modulesKey, modulesKey);
} else {
// we have a conflict, so, let's resolve which one to keep (the old one or this one)
if (PythonPathHelper.isValidSourceFile(f.getName(), dottedValidSourceFiles)) {
// source files have priority over other modules (dlls) -- if both are source, there is no real way to resolve
// this priority, so, let's just add it over.
keys.put(modulesKey, modulesKey);
}
}
}
}
for (Map.Entry<String, File> packageEntry : packages.entrySet()) {
buffer.clear();
File f = packageEntry.getValue();
ModulesKey modulesKeyForFolder = new ModulesKeyForFolder(buffer.append(packageEntry.getKey()).append(".__init__").toString(), f);
if (!keys.containsKey(modulesKeyForFolder)) {
keys.put(modulesKeyForFolder, modulesKeyForFolder);
}
}
}
Aggregations