From 3091857bf1a800b21c4f05ca345f4a99f4fb26fc Mon Sep 17 00:00:00 2001 From: Markus Schorn Date: Wed, 6 Jun 2007 12:57:37 +0000 Subject: [PATCH] Add assertions to check that macro definitions are not reused after updating a file in the index. --- .../internal/core/index/IndexBasedCodeReaderFactory.java | 9 +++++++-- .../core/pdom/indexer/fast/PDOMFastIndexerTask.java | 1 + 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/IndexBasedCodeReaderFactory.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/IndexBasedCodeReaderFactory.java index 11393cb1b80..41d4c2c6ede 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/IndexBasedCodeReaderFactory.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/IndexBasedCodeReaderFactory.java @@ -61,6 +61,10 @@ public class IndexBasedCodeReaderFactory implements ICodeReaderFactory { public IIndexFile fFile= null; public int fRequested= 0; + + public boolean hasCachedMacros() { + return fMacros != null; + } } private static class NeedToParseException extends Exception { private static final long serialVersionUID = 1L; @@ -208,10 +212,11 @@ public class IndexBasedCodeReaderFactory implements ICodeReaderFactory { } private void getInfosForMacroDictionary(IndexFileInfo fileInfo, LinkedHashSet/**/ target) throws CoreException, NeedToParseException { - if (!target.add(fileInfo)) { + // in case the file is already included, don't load the macros again. + if (isIncluded(fileInfo)) { return; } - if (isIncluded(fileInfo)) { + if (!target.add(fileInfo)) { return; } final IIndexFile file= fileInfo.fFile; diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/indexer/fast/PDOMFastIndexerTask.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/indexer/fast/PDOMFastIndexerTask.java index 17647cf4cb8..ce8cd92671c 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/indexer/fast/PDOMFastIndexerTask.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/indexer/fast/PDOMFastIndexerTask.java @@ -199,6 +199,7 @@ class PDOMFastIndexerTask extends PDOMIndexerTask implements CallbackHandler { throws CoreException { IndexFileInfo info= fCodeReaderFactory.createFileInfo(path); info.fFile= file; + assert !info.hasCachedMacros(); if (info.fRequested != IndexFileInfo.NOT_REQUESTED) { info.fRequested= IndexFileInfo.NOT_REQUESTED; return true;