예제 #1
0
  public void runFinish() {
    getFileHandler().refreshFolder();
    getFileHandler().refreshAll(getSootSelection().getProject());
    // for updating markers
    SootPlugin.getDefault().getManager().updateSootRanFlag();
    final IEditorPart activeEdPart =
        SootPlugin.getDefault()
            .getWorkbench()
            .getActiveWorkbenchWindow()
            .getActivePage()
            .getActiveEditor();
    SootPlugin.getDefault().getPartManager().updatePart(activeEdPart);
    // run cfgviewer
    if (getCfgList() != null) {
      // currently this is the call graph list of pkgs
      GraphGenerator generator = new GraphGenerator();
      generator.setChildren(convertPkgList(getCfgList()));
      GraphPlugin.getDefault().setGenerator(generator);

      generator.run(null);
    }
  }
  @Nullable
  private static Pair<List<String>, Boolean> keysOrder(final ResourceBundle resourceBundle) {
    final boolean[] isAlphaSorted = new boolean[] {true};
    final Graph<String> generator =
        GraphGenerator.generate(
            CachingSemiGraph.cache(
                new InboundSemiGraph<String>() {
                  @Override
                  public Collection<String> getNodes() {
                    final Set<String> nodes = new LinkedHashSet<>();
                    for (PropertiesFile propertiesFile : resourceBundle.getPropertiesFiles()) {
                      for (IProperty property : propertiesFile.getProperties()) {
                        final String key = property.getKey();
                        if (key != null) {
                          nodes.add(key);
                        }
                      }
                    }
                    return nodes;
                  }

                  @Override
                  public Iterator<String> getIn(String n) {
                    final Collection<String> siblings = new LinkedHashSet<>();
                    for (PropertiesFile propertiesFile : resourceBundle.getPropertiesFiles()) {
                      for (IProperty property : propertiesFile.findPropertiesByKey(n)) {
                        PsiElement sibling = property.getPsiElement().getNextSibling();
                        while (sibling instanceof PsiWhiteSpace || sibling instanceof PsiComment) {
                          sibling = sibling.getNextSibling();
                        }
                        if (sibling instanceof IProperty) {
                          final String key = ((IProperty) sibling).getKey();
                          if (key != null) {
                            if (isAlphaSorted[0]
                                && String.CASE_INSENSITIVE_ORDER.compare(n, key) > 0) {
                              isAlphaSorted[0] = false;
                            }
                            siblings.add(key);
                          }
                        }
                      }
                    }
                    return siblings.iterator();
                  }
                }));
    DFSTBuilder<String> dfstBuilder = new DFSTBuilder<>(generator);
    final boolean acyclic = dfstBuilder.isAcyclic();
    if (acyclic) {
      if (isAlphaSorted[0]) {
        final List<String> sortedNodes = new ArrayList<>(generator.getNodes());
        Collections.sort(sortedNodes, String.CASE_INSENSITIVE_ORDER);
        return Pair.create(sortedNodes, true);
      } else {
        final List<String> dfsNodes = dfstBuilder.getSortedNodes();
        Collections.reverse(dfsNodes);
        return Pair.create(dfsNodes, false);
      }
    } else {
      return null;
    }
  }