Skip to content

Commit

Permalink
[fix] Resolve name of anonymous class to empty string #86
Browse files Browse the repository at this point in the history
  • Loading branch information
slarse committed Mar 29, 2020
1 parent d96702c commit 6b0c63b
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/main/java/se/kth/spork/spoon/ContentResolver.java
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,11 @@ public static RoledValues getContent(CtElement elem) {
} else if (elem instanceof CtReference || elem instanceof CtNamedElement) {
String name = elem.getValueByRole(CtRole.NAME);
if (!name.matches("\\d+")) {
// Only pick up name if it's not a digit.
// A digit implies anonymous function, see https://github.com/kth/spork/issues/86 for why we don't
// want those.
// If the name is a digit, it's an anonymous class. We resolve that to the empty string to prevent
// content mismatching on the names of anonymous functions, which don't matter as far as merging goes.
// This might cause other issues, though, but it's the best idea I've got at this time.
rvs.add(CtRole.NAME, "");
} else {
rvs.add(CtRole.NAME, elem.getValueByRole(CtRole.NAME));
}
} else if (elem instanceof CtBinaryOperator || elem instanceof CtUnaryOperator || elem instanceof CtOperatorAssignment) {
Expand Down

0 comments on commit 6b0c63b

Please sign in to comment.