use of com.redhat.ceylon.model.typechecker.model.Package in project ceylon-compiler by ceylon.
the class CeylonDocTool method collectSubclasses.
private void collectSubclasses() throws IOException {
for (Module module : modules) {
for (Package pkg : getPackages(module)) {
for (Declaration decl : pkg.getMembers()) {
if (!shouldInclude(decl)) {
continue;
}
if (decl instanceof ClassOrInterface) {
ClassOrInterface c = (ClassOrInterface) decl;
// subclasses map
if (c instanceof Class) {
Type superclass = c.getExtendedType();
if (superclass != null) {
TypeDeclaration superdec = superclass.getDeclaration();
if (subclasses.get(superdec) == null) {
subclasses.put(superdec, new ArrayList<Class>());
}
subclasses.get(superdec).add((Class) c);
}
}
List<Type> satisfiedTypes = new ArrayList<Type>(c.getSatisfiedTypes());
if (satisfiedTypes != null && satisfiedTypes.isEmpty() == false) {
// satisfying classes or interfaces map
for (Type satisfiedType : satisfiedTypes) {
TypeDeclaration superdec = satisfiedType.getDeclaration();
if (satisfyingClassesOrInterfaces.get(superdec) == null) {
satisfyingClassesOrInterfaces.put(superdec, new ArrayList<ClassOrInterface>());
}
satisfyingClassesOrInterfaces.get(superdec).add(c);
}
}
}
}
}
}
}
use of com.redhat.ceylon.model.typechecker.model.Package in project ceylon-compiler by ceylon.
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 com.redhat.ceylon.model.typechecker.model.Package in project ceylon-compiler by ceylon.
the class Naming method makeTypeDeclaration.
private <R> R makeTypeDeclaration(TypeDeclarationBuilder<R> declarationBuilder, final TypeDeclaration decl, DeclNameFlag... options) {
EnumSet<DeclNameFlag> flags = EnumSet.noneOf(DeclNameFlag.class);
flags.addAll(Arrays.asList(options));
if (flags.contains(DeclNameFlag.ANNOTATION) && !Decl.isAnnotationClass(decl)) {
throw new BugException(decl.getName());
}
if (flags.contains(DeclNameFlag.ANNOTATIONS) && !(Decl.isAnnotationClass(decl) || decl instanceof Class || gen().isSequencedAnnotation((Class) decl))) {
throw new BugException(decl.getName());
}
java.util.List<Scope> l = new java.util.ArrayList<Scope>();
Scope s = decl;
do {
l.add(s);
s = s.getContainer();
} while (!(s instanceof Package));
Collections.reverse(l);
if (flags.contains(DeclNameFlag.QUALIFIED) && (!decl.isAnonymous() || decl.isNamed())) {
final List<String> packageName;
if (!AbstractTransformer.isJavaArray(decl))
packageName = ((Package) s).getName();
else
packageName = COM_REDHAT_CEYLON_LANGUAGE_PACKAGE;
if (packageName.isEmpty() || !packageName.get(0).isEmpty()) {
declarationBuilder.select("");
}
for (int ii = 0; ii < packageName.size(); ii++) {
declarationBuilder.select(quoteIfJavaKeyword(packageName.get(ii)));
}
}
for (int ii = 0; ii < l.size(); ii++) {
Scope scope = l.get(ii);
final boolean last = ii == l.size() - 1;
appendTypeDeclaration(decl, flags, declarationBuilder, scope, last);
}
return declarationBuilder.result();
}
use of com.redhat.ceylon.model.typechecker.model.Package in project ceylon-compiler by ceylon.
the class Naming method getTypeArgumentDescriptorName.
public String getTypeArgumentDescriptorName(TypeParameter tp) {
String name;
if (tp.isCaptured()) {
// must build unique name
StringBuilder sb = new StringBuilder();
LinkedList<Declaration> decls = new LinkedList<Declaration>();
Scope scope = tp;
while (scope != null && scope instanceof Package == false) {
if (scope instanceof Declaration)
decls.add((Declaration) scope);
scope = scope.getContainer();
}
Iterator<Declaration> iterator = decls.descendingIterator();
while (iterator.hasNext()) {
sb.append(iterator.next().getName());
if (iterator.hasNext())
sb.append("$");
}
name = sb.toString();
} else {
name = tp.getName();
}
return prefixName(Prefix.$reified$, name);
}
use of com.redhat.ceylon.model.typechecker.model.Package in project ceylon-compiler by ceylon.
the class MethodDefinitionBuilder method isParamTypeLocalToMethod.
private boolean isParamTypeLocalToMethod(Parameter parameter, Type nonWideningType) {
// error recovery
if (nonWideningType == null)
return false;
if (parameter.getModel().getTypeErased()) {
return false;
}
Declaration method = parameter.getDeclaration();
TypeDeclaration paramTypeDecl = nonWideningType.getDeclaration();
if (paramTypeDecl instanceof TypeParameter && Decl.equalScopeDecl(paramTypeDecl.getContainer(), method)) {
return false;
}
Scope scope = paramTypeDecl.getContainer();
while (scope != null && !(scope instanceof Package)) {
if (Decl.equalScopeDecl(scope, method)) {
return true;
}
scope = scope.getContainer();
}
return false;
}
Aggregations