use of org.eclipse.ceylon.model.typechecker.model.Package in project ceylon by eclipse.
the class ModuleDoc method generate.
public void generate() throws IOException {
writeHeader("Overview");
writeNavBar();
open("div class='container-fluid'");
writeDescription();
writePackagesTable("Packages", tool.getPackages(module));
writeDependencies();
close("div");
for (Package pkg : module.getPackages()) {
if (tool.isRootPackage(module, pkg) && !pkg.getMembers().isEmpty()) {
rootPackageDoc = new PackageDoc(tool, writer, pkg);
rootPackageDoc.generate();
}
}
writeFooter();
}
use of org.eclipse.ceylon.model.typechecker.model.Package in project ceylon by eclipse.
the class PackageDoc method writeSubpackages.
private void writeSubpackages() throws IOException {
if (!sharingPageWithModule) {
List<Package> subpackages = new ArrayList<Package>();
for (Package p : module.getPackages()) {
if (p.getName().size() == pkg.getName().size() + 1 && p.getNameAsString().startsWith(pkg.getNameAsString()) && tool.shouldInclude(p)) {
subpackages.add(p);
}
}
Collections.sort(subpackages, ReferenceableComparatorByName.INSTANCE);
writePackagesTable("Subpackages", subpackages);
}
}
use of org.eclipse.ceylon.model.typechecker.model.Package in project ceylon by eclipse.
the class ExpressionVisitor method resolveQualifiedTypeExpression.
private TypeDeclaration resolveQualifiedTypeExpression(Tree.QualifiedTypeExpression that, boolean error) {
if (checkMember(that)) {
Tree.Primary primary = that.getPrimary();
Tree.Identifier id = that.getIdentifier();
List<Type> signature = that.getSignature();
boolean spread = that.getEllipsis();
String name = name(id);
String container;
boolean ambiguous;
TypeDeclaration type;
Type pt;
if (primary instanceof Tree.Package) {
Package pack = unit.getPackage();
container = "package '" + pack.getNameAsString() + "'";
type = getPackageTypeDeclaration(name, signature, spread, unit);
ambiguous = false;
pt = null;
} else {
pt = primary.getTypeModel().resolveAliases();
TypeDeclaration d = getDeclaration(that, pt);
if (d instanceof Constructor) {
d = d.getExtendedType().getDeclaration();
}
container = "type '" + d.getName(unit) + "'";
Scope scope = that.getScope();
type = getTypeMember(d, name, signature, spread, unit, scope);
ambiguous = type == null && d.isMemberAmbiguous(name, unit, signature, spread);
if (type == null) {
container += memberCorrectionMessage(name, d, scope, unit, cancellable);
}
}
if (type == null) {
if (error) {
if (ambiguous) {
that.addError("member type is ambiguous: '" + name + "' for " + container);
} else {
that.addError("member type is not defined: '" + name + "' in " + container, 100);
unit.setUnresolvedReferences();
}
}
} else {
type = (TypeDeclaration) handleAbstractionOrHeader(type, that, error);
if (error) {
checkStaticPrimary(that, primary, type, pt);
}
that.setDeclaration(type);
resetSuperReference(that);
if (!isSelfReference(primary) && !type.isShared()) {
type.setOtherInstanceAccess(true);
}
if (error) {
if (checkConcreteClass(type, that)) {
if (checkVisibleConstructor(that, type)) {
checkQualifiedTypeAndConstructorVisibility(that, type, name, container);
}
}
if (!inExtendsClause) {
checkSuperMember(that, signature, spread);
}
}
}
return type;
} else {
return null;
}
}
use of org.eclipse.ceylon.model.typechecker.model.Package 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.Package 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;
}
Aggregations