use of org.eclipse.ceylon.model.typechecker.model.Package in project ceylon by eclipse.
the class ModelLoaderTests method functionalParameterParameterNames.
@Test
public void functionalParameterParameterNames() {
compile("FunctionalParameterParameterNames.ceylon");
try {
verifyCompilerClassLoading("functionalparameterparameternamestest.ceylon", new RunnableTest() {
@Override
public void test(ModelLoader loader) {
Module mod = loader.getLoadedModule(moduleForJavaModelLoading(), moduleVersionForJavaModelLoading());
Assert.assertNotNull(mod);
Package p = mod.getDirectPackage(packageForJavaModelLoading());
Assert.assertNotNull(p);
Declaration fpClass = p.getDirectMember("FunctionalParameterParameterNames", Collections.<Type>emptyList(), false);
Assert.assertNotNull(fpClass);
{
// functionalParameter
Function fp = (Function) fpClass.getDirectMember("functionalParameter", null, false);
Assert.assertNotNull(fp);
Assert.assertEquals(1, fp.getParameterLists().size());
Assert.assertEquals(1, fp.getParameterLists().get(0).getParameters().size());
Assert.assertEquals("Anything(Anything(String))", typeName(fp));
Parameter paramF = fp.getParameterLists().get(0).getParameters().get(0);
Assert.assertTrue(paramF.isDeclaredAnything());
Assert.assertEquals("f", paramF.getName());
Assert.assertTrue(paramF.getModel() instanceof Function);
Function modelF = (Function) paramF.getModel();
Assert.assertTrue(modelF.isDeclaredVoid());
Assert.assertEquals("Anything(String)", typeName(modelF));
Assert.assertEquals("f", modelF.getName());
Assert.assertEquals(1, modelF.getParameterLists().size());
Assert.assertEquals(1, modelF.getParameterLists().get(0).getParameters().size());
Parameter paramS = modelF.getParameterLists().get(0).getParameters().get(0);
Assert.assertEquals("s", paramS.getName());
Assert.assertTrue(paramS.getModel() instanceof Value);
Value modelS = (Value) paramS.getModel();
Assert.assertEquals("s", modelS.getName());
Assert.assertEquals("String", typeName(modelS));
}
{
// callableValueParameter
Function fp = (Function) fpClass.getDirectMember("callableValueParameter", null, false);
Assert.assertNotNull(fp);
Assert.assertEquals(1, fp.getParameterLists().size());
Assert.assertEquals(1, fp.getParameterLists().get(0).getParameters().size());
Assert.assertEquals("Anything(Anything(String))", typeName(fp));
Parameter paramF = fp.getParameterLists().get(0).getParameters().get(0);
Assert.assertEquals("f", paramF.getName());
Assert.assertFalse(paramF.isDeclaredAnything());
Assert.assertTrue(paramF.getModel() instanceof Value);
Value modelF = (Value) paramF.getModel();
Assert.assertEquals("f", modelF.getName());
Assert.assertEquals("Anything(String)", typeName(modelF));
}
{
// functionalParameterNested
Function fp = (Function) fpClass.getDirectMember("functionalParameterNested", null, false);
Assert.assertNotNull(fp);
Assert.assertEquals(1, fp.getParameterLists().size());
Assert.assertEquals(1, fp.getParameterLists().get(0).getParameters().size());
Assert.assertEquals("Anything(Anything(Anything(String)))", typeName(fp));
Parameter paramF = fp.getParameterLists().get(0).getParameters().get(0);
Assert.assertEquals("f", paramF.getName());
Assert.assertTrue(paramF.isDeclaredAnything());
Assert.assertTrue(paramF.getModel() instanceof Function);
Function modelF = (Function) paramF.getModel();
Assert.assertEquals("Anything(Anything(String))", typeName(modelF));
Assert.assertEquals("f", modelF.getName());
Assert.assertTrue(modelF.isDeclaredVoid());
Assert.assertEquals(1, modelF.getParameterLists().size());
Assert.assertEquals(1, modelF.getParameterLists().get(0).getParameters().size());
Parameter paramF2 = modelF.getParameterLists().get(0).getParameters().get(0);
Assert.assertTrue(paramF2.isDeclaredAnything());
Assert.assertEquals("f2", paramF2.getName());
Assert.assertTrue(paramF2.getModel() instanceof Function);
Function modelF2 = (Function) paramF2.getModel();
Assert.assertEquals("Anything(String)", typeName(modelF2));
Assert.assertEquals("f2", modelF2.getName());
Assert.assertTrue(modelF2.isDeclaredVoid());
Assert.assertEquals(1, modelF2.getParameterLists().size());
Assert.assertEquals(1, modelF2.getParameterLists().get(0).getParameters().size());
Parameter paramS = modelF2.getParameterLists().get(0).getParameters().get(0);
Assert.assertEquals("s", paramS.getName());
Assert.assertTrue(paramS.getModel() instanceof Value);
Value modelS = (Value) paramS.getModel();
Assert.assertEquals("s", modelS.getName());
Assert.assertEquals("String", typeName(modelS));
}
{
// functionalParameterNested2
Function fp = (Function) fpClass.getDirectMember("functionalParameterNested2", null, false);
Assert.assertNotNull(fp);
Assert.assertEquals(1, fp.getParameterLists().size());
Assert.assertEquals(1, fp.getParameterLists().get(0).getParameters().size());
Assert.assertEquals("Anything(Anything(Anything(String, Anything(Boolean, Integer))))", typeName(fp));
Parameter paramF = fp.getParameterLists().get(0).getParameters().get(0);
Assert.assertEquals("f", paramF.getName());
Assert.assertTrue(paramF.getModel() instanceof Function);
Function modelF = (Function) paramF.getModel();
Assert.assertEquals("f", modelF.getName());
Assert.assertEquals("Anything(Anything(String, Anything(Boolean, Integer)))", typeName(modelF));
Assert.assertEquals(1, modelF.getParameterLists().size());
Assert.assertEquals(1, modelF.getParameterLists().get(0).getParameters().size());
Parameter paramF2 = modelF.getParameterLists().get(0).getParameters().get(0);
Assert.assertEquals("f2", paramF2.getName());
Assert.assertTrue(paramF2.getModel() instanceof Function);
Function modelF2 = (Function) paramF2.getModel();
Assert.assertEquals("Anything(String, Anything(Boolean, Integer))", typeName(modelF2));
Assert.assertEquals("f2", modelF2.getName());
Assert.assertEquals(1, modelF2.getParameterLists().size());
Assert.assertEquals(2, modelF2.getParameterLists().get(0).getParameters().size());
Parameter paramS = modelF2.getParameterLists().get(0).getParameters().get(0);
Assert.assertEquals("s", paramS.getName());
Assert.assertTrue(paramS.getModel() instanceof Value);
Value modelS = (Value) paramS.getModel();
Assert.assertEquals("String", typeName(modelS));
Assert.assertEquals("s", modelS.getName());
Parameter paramF3 = modelF2.getParameterLists().get(0).getParameters().get(1);
Assert.assertEquals("f3", paramF3.getName());
Assert.assertTrue(paramF3.getModel() instanceof Function);
Function modelF3 = (Function) paramF3.getModel();
Assert.assertEquals("Anything(Boolean, Integer)", typeName(modelF3));
Assert.assertEquals("f3", modelF3.getName());
Assert.assertEquals(1, modelF3.getParameterLists().size());
Assert.assertEquals(2, modelF3.getParameterLists().get(0).getParameters().size());
Parameter paramB1 = modelF3.getParameterLists().get(0).getParameters().get(0);
Assert.assertEquals("b1", paramB1.getName());
Assert.assertTrue(paramB1.getModel() instanceof Value);
Value modelB1 = (Value) paramB1.getModel();
Assert.assertEquals("Boolean", typeName(modelB1));
Assert.assertEquals("b1", modelB1.getName());
Parameter paramI2 = modelF3.getParameterLists().get(0).getParameters().get(1);
Assert.assertEquals("i2", paramI2.getName());
Assert.assertTrue(paramI2.getModel() instanceof Value);
Value modelI2 = (Value) paramI2.getModel();
Assert.assertEquals("i2", modelI2.getName());
Assert.assertEquals("Integer", typeName(modelI2));
}
{
// functionalParameterMpl
Function fp = (Function) fpClass.getDirectMember("functionalParameterMpl", null, false);
Assert.assertNotNull(fp);
Assert.assertEquals(1, fp.getParameterLists().size());
Assert.assertEquals(1, fp.getParameterLists().get(0).getParameters().size());
Assert.assertEquals("Anything(Anything(Integer)(String))", typeName(fp));
Parameter paramF = fp.getParameterLists().get(0).getParameters().get(0);
Assert.assertTrue(paramF.isDeclaredAnything());
Assert.assertEquals("mpl", paramF.getName());
Assert.assertTrue(paramF.getModel() instanceof Function);
Function modelF = (Function) paramF.getModel();
Assert.assertTrue(modelF.isDeclaredVoid());
Assert.assertEquals("Anything(Integer)(String)", typeName(modelF));
Assert.assertEquals("mpl", modelF.getName());
Assert.assertEquals(2, modelF.getParameterLists().size());
Assert.assertEquals(1, modelF.getParameterLists().get(0).getParameters().size());
Assert.assertEquals(1, modelF.getParameterLists().get(1).getParameters().size());
Parameter paramS = modelF.getParameterLists().get(0).getParameters().get(0);
Assert.assertEquals("s", paramS.getName());
Assert.assertTrue(paramS.getModel() instanceof Value);
Value modelS = (Value) paramS.getModel();
Assert.assertEquals("s", modelS.getName());
Assert.assertEquals("String", typeName(modelS));
Parameter paramS2 = modelF.getParameterLists().get(1).getParameters().get(0);
Assert.assertEquals("i2", paramS2.getName());
Assert.assertTrue(paramS2.getModel() instanceof Value);
Value modelS2 = (Value) paramS2.getModel();
Assert.assertEquals("i2", modelS2.getName());
Assert.assertEquals("Integer", typeName(modelS2));
}
{
// functionalParameterMpl2
Function fp = (Function) fpClass.getDirectMember("functionalParameterMpl2", null, false);
Assert.assertNotNull(fp);
Assert.assertEquals(1, fp.getParameterLists().size());
Assert.assertEquals(1, fp.getParameterLists().get(0).getParameters().size());
Parameter paramMpl = fp.getParameterLists().get(0).getParameters().get(0);
Assert.assertEquals("mpl", paramMpl.getName());
Assert.assertTrue(paramMpl.getModel() instanceof Function);
Function modelMpl = (Function) paramMpl.getModel();
Assert.assertEquals("mpl", modelMpl.getName());
Assert.assertEquals(2, modelMpl.getParameterLists().size());
Assert.assertEquals(1, modelMpl.getParameterLists().get(0).getParameters().size());
Assert.assertEquals(1, modelMpl.getParameterLists().get(1).getParameters().size());
Parameter paramS = modelMpl.getParameterLists().get(0).getParameters().get(0);
Assert.assertEquals("s", paramS.getName());
Assert.assertTrue(paramS.getModel() instanceof Value);
Value modelS = (Value) paramS.getModel();
Assert.assertEquals("s", modelS.getName());
Assert.assertEquals("String", typeName(modelS));
Parameter paramF = modelMpl.getParameterLists().get(1).getParameters().get(0);
Assert.assertEquals("f", paramF.getName());
Assert.assertTrue(paramF.getModel() instanceof Function);
Function modelF = (Function) paramF.getModel();
Assert.assertEquals("f", modelF.getName());
Assert.assertEquals(1, modelF.getParameterLists().size());
Assert.assertEquals(2, modelF.getParameterLists().get(0).getParameters().size());
Parameter paramB1 = modelF.getParameterLists().get(0).getParameters().get(0);
Assert.assertEquals("b1", paramB1.getName());
Assert.assertTrue(paramB1.getModel() instanceof Value);
Value modelB1 = (Value) paramB1.getModel();
Assert.assertEquals("b1", modelB1.getName());
Assert.assertEquals("Boolean", typeName(modelB1));
Parameter paramI2 = modelF.getParameterLists().get(0).getParameters().get(1);
Assert.assertEquals("i2", paramI2.getName());
Assert.assertTrue(paramI2.getModel() instanceof Value);
Value modelI2 = (Value) paramI2.getModel();
Assert.assertEquals("i2", modelI2.getName());
Assert.assertEquals("Integer", typeName(modelI2));
}
{
// functionalParameterMpl3
Function fp = (Function) fpClass.getDirectMember("functionalParameterMpl3", null, false);
Assert.assertNotNull(fp);
Assert.assertEquals(1, fp.getParameterLists().size());
Assert.assertEquals(1, fp.getParameterLists().get(0).getParameters().size());
Parameter paramMpl = fp.getParameterLists().get(0).getParameters().get(0);
Assert.assertEquals("mpl", paramMpl.getName());
Assert.assertTrue(paramMpl.getModel() instanceof Function);
Function modelMpl = (Function) paramMpl.getModel();
Assert.assertEquals("mpl", modelMpl.getName());
Assert.assertEquals(2, modelMpl.getParameterLists().size());
Assert.assertEquals(1, modelMpl.getParameterLists().get(0).getParameters().size());
Assert.assertEquals(1, modelMpl.getParameterLists().get(1).getParameters().size());
Parameter paramF = modelMpl.getParameterLists().get(0).getParameters().get(0);
Assert.assertEquals("f", paramF.getName());
Assert.assertTrue(paramF.getModel() instanceof Function);
Function modelF = (Function) paramF.getModel();
Assert.assertEquals("f", modelF.getName());
Assert.assertEquals(1, modelF.getParameterLists().size());
Assert.assertEquals(2, modelF.getParameterLists().get(0).getParameters().size());
Parameter paramB1 = modelF.getParameterLists().get(0).getParameters().get(0);
Assert.assertEquals("b1", paramB1.getName());
Assert.assertTrue(paramB1.getModel() instanceof Value);
Value modelB1 = (Value) paramB1.getModel();
Assert.assertEquals("b1", modelB1.getName());
Assert.assertEquals("Boolean", typeName(modelB1));
Parameter paramI2 = modelF.getParameterLists().get(0).getParameters().get(1);
Assert.assertEquals("i2", paramI2.getName());
Assert.assertTrue(paramI2.getModel() instanceof Value);
Value modelI2 = (Value) paramI2.getModel();
Assert.assertEquals("i2", modelI2.getName());
Assert.assertEquals("Integer", typeName(modelI2));
Parameter paramS = modelMpl.getParameterLists().get(1).getParameters().get(0);
Assert.assertEquals("s", paramS.getName());
Assert.assertTrue(paramS.getModel() instanceof Value);
Value modelS = (Value) paramS.getModel();
Assert.assertEquals("s", modelS.getName());
Assert.assertEquals("String", typeName(modelS));
}
{
// functionalParameterReturningCallable
Function fp = (Function) fpClass.getDirectMember("functionalParameterReturningCallable", null, false);
Assert.assertNotNull(fp);
Assert.assertEquals(1, fp.getParameterLists().size());
Assert.assertEquals(1, fp.getParameterLists().get(0).getParameters().size());
Parameter paramF = fp.getParameterLists().get(0).getParameters().get(0);
Assert.assertEquals("f", paramF.getName());
Assert.assertTrue(paramF.getModel() instanceof Function);
Function modelF = (Function) paramF.getModel();
Assert.assertEquals("f", modelF.getName());
Assert.assertEquals("Anything()", modelF.getType().asString());
Assert.assertEquals(1, modelF.getParameterLists().size());
Assert.assertEquals(1, modelF.getParameterLists().get(0).getParameters().size());
Parameter paramS = modelF.getParameterLists().get(0).getParameters().get(0);
Assert.assertEquals("s", paramS.getName());
Assert.assertTrue(paramS.getModel() instanceof Value);
Value modelS = (Value) paramS.getModel();
Assert.assertEquals("s", modelS.getName());
Assert.assertEquals("String", modelS.getType().asString());
}
{
// functionalParameterReturningCallable
Function fp = (Function) fpClass.getDirectMember("functionalParameterTakingCallable", null, false);
Assert.assertNotNull(fp);
Assert.assertEquals(1, fp.getParameterLists().size());
Assert.assertEquals(1, fp.getParameterLists().get(0).getParameters().size());
Parameter paramF = fp.getParameterLists().get(0).getParameters().get(0);
Assert.assertEquals("f", paramF.getName());
Assert.assertTrue(paramF.getModel() instanceof Function);
Function modelF = (Function) paramF.getModel();
Assert.assertEquals("f", modelF.getName());
Assert.assertEquals("Anything", modelF.getType().asString());
Assert.assertEquals(1, modelF.getParameterLists().size());
Assert.assertEquals(1, modelF.getParameterLists().get(0).getParameters().size());
Parameter paramF2 = modelF.getParameterLists().get(0).getParameters().get(0);
Assert.assertEquals("f2", paramF2.getName());
Assert.assertTrue(paramF2.getModel() instanceof Value);
Value modelF2 = (Value) paramF2.getModel();
Assert.assertEquals("f2", modelF2.getName());
Assert.assertEquals("Anything(String)", modelF2.getType().asString());
}
{
// functionalParameterVariadicStar
Function fp = (Function) fpClass.getDirectMember("functionalParameterVariadicStar", null, false);
Assert.assertNotNull(fp);
Assert.assertEquals(1, fp.getParameterLists().size());
Assert.assertEquals(1, fp.getParameterLists().get(0).getParameters().size());
Assert.assertEquals("Anything(Anything(String*))", typeName(fp));
Parameter paramF = fp.getParameterLists().get(0).getParameters().get(0);
Assert.assertTrue(paramF.isDeclaredAnything());
Assert.assertEquals("f", paramF.getName());
Assert.assertTrue(paramF.getModel() instanceof Function);
Function modelF = (Function) paramF.getModel();
Assert.assertTrue(modelF.isDeclaredVoid());
Assert.assertEquals("Anything(String*)", typeName(modelF));
Assert.assertEquals("f", modelF.getName());
Assert.assertEquals(1, modelF.getParameterLists().size());
Assert.assertEquals(1, modelF.getParameterLists().get(0).getParameters().size());
Parameter paramS = modelF.getParameterLists().get(0).getParameters().get(0);
Assert.assertEquals("s", paramS.getName());
Assert.assertTrue(paramS.isSequenced());
Assert.assertFalse(paramS.isAtLeastOne());
Assert.assertTrue(paramS.getModel() instanceof Value);
Value modelS = (Value) paramS.getModel();
Assert.assertEquals("s", modelS.getName());
Assert.assertEquals("String[]", typeName(modelS));
}
{
// functionalParameterVariadicPlus
Function fp = (Function) fpClass.getDirectMember("functionalParameterVariadicPlus", null, false);
Assert.assertNotNull(fp);
Assert.assertEquals(1, fp.getParameterLists().size());
Assert.assertEquals(1, fp.getParameterLists().get(0).getParameters().size());
Assert.assertEquals("Anything(Anything(String+))", typeName(fp));
Parameter paramF = fp.getParameterLists().get(0).getParameters().get(0);
Assert.assertTrue(paramF.isDeclaredAnything());
Assert.assertEquals("f", paramF.getName());
Assert.assertTrue(paramF.getModel() instanceof Function);
Function modelF = (Function) paramF.getModel();
Assert.assertTrue(modelF.isDeclaredVoid());
Assert.assertEquals("Anything(String+)", typeName(modelF));
Assert.assertEquals("f", modelF.getName());
Assert.assertEquals(1, modelF.getParameterLists().size());
Assert.assertEquals(1, modelF.getParameterLists().get(0).getParameters().size());
Parameter paramS = modelF.getParameterLists().get(0).getParameters().get(0);
Assert.assertEquals("s", paramS.getName());
Assert.assertTrue(paramS.isSequenced());
Assert.assertTrue(paramS.isAtLeastOne());
Assert.assertTrue(paramS.getModel() instanceof Value);
Value modelS = (Value) paramS.getModel();
Assert.assertEquals("s", modelS.getName());
Assert.assertEquals("[String+]", typeName(modelS));
}
}
private String typeName(FunctionOrValue fp) {
if (fp instanceof Function) {
return fp.appliedTypedReference(null, Collections.<Type>emptyList()).getFullType().asString();
} else if (fp instanceof Value) {
return fp.getType().asString();
}
return null;
}
});
} catch (RuntimeException e) {
if (e.getCause() instanceof org.junit.ComparisonFailure) {
throw (org.junit.ComparisonFailure) e.getCause();
} else if (e.getCause() instanceof java.lang.AssertionError) {
throw (java.lang.AssertionError) e.getCause();
}
throw e;
}
}
use of org.eclipse.ceylon.model.typechecker.model.Package in project ceylon by eclipse.
the class JsonModule method getPackage.
@Override
public Package getPackage(String name) {
if ("default".equals(name)) {
name = "";
}
// search direct packages
Package p = getDirectPackage(name);
if (p != null) {
return p;
}
// search imported modules
HashSet<Module> visited = new HashSet<Module>();
visited.add(this);
for (ModuleImport imp : getImports()) {
p = getPackageFromImport(name, imp.getModule(), visited);
if (p != null) {
return p;
}
}
// not found
return null;
}
use of org.eclipse.ceylon.model.typechecker.model.Package in project ceylon by eclipse.
the class PhasedUnits method checkModuleFilters.
private boolean checkModuleFilters(boolean definesModule) {
if (moduleFilters == null || moduleFilters.isEmpty())
return true;
Package pkg = moduleSourceMapper.getCurrentPackage();
String pkgName = pkg.getNameAsString();
/*
; filter example syntax:
module-list+ (wanted-modules+) -> allowed-paths*
; Filter unwanted modules
a, a.b, aa, b (a) -> a, a.b
; Filter unwanted longer-named modules
a.b.c, a.b.d (a.b) ->
; Allow going to the module we're looking for
a, a.b, a.b.c (a.b.c) -> a, a.b, a.b.c
; Allow any package in the default module
a, b, c (default) -> a, b, c
*/
for (String module : moduleFilters) {
// Are we looking for the default module?
if (module.equals(Module.DEFAULT_MODULE_NAME)) {
// and we're not defining a new module.
if (pkg.getModule().isDefaultModule() && !definesModule) {
return true;
}
// None of the other rules apply to the default module.
continue;
}
// if we're not defining it we will just have to deal with the error elsewhere (its absence).
if (pkgName.equals(module)) {
return true;
}
// an error later because a module can't contain another module
if (pkgName.startsWith(module + ".") && pkg.getModule().getNameAsString().equals(module)) {
return true;
}
// and we're not defining a new module
if (module.startsWith(pkgName + ".") && pkg.getModule().isDefaultModule() && !definesModule) {
return true;
}
}
return false;
}
use of org.eclipse.ceylon.model.typechecker.model.Package in project ceylon by eclipse.
the class LanguageCompiler method initRound.
@Override
public void initRound(JavaCompiler prev) {
super.initRound(prev);
// round compilers don't add module trees, it's already done by the first one
addModuleTrees = false;
PhasedUnits oldPUs = ((LanguageCompiler) prev).phasedUnits;
ModuleManager moduleManager = phasedUnits.getModuleManager();
ModuleSourceMapper moduleSourceMapper = phasedUnits.getModuleSourceMapper();
for (PhasedUnit pu : oldPUs.getPhasedUnits()) {
if (pu instanceof CeylonPhasedUnit) {
CeylonPhasedUnit cpu = (CeylonPhasedUnit) pu;
// FIXME: this is bad in many ways
String pkgName;
try {
pkgName = getPackage(((CeylonPhasedUnit) pu).getFileObject());
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
continue;
}
// make a Package with no module yet, we will resolve them later
/*
* Stef: see javadoc for findOrCreateModulelessPackage() for why this is here.
*/
org.eclipse.ceylon.model.typechecker.model.Package p = modelLoader.findOrCreateModulelessPackage(pkgName == null ? "" : pkgName);
CeylonPhasedUnit newPu = new CeylonPhasedUnit(pu.getUnitFile(), pu.getSrcDir(), pu.getCompilationUnit(), p, moduleManager, moduleSourceMapper, ceylonContext, cpu.getFileObject(), cpu.getLineMap());
phasedUnits.addPhasedUnit(pu.getUnitFile(), newPu);
} else {
phasedUnits.addPhasedUnit(pu.getUnitFile(), pu);
}
}
}
use of org.eclipse.ceylon.model.typechecker.model.Package in project ceylon by eclipse.
the class LanguageCompiler method genCodeUnlessError.
private JavaFileObject genCodeUnlessError(Env<AttrContext> env, JCClassDecl cdef) throws IOException {
CeylonFileObject sourcefile = (CeylonFileObject) env.toplevel.sourcefile;
try {
// do not look at the global number of errors but only those for this file
if (super.gen.genClass(env, cdef)) {
String packageName = cdef.sym.packge().getQualifiedName().toString();
Package pkg = modelLoader.findPackage(packageName);
if (pkg == null)
throw new RuntimeException("Failed to find package: " + packageName);
Module module = pkg.getModule();
if (!module.isDefaultModule()) {
String moduleName = module.getNameAsString();
CeylonFileObject moduleFileObject = moduleNamesToFileObjects.get(moduleName);
// if there's no module source file object it means the module descriptor had parse errors
if (moduleFileObject == null || moduleFileObject.hasError()) {
// we do not produce any class files for modules with errors
if (options.get(Option.VERBOSE) != null) {
log.printRawLines(WriterKind.NOTICE, "[Not writing class " + cdef.sym.className() + " because its module has errors: " + moduleName + "]");
}
return null;
}
}
return writer.writeClass(cdef.sym);
}
} catch (ClassWriter.PoolOverflow ex) {
log.error(cdef.pos(), "limit.pool");
} catch (ClassWriter.StringOverflow ex) {
log.error(cdef.pos(), "limit.string.overflow", ex.value.substring(0, 20));
} catch (CompletionFailure ex) {
chk.completionError(cdef.pos(), ex);
} catch (AssertionError e) {
throw new RuntimeException("Error generating bytecode for " + sourcefile.getName(), e);
}
return null;
}
Aggregations