Skip to content

Commit

Permalink
Merge pull request #42 from barbosamaatheus/feature/definition
Browse files Browse the repository at this point in the history
feat(#31): add support for marking in multiple classes
  • Loading branch information
pauloborba authored Aug 13, 2021
2 parents 49bc5fa + febb6e5 commit 5510a3d
Show file tree
Hide file tree
Showing 2 changed files with 71 additions and 16 deletions.
50 changes: 34 additions & 16 deletions src/test/java/br/unc/cic/analysis/test/DefinitionFactory.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@

import br.unb.cic.analysis.AbstractMergeConflictDefinition;

import java.util.*;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

public class DefinitionFactory {
Expand All @@ -12,22 +15,37 @@ public static AbstractMergeConflictDefinition definition(String className, int s
}

public static AbstractMergeConflictDefinition definition(String className, int sourceLines[], int sinkLines[], boolean recursive) {
return definition(Arrays.asList(new MarkingClass(className, sourceLines, sinkLines)), recursive);
};

/**
*
* @param markingClassList It is a list of tags. Each tag as lines marked as source and as lines marked as sink
* and the name of the class where the lines were marked.
* @param recursive Indicates whether the loading of statements will be done recursively or not.
* @return
*/
public static AbstractMergeConflictDefinition definition(List<MarkingClass> markingClassList, boolean recursive) {
return new AbstractMergeConflictDefinition(recursive) {
@Override
protected Map<String, List<Integer>> sourceDefinitions() {
Map<String, List<Integer>> res = new HashMap<>();
List<Integer> lines = Arrays.stream(sourceLines).boxed().collect(Collectors.toList());
res.put(className, lines);
return res;
@Override
protected Map<String, List<Integer>> sourceDefinitions() {
Map<String, List<Integer>> res = new HashMap<>();
for(MarkingClass m: markingClassList){
List<Integer> lines = Arrays.stream(m.getSourceLines()).boxed().collect(Collectors.toList());
res.put(m.getClassName(), lines);
}
return res;
}

@Override
protected Map<String, List<Integer>> sinkDefinitions() {
Map<String, List<Integer>> res = new HashMap<>();
List<Integer> lines = Arrays.stream(sinkLines).boxed().collect(Collectors.toList());
res.put(className, lines);
return res;
@Override
protected Map<String, List<Integer>> sinkDefinitions() {
Map<String, List<Integer>> res = new HashMap<>();
for(MarkingClass m: markingClassList) {
List<Integer> lines = Arrays.stream(m.getSinkLines()).boxed().collect(Collectors.toList());
res.put(m.getClassName(), lines);
}
};
}
}
return res;
}
};
}
}
37 changes: 37 additions & 0 deletions src/test/java/br/unc/cic/analysis/test/MarkingClass.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package br.unc.cic.analysis.test;

public class MarkingClass {
String className;
int sourceLines[];
int sinkLines[];

public MarkingClass(String className, int[] sourceLines, int[] sinkLines) {
this.className = className;
this.sourceLines = sourceLines;
this.sinkLines = sinkLines;
}

public String getClassName() {
return className;
}

public void setClassName(String className) {
this.className = className;
}

public int[] getSourceLines() {
return sourceLines;
}

public void setSourceLines(int[] sourceLines) {
this.sourceLines = sourceLines;
}

public int[] getSinkLines() {
return sinkLines;
}

public void setSinkLines(int[] sinkLines) {
this.sinkLines = sinkLines;
}
}

0 comments on commit 5510a3d

Please sign in to comment.