use of org.eclipse.ceylon.model.typechecker.model.Module in project ceylon by eclipse.
the class CachedTOCJarsTest method spacesOnPathTest.
@Test
public void spacesOnPathTest() throws IOException {
CachedTOCJars cachedTOCJars = new CachedTOCJars();
Module module = new Module();
module.setName(Collections.singletonList("testModule"));
module.setVersion("testVersion");
final File artifactFile = File.createTempFile("path with spaces", ".jar");
try {
artifactFile.deleteOnExit();
ZipOutputStream artifactOut = new ZipOutputStream(new FileOutputStream(artifactFile));
try {
artifactOut.putNextEntry(new ZipEntry(ALSO_INSIDE_JAR));
} finally {
artifactOut.close();
}
ArtifactResult artifact = new TestArtifactResult(artifactFile, module);
cachedTOCJars.addJar(artifact, module);
String uriPart = cachedTOCJars.getContentUri(module, ALSO_INSIDE_JAR).getSchemeSpecificPart();
// I'm not comparing URI part for equality to avoid symbolic links resolution issues.
Assert.assertTrue(uriPart, uriPart.endsWith(artifactFile.getName() + "!" + ALSO_INSIDE_JAR));
} finally {
artifactFile.delete();
}
}
use of org.eclipse.ceylon.model.typechecker.model.Module in project ceylon by eclipse.
the class TypeChecker method executePhases.
private void executePhases(PhasedUnits phasedUnits, boolean forceSilence) {
List<PhasedUnit> listOfUnits = phasedUnits.getPhasedUnits();
phasedUnits.getModuleManager().prepareForTypeChecking();
phasedUnits.visitModules();
phasedUnits.getModuleManager().modulesVisited();
// By now le language module version should be known
// (as local) or we should use the default one.
Module languageModule = context.getModules().getLanguageModule();
if (languageModule.getVersion() == null) {
languageModule.setVersion(LANGUAGE_MODULE_VERSION);
}
ModuleValidator moduleValidator = new ModuleValidator(context, phasedUnits);
if (verifyDependencies) {
moduleValidator.verifyModuleDependencyTree();
}
phasedUnitsOfDependencies = moduleValidator.getPhasedUnitsOfDependencies();
executePhases(listOfUnits);
if (!forceSilence) {
for (PhasedUnit pu : listOfUnits) {
if (verbose) {
pu.display();
}
pu.generateStatistics(statsVisitor);
pu.runAssertions(assertionVisitor);
}
if (verbose || statistics) {
statsVisitor.print();
}
assertionVisitor.print(verbose);
}
}
use of org.eclipse.ceylon.model.typechecker.model.Module in project ceylon by eclipse.
the class AnalyzerUtil method importedPackage.
static Package importedPackage(Tree.ImportPath path, Unit unit) {
if (path != null && !path.getIdentifiers().isEmpty()) {
String nameToImport = formatPath(path.getIdentifiers());
Module module = path.getUnit().getPackage().getModule();
Package pkg = module.getPackage(nameToImport);
if (pkg != null) {
Module pkgMod = pkg.getModule();
if (pkgMod.equals(module)) {
return pkg;
}
if (!pkg.isShared()) {
path.addError("imported package is not visible: package '" + nameToImport + "' is not shared by module '" + pkgMod.getNameAsString() + "'", 402);
} else if (!pkg.withinRestrictions(unit)) {
path.addError("imported package is not visible: package '" + nameToImport + "' is restricted by module '" + pkgMod.getNameAsString() + "'");
}
// if (module.isDefault() &&
// !pkg.getModule().isDefault() &&
// !pkg.getModule().getNameAsString()
// .equals(Module.LANGUAGE_MODULE_NAME)) {
// path.addError("package belongs to a module and may not be imported by default module: " +
// nameToImport);
// }
// check that the package really does belong to
// an imported module, to work around bug where
// default package thinks it can see stuff in
// all modules in the same source dir
Set<Module> visited = new HashSet<Module>();
for (ModuleImport mi : module.getImports()) {
if (findModuleInTransitiveImports(mi.getModule(), pkgMod, visited)) {
return pkg;
}
}
} else {
for (ModuleImport mi : module.getImports()) {
if (mi.isNative()) {
String name = mi.getModule().getNameAsString();
Backends backends = path.getUnit().getSupportedBackends();
if (!isForBackend(mi.getNativeBackends(), backends) && (nameToImport.equals(name) || nameToImport.startsWith(name + "."))) {
return null;
}
if (!isForBackend(Backend.Java.asSet(), backends) && unit.isJdkPackage(nameToImport)) {
return null;
}
}
}
}
String help = module.isDefaultModule() ? " (define a module and add module import to its module descriptor)" : " (add module import to module descriptor of '" + module.getNameAsString() + "')";
path.addError("package not found in imported modules: '" + nameToImport + "'" + help, 7000);
}
return null;
}
use of org.eclipse.ceylon.model.typechecker.model.Module in project ceylon by eclipse.
the class AnalyzerUtil method importedModule.
static Module importedModule(Tree.ImportPath path, boolean restriction) {
if (path != null && !path.getIdentifiers().isEmpty()) {
String nameToImport = formatPath(path.getIdentifiers());
Module module = path.getUnit().getPackage().getModule();
Package pkg = module.getPackage(nameToImport);
if (pkg != null) {
Module mod = pkg.getModule();
String moduleName = mod.getNameAsString();
if (!pkg.getNameAsString().equals(moduleName)) {
path.addError("not a module: '" + nameToImport + "' is a package belonging to '" + moduleName + "'");
return null;
}
if (mod.equals(module)) {
return mod;
}
// check that the package really does belong to
// an imported module, to work around bug where
// default package thinks it can see stuff in
// all modules in the same source dir
Set<Module> visited = new HashSet<Module>();
for (ModuleImport mi : module.getImports()) {
if (findModuleInTransitiveImports(mi.getModule(), mod, visited)) {
return mod;
}
}
}
if (!restriction) {
path.addError("module not found in imported modules: '" + nameToImport + "'", 7000);
}
}
return null;
}
use of org.eclipse.ceylon.model.typechecker.model.Module in project ceylon by eclipse.
the class ExpressionTransformer method transform.
public JCTree transform(Tree.ModuleLiteral expr) {
at(expr);
Module mod = (Module) expr.getImportPath().getModel();
return makeModuleLiteralCall(mod);
}
Aggregations