1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-08-11 18:25:40 +02:00

Prevent duplicate task-tags when using full indexer, bug 287181.

This commit is contained in:
Markus Schorn 2009-09-30 15:33:41 +00:00
parent 1596d56719
commit 5707b6bf0c

View file

@ -12,6 +12,7 @@
package org.eclipse.cdt.internal.core.pdom.indexer; package org.eclipse.cdt.internal.core.pdom.indexer;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashSet;
import java.util.List; import java.util.List;
import org.eclipse.cdt.core.dom.ast.IASTComment; import org.eclipse.cdt.core.dom.ast.IASTComment;
@ -53,13 +54,19 @@ public class TodoTaskParser {
} }
public Task[] parse(IASTComment[] comments) { public Task[] parse(IASTComment[] comments) {
HashSet<String> locKeys= new HashSet<String>();
List<Task> tasks = new ArrayList<Task>(); List<Task> tasks = new ArrayList<Task>();
for (int i = 0; i < comments.length; i++) { for (IASTComment comment : comments) {
IASTComment comment = comments[i];
IASTFileLocation location = comment.getFileLocation(); IASTFileLocation location = comment.getFileLocation();
if (location != null) { // be defensive, bug 213307 if (location != null) { // be defensive, bug 213307
parse(comment.getComment(), location.getFileName(), location.getNodeOffset(), final String fileName = location.getFileName();
location.getStartingLineNumber(), tasks); final int nodeOffset = location.getNodeOffset();
final String key= fileName + ':' + nodeOffset;
// full indexer can yield duplicate comments, make sure to handle each comment only once (bug 287181)
if (locKeys.add(key)) {
parse(comment.getComment(), fileName, nodeOffset,
location.getStartingLineNumber(), tasks);
}
} }
} }
if (tasks.isEmpty()) { if (tasks.isEmpty()) {