mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-29 20:05:35 +02:00
Fix for 180161, indexing stddef.h up-front.
This commit is contained in:
parent
6d2679f27e
commit
0c941b8724
13 changed files with 239 additions and 102 deletions
|
@ -22,10 +22,9 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunctionType;
|
|||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPMember;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPMethod;
|
||||
import org.eclipse.cdt.core.model.ICProject;
|
||||
import org.eclipse.cdt.core.testplugin.CProjectHelper;
|
||||
import org.eclipse.cdt.internal.core.CCoreInternals;
|
||||
import org.eclipse.cdt.internal.core.pdom.PDOM;
|
||||
import org.eclipse.core.resources.IResource;
|
||||
import org.eclipse.core.runtime.NullProgressMonitor;
|
||||
|
||||
/**
|
||||
* Tests for verifying whether the PDOM correctly stores information about
|
||||
|
@ -48,7 +47,8 @@ public class MethodTests extends PDOMTestBase {
|
|||
protected void tearDown() throws Exception {
|
||||
pdom.releaseReadLock();
|
||||
if (project != null) {
|
||||
project.getProject().delete(IResource.FORCE | IResource.ALWAYS_DELETE_PROJECT_CONTENT, new NullProgressMonitor());
|
||||
CProjectHelper.delete(project);
|
||||
project= null;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -182,8 +182,10 @@ abstract public class PDOMWriter {
|
|||
prepareInMap(symbolMap, newPath);
|
||||
addToMap(symbolMap, 0, newPath, include);
|
||||
}
|
||||
stack.add(currentPath);
|
||||
currentPath= findLocation(include.getPath());
|
||||
if (include.isResolved()) {
|
||||
stack.add(currentPath);
|
||||
currentPath= findLocation(include.getPath());
|
||||
}
|
||||
}
|
||||
stack.add(currentPath);
|
||||
while (!stack.isEmpty()) {
|
||||
|
|
|
@ -25,6 +25,7 @@ public abstract class AbstractPDOMIndexer implements IPDOMIndexer {
|
|||
|
||||
public AbstractPDOMIndexer() {
|
||||
fProperties.put(IndexerPreferences.KEY_INDEX_ALL_FILES, String.valueOf(false));
|
||||
fProperties.put(IndexerPreferences.KEY_FILES_TO_PARSE_UP_FRONT, ""); //$NON-NLS-1$
|
||||
}
|
||||
|
||||
public ICProject getProject() {
|
||||
|
@ -67,4 +68,15 @@ public abstract class AbstractPDOMIndexer implements IPDOMIndexer {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
public String[] getFilesToParseUpFront() {
|
||||
String prefSetting= getProperty(IndexerPreferences.KEY_FILES_TO_PARSE_UP_FRONT);
|
||||
if (prefSetting != null) {
|
||||
prefSetting= prefSetting.trim();
|
||||
if (prefSetting.length() > 0) {
|
||||
return prefSetting.split(","); //$NON-NLS-1$
|
||||
}
|
||||
}
|
||||
return new String[0];
|
||||
}
|
||||
}
|
||||
|
|
|
@ -36,18 +36,22 @@ import org.osgi.service.prefs.Preferences;
|
|||
* @since 4.0
|
||||
*/
|
||||
public class IndexerPreferences {
|
||||
private static final String DEFAULT_INDEX_IMPORT_LOCATION = ".settings/cdt-index.zip"; //$NON-NLS-1$
|
||||
public static final int SCOPE_INSTANCE = 0;
|
||||
public static final int SCOPE_PROJECT_PRIVATE = 1;
|
||||
public static final int SCOPE_PROJECT_SHARED = 2;
|
||||
|
||||
public static final String KEY_INDEXER_ID= "indexerId"; //$NON-NLS-1$
|
||||
public static final String KEY_INDEX_ALL_FILES= "indexAllFiles"; //$NON-NLS-1$
|
||||
public static final String KEY_FILES_TO_PARSE_UP_FRONT= "filesToParseUpFront"; //$NON-NLS-1$
|
||||
|
||||
private static final String DEFAULT_INDEX_IMPORT_LOCATION = ".settings/cdt-index.zip"; //$NON-NLS-1$
|
||||
private static final String DEFAULT_FILES_TO_PARSE_UP_FRONT= "stdarg.h, stddef.h, sys/types.h"; //$NON-NLS-1$
|
||||
|
||||
private static final String QUALIFIER = CCorePlugin.PLUGIN_ID;
|
||||
private static final String INDEXER_NODE = "indexer"; //$NON-NLS-1$
|
||||
private static final String KEY_INDEXER_PREFS_SCOPE = "preferenceScope"; //$NON-NLS-1$
|
||||
private static final String KEY_INDEX_IMPORT_LOCATION = "indexImportLocation"; //$NON-NLS-1$
|
||||
|
||||
public static final int SCOPE_INSTANCE = 0;
|
||||
public static final int SCOPE_PROJECT_PRIVATE = 1;
|
||||
public static final int SCOPE_PROJECT_SHARED = 2;
|
||||
|
||||
/**
|
||||
* Returns the scope that is selected for the project.
|
||||
|
@ -267,6 +271,7 @@ public class IndexerPreferences {
|
|||
prefs.put(KEY_INDEXER_ID, IPDOMManager.ID_FAST_INDEXER);
|
||||
prefs.putBoolean(KEY_INDEX_ALL_FILES, false);
|
||||
prefs.put(KEY_INDEX_IMPORT_LOCATION, DEFAULT_INDEX_IMPORT_LOCATION);
|
||||
prefs.put(KEY_FILES_TO_PARSE_UP_FRONT, DEFAULT_FILES_TO_PARSE_UP_FRONT);
|
||||
}
|
||||
|
||||
public static void addChangeListener(IProject prj, IPreferenceChangeListener pcl) {
|
||||
|
|
|
@ -11,12 +11,15 @@
|
|||
|
||||
package org.eclipse.cdt.internal.core.pdom.indexer;
|
||||
|
||||
import java.net.URI;
|
||||
import java.text.MessageFormat;
|
||||
import java.text.NumberFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.eclipse.cdt.core.CCorePlugin;
|
||||
|
@ -31,29 +34,42 @@ import org.eclipse.cdt.core.index.IndexLocationFactory;
|
|||
import org.eclipse.cdt.core.model.CoreModel;
|
||||
import org.eclipse.cdt.core.model.CoreModelUtil;
|
||||
import org.eclipse.cdt.core.model.ICProject;
|
||||
import org.eclipse.cdt.core.model.ILanguage;
|
||||
import org.eclipse.cdt.core.model.ITranslationUnit;
|
||||
import org.eclipse.cdt.core.model.LanguageManager;
|
||||
import org.eclipse.cdt.core.parser.CodeReader;
|
||||
import org.eclipse.cdt.core.parser.IScannerInfo;
|
||||
import org.eclipse.cdt.core.parser.IScannerInfoProvider;
|
||||
import org.eclipse.cdt.core.parser.ScannerInfo;
|
||||
import org.eclipse.cdt.internal.core.CContentTypes;
|
||||
import org.eclipse.cdt.internal.core.index.IIndexFragmentFile;
|
||||
import org.eclipse.cdt.internal.core.index.IWritableIndex;
|
||||
import org.eclipse.cdt.internal.core.pdom.IndexerProgress;
|
||||
import org.eclipse.cdt.internal.core.pdom.PDOMWriter;
|
||||
import org.eclipse.cdt.internal.core.pdom.db.ChunkCache;
|
||||
import org.eclipse.core.resources.IProject;
|
||||
import org.eclipse.core.resources.IResource;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
import org.eclipse.core.runtime.IPath;
|
||||
import org.eclipse.core.runtime.IProgressMonitor;
|
||||
import org.eclipse.core.runtime.IStatus;
|
||||
import org.eclipse.core.runtime.Path;
|
||||
import org.eclipse.core.runtime.Platform;
|
||||
import org.eclipse.core.runtime.content.IContentType;
|
||||
|
||||
public abstract class PDOMIndexerTask extends PDOMWriter implements IPDOMIndexerTask {
|
||||
private static final Object NO_CONTEXT = new Object();
|
||||
private static final int MAX_ERRORS = 500;
|
||||
private static final String TRUE = "true"; //$NON-NLS-1$
|
||||
|
||||
private IPDOMIndexer fIndexer;
|
||||
private AbstractPDOMIndexer fIndexer;
|
||||
protected Map/*<IIndexFileLocation, Object>*/ fContextMap = new HashMap/*<IIndexFileLocation, Object>*/();
|
||||
private boolean fCheckTimestamps= false;
|
||||
private List fFilesUpFront= new ArrayList();
|
||||
private String fDummyFileName;
|
||||
private URI fDummyFileURI;
|
||||
|
||||
protected PDOMIndexerTask(IPDOMIndexer indexer) {
|
||||
protected PDOMIndexerTask(AbstractPDOMIndexer indexer) {
|
||||
fIndexer= indexer;
|
||||
setShowActivity(checkDebugOption(TRACE_ACTIVITY, TRUE));
|
||||
setShowProblems(checkDebugOption(TRACE_PROBLEMS, TRUE));
|
||||
|
@ -75,6 +91,10 @@ public abstract class PDOMIndexerTask extends PDOMWriter implements IPDOMIndexer
|
|||
fCheckTimestamps= val;
|
||||
}
|
||||
|
||||
final public void setParseUpFront() {
|
||||
fFilesUpFront.addAll(Arrays.asList(fIndexer.getFilesToParseUpFront()));
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks whether a given debug option is enabled. See {@link IPDOMIndexerTask}
|
||||
* for valid values.
|
||||
|
@ -100,8 +120,16 @@ public abstract class PDOMIndexerTask extends PDOMWriter implements IPDOMIndexer
|
|||
* @see #parseTUs(IWritableIndex, int, Collection, Collection, IProgressMonitor)
|
||||
* @since 4.0
|
||||
*/
|
||||
abstract protected IASTTranslationUnit createAST(ITranslationUnit tu, IProgressMonitor pm) throws CoreException, InterruptedException;
|
||||
abstract protected IASTTranslationUnit createAST(ITranslationUnit tu, IProgressMonitor pm) throws CoreException;
|
||||
|
||||
/**
|
||||
* Called to create the ast for pre-parsed files. May return <code>null</code>.
|
||||
* @throws CoreException
|
||||
* @since 4.0
|
||||
*/
|
||||
protected IASTTranslationUnit createAST(ILanguage lang, CodeReader codeReader, IScannerInfo scanInfo, IProgressMonitor pm) throws CoreException {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convenience method for subclasses, parses the files calling out to the methods
|
||||
|
@ -114,6 +142,11 @@ public abstract class PDOMIndexerTask extends PDOMWriter implements IPDOMIndexer
|
|||
* @since 4.0
|
||||
*/
|
||||
protected void parseTUs(IWritableIndex index, int readlockCount, Collection sources, Collection headers, IProgressMonitor monitor) throws CoreException, InterruptedException {
|
||||
for (Iterator iter = fFilesUpFront.iterator(); iter.hasNext();) {
|
||||
String upfront= (String) iter.next();
|
||||
parseUpFront(upfront, index, readlockCount, monitor);
|
||||
}
|
||||
|
||||
// sources first
|
||||
for (Iterator iter = sources.iterator(); iter.hasNext();) {
|
||||
if (monitor.isCanceled())
|
||||
|
@ -211,6 +244,74 @@ public abstract class PDOMIndexerTask extends PDOMWriter implements IPDOMIndexer
|
|||
}
|
||||
}
|
||||
|
||||
private void parseUpFront(String file, IWritableIndex index, int readlockCount, IProgressMonitor pm) throws CoreException, InterruptedException {
|
||||
file= file.trim();
|
||||
if (file.length() == 0) {
|
||||
return;
|
||||
}
|
||||
IPath path= new Path(file);
|
||||
try {
|
||||
if (fShowActivity) {
|
||||
System.out.println("Indexer: parsing " + file + " up front"); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
}
|
||||
pm.subTask(MessageFormat.format(Messages.PDOMIndexerTask_parsingFileTask,
|
||||
new Object[]{path.lastSegment(), path.removeLastSegments(1).toString()}));
|
||||
long start= System.currentTimeMillis();
|
||||
|
||||
IASTTranslationUnit ast= null;
|
||||
final IProject project = getProject().getProject();
|
||||
IContentType ct= CContentTypes.getContentType(project, file);
|
||||
if (ct != null) {
|
||||
ILanguage lang = LanguageManager.getInstance().getLanguage(ct);
|
||||
if (lang != null) {
|
||||
IScannerInfoProvider provider= CCorePlugin.getDefault().getScannerInfoProvider(project);
|
||||
IScannerInfo scanInfo;
|
||||
if (provider != null) {
|
||||
scanInfo= provider.getScannerInformation(project);
|
||||
}
|
||||
else {
|
||||
scanInfo= new ScannerInfo();
|
||||
}
|
||||
String code= "#include \"" + file + "\"\n"; //$NON-NLS-1$ //$NON-NLS-2$
|
||||
if (fDummyFileName == null) {
|
||||
fDummyFileName= project.getLocation().append("___").toString(); //$NON-NLS-1$
|
||||
fDummyFileURI= findLocation(fDummyFileName).getURI();
|
||||
}
|
||||
CodeReader codeReader= new CodeReader(fDummyFileName, code.toCharArray());
|
||||
ast= createAST(lang, codeReader, scanInfo, pm);
|
||||
}
|
||||
}
|
||||
|
||||
fStatistics.fParsingTime += System.currentTimeMillis()-start;
|
||||
if (ast != null) {
|
||||
addSymbols(ast, index, readlockCount, pm);
|
||||
updateInfo(-1, +1, 0);
|
||||
}
|
||||
}
|
||||
catch (CoreException e) {
|
||||
swallowError(path, e);
|
||||
}
|
||||
catch (RuntimeException e) {
|
||||
swallowError(path, e);
|
||||
}
|
||||
catch (Error e) {
|
||||
swallowError(path, e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Overriders must call super.needToUpdate(). If <code>false</code> is returned
|
||||
* this must be passed on to their caller:
|
||||
* <pre>
|
||||
* if (super.needToUpdate()) {
|
||||
* // your code
|
||||
* }
|
||||
* return false;
|
||||
*/
|
||||
protected boolean needToUpdate(IIndexFileLocation fileLoc) throws CoreException {
|
||||
return fDummyFileURI==null || !fDummyFileURI.equals(fileLoc.getURI());
|
||||
}
|
||||
|
||||
private void swallowError(IPath file, Throwable e) throws CoreException {
|
||||
IStatus status= CCorePlugin.createStatus(
|
||||
MessageFormat.format(Messages.PDOMIndexerTask_errorWhileParsing, new Object[]{file}), e);
|
||||
|
|
|
@ -36,17 +36,11 @@ public class PDOMRebuildTask implements IPDOMIndexerTask {
|
|||
|
||||
private final IPDOMIndexer fIndexer;
|
||||
private final IndexerProgress fProgress;
|
||||
private final boolean fCheckTimestamps;
|
||||
private volatile IPDOMIndexerTask fDelegate;
|
||||
|
||||
public PDOMRebuildTask(IPDOMIndexer indexer) {
|
||||
this(indexer, false);
|
||||
}
|
||||
|
||||
public PDOMRebuildTask(IPDOMIndexer indexer, boolean checkTimestamps) {
|
||||
fIndexer= indexer;
|
||||
fProgress= createProgress();
|
||||
fCheckTimestamps= checkTimestamps;
|
||||
}
|
||||
|
||||
private IndexerProgress createProgress() {
|
||||
|
@ -106,7 +100,8 @@ public class PDOMRebuildTask implements IPDOMIndexerTask {
|
|||
ITranslationUnit[] tus= (ITranslationUnit[]) sources.toArray(new ITranslationUnit[sources.size()]);
|
||||
fDelegate= fIndexer.createTask(tus, NO_TUS, NO_TUS);
|
||||
if (fDelegate instanceof PDOMIndexerTask) {
|
||||
((PDOMIndexerTask) fDelegate).setCheckTimestamps(fCheckTimestamps);
|
||||
((PDOMIndexerTask) fDelegate).setCheckTimestamps(true);
|
||||
((PDOMIndexerTask) fDelegate).setParseUpFront();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -42,7 +42,7 @@ import org.eclipse.core.runtime.IProgressMonitor;
|
|||
class PDOMFastIndexerTask extends PDOMIndexerTask {
|
||||
private List fChanged = new ArrayList();
|
||||
private List fRemoved = new ArrayList();
|
||||
private IWritableIndex index;
|
||||
private IWritableIndex fIndex;
|
||||
private IndexBasedCodeReaderFactory fCodeReaderFactory;
|
||||
private Map fIflCache;
|
||||
|
||||
|
@ -59,7 +59,7 @@ class PDOMFastIndexerTask extends PDOMIndexerTask {
|
|||
long start = System.currentTimeMillis();
|
||||
try {
|
||||
setupIndexAndReaderFactory();
|
||||
index.acquireReadLock();
|
||||
fIndex.acquireReadLock();
|
||||
try {
|
||||
registerTUsInReaderFactory(fChanged);
|
||||
|
||||
|
@ -68,7 +68,7 @@ class PDOMFastIndexerTask extends PDOMIndexerTask {
|
|||
if (monitor.isCanceled())
|
||||
return;
|
||||
ITranslationUnit tu = (ITranslationUnit)i.next();
|
||||
removeTU(index, tu, 1);
|
||||
removeTU(fIndex, tu, 1);
|
||||
if (tu.isSourceUnit()) {
|
||||
updateInfo(1, 0, 0);
|
||||
}
|
||||
|
@ -88,26 +88,26 @@ class PDOMFastIndexerTask extends PDOMIndexerTask {
|
|||
}
|
||||
}
|
||||
|
||||
parseTUs(index, 1, sources, headers, monitor);
|
||||
parseTUs(fIndex, 1, sources, headers, monitor);
|
||||
if (monitor.isCanceled()) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
finally {
|
||||
index.releaseReadLock();
|
||||
fIndex.releaseReadLock();
|
||||
}
|
||||
} catch (CoreException e) {
|
||||
CCorePlugin.log(e);
|
||||
} catch (InterruptedException e) {
|
||||
}
|
||||
traceEnd(start, index);
|
||||
traceEnd(start, fIndex);
|
||||
}
|
||||
|
||||
private void setupIndexAndReaderFactory() throws CoreException {
|
||||
this.index= ((IWritableIndexManager) CCorePlugin.getIndexManager()).getWritableIndex(getProject());
|
||||
this.index.resetCacheCounters();
|
||||
this.fIndex= ((IWritableIndexManager) CCorePlugin.getIndexManager()).getWritableIndex(getProject());
|
||||
this.fIndex.resetCacheCounters();
|
||||
this.fIflCache = new HashMap/*<String,IIndexFileLocation>*/();
|
||||
this.fCodeReaderFactory = new IndexBasedCodeReaderFactory(index, fIflCache);
|
||||
this.fCodeReaderFactory = new IndexBasedCodeReaderFactory(fIndex, fIflCache);
|
||||
}
|
||||
|
||||
private void registerTUsInReaderFactory(Collection files) throws CoreException {
|
||||
|
@ -128,8 +128,7 @@ class PDOMFastIndexerTask extends PDOMIndexerTask {
|
|||
return result;
|
||||
}
|
||||
|
||||
protected IASTTranslationUnit createAST(ITranslationUnit tu, IProgressMonitor pm) throws CoreException,
|
||||
InterruptedException {
|
||||
protected IASTTranslationUnit createAST(ITranslationUnit tu, IProgressMonitor pm) throws CoreException {
|
||||
IPath path = tu.getLocation();
|
||||
if (path == null) {
|
||||
return null;
|
||||
|
@ -148,8 +147,12 @@ class PDOMFastIndexerTask extends PDOMIndexerTask {
|
|||
return null;
|
||||
}
|
||||
|
||||
return createAST(language, codeReader, scanner, pm);
|
||||
}
|
||||
|
||||
protected IASTTranslationUnit createAST(ILanguage lang, CodeReader codeReader, IScannerInfo scanInfo, IProgressMonitor pm) throws CoreException {
|
||||
// get the AST in a "Fast" way
|
||||
IASTTranslationUnit ast= language.getASTTranslationUnit(codeReader, scanner, fCodeReaderFactory, index, ParserUtil.getParserLogService());
|
||||
IASTTranslationUnit ast= lang.getASTTranslationUnit(codeReader, scanInfo, fCodeReaderFactory, fIndex, ParserUtil.getParserLogService());
|
||||
if (pm.isCanceled()) {
|
||||
return null;
|
||||
}
|
||||
|
@ -160,9 +163,12 @@ class PDOMFastIndexerTask extends PDOMIndexerTask {
|
|||
}
|
||||
|
||||
protected boolean needToUpdate(IIndexFileLocation location) throws CoreException {
|
||||
// file is requested or is not yet indexed.
|
||||
FileInfo info= fCodeReaderFactory.createFileInfo(location);
|
||||
return info.isRequested() || info.fFile == null;
|
||||
if (super.needToUpdate(location)) {
|
||||
// file is requested or is not yet indexed.
|
||||
FileInfo info= fCodeReaderFactory.createFileInfo(location);
|
||||
return info.isRequested() || info.fFile == null;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
protected boolean postAddToIndex(IIndexFileLocation path, IIndexFile file)
|
||||
|
|
|
@ -25,7 +25,12 @@ import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
|
|||
import org.eclipse.cdt.core.index.IIndexFile;
|
||||
import org.eclipse.cdt.core.index.IIndexFileLocation;
|
||||
import org.eclipse.cdt.core.index.IndexLocationFactory;
|
||||
import org.eclipse.cdt.core.model.ILanguage;
|
||||
import org.eclipse.cdt.core.model.ITranslationUnit;
|
||||
import org.eclipse.cdt.core.parser.CodeReader;
|
||||
import org.eclipse.cdt.core.parser.IScannerInfo;
|
||||
import org.eclipse.cdt.core.parser.ParserUtil;
|
||||
import org.eclipse.cdt.internal.core.dom.SavedCodeReaderFactory;
|
||||
import org.eclipse.cdt.internal.core.index.IWritableIndex;
|
||||
import org.eclipse.cdt.internal.core.index.IWritableIndexManager;
|
||||
import org.eclipse.cdt.internal.core.pdom.indexer.PDOMIndexerTask;
|
||||
|
@ -127,8 +132,7 @@ class PDOMFullIndexerTask extends PDOMIndexerTask {
|
|||
return result;
|
||||
}
|
||||
|
||||
protected IASTTranslationUnit createAST(ITranslationUnit tu, IProgressMonitor pm) throws CoreException,
|
||||
InterruptedException {
|
||||
protected IASTTranslationUnit createAST(ITranslationUnit tu, IProgressMonitor pm) throws CoreException {
|
||||
IPath path = tu.getLocation();
|
||||
if (path == null) {
|
||||
return null;
|
||||
|
@ -140,13 +144,25 @@ class PDOMFullIndexerTask extends PDOMIndexerTask {
|
|||
return tu.getAST(null, options);
|
||||
}
|
||||
|
||||
protected boolean needToUpdate(IIndexFileLocation location) throws CoreException {
|
||||
Object required= filePathsToParse.get(location);
|
||||
if (required == null) {
|
||||
required= MISSING;
|
||||
filePathsToParse.put(location, required);
|
||||
protected IASTTranslationUnit createAST(ILanguage lang, CodeReader codeReader, IScannerInfo scanInfo, IProgressMonitor pm) throws CoreException {
|
||||
SavedCodeReaderFactory codeReaderFactory= SavedCodeReaderFactory.getInstance();
|
||||
IASTTranslationUnit ast= lang.getASTTranslationUnit(codeReader, scanInfo, codeReaderFactory, null, ParserUtil.getParserLogService());
|
||||
if (pm.isCanceled()) {
|
||||
return null;
|
||||
}
|
||||
return required != SKIP;
|
||||
return ast;
|
||||
}
|
||||
|
||||
protected boolean needToUpdate(IIndexFileLocation location) throws CoreException {
|
||||
if (super.needToUpdate(location)) {
|
||||
Object required= filePathsToParse.get(location);
|
||||
if (required == null) {
|
||||
required= MISSING;
|
||||
filePathsToParse.put(location, required);
|
||||
}
|
||||
return required != SKIP;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
protected boolean postAddToIndex(IIndexFileLocation location, IIndexFile file)
|
||||
|
|
|
@ -15,6 +15,15 @@ import java.util.Properties;
|
|||
|
||||
import org.eclipse.core.resources.IProject;
|
||||
import org.eclipse.core.runtime.IProgressMonitor;
|
||||
import org.eclipse.swt.SWT;
|
||||
import org.eclipse.swt.widgets.Button;
|
||||
import org.eclipse.swt.widgets.Composite;
|
||||
import org.eclipse.swt.widgets.Label;
|
||||
import org.eclipse.swt.widgets.Text;
|
||||
|
||||
import org.eclipse.cdt.utils.ui.controls.ControlFactory;
|
||||
|
||||
import org.eclipse.cdt.internal.core.pdom.indexer.IndexerPreferences;
|
||||
|
||||
|
||||
/**
|
||||
|
@ -24,6 +33,9 @@ public abstract class AbstractIndexerPage extends AbstractCOptionPage {
|
|||
protected static final String INDEX_ALL_FILES = DialogsMessages.AbstractIndexerPage_indexAllFiles;
|
||||
protected static final String TRUE = String.valueOf(true);
|
||||
|
||||
private Button fAllFiles;
|
||||
private Text fFilesToParseUpFront;
|
||||
|
||||
protected AbstractIndexerPage() {
|
||||
super();
|
||||
}
|
||||
|
@ -36,18 +48,43 @@ public abstract class AbstractIndexerPage extends AbstractCOptionPage {
|
|||
return null;
|
||||
}
|
||||
|
||||
public void createControl(Composite parent) {
|
||||
Composite page = ControlFactory.createComposite(parent, 1);
|
||||
fAllFiles= createAllFilesButton(page);
|
||||
fFilesToParseUpFront= createParseUpFrontTextField(page);
|
||||
setControl(page);
|
||||
}
|
||||
|
||||
/**
|
||||
* Use the properties to initialize the controls of the page. Fill in defaults
|
||||
* for properties that are missing.
|
||||
* @since 4.0
|
||||
*/
|
||||
abstract public void setProperties(Properties properties);
|
||||
public void setProperties(Properties properties) {
|
||||
if (fAllFiles != null) {
|
||||
boolean indexAllFiles= TRUE.equals(properties.get(IndexerPreferences.KEY_INDEX_ALL_FILES));
|
||||
fAllFiles.setSelection(indexAllFiles);
|
||||
}
|
||||
if (fFilesToParseUpFront != null) {
|
||||
String files = getNotNull(properties, IndexerPreferences.KEY_FILES_TO_PARSE_UP_FRONT);
|
||||
fFilesToParseUpFront.setText(files);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the properties according to the selections on the page.
|
||||
* @since 4.0
|
||||
*/
|
||||
abstract public Properties getProperties();
|
||||
public Properties getProperties(){
|
||||
Properties props= new Properties();
|
||||
if (fAllFiles != null) {
|
||||
props.put(IndexerPreferences.KEY_INDEX_ALL_FILES, String.valueOf(fAllFiles.getSelection()));
|
||||
}
|
||||
if (fFilesToParseUpFront != null) {
|
||||
props.put(IndexerPreferences.KEY_FILES_TO_PARSE_UP_FRONT, fFilesToParseUpFront.getText());
|
||||
}
|
||||
return props;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@link #getProperties()} will be called instead.
|
||||
|
@ -64,11 +101,26 @@ public abstract class AbstractIndexerPage extends AbstractCOptionPage {
|
|||
}
|
||||
|
||||
/**
|
||||
* The framework disables and enables controls created by this page.
|
||||
* After controls are enabled {@link #updateEnablement()} is called to
|
||||
* allow for disabeling controls.
|
||||
* @since 4.0
|
||||
* @deprecated, never called.
|
||||
*/
|
||||
public void updateEnablement() {
|
||||
}
|
||||
|
||||
private String getNotNull(Properties properties, String key) {
|
||||
String files= (String) properties.get(key);
|
||||
if (files == null) {
|
||||
files= ""; //$NON-NLS-1$
|
||||
}
|
||||
return files;
|
||||
}
|
||||
|
||||
private Text createParseUpFrontTextField(Composite page) {
|
||||
new Label(page, SWT.NONE);
|
||||
ControlFactory.createLabel(page, DialogsMessages.AbstractIndexerPage_indexUpFront);
|
||||
return ControlFactory.createTextField(page);
|
||||
}
|
||||
|
||||
private Button createAllFilesButton(Composite page) {
|
||||
return ControlFactory.createCheckBox(page, INDEX_ALL_FILES);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -12,35 +12,7 @@
|
|||
|
||||
package org.eclipse.cdt.ui.dialogs;
|
||||
|
||||
import java.util.Properties;
|
||||
|
||||
import org.eclipse.swt.widgets.Button;
|
||||
import org.eclipse.swt.widgets.Composite;
|
||||
|
||||
import org.eclipse.cdt.utils.ui.controls.ControlFactory;
|
||||
|
||||
import org.eclipse.cdt.internal.core.pdom.indexer.IndexerPreferences;
|
||||
|
||||
|
||||
public class DOMSourceIndexerBlock extends AbstractIndexerPage {
|
||||
private Button fAllFiles;
|
||||
|
||||
|
||||
public void createControl(Composite parent) {
|
||||
Composite page = ControlFactory.createComposite(parent, 1);
|
||||
fAllFiles= ControlFactory.createCheckBox(page, INDEX_ALL_FILES);
|
||||
setControl(page);
|
||||
|
||||
}
|
||||
|
||||
public Properties getProperties() {
|
||||
Properties props= new Properties();
|
||||
props.put(IndexerPreferences.KEY_INDEX_ALL_FILES, String.valueOf(fAllFiles.getSelection()));
|
||||
return props;
|
||||
}
|
||||
|
||||
public void setProperties(Properties properties) {
|
||||
boolean indexAllFiles= TRUE.equals(properties.get(IndexerPreferences.KEY_INDEX_ALL_FILES));
|
||||
fAllFiles.setSelection(indexAllFiles);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,6 +16,7 @@ import org.eclipse.osgi.util.NLS;
|
|||
public class DialogsMessages extends NLS {
|
||||
private static final String BUNDLE_NAME = "org.eclipse.cdt.ui.dialogs.DialogsMessages"; //$NON-NLS-1$
|
||||
public static String AbstractIndexerPage_indexAllFiles;
|
||||
public static String AbstractIndexerPage_indexUpFront;
|
||||
public static String PreferenceScopeBlock_enableProjectSettings;
|
||||
public static String PreferenceScopeBlock_preferenceLink;
|
||||
public static String PreferenceScopeBlock_storeWithProject;
|
||||
|
|
|
@ -12,3 +12,4 @@ PreferenceScopeBlock_enableProjectSettings=Enable project specific settings
|
|||
PreferenceScopeBlock_storeWithProject=Store settings with project
|
||||
PreferenceScopeBlock_preferenceLink=<a>Configure Workspace Settings...</a>
|
||||
AbstractIndexerPage_indexAllFiles=Index all files (files neither built nor included, also)
|
||||
AbstractIndexerPage_indexUpFront=Files to index up-front:
|
||||
|
|
|
@ -11,32 +11,6 @@
|
|||
|
||||
package org.eclipse.cdt.ui.dialogs;
|
||||
|
||||
import java.util.Properties;
|
||||
|
||||
import org.eclipse.swt.widgets.Button;
|
||||
import org.eclipse.swt.widgets.Composite;
|
||||
|
||||
import org.eclipse.cdt.utils.ui.controls.ControlFactory;
|
||||
|
||||
import org.eclipse.cdt.internal.core.pdom.indexer.IndexerPreferences;
|
||||
|
||||
public class FastIndexerBlock extends AbstractIndexerPage {
|
||||
private Button fAllFiles;
|
||||
|
||||
public void createControl(Composite parent) {
|
||||
Composite page = ControlFactory.createComposite(parent, 1);
|
||||
fAllFiles= ControlFactory.createCheckBox(page, INDEX_ALL_FILES);
|
||||
setControl(page);
|
||||
}
|
||||
|
||||
public Properties getProperties() {
|
||||
Properties props= new Properties();
|
||||
props.put(IndexerPreferences.KEY_INDEX_ALL_FILES, String.valueOf(fAllFiles.getSelection()));
|
||||
return props;
|
||||
}
|
||||
|
||||
public void setProperties(Properties properties) {
|
||||
boolean indexAllFiles= TRUE.equals(properties.get(IndexerPreferences.KEY_INDEX_ALL_FILES));
|
||||
fAllFiles.setSelection(indexAllFiles);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue