1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-29 19:45:01 +02:00

Fixed a bug that caused files to disappear from the index sometimes.

This commit is contained in:
Sergey Prigogin 2012-08-31 17:57:34 -07:00
parent 0dfb1ee847
commit 600c3b1b32
2 changed files with 6 additions and 3 deletions

View file

@ -74,6 +74,7 @@ public abstract class AbstractIndexerTask extends PDOMWriter {
public static enum UnusedHeaderStrategy { skip, useC, useCPP, useDefaultLanguage, useBoth } public static enum UnusedHeaderStrategy { skip, useC, useCPP, useDefaultLanguage, useBoth }
private static final int MAX_ERRORS = 500; private static final int MAX_ERRORS = 500;
// Order of constants is important. Stronger update types have to precede the weaker ones.
private static enum UpdateKind { REQUIRED_SOURCE, REQUIRED_HEADER, ONE_LINKAGE_HEADER, OTHER_HEADER } private static enum UpdateKind { REQUIRED_SOURCE, REQUIRED_HEADER, ONE_LINKAGE_HEADER, OTHER_HEADER }
private static class LinkageTask { private static class LinkageTask {
@ -119,7 +120,8 @@ public abstract class AbstractIndexerTask extends PDOMWriter {
boolean requestUpdate(IIndexFragmentFile ifile, Object tu, UpdateKind kind) { boolean requestUpdate(IIndexFragmentFile ifile, Object tu, UpdateKind kind) {
if (tu != null) if (tu != null)
fTu= tu; fTu= tu;
if (fKind == null) // Change fKind only if it becomes stronger as a result.
if (fKind == null || (kind != null && kind.compareTo(fKind) < 0))
fKind= kind; fKind= kind;
if (ifile == null) { if (ifile == null) {

View file

@ -200,6 +200,7 @@ import org.eclipse.cdt.ui.text.folding.ICFoldingStructureProvider;
import org.eclipse.cdt.internal.core.model.ASTCache.ASTRunnable; import org.eclipse.cdt.internal.core.model.ASTCache.ASTRunnable;
import org.eclipse.cdt.internal.core.pdom.indexer.IndexerPreferences; import org.eclipse.cdt.internal.core.pdom.indexer.IndexerPreferences;
import org.eclipse.cdt.internal.corext.util.CModelUtil;
import org.eclipse.cdt.internal.corext.util.CodeFormatterUtil; import org.eclipse.cdt.internal.corext.util.CodeFormatterUtil;
import org.eclipse.cdt.internal.ui.CPluginImages; import org.eclipse.cdt.internal.ui.CPluginImages;
@ -1286,11 +1287,11 @@ public class CEditor extends TextEditor implements ICEditor, ISelectionChangedLi
try { try {
IIndexManager indexManager = CCorePlugin.getIndexManager(); IIndexManager indexManager = CCorePlugin.getIndexManager();
if (tuToReset != null) { if (tuToReset != null) {
indexManager.update(new ICElement[] { tuToReset }, indexManager.update(new ICElement[] { CModelUtil.toOriginal(tuToReset) },
IIndexManager.RESET_INDEX_INCLUSION | IIndexManager.UPDATE_CHECK_TIMESTAMPS); IIndexManager.RESET_INDEX_INCLUSION | IIndexManager.UPDATE_CHECK_TIMESTAMPS);
} }
if (tuToAdd != null) { if (tuToAdd != null) {
indexManager.update(new ICElement[] { tuToAdd }, indexManager.update(new ICElement[] { CModelUtil.toOriginal(tuToAdd) },
IIndexManager.FORCE_INDEX_INCLUSION | IIndexManager.UPDATE_CHECK_TIMESTAMPS); IIndexManager.FORCE_INDEX_INCLUSION | IIndexManager.UPDATE_CHECK_TIMESTAMPS);
} }
} catch (CoreException e) { } catch (CoreException e) {