use of org.eclipse.ceylon.model.typechecker.model.Declaration in project ceylon by eclipse.
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 org.eclipse.ceylon.model.typechecker.model.Declaration in project ceylon by eclipse.
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 org.eclipse.ceylon.model.typechecker.model.Declaration in project ceylon by eclipse.
the class ClassOrPackageDoc method getParametersAssertions.
private Map<Parameter, Map<Tree.Assertion, List<Tree.Condition>>> getParametersAssertions(final Declaration decl) {
final Map<Parameter, Map<Tree.Assertion, List<Tree.Condition>>> parametersAssertions = new LinkedHashMap<Parameter, Map<Tree.Assertion, List<Tree.Condition>>>();
if (((Functional) decl).getParameterLists().isEmpty()) {
return parametersAssertions;
}
Node node = tool.getNode(decl);
PhasedUnit pu = tool.getUnit(decl);
if (node == null || pu == null) {
return parametersAssertions;
}
Tree.Body body = null;
if (node instanceof Tree.MethodDefinition) {
body = ((Tree.MethodDefinition) node).getBlock();
} else if (node instanceof Tree.ClassDefinition) {
body = ((Tree.ClassDefinition) node).getClassBody();
}
if (body == null) {
return parametersAssertions;
}
final Map<String, Parameter> parametersNames = new HashMap<String, Parameter>();
for (ParameterList parameterList : ((Functional) decl).getParameterLists()) {
for (Parameter parameter : parameterList.getParameters()) {
parametersNames.put(parameter.getName(), parameter);
}
}
body.visitChildren(new Visitor() {
private boolean stop = false;
private Tree.Assertion assertion = null;
private Set<Parameter> referencedParameters = new HashSet<Parameter>();
@Override
public void visit(Tree.Assertion that) {
assertion = that;
super.visit(that);
assertion = null;
}
@Override
public void visit(Tree.Condition that) {
referencedParameters.clear();
super.visit(that);
if (assertion != null && !referencedParameters.isEmpty()) {
for (Parameter referencedParameter : referencedParameters) {
Map<Tree.Assertion, List<Tree.Condition>> parameterAssertions = parametersAssertions.get(referencedParameter);
if (parameterAssertions == null) {
parameterAssertions = new LinkedHashMap<Tree.Assertion, List<Tree.Condition>>();
parametersAssertions.put(referencedParameter, parameterAssertions);
}
List<Tree.Condition> parameterConditions = parameterAssertions.get(assertion);
if (parameterConditions == null) {
parameterConditions = new ArrayList<Tree.Condition>();
parameterAssertions.put(assertion, parameterConditions);
}
parameterConditions.add(that);
}
}
}
@Override
public void visit(Tree.BaseMemberExpression that) {
if (assertion != null) {
Declaration d = that.getDeclaration();
Scope realScope = org.eclipse.ceylon.model.typechecker.model.ModelUtil.getRealScope(d.getScope());
if (parametersNames.containsKey(d.getName()) && realScope == decl) {
referencedParameters.add(parametersNames.get(d.getName()));
}
}
super.visit(that);
}
@Override
public void visit(Tree.Statement that) {
if (assertion == null) {
stop = true;
}
super.visit(that);
}
@Override
public void visitAny(Node that) {
if (!stop) {
super.visitAny(that);
}
}
});
return parametersAssertions;
}
use of org.eclipse.ceylon.model.typechecker.model.Declaration in project ceylon by eclipse.
the class IndexApiDoc method collectDeclarations.
private List<Declaration> collectDeclarations() {
List<Declaration> declarations = new ArrayList<Declaration>();
for (Package pkg : tool.getPackages(module)) {
if (tool.shouldInclude(pkg)) {
List<Declaration> members = pkg.getMembers();
for (Declaration member : members) {
if (tool.shouldInclude(member)) {
if (member instanceof Value && ((Value) member).getTypeDeclaration().isAnonymous()) {
continue;
}
declarations.add(member);
}
}
}
}
Collections.sort(declarations, ReferenceableComparatorByName.INSTANCE);
return declarations;
}
use of org.eclipse.ceylon.model.typechecker.model.Declaration in project ceylon by eclipse.
the class AnnotationInvocationVisitor method annoClass.
public static Class annoClass(Tree.InvocationExpression invocation) {
Declaration declaration = ((Tree.BaseMemberOrTypeExpression) invocation.getPrimary()).getDeclaration();
Set<Declaration> ctors = new HashSet<Declaration>();
while (declaration instanceof Function) {
if (!ctors.add(declaration)) {
throw new BugException(invocation, "recursive annotation constructor");
}
declaration = ((AnnotationInvocation) ((Function) declaration).getAnnotationConstructor()).getPrimary();
}
if (declaration instanceof Class) {
return (Class) declaration;
} else {
throw new BugException(invocation, "invocation primary has unexpected declaration: " + declaration);
}
}
Aggregations