use of com.redhat.ceylon.model.typechecker.model.TypeDeclaration in project ceylon-compiler by ceylon.
the class CeylonDocTool method getFileName.
public String getFileName(TypeDeclaration type) {
// we need postfix, because objects can have same file name like classes/interfaces in not case-sensitive file systems
String postfix;
if (type instanceof Class && type.isAnonymous()) {
postfix = ".object";
} else {
postfix = ".type";
}
List<String> names = new LinkedList<String>();
Scope scope = type;
while (scope instanceof TypeDeclaration) {
names.add(0, ((TypeDeclaration) scope).getName());
scope = scope.getContainer();
}
return join(".", names) + postfix + ".html";
}
use of com.redhat.ceylon.model.typechecker.model.TypeDeclaration in project ceylon-compiler by ceylon.
the class CeylonDocTool method collectAnnotationConstructors.
private void collectAnnotationConstructors() {
for (Module module : modules) {
for (Package pkg : getPackages(module)) {
for (Declaration decl : pkg.getMembers()) {
if (decl instanceof Function && decl.isAnnotation() && shouldInclude(decl)) {
Function annotationCtor = (Function) decl;
TypeDeclaration annotationType = annotationCtor.getTypeDeclaration();
List<Function> annotationConstructorList = annotationConstructors.get(annotationType);
if (annotationConstructorList == null) {
annotationConstructorList = new ArrayList<Function>();
annotationConstructors.put(annotationType, annotationConstructorList);
}
annotationConstructorList.add(annotationCtor);
}
}
}
}
}
use of com.redhat.ceylon.model.typechecker.model.TypeDeclaration in project ceylon-compiler by ceylon.
the class CeylonDocTool method getObjectFile.
private File getObjectFile(Object modPgkOrDecl) throws IOException {
final File file;
if (modPgkOrDecl instanceof TypeDeclaration) {
TypeDeclaration type = (TypeDeclaration) modPgkOrDecl;
String filename = getFileName(type);
file = new File(getFolder(type), filename);
} else if (modPgkOrDecl instanceof Module) {
String filename = "index.html";
file = new File(getApiOutputFolder((Module) modPgkOrDecl), filename);
} else if (modPgkOrDecl instanceof Package) {
String filename = "index.html";
file = new File(getFolder((Package) modPgkOrDecl), filename);
} else {
throw new RuntimeException(CeylondMessages.msg("error.unexpected", modPgkOrDecl));
}
return file.getCanonicalFile();
}
use of com.redhat.ceylon.model.typechecker.model.TypeDeclaration in project ceylon-compiler by ceylon.
the class ClassDoc method loadInheritedMembers.
private void loadInheritedMembers(MemberSpecification specification, List<TypeDeclaration> superClassOrInterfaceList, Map<MemberSpecification, Map<TypeDeclaration, SortedMap<String, Declaration>>> superClassOrInterfaceInheritedMemebers) {
LinkedHashMap<TypeDeclaration, SortedMap<String, Declaration>> inheritedMembersMap = new LinkedHashMap<TypeDeclaration, SortedMap<String, Declaration>>();
for (TypeDeclaration superClassOrInterface : superClassOrInterfaceList) {
SortedMap<String, Declaration> inheritedMembers = new TreeMap<String, Declaration>();
for (Declaration member : superClassOrInterface.getMembers()) {
if (specification.isSatisfiedBy(member) && tool.shouldInclude(member)) {
inheritedMembers.put(Util.getDeclarationName(member), member);
for (String alias : member.getAliases()) {
inheritedMembers.put(alias, member);
}
}
}
if (!inheritedMembers.isEmpty()) {
inheritedMembersMap.put(superClassOrInterface, inheritedMembers);
}
}
superClassOrInterfaceInheritedMemebers.put(specification, inheritedMembersMap);
}
use of com.redhat.ceylon.model.typechecker.model.TypeDeclaration in project ceylon-compiler by ceylon.
the class ClassDoc method collectSupertypes.
private List<TypeDeclaration> collectSupertypes(TypeDeclaration type) {
List<TypeDeclaration> supertypes = new ArrayList<TypeDeclaration>();
if (type instanceof Class && type.getExtendedType() != null) {
supertypes.add(type.getExtendedType().getDeclaration());
}
List<Type> satisfiedTypes = type.getSatisfiedTypes();
if (satisfiedTypes != null) {
for (Type satisfiedType : satisfiedTypes) {
supertypes.add(satisfiedType.getDeclaration());
}
}
return supertypes;
}
Aggregations