Skip to content

Commit

Permalink
[fix] Properly merge implicitness of values #43
Browse files Browse the repository at this point in the history
  • Loading branch information
slarse committed Mar 15, 2020
1 parent fa13683 commit c0aebe4
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/main/java/se/kth/spork/spoon/Spoon3dmMerge.java
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,10 @@ public RoledValues apply(SpoonNode wrapper) {
CtElement elem = wrapper.getElement();
RoledValues rvs = new RoledValues();

// general values
rvs.add(CtRole.IS_IMPLICIT, elem.isImplicit());

// element-specific values
if (elem instanceof CtLiteral) {
CtLiteral<?> lit = (CtLiteral<?>) elem;
rvs.add(CtRole.VALUE, lit.getValue());
Expand Down Expand Up @@ -263,6 +267,14 @@ private static void handleContentConflicts(TStar<SpoonNode, RoledValues> delta)
break;
case COMMENT_CONTENT:
merged = mergeComments(baseValOpt.orElse(""), leftVal, rightVal);
break;
case IS_IMPLICIT:
if (baseValOpt.isPresent()) {
merged = Optional.of(!(Boolean) baseValOpt.get());
} else {
// when in doubt, discard implicitness
merged = Optional.of(false);
}
default:
// pass
}
Expand Down
5 changes: 5 additions & 0 deletions src/test/resources/clean/both_modified/implicitness/Base.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
class Cls {
public static void main(String[] args) {
System.out.println(args);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
class Cls {
public static void main(String[] args) {
java.lang.String s = args[0];
System.out.println(s);
}
}
6 changes: 6 additions & 0 deletions src/test/resources/clean/both_modified/implicitness/Left.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
class Cls {
public static void main(String[] args) {
String s = args[0];
System.out.println(s);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
class Cls {
public static void main(String[] args) {
java.lang.String s = args[0];
System.out.println(s);
}
}

0 comments on commit c0aebe4

Please sign in to comment.