Shifts call graph builder (cg) in given sequence to ensure that it will run before all the analyses that it does not require.
(List<AnalysisConfig> analyses)
| 170 | * it will run before all the analyses that it does not require. |
| 171 | */ |
| 172 | private List<AnalysisConfig> shiftCG(List<AnalysisConfig> analyses) { |
| 173 | AnalysisConfig cg = CollectionUtils.findFirst(analyses, |
| 174 | AnalysisPlanner::isCG); |
| 175 | Set<AnalysisConfig> required = manager.getAllRequiredConfigs(cg); |
| 176 | List<AnalysisConfig> notRequired = new ArrayList<>(); |
| 177 | // obtain the analyses that run before cg but not required by cg |
| 178 | for (AnalysisConfig c : analyses) { |
| 179 | if (c.equals(cg)) { |
| 180 | break; |
| 181 | } |
| 182 | if (!required.contains(c)) { |
| 183 | notRequired.add(c); |
| 184 | } |
| 185 | } |
| 186 | List<AnalysisConfig> result = new ArrayList<>(analyses.size()); |
| 187 | // add analyses that are required by cg |
| 188 | for (AnalysisConfig c : analyses) { |
| 189 | if (required.contains(c)) { |
| 190 | result.add(c); |
| 191 | } |
| 192 | if (c.equals(cg)) { // found cg, break |
| 193 | break; |
| 194 | } |
| 195 | } |
| 196 | result.add(cg); // add cg |
| 197 | // add analyses that are not required by cg but placed before cg |
| 198 | // in the original sequence |
| 199 | result.addAll(notRequired); |
| 200 | // add remaining analyses |
| 201 | for (int i = analyses.indexOf(cg) + 1; i < analyses.size(); ++i) { |
| 202 | result.add(analyses.get(i)); |
| 203 | } |
| 204 | return result; |
| 205 | } |
| 206 | |
| 207 | /** |
| 208 | * Builds a dependence graph for AnalysisConfigs. |
no test coverage detected