use of org.eclipse.ceylon.model.typechecker.model.ClassOrInterface in project ceylon by eclipse.
the class BoxingDeclarationVisitor method setErasureState.
private void setErasureState(TypedDeclaration decl) {
// deal with invalid input
if (decl == null)
return;
Type type = decl.getType();
boolean erased = false;
boolean untrusted = false;
if (type != null) {
if (hasErasure(type) || hasSubstitutedBounds(type) || type.isTypeConstructor()) {
erased = true;
}
if (decl.isActual() && decl.getContainer() instanceof ClassOrInterface) {
TypedDeclaration refinedDeclaration = getRefinedDeclarationForWideningRules(decl);
if (refinedDeclaration != null && refinedDeclaration != decl && decl.getUntrustedType() == null) {
// make sure the refined decl is set before we look at it
setErasureState(refinedDeclaration);
}
// make sure we did not lose type information due to non-widening
if (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
untrusted = true;
erased = true;
}
}
}
decl.setTypeErased(erased);
if (isPinnedType(decl)) {
untrusted = true;
}
decl.setUntrustedType(untrusted);
}
use of org.eclipse.ceylon.model.typechecker.model.ClassOrInterface in project ceylon by eclipse.
the class CeylonDoc method getIcons.
protected final List<String> getIcons(Object obj) {
List<String> icons = new ArrayList<String>();
if (obj instanceof Declaration) {
Declaration decl = (Declaration) obj;
Annotation deprecated = Util.findAnnotation(decl, "deprecated");
if (deprecated != null) {
icons.add("icon-decoration-deprecated");
}
if (decl instanceof ClassOrInterface || decl instanceof Constructor) {
if (decl instanceof Interface) {
icons.add("icon-interface");
if (Util.isEnumerated((ClassOrInterface) decl)) {
icons.add("icon-decoration-enumerated");
}
}
if (decl instanceof Class) {
Class klass = (Class) decl;
if (klass.isAnonymous()) {
icons.add("icon-object");
} else {
icons.add("icon-class");
}
if (klass.isAbstract()) {
icons.add("icon-decoration-abstract");
}
if (klass.isFinal() && !klass.isAnonymous() && !klass.isAnnotation()) {
icons.add("icon-decoration-final");
}
if (Util.isEnumerated(klass)) {
icons.add("icon-decoration-enumerated");
}
}
if (decl instanceof Constructor) {
icons.add("icon-class");
}
if (!decl.isShared()) {
icons.add("icon-decoration-local");
}
}
if (decl instanceof TypedDeclaration) {
if (decl.isShared()) {
icons.add("icon-shared-member");
} else {
icons.add("icon-local-member");
}
if (decl.isFormal()) {
icons.add("icon-decoration-formal");
}
if (decl.isActual()) {
Declaration refinedDeclaration = decl.getRefinedDeclaration();
if (refinedDeclaration != null) {
if (refinedDeclaration.isFormal()) {
icons.add("icon-decoration-impl");
}
if (refinedDeclaration.isDefault()) {
icons.add("icon-decoration-over");
}
}
}
if (((TypedDeclaration) decl).isVariable()) {
icons.add("icon-decoration-variable");
}
}
if (decl instanceof TypeAlias || decl instanceof NothingType) {
icons.add("icon-type-alias");
}
if (decl.isAnnotation()) {
icons.add("icon-decoration-annotation");
}
}
if (obj instanceof Package) {
Package pkg = (Package) obj;
icons.add("icon-package");
if (!pkg.isShared()) {
icons.add("icon-decoration-local");
}
}
if (obj instanceof ModuleImport) {
ModuleImport moduleImport = (ModuleImport) obj;
icons.add("icon-module");
if (moduleImport.isExport()) {
icons.add("icon-module-exported-decoration");
}
if (moduleImport.isOptional()) {
icons.add("icon-module-optional-decoration");
}
}
if (obj instanceof Module) {
icons.add("icon-module");
}
return icons;
}
use of org.eclipse.ceylon.model.typechecker.model.ClassOrInterface in project ceylon by eclipse.
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 org.eclipse.ceylon.model.typechecker.model.ClassOrInterface in project ceylon by eclipse.
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 org.eclipse.ceylon.model.typechecker.model.ClassOrInterface in project ceylon by eclipse.
the class LinkRenderer method getExternalUrl.
private String getExternalUrl(Object to) {
String url = null;
if (to instanceof Module) {
url = getExternalModuleUrl((Module) to);
if (url != null) {
url += "index.html";
}
} else if (to instanceof Package) {
Package pkg = (Package) to;
url = getExternalModuleUrl(pkg.getModule());
if (url != null) {
url += buildPackageUrlPath(pkg);
url += "index.html";
}
} else if (to instanceof ClassOrInterface) {
ClassOrInterface klass = (ClassOrInterface) to;
Package pkg = getPackage(klass);
url = getExternalModuleUrl(pkg.getModule());
if (url != null) {
url += buildPackageUrlPath(pkg);
url += ceylonDocTool.getFileName(klass);
}
}
return url;
}
Aggregations