Skip to content

Commit

Permalink
prepared for execution on bears dataset repositories (#205)
Browse files Browse the repository at this point in the history
* prepared for execution on bears dataset

* EntityTypeInfoResolver bug fixed
  • Loading branch information
khaes-kth authored Feb 6, 2020
1 parent 00d1b31 commit 1cad743
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 5 deletions.
6 changes: 6 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,12 @@
<artifactId>org.eclipse.jgit</artifactId>
<version>3.5.3.201412180710-r</version>
</dependency>
<!-- <dependency>
<groupId>org.eclipse.jgit</groupId>
<artifactId>org.eclipse.jgit</artifactId>
<version>5.6.0.201912101111-r</version>
</dependency> -->

<dependency>
<groupId>org.gitective</groupId>
<artifactId>gitective-core</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,11 @@ public void setPattern(ChangePatternSpecification pattern) {

@Override
public String toString() {
return "ChangePatternInstance [actions=" + actions + "]";
try {
return "ChangePatternInstance [actions=" + actions + "]";
} catch (Exception e) {
return "";
}
}

public Map<PatternAction, MatchingAction> getMapping() {
Expand Down
16 changes: 13 additions & 3 deletions src/main/java/fr/inria/coming/repairability/repairtools/Arja.java
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,12 @@ public boolean filter(ChangePatternInstance instance, IRevision revision, Diff d
if (!mapping.hasSrc(((Insert) op.getAction()).getParent()))
return false;

CtElement srcRoot = ASTInfoResolver.getRootNode(((InsertOperation) op).getParent());
CtElement parentOfInsertedNode = ((InsertOperation) op).getParent();

if(parentOfInsertedNode == null) // smallcreep__cucumber-seeds
return false;

CtElement srcRoot = ASTInfoResolver.getRootNode(parentOfInsertedNode);
return canBeReproducedFromSrc(srcRoot, (CtStatement) op.getSrcNode());
} else if (op instanceof UpdateOperation) {
return canBeReproducedFromSrc(ASTInfoResolver.getRootNode(op.getSrcNode()),
Expand Down Expand Up @@ -136,8 +141,13 @@ public boolean filter(ChangePatternInstance instance, IRevision revision, Diff d
// the inserted node is a part of a parent inserted node
return false;

CtElement insertedNodeParent = ((InsertOperation)insOp).getParent();

if(insertedNodeParent == null)
return false;

List<CtElement> insPars =
ASTInfoResolver.getNSubsequentParents(((InsertOperation)insOp).getParent(), INS_DEL_COMMON_PAR_HEIGHT),
ASTInfoResolver.getNSubsequentParents(insertedNodeParent, INS_DEL_COMMON_PAR_HEIGHT),
delPars = ASTInfoResolver.getNSubsequentParents(delOp.getSrcNode(), INS_DEL_COMMON_PAR_HEIGHT);

Set<CtElement> insDistinctParsSet = new HashSet<CtElement>();
Expand All @@ -147,7 +157,7 @@ public boolean filter(ChangePatternInstance instance, IRevision revision, Diff d
if (insDistinctParsSet.size() == insPars.size())
return false;

CtElement srcRoot = ASTInfoResolver.getRootNode(((InsertOperation) op).getParent());
CtElement srcRoot = ASTInfoResolver.getRootNode(insertedNodeParent);
return canBeReproducedFromSrc(srcRoot, (CtStatement) op.getSrcNode());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,12 @@ private boolean doesElementOccursInSrcNode(CtElement srcNode, CtElement element)

String elementStr = element.toString();
for (CtElement srcElement : allSrcElements) {
String srcElementStr = srcElement.toString();
String srcElementStr;
try {
srcElementStr = srcElement.toString();
}catch(Exception e) {
continue; // ex.: on "org-tigris-jsapar__jsapar" repo
}
if (srcElementStr.equals(elementStr))
return true;
else if (srcElementStr.replace(elementStr, "").trim().equals(elementStr.trim()))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ private void loadChildrenToParentsRelationsBetweenEntityTypes() {
childrenToParentsRelationsBetweenEntityTypes = new HashMap<>();
try {
Scanner sc = new Scanner(new File(getClass().getClassLoader().getResource(CLASSES_HIERARCHY_FILE_NAME).getFile()));
// Scanner sc = new Scanner(new File("/data/template-based/coming-test/data.txt"));

while (sc.hasNextLine()) {
String line = sc.nextLine();
Expand Down

0 comments on commit 1cad743

Please sign in to comment.