@SuppressFBWarnings(value="NP_LOAD_OF_KNOWN_NULL_VALUE", justification = "FindBugs doesn't like passing nulls to a method that can take null")
static void fireVisitChunkCallbacks(@CheckForNull FlowNode next, @Nonnull FlowNode current, @CheckForNull FlowNode prev,
@Nonnull SimpleChunkVisitor visitor, @Nonnull ChunkFinder finder, @Nonnull ForkScanner scanner) {
boolean boundary = false;
if (prev == null && finder.isStartInsideChunk()) {
visitor.chunkEnd(current, prev, scanner);
boundary = true;
if (finder.isChunkStart(current, prev)) {
visitor.chunkStart(current, next, scanner);
}
} else {
if (finder.isChunkStart(current, prev)) {
visitor.chunkStart(current, next, scanner);
boundary = true;
}
if (finder.isChunkEnd(current, prev)) {
visitor.chunkEnd(current, prev, scanner);
boundary = true;
}
}
if (!boundary) {
visitor.atomNode(next, current, prev, scanner);
}
}