Exemplo n.º 1
0
 @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 isAffectingOtherFiles() {
   if (declaration == null) {
     return false;
   }
   if (declaration.isToplevel() || declaration.isShared()) {
     return true;
   }
   if (declaration.isParameter()) {
     FunctionOrValue fov = (FunctionOrValue) declaration;
     Declaration container = fov.getInitializerParameter().getDeclaration();
     if (container.isToplevel() || container.isShared()) {
       return true;
     }
   }
   return false;
 }