use of org.eclipse.ceylon.model.typechecker.model.TypeAlias in project ceylon by eclipse.
the class ClassDoc method loadMembers.
private void loadMembers() {
constructors = new TreeMap<String, Declaration>();
methods = new TreeMap<String, SortedSet<Function>>();
attributes = new TreeMap<String, TypedDeclaration>();
innerInterfaces = new TreeMap<String, Interface>();
innerClasses = new TreeMap<String, Class>();
innerExceptions = new TreeMap<String, Class>();
innerAliases = new TreeMap<String, TypeAlias>();
superClasses = getAncestors(klass);
superInterfaces = getSuperInterfaces(klass);
for (Declaration m : klass.getMembers()) {
if (tool.shouldInclude(m)) {
if (ModelUtil.isConstructor(m)) {
addTo(constructors, m);
} else if (m instanceof Value) {
addTo(attributes, (Value) m);
} else if (m instanceof Function) {
if (m.isAbstraction() && m.getOverloads().size() > 0) {
// we want document each overloads, see https://github.com/ceylon/ceylon/issues/5748
continue;
}
addTo(methods, (Function) m);
} else if (m instanceof Interface) {
addTo(innerInterfaces, (Interface) m);
} else if (m instanceof Class) {
Class c = (Class) m;
if (Util.isThrowable(c)) {
addTo(innerExceptions, c);
} else {
addTo(innerClasses, c);
}
} else if (m instanceof TypeAlias) {
addTo(innerAliases, (TypeAlias) m);
}
}
}
Collections.sort(superInterfaces, ReferenceableComparatorByName.INSTANCE);
loadInheritedMembers(attributeSpecification, superClasses, superclassInheritedMembers);
loadInheritedMembers(methodSpecification, superClasses, superclassInheritedMembers);
loadInheritedMembers(attributeSpecification, superInterfaces, interfaceInheritedMembers);
loadInheritedMembers(methodSpecification, superInterfaces, interfaceInheritedMembers);
}
use of org.eclipse.ceylon.model.typechecker.model.TypeAlias in project ceylon by eclipse.
the class GenerateJsVisitor method qualifiedPath.
public String qualifiedPath(final Node that, final Declaration d, final boolean inProto) {
if (d instanceof Constructor) {
Class c = (Class) d.getContainer();
final String rval = qualifiedPath(that, c, inProto);
return rval.isEmpty() ? names.name(c) : rval + "." + names.name(c);
}
final boolean isMember = d.isClassOrInterfaceMember();
final boolean imported = isImported(that == null ? null : that.getUnit().getPackage(), d);
if (!isMember && imported) {
return names.moduleAlias(d.getUnit().getPackage().getModule());
} else if (opts.isOptimize() && !inProto) {
if (isMember && !(d.isParameter() && !d.isJsCaptured())) {
TypeDeclaration id = that.getScope().getInheritingDeclaration(d);
TypeDeclaration nd = null;
if (id == null) {
// a local declaration of some kind,
// perhaps in an outer scope
id = (TypeDeclaration) d.getContainer();
if (id.isNativeHeader()) {
nd = (TypeDeclaration) ModelUtil.getNativeDeclaration(id, Backend.JavaScript);
}
}
Scope scope = ModelUtil.getRealScope(that.getScope());
if (scope instanceof Value && !(ModelUtil.getRealScope(scope) instanceof ClassOrInterface)) {
scope = ModelUtil.getRealScope(scope.getContainer());
}
if ((scope != null) && (that instanceof Tree.ClassDeclaration || that instanceof Tree.InterfaceDeclaration || that instanceof Tree.Constructor)) {
// class/interface aliases have no own "this"
scope = scope.getContainer();
}
final StringBuilder path = new StringBuilder();
final Declaration innermostDeclaration = ModelUtil.getContainingDeclarationOfScope(scope);
while (scope != null) {
if (scope instanceof Constructor && scope == innermostDeclaration) {
TypeDeclaration consCont = (TypeDeclaration) scope.getContainer();
if (that instanceof Tree.BaseTypeExpression) {
path.append(names.name(consCont));
} else if (d.isStatic()) {
path.append(names.name(consCont)).append(".$st$");
} else {
path.append(names.self(consCont));
}
if (scope == id || (nd != null && scope == nd)) {
break;
}
scope = consCont;
} else if (scope instanceof TypeDeclaration) {
if (path.length() > 0) {
if (scope instanceof Constructor == false) {
Constructor constr = scope instanceof Class ? ((Class) scope).getDefaultConstructor() : null;
if ((constr == null || !ModelUtil.contains(constr, (Scope) innermostDeclaration)) && !d.isStatic()) {
path.append(".outer$");
}
}
} else if (d instanceof Constructor && ModelUtil.getContainingDeclaration(d) == scope) {
if (!d.getName().equals(((TypeDeclaration) scope).getName())) {
if (path.length() > 0) {
path.append('.');
}
path.append(names.name((TypeDeclaration) scope));
}
} else {
if (path.length() > 0) {
path.append('.');
}
if (d.isStatic()) {
if (d instanceof TypedDeclaration) {
TypedDeclaration orig = ((TypedDeclaration) d).getOriginalDeclaration();
path.append(names.name((ClassOrInterface) (orig == null ? d : orig).getContainer())).append(".$st$");
} else if (d instanceof TypeDeclaration) {
path.append(names.name((ClassOrInterface) d.getContainer())).append(".$st$");
}
} else {
path.append(names.self((TypeDeclaration) scope));
}
}
} else {
path.setLength(0);
}
if (scope == id || (nd != null && scope == nd)) {
break;
}
scope = scope.getContainer();
}
if (id != null && path.length() == 0 && !ModelUtil.contains(id, that.getScope())) {
// Import of toplevel object or constructor
if (imported) {
path.append(names.moduleAlias(id.getUnit().getPackage().getModule())).append('.');
}
if (id.isAnonymous()) {
path.append(names.objectName(id));
} else {
Import imp = findImport(that, d);
if (imp == null) {
path.append(names.name(id));
} else {
path.append(names.objectName(imp.getTypeDeclaration()));
}
}
}
return path.toString();
}
} else if (d != null) {
if (isMember && (d.isShared() || inProto || !d.isParameter() && AttributeGenerator.defineAsProperty(d))) {
TypeDeclaration id = d instanceof TypeAlias ? (TypeDeclaration) d : that.getScope().getInheritingDeclaration(d);
if (id == null) {
// a local declaration of some kind,
// perhaps in an outer scope
id = (TypeDeclaration) d.getContainer();
if (id.isToplevel() && !ModelUtil.contains(id, that.getScope())) {
// Import of toplevel object or constructor
final StringBuilder sb = new StringBuilder();
if (imported) {
sb.append(names.moduleAlias(id.getUnit().getPackage().getModule())).append('.');
}
sb.append(id.isAnonymous() ? names.objectName(id) : names.name(id));
return sb.toString();
} else if (d instanceof Constructor) {
return names.name(id);
} else {
// a shared local declaration
return names.self(id);
}
} else {
// inherited by an outer scope
return names.self(id);
}
}
}
return "";
}
Aggregations