1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-23 14:42:11 +02:00

Bug 319033: Exception in stand-alone indexer.

This commit is contained in:
Markus Schorn 2010-07-07 09:16:56 +00:00
parent bf5126ad89
commit d0de0c79ee
5 changed files with 21 additions and 3 deletions

View file

@ -66,6 +66,11 @@ public class StandaloneIndexerInputAdapter extends IndexerInputAdapter {
return isValidSourceUnitName((String) tu);
}
@Override
public boolean isIndexedOnlyIfIncluded(Object tu) {
return false;
}
@Override
public boolean isSource(String filename) {
return isValidSourceUnitName(filename);

View file

@ -172,6 +172,7 @@ public class CPreprocessor implements ILexerLog, IScanner, IAdaptable {
private int fContentAssistLimit= -1;
private boolean fHandledCompletion= false;
private boolean fSplitShiftRightOperator= false;
private int fTokenCount= 0;
// state information
private final CharArrayMap<PreprocessorMacro> fMacroDictionary = new CharArrayMap<PreprocessorMacro>(512);
@ -462,6 +463,9 @@ public class CPreprocessor implements ILexerLog, IScanner, IAdaptable {
if (t != null) {
fPrefetchedTokens= (Token) t.getNext();
t.setNext(null);
if (++fTokenCount > 1000) {
throw new OffsetLimitReachedException(0, t);
}
return t;
}

View file

@ -53,7 +53,6 @@ import org.eclipse.cdt.internal.core.index.IndexBasedFileContentProvider;
import org.eclipse.cdt.internal.core.parser.scanner.InternalFileContentProvider;
import org.eclipse.cdt.internal.core.parser.scanner.StreamHasher;
import org.eclipse.cdt.internal.core.pdom.dom.PDOMNotImplementedError;
import org.eclipse.cdt.internal.core.pdom.indexer.PotentialTranslationUnit;
import org.eclipse.cdt.utils.EFSExtensionManager;
import org.eclipse.core.runtime.Assert;
import org.eclipse.core.runtime.CoreException;
@ -385,7 +384,7 @@ public abstract class AbstractIndexerTask extends PDOMWriter {
continue;
final IIndexFragmentFile[] indexFiles= fIndex.getWritableFiles(ifl);
if (!(tu instanceof PotentialTranslationUnit)) {
if (!fResolver.isIndexedOnlyIfIncluded(tu)) {
final boolean isSourceUnit= fResolver.isSourceUnit(tu);
final boolean isExcludedSource= isSourceUnit && !fIndexFilesWithoutConfiguration && !fResolver.isFileBuildConfigured(tu);

View file

@ -49,6 +49,12 @@ public abstract class IndexerInputAdapter extends ASTFilePathResolver {
*/
public abstract boolean isFileBuildConfigured(Object tu);
/**
* Returns whether the given translation-unit is not indexed unless it gets included.
* This applies to files that are outside of a source root.
*/
public abstract boolean isIndexedOnlyIfIncluded(Object tu);
/**
* Tests whether the file in the index is allowed to be part of an SDK. If not
* it will be indexed.
@ -69,7 +75,6 @@ public abstract class IndexerInputAdapter extends ASTFilePathResolver {
* Returns a code reader for the given input file.
*/
public abstract FileContent getCodeReader(Object tu);
/**
* Returns the encoding for the file.
*/

View file

@ -234,6 +234,11 @@ public class ProjectIndexerInputAdapter extends IndexerInputAdapter {
return !CoreModel.isScannerInformationEmpty(tu.getResource());
}
@Override
public boolean isIndexedOnlyIfIncluded(Object tu) {
return tu instanceof PotentialTranslationUnit;
}
@Override
public boolean isSourceUnit(Object tuo) {
ITranslationUnit tu= (ITranslationUnit) tuo;