use of com.redhat.ceylon.model.typechecker.model.Declaration in project ceylon-compiler by ceylon.
the class ClassDoc method writeInheritedMembers.
private void writeInheritedMembers(MemberSpecification specification, String tableTitle, String rowTitle) throws IOException {
boolean first = true;
Map<TypeDeclaration, SortedMap<String, Declaration>> superClassInheritedMembersMap = superclassInheritedMembers.get(specification);
List<TypeDeclaration> superClasses = new ArrayList<TypeDeclaration>(superclassInheritedMembers.get(specification).keySet());
Collections.sort(superClasses, ReferenceableComparatorByName.INSTANCE);
for (TypeDeclaration superClass : superClasses) {
SortedMap<String, Declaration> inheritedMembers = superClassInheritedMembersMap.get(superClass);
if (first) {
first = false;
openTable(null, tableTitle, 1, false);
}
writeInheritedMembersRow(rowTitle, superClass, inheritedMembers);
}
Map<TypeDeclaration, SortedMap<String, Declaration>> superInterfaceInheritedMembersMap = interfaceInheritedMembers.get(specification);
List<TypeDeclaration> superInterfaces = new ArrayList<TypeDeclaration>(superInterfaceInheritedMembersMap.keySet());
Collections.sort(superInterfaces, ReferenceableComparatorByName.INSTANCE);
for (TypeDeclaration superInterface : superInterfaces) {
SortedMap<String, Declaration> members = superInterfaceInheritedMembersMap.get(superInterface);
if (members == null || members.isEmpty()) {
continue;
}
if (first) {
first = false;
openTable(null, tableTitle, 1, false);
}
writeInheritedMembersRow(rowTitle, superInterface, members);
}
if (!first) {
closeTable();
}
}
use of com.redhat.ceylon.model.typechecker.model.Declaration in project ceylon-compiler by ceylon.
the class ClassDoc method writeInheritedMembersRow.
private void writeInheritedMembersRow(String title, TypeDeclaration superType, SortedMap<String, Declaration> members) throws IOException {
open("tr", "td");
write(title);
writeIcon(superType);
linkRenderer().to(superType).useScope(klass).withinText(true).write();
open("div class='inherited-members'");
boolean first = true;
for (Entry<String, Declaration> entry : members.entrySet()) {
if (!first) {
write(", ");
} else {
first = false;
}
String name = entry.getKey();
Declaration member = entry.getValue();
boolean alias = Util.nullSafeCompare(name, Util.getDeclarationName(member)) != 0;
LinkRenderer linkRenderer = linkRenderer().withinText(true).to(member).useScope(klass).printMemberContainerName(false);
if (alias) {
StringBuilder sb = new StringBuilder();
sb.append("<code><span class='");
if (member instanceof TypeDeclaration)
sb.append("type-");
sb.append("identifier'>");
sb.append(name);
sb.append("</span></code>");
linkRenderer.useCustomText(sb.toString());
}
linkRenderer.write();
}
close("div");
close("td", "tr");
}
use of com.redhat.ceylon.model.typechecker.model.Declaration in project ceylon-compiler by ceylon.
the class ClassOrPackageDoc method writeLinkToRefinedDeclaration.
private void writeLinkToRefinedDeclaration(FunctionOrValue d) throws IOException {
Declaration topMostRefinedDecl = d.getRefinedDeclaration();
if (topMostRefinedDecl != null && topMostRefinedDecl != d) {
Declaration bottomMostRefinedDecl = findBottomMostRefinedDeclaration(d);
open("div class='refined section'");
around("span class='title'", "Refines ");
if (bottomMostRefinedDecl != null && bottomMostRefinedDecl != topMostRefinedDecl) {
linkRenderer().to(bottomMostRefinedDecl).withinText(true).useCustomText(getNameWithContainer(bottomMostRefinedDecl)).write();
around("span class='title'", " ultimately refines ");
linkRenderer().to(topMostRefinedDecl).withinText(true).useCustomText(getNameWithContainer(topMostRefinedDecl)).write();
} else {
linkRenderer().to(topMostRefinedDecl).withinText(true).useCustomText(getNameWithContainer(topMostRefinedDecl)).write();
}
close("div");
}
}
use of com.redhat.ceylon.model.typechecker.model.Declaration in project ceylon-compiler by ceylon.
the class StatementTransformer method definitelySatisfiedOrNot.
private boolean definitelySatisfiedOrNot(java.util.List<Tree.Condition> conditions, boolean satisfied) {
if (conditions.size() != 1) {
return false;
}
Tree.Condition condition = conditions.get(0);
if (!(condition instanceof Tree.BooleanCondition)) {
return false;
}
Tree.Term term = ((Tree.BooleanCondition) condition).getExpression().getTerm();
if (!(term instanceof Tree.BaseMemberExpression)) {
return false;
}
Declaration declaration = ((Tree.BaseMemberExpression) term).getDeclaration();
return declaration instanceof Value && satisfied ? isBooleanTrue(declaration) : isBooleanFalse(declaration);
}
use of com.redhat.ceylon.model.typechecker.model.Declaration 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);
}
Aggregations