Пример #1
0
  @SuppressWarnings({"rawtypes", "unchecked"})
  public void classifyVarConn() {
    System.out.println("[classify] starting...");
    Collection<HashSet> groups = varConn.findConnectedComponents();
    Collection<Set> refactorableGroups = new HashSet();
    Set<String> noRefactorableClsNameInRG = new HashSet<String>();
    for (Set c : groups) {
      Set clsNames = getClassNamesInGroup(c);
      if (clsNames.size() == 1) {
        Set<SootField> clsFields = protectedFieldsInAllClass.get(clsNames.iterator().next());
        if (clsFields != null && !c.containsAll(clsFields)) {
          refactorableGroups.add(c);
        }
      }
    }
    for (Set c : refactorableGroups) {
      SootField sf = (SootField) c.iterator().next();
      String clsName = sf.getDeclaringClass().getName();
      Collection fieldsModules = refactorableClass.get(clsName);
      if (fieldsModules == null) {
        fieldsModules = new HashSet();
        refactorableClass.put(clsName, fieldsModules);
      }
      fieldsModules.add(c);
    }

    for (Entry entry : refactorableClass.entrySet()) {
      if (((Collection) entry.getValue()).size() == 1) {
        noRefactorableClsNameInRG.add((String) entry.getKey());
      }
    }
    for (String s : noRefactorableClsNameInRG) {
      Collection c = refactorableClass.get(s);
      if (c != null) {
        refactorableClass.remove(s);
      }
    }
  }