Search in sources :

Example 1 with ImportModule

use of org.eclipse.ceylon.compiler.typechecker.tree.Tree.ImportModule in project ceylon by eclipse.

the class ModuleValidator method verifyNative.

private void verifyNative(Module module) {
    for (ImportModule imp : moduleManagerUtil.retrieveModuleImportNodes(module)) {
        Module importedModule;
        Node node;
        if (imp.getImportPath() != null) {
            node = imp.getImportPath();
            importedModule = (Module) imp.getImportPath().getModel();
        } else {
            node = imp.getQuotedLiteral();
            importedModule = moduleManagerUtil.getModuleForNode(node);
            if (importedModule == null)
                continue;
        }
        Backends bs = getNativeBackend(imp.getAnnotationList(), imp.getUnit());
        if (bs.none()) {
            if (importedModule.isNative() && !module.isNative()) {
                node.addError(new ModuleSourceMapper.ModuleDependencyAnalysisError(node, "native import for cross-platform module" + " (mark either the module or the import as native)", 20000));
            }
        } else if (importedModule.isNative() && !bs.supports(importedModule.getNativeBackends())) {
            node.addError(new ModuleSourceMapper.ModuleDependencyAnalysisError(node, "native backend name conflicts with imported module: '\"" + bs + "\"' is not '\"" + importedModule.getNativeBackends().names() + "\"'"));
        }
    }
}
Also used : Backends(org.eclipse.ceylon.common.Backends) Node(org.eclipse.ceylon.compiler.typechecker.tree.Node) ImportModule(org.eclipse.ceylon.compiler.typechecker.tree.Tree.ImportModule) Module(org.eclipse.ceylon.model.typechecker.model.Module) ImportModule(org.eclipse.ceylon.compiler.typechecker.tree.Tree.ImportModule)

Aggregations

Backends (org.eclipse.ceylon.common.Backends)1 Node (org.eclipse.ceylon.compiler.typechecker.tree.Node)1 ImportModule (org.eclipse.ceylon.compiler.typechecker.tree.Tree.ImportModule)1 Module (org.eclipse.ceylon.model.typechecker.model.Module)1