use of com.redhat.ceylon.model.typechecker.model.ClassOrInterface 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.ClassOrInterface in project ceylon-compiler by ceylon.
the class ClassDoc method writeListOnSummary.
private void writeListOnSummary(String cssClass, String title, List<?> types) throws IOException {
if (!isEmpty(types)) {
open("div class='" + cssClass + " section'");
around("span class='title'", title);
boolean first = true;
for (Object type : types) {
if (!first) {
write(", ");
} else {
first = false;
}
if (type instanceof TypedDeclaration) {
TypedDeclaration decl = (TypedDeclaration) type;
linkRenderer().to(decl).useScope(klass).write();
} else if (type instanceof ClassOrInterface) {
ClassOrInterface coi = (ClassOrInterface) type;
linkRenderer().to(coi).useScope(klass).printAbbreviated(!isAbbreviatedType(coi)).write();
} else {
Type pt = (Type) type;
linkRenderer().to(pt).useScope(klass).printAbbreviated(!isAbbreviatedType(pt.getDeclaration())).write();
}
}
close("div");
}
}
use of com.redhat.ceylon.model.typechecker.model.ClassOrInterface in project ceylon-compiler by ceylon.
the class ClassDoc method writeInnerTypes.
private void writeInnerTypes(Map<String, ? extends TypeDeclaration> innerTypeDeclarations, String id, String title) throws IOException {
if (!innerTypeDeclarations.isEmpty()) {
openTable(id, title, 2, true);
for (Entry<String, ? extends TypeDeclaration> entry : innerTypeDeclarations.entrySet()) {
TypeDeclaration innerTypeDeclaration = entry.getValue();
String name = entry.getKey();
if (innerTypeDeclaration instanceof ClassOrInterface) {
ClassOrInterface innerClassOrInterface = (ClassOrInterface) innerTypeDeclaration;
tool.doc(innerClassOrInterface);
doc(name, innerClassOrInterface);
}
if (innerTypeDeclaration instanceof TypeAlias) {
TypeAlias innerAlias = (TypeAlias) innerTypeDeclaration;
doc(name, innerAlias);
}
}
closeTable();
}
}
use of com.redhat.ceylon.model.typechecker.model.ClassOrInterface in project ceylon-compiler by ceylon.
the class TypeParameterCaptureVisitor method visit.
@Override
public void visit(Tree.ClassOrInterface that) {
ClassOrInterface model = that.getDeclarationModel();
if (model != null && !model.isAlias() && !model.isToplevel() && !model.isMember()) {
// it's a local type, capture!
captureTypeParameters(model);
}
super.visit(that);
}
use of com.redhat.ceylon.model.typechecker.model.ClassOrInterface in project ceylon-compiler by ceylon.
the class BoxingDeclarationVisitor method setErasureState.
private void setErasureState(TypedDeclaration decl) {
// deal with invalid input
if (decl == null)
return;
Type type = decl.getType();
if (type != null) {
if (hasErasure(type) || hasSubstitutedBounds(type) || type.isTypeConstructor()) {
decl.setTypeErased(true);
}
if (decl.isActual() && decl.getContainer() instanceof ClassOrInterface && // make sure we did not lose type information due to non-widening
isWideningTypedDeclaration(decl)) {
// widening means not trusting the type, otherwise we end up thinking that the type is
// something it's not and regular erasure rules don't apply there
decl.setUntrustedType(true);
decl.setTypeErased(true);
}
}
}
Aggregations