Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ void reportNonMarkdownSyntax(SyntaxTrivia trivia, Position start, Position end)
static String replaceQuotedCodeWithBlanks(String javadoc) {
StringBuilder result = new StringBuilder();
int currentPosition = 0;
Pattern printablePattern = Pattern.compile("\\p{Print}");
while (currentPosition != -1) {
int nextQuote = javadoc.indexOf("`", currentPosition);
if (nextQuote != -1) {
Expand All @@ -125,8 +126,7 @@ static String replaceQuotedCodeWithBlanks(String javadoc) {
int endOfQuote = currentPosition == -1 ? javadoc.length() : currentPosition;
// Replace all printable characters by spaces, so that they can't be interpreted as tags.
// Don't replace non-printable characters, as this could interfere with line counting.
result.append(javadoc.substring(nextQuote, endOfQuote)
.replaceAll("\\p{Print}", " "));
result.append(printablePattern.matcher(javadoc.substring(nextQuote, endOfQuote)).replaceAll(" "));
} else {
result.append(javadoc, currentPosition, javadoc.length());
currentPosition = -1;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import java.util.Locale;
import java.util.Map;
import java.util.Set;
import java.util.regex.Pattern;
import org.sonar.check.Rule;
import org.sonar.java.checks.helpers.ExpressionsHelper;
import org.sonar.java.model.ExpressionUtils;
Expand Down Expand Up @@ -191,14 +192,15 @@ private static Tree findDeclarationScope(Tree tree) {
// when all-uppercase, or split further on capital-letter boundaries.
static List<String> tokenizeIdentifier(String identifier) {
List<String> words = new ArrayList<>();
Pattern splitPattern = Pattern.compile("(?=[A-Z])");
for (String part : identifier.split("_")) {
if (part.isEmpty()) {
continue;
}
if (isAllUppercaseWithLetter(part)) {
words.add(part.toLowerCase(Locale.ROOT));
} else {
for (String sub : part.split("(?=[A-Z])")) {
for (String sub : splitPattern.split(part)) {
if (!sub.isEmpty()) {
words.add(sub.toLowerCase(Locale.ROOT));
}
Expand Down
Loading