in duplicates/ide/impl/src/org/netbeans/modules/jackpot30/impl/duplicates/ComputeDuplicates.java [174:235]
private DuplicateDescription nextDescription() throws IOException {
while (duplicateCandidates.hasNext()) {
String longest = duplicateCandidates.next();
List<Span> foundDuplicates = new LinkedList<Span>();
Query query = new TermQuery(new Term("duplicatesGeneralized", longest));
for (Entry<IndexReader, FileObject> e : readers2Roots.entrySet()) {
Searcher s = new IndexSearcher(e.getKey());
BitSet matchingDocuments = new BitSet(e.getKey().maxDoc());
Collector c = new BitSetCollector(matchingDocuments);
s.search(query, c);
for (int docNum = matchingDocuments.nextSetBit(0); docNum >= 0; docNum = matchingDocuments.nextSetBit(docNum + 1)) {
final Document doc = e.getKey().document(docNum);
int pos = Arrays.binarySearch(doc.getValues("duplicatesGeneralized"), longest);
if (pos < 0) {
continue;
}
String spanSpec = doc.getValues("duplicatesPositions")[pos];
String relPath = doc.getField("duplicatesPath").stringValue();
for (String spanPart : spanSpec.split(";")) {
Span span = Span.of(e.getValue().getFileObject(relPath), spanPart);
if (span != null) {
foundDuplicates.add(span);
}
}
}
}
if (foundDuplicates.size() >= minDuplicates) {
DuplicateDescription current = DuplicateDescription.of(foundDuplicates, getValue(longest), longest);
boolean add = true;
for (Iterator<DuplicateDescription> it = result.iterator(); it.hasNext();) {
DuplicateDescription existing = it.next();
if (subsumes(existing, current)) {
add = false;
break;
}
if (subsumes(current, existing)) {
//can happen? (note that the duplicates are sorted by value)
it.remove();
}
}
if (add) {
result.add(current);
return current;
}
}
}
return null;
}