mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-01 06:05:24 +02:00
bug 240371, standalone indexer needs a scanner info provider
This commit is contained in:
parent
f74aa0ca4a
commit
30ddbb8708
8 changed files with 161 additions and 28 deletions
|
@ -0,0 +1,28 @@
|
||||||
|
/*******************************************************************************
|
||||||
|
* Copyright (c) 2008 IBM Corporation and others.
|
||||||
|
* All rights reserved. This program and the accompanying materials
|
||||||
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
|
* which accompanies this distribution, and is available at
|
||||||
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
|
*
|
||||||
|
* Contributors:
|
||||||
|
* IBM - Initial API and implementation
|
||||||
|
*******************************************************************************/
|
||||||
|
|
||||||
|
package org.eclipse.cdt.internal.core.indexer;
|
||||||
|
|
||||||
|
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.
|
||||||
|
*
|
||||||
|
* @see IScannerInfoProvider
|
||||||
|
*/
|
||||||
|
public interface IStandaloneScannerInfoProvider {
|
||||||
|
|
||||||
|
IScannerInfo getScannerInformation(String path);
|
||||||
|
}
|
|
@ -39,7 +39,7 @@ import org.eclipse.core.runtime.CoreException;
|
||||||
*
|
*
|
||||||
* @since 4.0
|
* @since 4.0
|
||||||
*/
|
*/
|
||||||
public class StandaloneFastIndexer extends StandaloneIndexer{
|
public class StandaloneFastIndexer extends StandaloneIndexer {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Construct a fast standalone indexer.
|
* Construct a fast standalone indexer.
|
||||||
|
@ -53,16 +53,46 @@ public class StandaloneFastIndexer extends StandaloneIndexer{
|
||||||
*/
|
*/
|
||||||
public StandaloneFastIndexer(File writableIndexFile, IIndexLocationConverter converter, Map<String, IPDOMLinkageFactory> linkageFactoryMappings,
|
public StandaloneFastIndexer(File writableIndexFile, IIndexLocationConverter converter, Map<String, IPDOMLinkageFactory> linkageFactoryMappings,
|
||||||
IScannerInfo scanner, ILanguageMapper mapper, IParserLogService log) throws CoreException {
|
IScannerInfo scanner, ILanguageMapper mapper, IParserLogService log) throws CoreException {
|
||||||
WritablePDOM pdom = new WritablePDOM(writableIndexFile, converter, linkageFactoryMappings);
|
super(new WritableCIndex(new WritablePDOM(writableIndexFile, converter, linkageFactoryMappings),new IIndexFragment[0]),
|
||||||
fIndex = new WritableCIndex(
|
false, mapper, log, scanner);
|
||||||
pdom,
|
|
||||||
new IIndexFragment[0]);
|
|
||||||
fIndexAllFiles = false;
|
|
||||||
fScanner = scanner;
|
|
||||||
fMapper = mapper;
|
|
||||||
fLog = log;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Construct a fast standalone indexer.
|
||||||
|
* @param writableIndexFile - the file where the PDOM index is stored
|
||||||
|
* @param converter - a converter used to convert between String locations and IIndexLocations
|
||||||
|
* @param linkageFactoryMappings - all of the available IPDOMLinkageFactories the index can use during indexing
|
||||||
|
* @param scannerProvider - provides include paths and defined symbols
|
||||||
|
* @param mapper - a mapper used to determine ICLanguage for a particular file
|
||||||
|
* @param log - logger
|
||||||
|
* @throws CoreException
|
||||||
|
*/
|
||||||
|
public StandaloneFastIndexer(File writableIndexFile, IIndexLocationConverter converter, Map<String, IPDOMLinkageFactory> linkageFactoryMappings,
|
||||||
|
IStandaloneScannerInfoProvider scannerProvider, ILanguageMapper mapper, IParserLogService log) throws CoreException {
|
||||||
|
super(new WritableCIndex(new WritablePDOM(writableIndexFile, converter, linkageFactoryMappings),new IIndexFragment[0]),
|
||||||
|
false, mapper, log, scannerProvider);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Construct a fast standalone indexer.
|
||||||
|
* @param writableIndexFile - the file where the PDOM index is stored
|
||||||
|
* @param converter - a converter used to convert between String locations and IIndexLocations
|
||||||
|
* @param linkageFactoryMappings - all of the available IPDOMLinkageFactories the index can use during indexing
|
||||||
|
* @param scannerProvider - provides include paths and defined symbols
|
||||||
|
* @param mapper - a mapper used to determine ICLanguage for a particular file
|
||||||
|
* @param log - logger
|
||||||
|
* @throws CoreException
|
||||||
|
*/
|
||||||
|
public StandaloneFastIndexer(File writableIndexFile, IIndexLocationConverter converter, Map<String, IPDOMLinkageFactory> linkageFactoryMappings,
|
||||||
|
ILanguageMapper mapper, IParserLogService log) throws CoreException {
|
||||||
|
super(new WritableCIndex(new WritablePDOM(writableIndexFile, converter, linkageFactoryMappings),new IIndexFragment[0]),
|
||||||
|
false, mapper, log, (IStandaloneScannerInfoProvider)null);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a delegate standalone indexing task
|
* Create a delegate standalone indexing task
|
||||||
*/
|
*/
|
||||||
|
@ -71,4 +101,5 @@ public class StandaloneFastIndexer extends StandaloneIndexer{
|
||||||
return new StandaloneFastIndexerTask(this, added, changed, removed);
|
return new StandaloneFastIndexerTask(this, added, changed, removed);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,7 +30,7 @@ import org.eclipse.cdt.core.dom.ICodeReaderFactory;
|
||||||
* @since 4.0
|
* @since 4.0
|
||||||
*/
|
*/
|
||||||
public class StandaloneFastIndexerTask extends StandaloneIndexerTask {
|
public class StandaloneFastIndexerTask extends StandaloneIndexerTask {
|
||||||
public StandaloneFastIndexerTask(StandaloneFastIndexer indexer, List added, List changed, List removed) {
|
public StandaloneFastIndexerTask(StandaloneFastIndexer indexer, List<String> added, List<String> changed, List<String> removed) {
|
||||||
super(indexer, added, changed, removed, true);
|
super(indexer, added, changed, removed, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -24,6 +24,7 @@ import org.eclipse.cdt.core.parser.IScannerInfo;
|
||||||
import org.eclipse.cdt.internal.core.index.IIndexFragment;
|
import org.eclipse.cdt.internal.core.index.IIndexFragment;
|
||||||
import org.eclipse.cdt.internal.core.index.WritableCIndex;
|
import org.eclipse.cdt.internal.core.index.WritableCIndex;
|
||||||
import org.eclipse.cdt.internal.core.pdom.WritablePDOM;
|
import org.eclipse.cdt.internal.core.pdom.WritablePDOM;
|
||||||
|
import org.eclipse.cdt.internal.core.pdom.dom.IPDOMLinkageFactory;
|
||||||
import org.eclipse.core.runtime.CoreException;
|
import org.eclipse.core.runtime.CoreException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -55,19 +56,33 @@ public class StandaloneFullIndexer extends StandaloneIndexer{
|
||||||
* by the source code being parsed.
|
* by the source code being parsed.
|
||||||
* @throws CoreException
|
* @throws CoreException
|
||||||
*/
|
*/
|
||||||
public StandaloneFullIndexer(File writableIndexFile, IIndexLocationConverter converter, Map linkageFactoryMappings,
|
public StandaloneFullIndexer(File writableIndexFile, IIndexLocationConverter converter, Map<String, IPDOMLinkageFactory> linkageFactoryMappings,
|
||||||
IScannerInfo scanner, ILanguageMapper mapper, IParserLogService log, ICodeReaderFactory codeReaderFactory) throws CoreException {
|
IScannerInfo scanner, ILanguageMapper mapper, IParserLogService log, ICodeReaderFactory codeReaderFactory) throws CoreException {
|
||||||
WritablePDOM pdom = new WritablePDOM(writableIndexFile, converter, linkageFactoryMappings);
|
super(new WritableCIndex(new WritablePDOM(writableIndexFile, converter, linkageFactoryMappings),new IIndexFragment[0]),
|
||||||
fIndex = new WritableCIndex(
|
false, mapper, log, scanner);
|
||||||
pdom,
|
|
||||||
new IIndexFragment[0]);
|
|
||||||
fIndexAllFiles = false;
|
|
||||||
fScanner = scanner;
|
|
||||||
fMapper = mapper;
|
|
||||||
fCodeReaderFactory = codeReaderFactory;
|
fCodeReaderFactory = codeReaderFactory;
|
||||||
fLog = log;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a full indexer.
|
||||||
|
* @param writableIndexFile - the file where the PDOM index is stored
|
||||||
|
* @param converter - a converter used to convert between String locations and IIndexLocations
|
||||||
|
* @param linkageFactoryMappings - all of the available IPDOMLinkageFactories the index can use during indexing
|
||||||
|
* @param scannerProvider - provides include paths and defined symbols
|
||||||
|
* @param mapper - a mapper used to determine ICLanguage for a particular file
|
||||||
|
* @param log - logger
|
||||||
|
* @param codeReaderFactory - factory that provides CodeReaders for files included
|
||||||
|
* by the source code being parsed.
|
||||||
|
* @throws CoreException
|
||||||
|
*/
|
||||||
|
public StandaloneFullIndexer(File writableIndexFile, IIndexLocationConverter converter, Map<String, IPDOMLinkageFactory> linkageFactoryMappings,
|
||||||
|
IStandaloneScannerInfoProvider scannerProvider, ILanguageMapper mapper, IParserLogService log, ICodeReaderFactory codeReaderFactory) throws CoreException {
|
||||||
|
super(new WritableCIndex(new WritablePDOM(writableIndexFile, converter, linkageFactoryMappings),new IIndexFragment[0]),
|
||||||
|
false, mapper, log, scannerProvider);
|
||||||
|
fCodeReaderFactory = codeReaderFactory;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the factory that provides CodeReaders for files included
|
* Returns the factory that provides CodeReaders for files included
|
||||||
* by the source code being parsed.
|
* by the source code being parsed.
|
||||||
|
@ -80,7 +95,7 @@ public class StandaloneFullIndexer extends StandaloneIndexer{
|
||||||
* Creates a delegate standalone indexing task
|
* Creates a delegate standalone indexing task
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
protected StandaloneIndexerTask createTask(List added, List changed, List removed) {
|
protected StandaloneIndexerTask createTask(List<String> added, List<String> changed, List<String> removed) {
|
||||||
return new StandaloneFullIndexerTask(this, added, changed, removed);
|
return new StandaloneFullIndexerTask(this, added, changed, removed);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -30,8 +30,8 @@ import org.eclipse.cdt.core.dom.ICodeReaderFactory;
|
||||||
* @since 4.0
|
* @since 4.0
|
||||||
*/
|
*/
|
||||||
public class StandaloneFullIndexerTask extends StandaloneIndexerTask {
|
public class StandaloneFullIndexerTask extends StandaloneIndexerTask {
|
||||||
public StandaloneFullIndexerTask(StandaloneFullIndexer indexer, List added,
|
public StandaloneFullIndexerTask(StandaloneFullIndexer indexer, List<String> added,
|
||||||
List changed, List removed) {
|
List<String> changed, List<String> removed) {
|
||||||
super(indexer, added, changed, removed, false);
|
super(indexer, added, changed, removed, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -16,14 +16,21 @@ import java.io.File;
|
||||||
import java.io.FilenameFilter;
|
import java.io.FilenameFilter;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collections;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.core.index.IIndexLocationConverter;
|
||||||
import org.eclipse.cdt.core.parser.IParserLogService;
|
import org.eclipse.cdt.core.parser.IParserLogService;
|
||||||
import org.eclipse.cdt.core.parser.IScannerInfo;
|
import org.eclipse.cdt.core.parser.IScannerInfo;
|
||||||
|
import org.eclipse.cdt.internal.core.index.IIndexFragment;
|
||||||
import org.eclipse.cdt.internal.core.index.IWritableIndex;
|
import org.eclipse.cdt.internal.core.index.IWritableIndex;
|
||||||
|
import org.eclipse.cdt.internal.core.index.WritableCIndex;
|
||||||
import org.eclipse.cdt.internal.core.pdom.IndexerProgress;
|
import org.eclipse.cdt.internal.core.pdom.IndexerProgress;
|
||||||
|
import org.eclipse.cdt.internal.core.pdom.WritablePDOM;
|
||||||
|
import org.eclipse.cdt.internal.core.pdom.dom.IPDOMLinkageFactory;
|
||||||
import org.eclipse.core.runtime.CoreException;
|
import org.eclipse.core.runtime.CoreException;
|
||||||
import org.eclipse.core.runtime.IProgressMonitor;
|
import org.eclipse.core.runtime.IProgressMonitor;
|
||||||
|
|
||||||
|
@ -72,7 +79,9 @@ public abstract class StandaloneIndexer {
|
||||||
/**
|
/**
|
||||||
* Empty list.
|
* Empty list.
|
||||||
*/
|
*/
|
||||||
protected static final List NO_TUS = new ArrayList();
|
protected static final List<String> NO_TUS = Collections.emptyList();
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The IWritableIndex that stores all bindings and names.
|
* The IWritableIndex that stores all bindings and names.
|
||||||
*/
|
*/
|
||||||
|
@ -87,13 +96,22 @@ public abstract class StandaloneIndexer {
|
||||||
/**
|
/**
|
||||||
* Collection of valid file extensions for C/C++ source.
|
* Collection of valid file extensions for C/C++ source.
|
||||||
*/
|
*/
|
||||||
protected Set fValidSourceUnitNames;
|
protected Set<String> fValidSourceUnitNames;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The IScannerInfo that provides include paths and defined symbols.
|
* The IScannerInfo that provides include paths and defined symbols.
|
||||||
|
* Either a single scanner info or a IStandaloneScannerInfoProvider must
|
||||||
|
* be provided, but not both. If a single IScannerInfo object is provided
|
||||||
|
* it will always be used. Otherwise the provider will be used.
|
||||||
*/
|
*/
|
||||||
protected IScannerInfo fScanner;
|
protected IScannerInfo fScanner;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates IScannerInfo objects from file paths, allows there
|
||||||
|
* to be separate scanner infos for specific files and folders.
|
||||||
|
*/
|
||||||
|
protected IStandaloneScannerInfoProvider fScannerInfoProvider;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The ILanguageMapper that determines the ILanguage for a file.
|
* The ILanguageMapper that determines the ILanguage for a file.
|
||||||
*/
|
*/
|
||||||
|
@ -146,6 +164,33 @@ public abstract class StandaloneIndexer {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
public StandaloneIndexer(IWritableIndex index, boolean indexAllFiles,
|
||||||
|
ILanguageMapper mapper, IParserLogService log, IScannerInfo scanner) {
|
||||||
|
fIndex = index;
|
||||||
|
fIndexAllFiles = indexAllFiles;
|
||||||
|
fMapper = mapper;
|
||||||
|
fLog = log;
|
||||||
|
fScanner = scanner;
|
||||||
|
fScannerInfoProvider = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public StandaloneIndexer(IWritableIndex index, boolean indexAllFiles,
|
||||||
|
ILanguageMapper mapper, IParserLogService log, IStandaloneScannerInfoProvider scannerProvider) {
|
||||||
|
fIndex = index;
|
||||||
|
fIndexAllFiles = indexAllFiles;
|
||||||
|
fMapper = mapper;
|
||||||
|
fLog = log;
|
||||||
|
fScanner = null;
|
||||||
|
fScannerInfoProvider = scannerProvider;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public void setScannerInfoProvider(IStandaloneScannerInfoProvider provider) {
|
||||||
|
fScannerInfoProvider = provider;
|
||||||
|
fScanner = null;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the index.
|
* Returns the index.
|
||||||
* @return the IWritable index the indexer is writing to
|
* @return the IWritable index the indexer is writing to
|
||||||
|
@ -165,14 +210,14 @@ public abstract class StandaloneIndexer {
|
||||||
/**
|
/**
|
||||||
* Returns the collection of valid file extensions for C/C++ source.
|
* Returns the collection of valid file extensions for C/C++ source.
|
||||||
*/
|
*/
|
||||||
public Set getValidSourceUnitNames() {
|
public Set<String> getValidSourceUnitNames() {
|
||||||
return fValidSourceUnitNames;
|
return fValidSourceUnitNames;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the collection of valid file extensions for C/C++ source.
|
* Sets the collection of valid file extensions for C/C++ source.
|
||||||
*/
|
*/
|
||||||
public void setValidSourceUnitNames(Set validSourceUnitNames) {
|
public void setValidSourceUnitNames(Set<String> validSourceUnitNames) {
|
||||||
fValidSourceUnitNames = validSourceUnitNames;
|
fValidSourceUnitNames = validSourceUnitNames;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -183,6 +228,21 @@ public abstract class StandaloneIndexer {
|
||||||
return fScanner;
|
return fScanner;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the IScannerInfo for the given path.
|
||||||
|
* If the current instance was created with an IScannerInfo instead of
|
||||||
|
* an IScannerInfoProvider then the path will be ignored and
|
||||||
|
* that IScannerInfo will always be returned.
|
||||||
|
*/
|
||||||
|
public IScannerInfo getScannerInfo(String path) {
|
||||||
|
if(fScanner != null)
|
||||||
|
return fScanner;
|
||||||
|
|
||||||
|
return fScannerInfoProvider.getScannerInformation(path);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the ILanguageMapper that determines the ILanguage for a file.
|
* Returns the ILanguageMapper that determines the ILanguage for a file.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -43,7 +43,7 @@ public abstract class StandaloneIndexerTask extends AbstractIndexerTask {
|
||||||
|
|
||||||
protected StandaloneIndexer fIndexer;
|
protected StandaloneIndexer fIndexer;
|
||||||
|
|
||||||
protected StandaloneIndexerTask(StandaloneIndexer indexer, Collection added, Collection changed, Collection removed, boolean isFast) {
|
protected StandaloneIndexerTask(StandaloneIndexer indexer, Collection<String> added, Collection<String> changed, Collection<String> removed, boolean isFast) {
|
||||||
super(concat(added, changed), removed.toArray(), new StandaloneIndexerInputAdapter(indexer), isFast);
|
super(concat(added, changed), removed.toArray(), new StandaloneIndexerInputAdapter(indexer), isFast);
|
||||||
fIndexer= indexer;
|
fIndexer= indexer;
|
||||||
setShowActivity(fIndexer.getShowActivity());
|
setShowActivity(fIndexer.getShowActivity());
|
||||||
|
|
|
@ -11,7 +11,6 @@
|
||||||
package org.eclipse.cdt.internal.core.indexer;
|
package org.eclipse.cdt.internal.core.indexer;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.parser.AbstractParserLogService;
|
import org.eclipse.cdt.core.parser.AbstractParserLogService;
|
||||||
import org.eclipse.cdt.core.parser.IParserLogService;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author crecoskie
|
* @author crecoskie
|
||||||
|
|
Loading…
Add table
Reference in a new issue