use of org.autorefactor.jdt.internal.corext.dom.SourceLocation in project AutoRefactor by JnRouvignac.
the class ObsoleteRemoveSemiColonCleanUp method maybeRemoveSuperfluousSemiColons.
private boolean maybeRemoveSuperfluousSemiColons(final ASTNode visited, final int start, final int end) {
if (end <= start) {
return true;
}
boolean result = true;
Map<String, SourceLocation> nonCommentsStrings = getNonCommentsStrings(visited, start, end);
for (Entry<String, SourceLocation> entry : nonCommentsStrings.entrySet()) {
String s = entry.getKey();
// $NON-NLS-1$
Matcher m = Pattern.compile("\\s*(;+)\\s*").matcher(s);
while (m.find()) {
int startPos = entry.getValue().getStartPosition();
SourceLocation toRemove = SourceLocation.fromPositions(startPos + m.start(1), startPos + m.end(1));
ASTRewrite rewrite = cuRewrite.getASTRewrite();
rewrite.remove(toRemove);
result = false;
}
}
return result;
}
Aggregations