Search in sources :

Example 16 with Module

use of org.eclipse.ceylon.model.typechecker.model.Module in project ceylon by eclipse.

the class ExpressionTransformer method makePackageLiteralCall.

private JCExpression makePackageLiteralCall(Package pkg) {
    // get the module
    Module module = pkg.getModule();
    JCExpression moduleCall = makeModuleLiteralCall(module);
    // now get the package
    return make().Apply(null, makeSelect(moduleCall, "findPackage"), List.<JCExpression>of(ceylonLiteral(pkg.getNameAsString())));
}
Also used : JCExpression(org.eclipse.ceylon.langtools.tools.javac.tree.JCTree.JCExpression) Module(org.eclipse.ceylon.model.typechecker.model.Module)

Example 17 with Module

use of org.eclipse.ceylon.model.typechecker.model.Module in project ceylon by eclipse.

the class CeylonClassWriter method writeClass.

@Override
public JavaFileObject writeClass(ClassSymbol c) throws IOException, PoolOverflow, StringOverflow {
    String packageName = c.packge().getQualifiedName().toString();
    Package pkg = modelLoader.findPackage(packageName);
    if (pkg == null)
        throw new RuntimeException("Failed to find package: " + packageName);
    Module module = pkg.getModule();
    fileManager.setModule(module);
    return super.writeClass(c);
}
Also used : Package(org.eclipse.ceylon.model.typechecker.model.Package) Module(org.eclipse.ceylon.model.typechecker.model.Module)

Example 18 with Module

use of org.eclipse.ceylon.model.typechecker.model.Module in project ceylon by eclipse.

the class JsIdentifierNames method setter.

/**
 * Determine the function name to be used in the generated JavaScript code
 * for the setter of the given declaration.
 */
public String setter(Declaration decl) {
    String name = getName(decl, true, false);
    final Module mod = decl.getUnit().getPackage().getModule();
    if (mod.getJsMajor() > 0 && (mod.getJsMajor() < 9 || (mod.getJsMajor() == 9 && mod.getJsMinor() < 1))) {
        return String.format("set%c%s", Character.toUpperCase(name.charAt(0)), name.substring(1));
    }
    return String.format("set$%s", name);
}
Also used : Module(org.eclipse.ceylon.model.typechecker.model.Module)

Example 19 with Module

use of org.eclipse.ceylon.model.typechecker.model.Module in project ceylon by eclipse.

the class JsOutput method encodeModel.

public void encodeModel(final JsIdentifierNames names) throws IOException {
    if (!modelDone) {
        modelDone = true;
        writeModelFile();
        out("\nvar _CTM$;function $CCMM$(){if (_CTM$===undefined)_CTM$=");
        writeModelRetriever();
        out(";return _CTM$;}\n");
        out("ex$.$CCMM$=$CCMM$;\n");
        if (!compilingLanguageModule) {
            Module clm = module.getLanguageModule();
            clalias = names.moduleAlias(clm) + ".";
            require(clm, names);
            out(clalias, "$addmod$(ex$,'", module.getNameAsString(), "/", module.getVersion(), "');\n");
        }
    }
}
Also used : Module(org.eclipse.ceylon.model.typechecker.model.Module)

Example 20 with Module

use of org.eclipse.ceylon.model.typechecker.model.Module in project ceylon by eclipse.

the class ModuleSourceMapper method attachErrorToDependencyDeclaration.

public void attachErrorToDependencyDeclaration(ModuleImport moduleImport, List<Module> dependencyTree, String error, boolean isError) {
    if (!attachErrorToDependencyDeclaration(moduleImport, error, isError)) {
        // the error to
        if (dependencyTree.size() >= 2) {
            Module rootModule = dependencyTree.get(0);
            Module originalImportedModule = dependencyTree.get(1);
            // find the original import
            for (ModuleImport imp : rootModule.getImports()) {
                if (imp.getModule() == originalImportedModule) {
                    // found it, try to attach the error
                    if (attachErrorToDependencyDeclaration(imp, error, isError)) {
                        // we're done
                        return;
                    } else {
                        // failed
                        break;
                    }
                }
            }
        }
        System.err.println("This might be a type checker bug, please report. \nExpecting to add missing dependency error on non present definition: " + error);
    }
}
Also used : ModuleImport(org.eclipse.ceylon.model.typechecker.model.ModuleImport) Module(org.eclipse.ceylon.model.typechecker.model.Module)

Aggregations

Module (org.eclipse.ceylon.model.typechecker.model.Module)113 LazyModule (org.eclipse.ceylon.model.loader.model.LazyModule)37 Package (org.eclipse.ceylon.model.typechecker.model.Package)26 ModuleImport (org.eclipse.ceylon.model.typechecker.model.ModuleImport)25 Declaration (org.eclipse.ceylon.model.typechecker.model.Declaration)20 TypeDeclaration (org.eclipse.ceylon.model.typechecker.model.TypeDeclaration)19 ArrayList (java.util.ArrayList)18 TypedDeclaration (org.eclipse.ceylon.model.typechecker.model.TypedDeclaration)16 File (java.io.File)14 Type (org.eclipse.ceylon.model.typechecker.model.Type)14 HashMap (java.util.HashMap)9 HashSet (java.util.HashSet)9 FunctionalInterfaceType (org.eclipse.ceylon.model.loader.mirror.FunctionalInterfaceType)9 UnknownType (org.eclipse.ceylon.model.typechecker.model.UnknownType)9 Test (org.junit.Test)9 Value (org.eclipse.ceylon.model.typechecker.model.Value)8 LinkedList (java.util.LinkedList)7 List (java.util.List)7 Backends (org.eclipse.ceylon.common.Backends)7 ClassMirror (org.eclipse.ceylon.model.loader.mirror.ClassMirror)7