@Override public void visit(Tree.AttributeDeclaration that) { if (that.getDeclarationModel() == declaration) { Tree.SpecifierOrInitializerExpression sie = that.getSpecifierOrInitializerExpression(); if (sie != null) { super.visit(that); specify(); } else { super.visit(that); if (declaration.isToplevel() && !isNativeHeader(declaration) && !isLate()) { if (isVariable()) { that.addError( "toplevel variable value must be initialized: '" + declaration.getName() + "'"); } else { that.addError("toplevel value must be specified: '" + declaration.getName() + "'"); } } else if (declaration.isClassOrInterfaceMember() && !isNativeHeader(declaration) && !declaration.isFormal() && that.getDeclarationModel().getInitializerParameter() == null && !that.getDeclarationModel().isLate() && declarationSection) { that.addError( "forward declaration may not occur in declaration section: '" + declaration.getName() + "'", 1450); } } } else { super.visit(that); } }
Declaration getDisplayedDeclaration(CeylonHierarchyNode node) { Declaration declaration = node.getDeclaration(); if (declaration != null && isShowingRefinements() && declaration.isClassOrInterfaceMember()) { declaration = (ClassOrInterface) declaration.getContainer(); } return declaration; }
public static Declaration getRefinedDeclaration(Declaration declaration) { // Reproduces the algorithm used to build the type hierarchy // first walk up the superclass hierarchy if (declaration.isClassOrInterfaceMember() && declaration.isShared()) { TypeDeclaration dec = (TypeDeclaration) declaration.getContainer(); List<Type> signature = getSignature(declaration); Declaration refined = declaration.getRefinedDeclaration(); while (dec != null) { Type extended = dec.getExtendedType(); if (extended != null) { TypeDeclaration superDec = extended.getDeclaration(); Declaration superMemberDec = superDec.getDirectMember(declaration.getName(), signature, false); if (superMemberDec != null) { Declaration superRefined = superMemberDec.getRefinedDeclaration(); if (superRefined != null && refined != null && !isAbstraction(superMemberDec) && superRefined.equals(refined)) { return superMemberDec; } } dec = superDec; } else { dec = null; } } // now look at the very top of the hierarchy, even if it is an interface Declaration refinedDeclaration = refined; if (refinedDeclaration != null && !declaration.equals(refinedDeclaration)) { List<Declaration> directlyInheritedMembers = getInterveningRefinements( declaration.getName(), signature, refinedDeclaration, (TypeDeclaration) declaration.getContainer(), (TypeDeclaration) refinedDeclaration.getContainer()); directlyInheritedMembers.remove(refinedDeclaration); // TODO: do something for the case of // multiple intervening interfaces? if (directlyInheritedMembers.size() == 1) { // exactly one intervening interface return directlyInheritedMembers.get(0); } else { // no intervening interfaces return refinedDeclaration; } } } return null; }