Skip to content

Commit

Permalink
fix: checks if the literal is a String
Browse files Browse the repository at this point in the history
  • Loading branch information
danglotb committed Sep 5, 2018
1 parent 2fc7ed9 commit 0a32a83
Showing 1 changed file with 4 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -85,10 +85,11 @@ public boolean matches(CtTypeReference element) {
}
}).forEach(ctTypeReference -> ctTypeReference.setSimpleName(getAmplifiedName(classTest)));
// need to update also all the String literals
amplifiedTest.getElements(new TypeFilter<CtLiteral<String>>(CtLiteral.class) {
amplifiedTest.getElements(new TypeFilter<CtLiteral>(CtLiteral.class) {
@Override
public boolean matches(CtLiteral<String> element) {
return element.getValue().contains(classTest.getSimpleName());
public boolean matches(CtLiteral element) {
return element.getValue() instanceof String &&
((String)element.getValue()).contains(classTest.getSimpleName());
}
}).forEach(stringCtLiteral ->
stringCtLiteral.setValue(stringCtLiteral.getValue().replaceAll(classTest.getSimpleName(), amplifiedName))
Expand Down

0 comments on commit 0a32a83

Please sign in to comment.