use of de.tum.in.www1.artemis.service.hestia.behavioral.GroupedFile in project Artemis by ls1intum.
the class CreateSolutionEntries method executeAction.
@Override
public boolean executeAction() {
var solutionEntries = new ArrayList<ProgrammingExerciseSolutionEntry>();
for (GroupedFile groupedFile : blackboard.getGroupedFiles()) {
for (GroupedFile.ChangeBlock changeBlock : groupedFile.getCommonChanges()) {
if (!changeBlock.isPotential()) {
solutionEntries.add(createSolutionEntry(groupedFile, changeBlock));
}
}
}
if (solutionEntries.equals(blackboard.getSolutionEntries())) {
return false;
}
blackboard.setSolutionEntries(solutionEntries);
return !blackboard.getSolutionEntries().isEmpty();
}
use of de.tum.in.www1.artemis.service.hestia.behavioral.GroupedFile in project Artemis by ls1intum.
the class FindCommonLines method executeAction.
@Override
public boolean executeAction() {
for (GroupedFile groupedFile : blackboard.getGroupedFiles()) {
List<Integer> commonLines = new ArrayList<>(groupedFile.getCoveredLines());
commonLines.retainAll(groupedFile.getChangedLines());
groupedFile.setCommonLines(commonLines);
}
return !blackboard.getGroupedFiles().stream().allMatch(groupedFile -> groupedFile.getCommonLines().isEmpty());
}
use of de.tum.in.www1.artemis.service.hestia.behavioral.GroupedFile in project ArTEMiS by ls1intum.
the class AddUncoveredLinesAsPotentialCodeBlocks method executeAction.
@Override
public boolean executeAction() {
boolean didChanges = false;
for (GroupedFile groupedFile : blackboard.getGroupedFiles()) {
var newChangeBlocks = new TreeSet<ChangeBlock>();
for (ChangeBlock commonChange : groupedFile.getCommonChanges()) {
var firstLine = commonChange.getLines().first();
var potentialPrefix = getPotentialPrefix(firstLine, groupedFile.getFileContent());
if (potentialPrefix != null) {
newChangeBlocks.add(potentialPrefix);
}
var lastLine = commonChange.getLines().last();
var potentialPostfix = getPotentialPostfix(lastLine, groupedFile.getFileContent());
if (potentialPostfix != null) {
newChangeBlocks.add(potentialPostfix);
}
}
if (!newChangeBlocks.isEmpty()) {
groupedFile.getCommonChanges().addAll(newChangeBlocks);
didChanges = true;
}
}
return didChanges;
}
use of de.tum.in.www1.artemis.service.hestia.behavioral.GroupedFile in project ArTEMiS by ls1intum.
the class CombineChangeBlocks method executeAction.
@Override
public boolean executeAction() throws BehavioralSolutionEntryGenerationException {
boolean didChanges = false;
for (GroupedFile groupedFile : blackboard.getGroupedFiles()) {
while (true) {
var currentChangeBlocks = new ArrayList<>(groupedFile.getCommonChanges());
var newChangeBlocks = new ArrayList<GroupedFile.ChangeBlock>();
for (int i = 0; i < currentChangeBlocks.size(); i++) {
var currentChangeBlock = currentChangeBlocks.get(i);
// If this is not the last change block check if it can be merged with the next change block
if (i < currentChangeBlocks.size() - 1) {
var nextChangeBlock = currentChangeBlocks.get(i + 1);
if (currentChangeBlock.intersectsOrTouches(nextChangeBlock)) {
var lines = new TreeSet<>(currentChangeBlock.getLines());
lines.addAll(nextChangeBlock.getLines());
newChangeBlocks.add(new GroupedFile.ChangeBlock(lines));
// Skip the next change block, as it has already been processed
i++;
continue;
}
}
newChangeBlocks.add(currentChangeBlock);
}
if (!newChangeBlocks.equals(currentChangeBlocks)) {
groupedFile.setCommonChanges(newChangeBlocks);
didChanges = true;
} else {
break;
}
}
}
return didChanges;
}
use of de.tum.in.www1.artemis.service.hestia.behavioral.GroupedFile in project ArTEMiS by ls1intum.
the class CreateSolutionEntries method executeAction.
@Override
public boolean executeAction() {
var solutionEntries = new ArrayList<ProgrammingExerciseSolutionEntry>();
for (GroupedFile groupedFile : blackboard.getGroupedFiles()) {
for (GroupedFile.ChangeBlock changeBlock : groupedFile.getCommonChanges()) {
if (!changeBlock.isPotential()) {
solutionEntries.add(createSolutionEntry(groupedFile, changeBlock));
}
}
}
if (solutionEntries.equals(blackboard.getSolutionEntries())) {
return false;
}
blackboard.setSolutionEntries(solutionEntries);
return !blackboard.getSolutionEntries().isEmpty();
}
Aggregations