@Override
 public Object[] getChildren(Object element) {
   if (element instanceof CeylonOutlineNode) {
     if (mode) {
       boolean includeParameters = !CeylonPlugin.getPreferences().getBoolean(PARAMS_IN_OUTLINES);
       CeylonOutlineNode node = (CeylonOutlineNode) element;
       CompilationUnit rootNode = getEditor().getParseController().getLastCompilationUnit();
       Node treeNode = Nodes.findNode(rootNode, node.getStartOffset(), node.getEndOffset());
       TypeDeclaration td;
       if (treeNode instanceof ClassOrInterface) {
         ClassOrInterface ci = (ClassOrInterface) treeNode;
         td = ci.getDeclarationModel();
       } else if (treeNode instanceof ObjectDefinition) {
         ObjectDefinition od = (ObjectDefinition) treeNode;
         td = od.getDeclarationModel().getTypeDeclaration();
       } else {
         return super.getChildren(element);
       }
       List<Declaration> list = new ArrayList<Declaration>();
       String filter = getFilterText().getText();
       for (int i = 0; i < filter.length(); i++) {
         char ch = filter.charAt(i);
         if (ch == '*' || i > 0 && Character.isUpperCase(ch)) {
           filter = filter.substring(0, i);
           break;
         }
       }
       Collection<DeclarationWithProximity> members =
           td.getMatchingMemberDeclarations(rootNode.getUnit(), td, filter, 0, null).values();
       for (DeclarationWithProximity dwp : members) {
         for (Declaration dec : overloads(dwp.getDeclaration())) {
           if (!(dec instanceof TypeParameter)) {
             if (includeParameters || !dec.isParameter()) {
               list.add(dec);
             }
           }
         }
       }
       if (!lexicalSortingAction.isChecked()) {
         Collections.sort(
             list,
             new Comparator<Declaration>() {
               public int compare(Declaration x, Declaration y) {
                 String xn = x.getContainer().getQualifiedNameString();
                 String yn = y.getContainer().getQualifiedNameString();
                 return xn.compareTo(yn);
               }
             });
       }
       return list.toArray();
     } else {
       return super.getChildren(element);
     }
   } else {
     return null;
   }
 }
 @Override
 public boolean select(Viewer viewer, Object parentElement, Object element) {
   if (element instanceof CeylonOutlineNode) {
     CeylonOutlineNode node = (CeylonOutlineNode) element;
     return node.isShared();
   } else if (element instanceof Declaration) {
     Declaration dec = (Declaration) element;
     return dec.isShared();
   } else {
     return true;
   }
 }
 @Override
 protected void gotoSelectedElement() {
   Object object = getSelectedElement();
   if (object instanceof CeylonOutlineNode) {
     dispose();
     CeylonOutlineNode on = (CeylonOutlineNode) object;
     int startOffset = on.getStartOffset();
     int endOffset = on.getEndOffset();
     getEditor().selectAndReveal(startOffset, endOffset - startOffset);
   } else if (object instanceof Referenceable) {
     dispose();
     gotoDeclaration((Referenceable) object);
   }
 }
 @Override
 protected void internalExpandToLevel(Widget w, int level) {
   if ( // !(fIsFiltering && !getFilterText().getText().isEmpty()) &&
   getFilterText().getText().isEmpty() && w instanceof Item) {
     Item i = (Item) w;
     if (i.getData() instanceof CeylonOutlineNode) {
       CeylonOutlineNode node = (CeylonOutlineNode) i.getData();
       int cat = node.getCategory();
       // TODO: leave unshared declarations collapsed?
       if (cat == CeylonOutlineNode.IMPORT_LIST_CATEGORY) {
         setExpanded(i, false);
         return;
       }
     }
   }
   super.internalExpandToLevel(w, level);
 }
 @Override
 public int compare(Viewer viewer, Object e1, Object e2) {
   if (e1 instanceof CeylonOutlineNode && e2 instanceof CeylonOutlineNode) {
     CeylonOutlineNode n1 = (CeylonOutlineNode) e1;
     CeylonOutlineNode n2 = (CeylonOutlineNode) e2;
     int cat = n1.getCategory() - n2.getCategory();
     if (cat != 0) return cat;
     String n1n = n1.getName();
     String n2n = n2.getName();
     if (n1n == n2n) return 0;
     if (n1n == null) return -1;
     if (n2n == null) return 1;
     return n1n.compareTo(n2n);
   } else if (e1 instanceof Declaration && e2 instanceof Declaration) {
     Unit unit = getEditor().getParseController().getLastCompilationUnit().getUnit();
     String e1n = ((Declaration) e1).getName(unit);
     String e2n = ((Declaration) e2).getName(unit);
     if (e1n == e2n) return 0;
     if (e1n == null) return -1;
     if (e2n == null) return 1;
     return e1n.compareTo(e2n);
   } else {
     return 0;
   }
 }
 private static Image getImageFor(CeylonOutlineNode n) {
   return getImageFor((Node) n.getTreeNode());
 }