n = JythonModulesManagerUtils.createModuleFromJar(emptyModuleForZip);
n = decorateModule(n, nature);
} else if (FileTypesPreferencesPage.isValidDll(emptyModuleForZip.pathInZip)) {
//.pyd
n = new CompiledModule(name, this);
n = decorateModule(n, nature);
} else if (PythonPathHelper.isValidSourceFile(emptyModuleForZip.pathInZip)) {
//handle python file from zip... we have to create it getting the contents from the zip file
try {
IDocument doc = FileUtilsFileBuffer.getDocFromZip(emptyModuleForZip.f,
emptyModuleForZip.pathInZip);
//NOTE: The nature (and so the grammar to be used) must be defined by this modules
//manager (and not by the initial caller)!!
n = AbstractModule.createModuleFromDoc(name, emptyModuleForZip.f, doc,
this.getNature(), false);
SourceModule zipModule = (SourceModule) n;
zipModule.zipFilePath = emptyModuleForZip.pathInZip;
n = decorateModule(n, nature);
} catch (Exception exc1) {
Log.log(exc1);
n = null;
}
}
} else {
//regular case... just go on and create it.
try {
//NOTE: The nature (and so the grammar to be used) must be defined by this modules
//manager (and not by the initial caller)!!
n = AbstractModule.createModule(name, e.f, this.getNature(), true);
n = decorateModule(n, nature);
} catch (IOException exc) {
keyForCacheAccess.name = name;
keyForCacheAccess.file = e.f;
doRemoveSingleModule(keyForCacheAccess);
n = null;
} catch (MisconfigurationException exc) {
Log.log(exc);
n = null;
}
}
}
}
} else { //ok, it does not have a file associated, so, we treat it as a builtin (this can happen in java jars)
n = checkOverride(name, nature, n);
if (n instanceof EmptyModule) {
if (acceptCompiledModule) {
n = new CompiledModule(name, this);
n = decorateModule(n, nature);
} else {
return null;
}
}
}
if (n != null) {
doAddSingleModule(createModulesKey(name, e.f), n);
} else {
Log.log(("The module " + name + " could not be found nor created!"));
}
}
if (n instanceof EmptyModule) {
throw new RuntimeException("Should not be an empty module anymore: " + n);
}
if (n instanceof SourceModule) {
SourceModule sourceModule = (SourceModule) n;
//now, here's a catch... it may be a bootstrap module...
if (sourceModule.isBootstrapModule()) {
//if it's a bootstrap module, we must replace it for the related compiled module.
n = new CompiledModule(name, this);
n = decorateModule(n, nature);
}
}
return n;