use of org.eclipse.ceylon.model.typechecker.model.Package in project ceylon by eclipse.
the class ImportVisitor method visit.
@Override
public void visit(Tree.Import that) {
Backends scopedBackends = that.getScope().getScopedBackends();
if (!scopedBackends.none() && !scopedBackends.supports(unit.getSupportedBackends())) {
return;
}
Tree.ImportPath path = that.getImportPath();
Package importedPackage = importedPackage(path, unit);
if (importedPackage != null) {
path.setModel(importedPackage);
Tree.ImportMemberOrTypeList imtl = that.getImportMemberOrTypeList();
if (imtl != null) {
ImportList il = imtl.getImportList();
il.setImportedScope(importedPackage);
Set<String> names = new HashSet<String>();
List<Tree.ImportMemberOrType> list = imtl.getImportMemberOrTypes();
for (Tree.ImportMemberOrType member : list) {
names.add(importMember(member, importedPackage, il));
}
if (imtl.getImportWildcard() != null) {
importAllMembers(importedPackage, names, il);
} else if (list.isEmpty()) {
imtl.addError("empty import list", 1020);
}
}
}
}
use of org.eclipse.ceylon.model.typechecker.model.Package in project ceylon by eclipse.
the class MissingNativeVisitor method checkNativeExistence.
private boolean checkNativeExistence(Node node, Declaration model, boolean nodeIsDecl) {
if (model == null)
return true;
if (!model.isToplevel() || !model.isNative())
return true;
Package pkg = ModelUtil.getPackage(model);
if (pkg == null)
return true;
if (nodeIsDecl && !model.isNativeHeader() && !ModelUtil.isForBackend(model.getNativeBackends(), forBackend)) {
// We don't care about declarations for other backends
return false;
}
if (ModelUtil.isForBackend(model.getNativeBackends(), forBackend)) {
return true;
} else {
Declaration hdr;
if (model.isNativeHeader()) {
hdr = model;
} else {
hdr = getNativeHeader(model);
}
if (hdr != null) {
if (ModelUtil.isImplemented(hdr)) {
return true;
}
Declaration impl = getNativeDeclaration(hdr, forBackend);
if (impl != null) {
return true;
}
} else {
// already by the typechecker
return true;
}
}
boolean ok = checkNative(node, model);
if (!ok) {
String name = model.getName();
String desc = name == null ? "header" : "'" + name + "'";
node.addError("no native implementation for backend: native " + desc + " is not implemented for the '" + forBackend.nativeAnnotation + "' backend", forBackend);
}
return true;
}
use of org.eclipse.ceylon.model.typechecker.model.Package in project ceylon by eclipse.
the class ModuleSourceMapper method createPackageAndAddToModule.
private void createPackageAndAddToModule(String path) {
final Package lastPkg = packageStack.peekLast();
List<String> parentName = lastPkg.getName();
final ArrayList<String> name = new ArrayList<String>(parentName.size() + 1);
name.addAll(parentName);
name.add(path);
Package pkg = moduleManager.createPackage(formatPath(name), currentModule != null ? currentModule : modules.getDefaultModule());
packageStack.addLast(pkg);
}
use of org.eclipse.ceylon.model.typechecker.model.Package in project ceylon by eclipse.
the class ModuleSourceMapper method visitModuleFile.
public void visitModuleFile() {
if (currentModule == null) {
final Package currentPkg = packageStack.peekLast();
final List<String> moduleName = currentPkg.getName();
// we don't know the version at this stage, will be filled later
currentModule = moduleManager.getOrCreateModule(moduleName, null);
if (currentModule != null) {
// TODO : not necessary anymore ? the phasedUnit will be added. And the buildModuleImport()
currentModule.setAvailable(true);
// function (which calls module.setAvailable()) will be called by the typeChecker
// BEFORE the ModuleValidator.verifyModuleDependencyTree() call that uses
// isAvailable()
Package pkg = currentModule.getDirectPackage(currentPkg.getNameAsString());
if (pkg == null) {
moduleManager.bindPackageToModule(currentPkg, currentModule);
} else {
// Tako: this is a work-around for the fact that the Package gets
// created before the Module it belongs to and that with multiple
// source folders we could end up with duplicate Packages.
// So we pop the newly created Package and replace it with the
// existing one we found in the Module
packageStack.pollLast();
packageStack.addLast(pkg);
}
} else {
addErrorToModule(new ArrayList<String>(), "module may not be defined at the top level of the hierarchy");
}
} else {
StringBuilder error = new StringBuilder("two modules within the same hierarchy: '");
error.append(formatPath(currentModule.getName())).append("' and '").append(formatPath(packageStack.peekLast().getName())).append("'");
addErrorToModule(currentModule.getName(), error.toString());
addErrorToModule(packageStack.peekLast().getName(), error.toString());
}
}
use of org.eclipse.ceylon.model.typechecker.model.Package in project ceylon by eclipse.
the class GenerateJsVisitor method visit.
@Override
public void visit(final Tree.PackageLiteral that) {
Package pkg = (Package) that.getImportPath().getModel();
MetamodelHelper.findModule(pkg.getModule(), this);
out(".findPackage('", pkg.getNameAsString(), "')");
}
Aggregations