}
public int[] toIntArray() {
- int size = (bytes.length / 4) + (bytes.length % 4 == 0 ? 0 : 1); // Pad the size to multiple of 4
+ // Pad the size to multiple of 4
+ int size = (bytes.length / 4) + (bytes.length % 4 == 0 ? 0 : 1);
ByteBuffer bb = ByteBuffer.allocate(size * 4);
bb.put(bytes);
bb.rewind();
if (c == 0) {
if (part1.getUnitStart() <= part2.getUnitStart()) {
if (part2.getUnitStart() + l2 <= part1.getUnitStart() + l1) {
- return 0; // part1 contains part2
+ // part1 contains part2
+ return 0;
} else {
- return -1; // SortedListsUtils#contains should continue search
+ // SortedListsUtils#contains should continue search
+ return -1;
}
} else {
- return 1; // unitStart of part1 is less than unitStart of part2 - SortedListsUtils#contains should stop search
+ // unitStart of part1 is less than unitStart of part2 - SortedListsUtils#contains should stop search
+ return 1;
}
} else {
return c;
if (c == 0) {
c = block1.getIndexInFile() + 1 - block2.getIndexInFile();
}
- if (c == 0) { // list1[i] == list2[j]
+ if (c == 0) {
+ // list1[i] == list2[j]
i++;
j++;
intersection.blocks.add(block2);
}
- if (c > 0) { // list1[i] > list2[j]
+ if (c > 0) {
+ // list1[i] > list2[j]
j++;
}
- if (c < 0) { // list1[i] < list2[j]
+ if (c < 0) {
+ // list1[i] < list2[j]
i++;
}
}
int size = fileBlocks.size();
// Godin: create one group per unique hash
- Map<ByteArray, BlocksGroup> groupsByHash = Maps.newHashMap(); // TODO Godin: can we create map with expected size?
+ // TODO Godin: can we create map with expected size?
+ Map<ByteArray, BlocksGroup> groupsByHash = Maps.newHashMap();
for (Block fileBlock : fileBlocks) {
ByteArray hash = fileBlock.getBlockHash();
BlocksGroup sameHash = groupsByHash.get(hash);
lastBlock.getEndLine());
// TODO Godin: maybe use FastStringComparator here ?
- if (originResourceId.equals(part.getResourceId())) { // part from origin
+ if (originResourceId.equals(part.getResourceId())) {
+ // part from origin
if (origin == null) {
origin = part;
// To calculate length important to use the origin, because otherwise block may come from DB without required data
public final class Edge {
- private int beginIndex; // can't be changed
+ // can't be changed
+ private int beginIndex;
+
private int endIndex;
private Node startNode;
- private Node endNode; // can't be changed, could be used as edge id
+
+ // can't be changed, could be used as edge id
+ private Node endNode;
// each time edge is created, a new end node is created
public Edge(int beginIndex, int endIndex, Node startNode) {
while (!stack.isEmpty()) {
Node node = stack.removeLast();
node.startSize = list.size();
- if (node.getEdges().isEmpty()) { // leaf
+ if (node.getEdges().isEmpty()) {
+ // leaf
list.add(node.depth);
node.endSize = list.size();
} else {
- if (!node.equals(tree.getRootNode())) { // inner node = not leaf and not root
+ if (!node.equals(tree.getRootNode())) {
+ // inner node = not leaf and not root
innerNodes.add(node);
}
for (Edge edge : node.getEdges()) {
active.canonize();
}
updateSuffixNode(lastParentNode, parentNode);
- active.incEndIndex(); // Now the endpoint is the next active point
+ active.incEndIndex();
+ // Now the endpoint is the next active point
active.canonize();
}
String originResourceId = fileBlocks.iterator().next().getResourceId();
Map<String, List<Block>> fromIndex = retrieveFromIndex(index, originResourceId, hashes);
- if (fromIndex.isEmpty() && hashes.size() == fileBlocks.size()) { // optimization for the case when there is no duplications
+ if (fromIndex.isEmpty() && hashes.size() == fileBlocks.size()) {
+ // optimization for the case when there is no duplications
return null;
}
// Identifiers, Keywords, Boolean Literals, The Null Literal
.token("\\p{javaJavaIdentifierStart}++\\p{javaJavaIdentifierPart}*+")
// Floating-Point Literals
- .token("[0-9_]++\\.([0-9_]++)?+" + EXP + "?+" + FLOAT_SUFFIX + "?+", NORMALIZED_NUMERIC_LITERAL) // Decimal
- .token("\\.[0-9_]++" + EXP + "?+" + FLOAT_SUFFIX + "?+", NORMALIZED_NUMERIC_LITERAL) // Decimal
- .token("[0-9_]++" + EXP + FLOAT_SUFFIX + "?+", NORMALIZED_NUMERIC_LITERAL) // Decimal
- .token("0[xX][0-9a-fA-F_]++\\.[0-9a-fA-F_]*+" + BINARY_EXP + "?+" + FLOAT_SUFFIX + "?+", NORMALIZED_NUMERIC_LITERAL) // Hexadecimal
- .token("0[xX][0-9a-fA-F_]++" + BINARY_EXP + FLOAT_SUFFIX + "?+", NORMALIZED_NUMERIC_LITERAL) // Hexadecimal
+ // Decimal
+ .token("[0-9_]++\\.([0-9_]++)?+" + EXP + "?+" + FLOAT_SUFFIX + "?+", NORMALIZED_NUMERIC_LITERAL)
+ // Decimal
+ .token("\\.[0-9_]++" + EXP + "?+" + FLOAT_SUFFIX + "?+", NORMALIZED_NUMERIC_LITERAL)
+ // Decimal
+ .token("[0-9_]++" + EXP + FLOAT_SUFFIX + "?+", NORMALIZED_NUMERIC_LITERAL)
+ // Hexadecimal
+ .token("0[xX][0-9a-fA-F_]++\\.[0-9a-fA-F_]*+" + BINARY_EXP + "?+" + FLOAT_SUFFIX + "?+", NORMALIZED_NUMERIC_LITERAL)
+ // Hexadecimal
+ .token("0[xX][0-9a-fA-F_]++" + BINARY_EXP + FLOAT_SUFFIX + "?+", NORMALIZED_NUMERIC_LITERAL)
// Integer Literals
- .token("0[xX][0-9a-fA-F_]++" + INT_SUFFIX + "?+", NORMALIZED_NUMERIC_LITERAL) // Hexadecimal
- .token("0[bB][01_]++" + INT_SUFFIX + "?+", NORMALIZED_NUMERIC_LITERAL) // Binary (Java 7)
- .token("[0-9_]++" + INT_SUFFIX + "?+", NORMALIZED_NUMERIC_LITERAL) // Decimal and Octal
+ // Hexadecimal
+ .token("0[xX][0-9a-fA-F_]++" + INT_SUFFIX + "?+", NORMALIZED_NUMERIC_LITERAL)
+ // Binary (Java 7)
+ .token("0[bB][01_]++" + INT_SUFFIX + "?+", NORMALIZED_NUMERIC_LITERAL)
+ // Decimal and Octal
+ .token("[0-9_]++" + INT_SUFFIX + "?+", NORMALIZED_NUMERIC_LITERAL)
// Any other character
.token(".")
.build();
@Override
public boolean consume(CodeReader code, TokenQueue output) {
if (code.popTo(matcher, tmpBuilder) > 0) {
- Cursor previousCursor = code.getPreviousCursor(); // see SONAR-2499
+ // see SONAR-2499
+ Cursor previousCursor = code.getPreviousCursor();
if (normalizationValue != null) {
output.add(new Token(normalizationValue, previousCursor.getLine(), previousCursor.getColumn()));
} else {
output.add(new Token(tmpBuilder.toString(), previousCursor.getLine(), previousCursor.getColumn()));
}
- tmpBuilder.setLength(0); // Godin: note that other channels use method delete in order to do the same thing
+ // Godin: note that other channels use method delete in order to do the same thing
+ tmpBuilder.setLength(0);
return true;
}
return false;