static Tree.Body getClassOrInterfaceBody(Tree.Declaration decNode) {
   if (decNode instanceof Tree.ClassDefinition) {
     Tree.ClassDefinition cd = (Tree.ClassDefinition) decNode;
     return cd.getClassBody();
   } else if (decNode instanceof Tree.InterfaceDefinition) {
     Tree.InterfaceDefinition id = (Tree.InterfaceDefinition) decNode;
     return id.getInterfaceBody();
   } else if (decNode instanceof Tree.ObjectDefinition) {
     Tree.ObjectDefinition od = (Tree.ObjectDefinition) decNode;
     return od.getClassBody();
   } else {
     return null;
   }
 }
 @Override
 public void visit(Tree.ObjectDefinition that) {
   if (that.getDeclarationModel() == declaration) {
     declare();
     specify();
   }
   super.visit(that);
 }
  static StyledString getStyledLabelFor(Node n) {
    // TODO: it would be much better to render types
    //      from the tree nodes instead of from the
    //      model nodes

    if (n instanceof Tree.TypeParameterDeclaration) {
      Tree.TypeParameterDeclaration ac = (Tree.TypeParameterDeclaration) n;
      return new StyledString(name(ac.getIdentifier()));
    }
    if (n instanceof Tree.AnyClass) {
      Tree.AnyClass ac = (Tree.AnyClass) n;
      StyledString label = new StyledString("class ", KW_STYLER);
      label.append(name(ac.getIdentifier()), TYPE_ID_STYLER);
      parameters(ac.getTypeParameterList(), label);
      parameters(ac.getParameterList(), label);
      return label;
    } else if (n instanceof Tree.AnyInterface) {
      Tree.AnyInterface ai = (Tree.AnyInterface) n;
      StyledString label = new StyledString("interface ", KW_STYLER);
      label.append(name(ai.getIdentifier()), TYPE_ID_STYLER);
      parameters(ai.getTypeParameterList(), label);
      return label;
    } else if (n instanceof Tree.ObjectDefinition) {
      Tree.ObjectDefinition ai = (Tree.ObjectDefinition) n;
      return new StyledString("object ", KW_STYLER).append(name(ai.getIdentifier()), ID_STYLER);
    } else if (n instanceof Tree.AttributeSetterDefinition) {
      Tree.AttributeSetterDefinition ai = (Tree.AttributeSetterDefinition) n;
      return new StyledString("assign ", KW_STYLER).append(name(ai.getIdentifier()), ID_STYLER);
    } else if (n instanceof Tree.TypedDeclaration) {
      Tree.TypedDeclaration td = (Tree.TypedDeclaration) n;
      String type;
      Styler styler;
      if (td.getType() instanceof Tree.VoidModifier) {
        type = "void";
        styler = KW_STYLER;
      } else {
        type = type(td.getType());
        styler = TYPE_STYLER;
      }
      StyledString label = new StyledString(type, styler);
      label.append(" ").append(name(td.getIdentifier()), ID_STYLER);
      if (n instanceof Tree.AnyMethod) {
        Tree.AnyMethod am = (Tree.AnyMethod) n;
        parameters(am.getTypeParameterList(), label);
        for (Tree.ParameterList pl : am.getParameterLists()) {
          parameters(pl, label);
        }
      }
      return label;
    } else if (n instanceof Tree.CompilationUnit) {
      Tree.CompilationUnit ai = (Tree.CompilationUnit) n;
      return new StyledString(ai.getUnit().getFilename());
    } else if (n instanceof Tree.ImportList) {
      return new StyledString("imports");
    } else if (n instanceof Tree.Import) {
      Tree.Import ai = (Tree.Import) n;
      if (ai.getImportPath() != null && !ai.getImportPath().getIdentifiers().isEmpty()) {
        return new StyledString(toPath(ai), QUALIFIER_STYLER);
      }
    } else if (n instanceof PackageNode) {
      PackageNode pn = (PackageNode) n;
      if (pn.getPackageName().isEmpty()) {
        return new StyledString("default package");
      } else {
        return new StyledString(pn.getPackageName(), QUALIFIER_STYLER);
      }
    }

    return new StyledString("<something>");
  }
  @Deprecated
  // replaced by RefineFormalMembersQuickFix.ceylon
  private void refineFormalMembers(IDocument document) throws ExecutionException {
    if (rootNode == null) return;
    TextChange change = new DocumentChange("Refine Members", document);
    change.setEdit(new MultiTextEdit());
    // TODO: copy/pasted from CeylonQuickFixAssistant
    Tree.Body body;
    int offset;
    if (node instanceof Tree.ClassDefinition) {
      ClassDefinition classDefinition = (Tree.ClassDefinition) node;
      body = classDefinition.getClassBody();
      offset = -1;
    } else if (node instanceof Tree.InterfaceDefinition) {
      Tree.InterfaceDefinition interfaceDefinition = (Tree.InterfaceDefinition) node;
      body = interfaceDefinition.getInterfaceBody();
      offset = -1;
    } else if (node instanceof Tree.ObjectDefinition) {
      Tree.ObjectDefinition objectDefinition = (Tree.ObjectDefinition) node;
      body = objectDefinition.getClassBody();
      offset = -1;
    } else if (node instanceof Tree.ObjectExpression) {
      Tree.ObjectExpression objectExpression = (Tree.ObjectExpression) node;
      body = objectExpression.getClassBody();
      offset = -1;
    } else if (node instanceof Tree.ClassBody || node instanceof Tree.InterfaceBody) {
      body = (Tree.Body) node;
      IEditorPart editor = getCurrentEditor();
      if (editor instanceof CeylonEditor) {
        CeylonEditor ce = (CeylonEditor) editor;
        offset = ce.getSelection().getOffset();
      } else {
        offset = -1;
      }
    } else {
      return;
    }
    if (body == null) {
      return;
    }
    boolean isInterface = body instanceof Tree.InterfaceBody;
    List<Tree.Statement> statements = body.getStatements();
    String indent;
    //        String bodyIndent = getIndent(body, document);
    String bodyIndent = utilJ2C().indents().getIndent(node, document);
    String delim = utilJ2C().indents().getDefaultLineDelimiter(document);
    if (statements.isEmpty()) {
      indent = delim + bodyIndent + utilJ2C().indents().getDefaultIndent();
      if (offset < 0) {
        offset = body.getStartIndex() + 1;
      }
    } else {
      Tree.Statement statement = statements.get(statements.size() - 1);
      indent = delim + utilJ2C().indents().getIndent(statement, document);
      if (offset < 0) {
        offset = statement.getEndIndex();
      }
    }
    StringBuilder result = new StringBuilder();
    Set<Declaration> already = new HashSet<Declaration>();
    ClassOrInterface ci = (ClassOrInterface) node.getScope();
    Unit unit = node.getUnit();
    Set<String> ambiguousNames = new HashSet<String>();
    // TODO: does not return unrefined overloaded
    //      versions of a method with one overlaad
    //      already refined
    Collection<DeclarationWithProximity> proposals =
        ci.getMatchingMemberDeclarations(unit, ci, "", 0).values();
    for (DeclarationWithProximity dwp : proposals) {
      Declaration dec = dwp.getDeclaration();
      for (Declaration d : overloads(dec)) {
        try {
          if (d.isFormal() && ci.isInheritedFromSupertype(d)) {
            appendRefinementText(isInterface, indent, result, ci, unit, d);
            importProposals().importSignatureTypes(d, rootNode, already);
            ambiguousNames.add(d.getName());
          }
        } catch (Exception e) {
          e.printStackTrace();
        }
      }
    }
    for (TypeDeclaration superType : ci.getSupertypeDeclarations()) {
      for (Declaration m : superType.getMembers()) {
        try {
          if (m.getName() != null && m.isShared()) {
            Declaration r = ci.getMember(m.getName(), null, false);
            if ((r == null || !r.refines(m) && !r.getContainer().equals(ci))
                && ambiguousNames.add(m.getName())) {
              appendRefinementText(isInterface, indent, result, ci, unit, m);
              importProposals().importSignatureTypes(m, rootNode, already);
            }
          }
        } catch (Exception e) {
          e.printStackTrace();
        }
      }
    }

    try {
      if (document.getChar(offset) == '}' && result.length() > 0) {
        result.append(delim).append(bodyIndent);
      }
    } catch (BadLocationException e) {
      e.printStackTrace();
    }
    importProposals().applyImports(change, already, rootNode, document);
    change.addEdit(new InsertEdit(offset, result.toString()));
    change.initializeValidationData(null);
    try {
      getWorkspace().run(new PerformChangeOperation(change), new NullProgressMonitor());
    } catch (CoreException ce) {
      ce.printStackTrace();
    }
  }