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

fix for bug 245443, standalone indexer needs to provide a Scanner Info object when parsing files up front

This commit is contained in:
Mike Kucera 2008-09-03 21:22:02 +00:00
parent 5b5efea7eb
commit 07a880257d
3 changed files with 46 additions and 3 deletions

View file

@ -15,8 +15,6 @@ import org.eclipse.cdt.core.parser.IScannerInfo;
import org.eclipse.cdt.core.parser.IScannerInfoProvider;
/**
* Returns a IScannerInfo for the given file by a path.
*
* Similar to IScannerInfoProvider but computes the IScannerInfo
* based on a String path instead of IResource.
*
@ -24,5 +22,20 @@ import org.eclipse.cdt.core.parser.IScannerInfoProvider;
*/
public interface IStandaloneScannerInfoProvider {
/**
* Returns an IScannerInfo for the given file path,
* or an empty IScannerInfo object if the file path is invalid.
*/
IScannerInfo getScannerInformation(String path);
/**
* Returns an IScannerInfo when you don't necessary have access to a path.
*
* This is used by the "parse up front" feature. Since we are parsing
* files outside of the project a "default" IScannerInfo object
* is needed to get the minimal amount of available info in order
* to parse the file.
* @param linkageID
*/
IScannerInfo getDefaultScannerInformation(int linkageID);
}

View file

@ -98,6 +98,7 @@ public abstract class StandaloneIndexer {
* be provided, but not both. If a single IScannerInfo object is provided
* it will always be used. Otherwise the provider will be used.
*/
@Deprecated
protected IScannerInfo fScanner;
/**
@ -158,6 +159,10 @@ public abstract class StandaloneIndexer {
}
};
/**
* @deprecated Its better to provide a scanner info provider instead.
*/
@Deprecated
public StandaloneIndexer(IWritableIndex index, boolean indexAllFiles,
ILanguageMapper mapper, IParserLogService log, IScannerInfo scanner) {
fIndex = index;
@ -217,7 +222,10 @@ public abstract class StandaloneIndexer {
/**
* Returns the IScannerInfo that provides include paths and defined symbols.
* @deprecated Should probably be using a IStandaloneScannerInfoProvider instead and
* calling getScannerInfo(String).
*/
@Deprecated
public IScannerInfo getScannerInfo() {
return fScanner;
}
@ -235,7 +243,14 @@ public abstract class StandaloneIndexer {
return fScannerInfoProvider.getScannerInformation(path);
}
/**
* Returns the IStandaloneScannerInfoProvider or null if one was not provided.
*/
public IStandaloneScannerInfoProvider getScannerInfoProvider() {
return fScannerInfoProvider;
}
/**
* Returns the ILanguageMapper that determines the ILanguage for a file.

View file

@ -20,6 +20,7 @@ import java.util.Iterator;
import org.eclipse.cdt.core.model.AbstractLanguage;
import org.eclipse.cdt.core.model.ILanguage;
import org.eclipse.cdt.core.parser.IParserLogService;
import org.eclipse.cdt.core.parser.IScannerInfo;
import org.eclipse.cdt.internal.core.index.IWritableIndex;
import org.eclipse.cdt.internal.core.pdom.AbstractIndexerTask;
import org.eclipse.cdt.internal.core.pdom.IndexerProgress;
@ -218,6 +219,20 @@ public abstract class StandaloneIndexerTask extends AbstractIndexerTask {
protected void logError(IStatus s) {
getLogService().traceLog(s.getMessage());
}
@SuppressWarnings("deprecation")
@Override
protected IScannerInfo createDefaultScannerConfig(int linkageID) {
IStandaloneScannerInfoProvider provider = fIndexer.getScannerInfoProvider();
if(provider != null)
return provider.getDefaultScannerInformation(linkageID);
IScannerInfo scannerInfo = fIndexer.getScannerInfo();
if(scannerInfo != null)
return scannerInfo;
return super.createDefaultScannerConfig(linkageID);
}
}