mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
Make rebuild index deterministic.
This commit is contained in:
parent
5c47f3f1a1
commit
97e64c95b3
1 changed files with 34 additions and 11 deletions
|
@ -11,12 +11,12 @@
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.internal.core.pdom.indexer;
|
package org.eclipse.cdt.internal.core.pdom.indexer;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
import java.util.Calendar;
|
import java.util.Calendar;
|
||||||
import java.util.LinkedHashSet;
|
import java.util.Comparator;
|
||||||
|
import java.util.HashSet;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import com.ibm.icu.text.NumberFormat;
|
|
||||||
|
|
||||||
import org.eclipse.cdt.core.CCorePlugin;
|
import org.eclipse.cdt.core.CCorePlugin;
|
||||||
import org.eclipse.cdt.core.dom.ILinkage;
|
import org.eclipse.cdt.core.dom.ILinkage;
|
||||||
import org.eclipse.cdt.core.dom.IPDOMIndexer;
|
import org.eclipse.cdt.core.dom.IPDOMIndexer;
|
||||||
|
@ -38,6 +38,7 @@ import org.eclipse.cdt.internal.core.pdom.IndexerProgress;
|
||||||
import org.eclipse.cdt.internal.core.pdom.db.ChunkCache;
|
import org.eclipse.cdt.internal.core.pdom.db.ChunkCache;
|
||||||
import org.eclipse.core.resources.IFile;
|
import org.eclipse.core.resources.IFile;
|
||||||
import org.eclipse.core.resources.IProject;
|
import org.eclipse.core.resources.IProject;
|
||||||
|
import org.eclipse.core.resources.IResource;
|
||||||
import org.eclipse.core.runtime.CoreException;
|
import org.eclipse.core.runtime.CoreException;
|
||||||
import org.eclipse.core.runtime.IPath;
|
import org.eclipse.core.runtime.IPath;
|
||||||
import org.eclipse.core.runtime.IProgressMonitor;
|
import org.eclipse.core.runtime.IProgressMonitor;
|
||||||
|
@ -47,6 +48,8 @@ import org.eclipse.core.runtime.Status;
|
||||||
import org.eclipse.core.runtime.content.IContentType;
|
import org.eclipse.core.runtime.content.IContentType;
|
||||||
import org.eclipse.osgi.util.NLS;
|
import org.eclipse.osgi.util.NLS;
|
||||||
|
|
||||||
|
import com.ibm.icu.text.NumberFormat;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Configures the abstract indexer task suitable for indexing projects.
|
* Configures the abstract indexer task suitable for indexing projects.
|
||||||
*/
|
*/
|
||||||
|
@ -104,14 +107,34 @@ public abstract class PDOMIndexerTask extends AbstractIndexerTask implements IPD
|
||||||
}
|
}
|
||||||
|
|
||||||
private static ITranslationUnit[] concat(ITranslationUnit[] added, ITranslationUnit[] changed) {
|
private static ITranslationUnit[] concat(ITranslationUnit[] added, ITranslationUnit[] changed) {
|
||||||
LinkedHashSet<ITranslationUnit> union = new LinkedHashSet<ITranslationUnit>(added.length + changed.length);
|
HashSet<ITranslationUnit> union = new HashSet<ITranslationUnit>(added.length + changed.length);
|
||||||
for (ITranslationUnit tu : added) {
|
union.addAll(Arrays.asList(added));
|
||||||
union.add(tu);
|
union.addAll(Arrays.asList(changed));
|
||||||
}
|
final ITranslationUnit[] result = union.toArray(new ITranslationUnit[union.size()]);
|
||||||
for (ITranslationUnit tu : changed) {
|
Arrays.sort(result, new Comparator<ITranslationUnit>() {
|
||||||
union.add(tu);
|
public int compare(ITranslationUnit o1, ITranslationUnit o2) {
|
||||||
}
|
IResource res1= o1.getResource();
|
||||||
return union.toArray(new ITranslationUnit[union.size()]);
|
IResource res2= o2.getResource();
|
||||||
|
if (res1 != null && res2 != null) {
|
||||||
|
return compare(res1.getFullPath().segments(), res2.getFullPath().segments());
|
||||||
|
}
|
||||||
|
return res1 != null ? -1 : res2 != null ? 1 : 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
private int compare(String[] s1, String[] s2) {
|
||||||
|
int max= Math.min(s1.length, s2.length) - 1;
|
||||||
|
for (int i = 0; i < max; i++) {
|
||||||
|
int cmp= s1[i].compareTo(s2[i]);
|
||||||
|
if (cmp != 0)
|
||||||
|
return cmp;
|
||||||
|
}
|
||||||
|
int cmp = s1.length-s2.length;
|
||||||
|
if (cmp != 0)
|
||||||
|
return cmp;
|
||||||
|
return s1[max].compareTo(s2[max]);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
public final void setParseUpFront() {
|
public final void setParseUpFront() {
|
||||||
|
|
Loading…
Add table
Reference in a new issue