mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-08-01 13:25:45 +02:00
Fix for 178088, options to skip references during indexing.
This commit is contained in:
parent
8067e74e3f
commit
ad8800e447
13 changed files with 277 additions and 97 deletions
|
@ -1,5 +1,5 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2006 Wind River Systems, Inc. and others.
|
* Copyright (c) 2006, 2007 Wind River Systems, Inc. and others.
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
|
@ -13,6 +13,10 @@ package org.eclipse.cdt.core.model;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.dom.ICodeReaderFactory;
|
import org.eclipse.cdt.core.dom.ICodeReaderFactory;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
|
import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
|
||||||
|
import org.eclipse.cdt.core.index.IIndex;
|
||||||
|
import org.eclipse.cdt.core.parser.CodeReader;
|
||||||
|
import org.eclipse.cdt.core.parser.IParserLogService;
|
||||||
|
import org.eclipse.cdt.core.parser.IScannerInfo;
|
||||||
import org.eclipse.core.runtime.CoreException;
|
import org.eclipse.core.runtime.CoreException;
|
||||||
import org.eclipse.core.runtime.PlatformObject;
|
import org.eclipse.core.runtime.PlatformObject;
|
||||||
|
|
||||||
|
@ -21,13 +25,44 @@ import org.eclipse.core.runtime.PlatformObject;
|
||||||
* @since 4.0
|
* @since 4.0
|
||||||
*/
|
*/
|
||||||
public abstract class AbstractLanguage extends PlatformObject implements ILanguage {
|
public abstract class AbstractLanguage extends PlatformObject implements ILanguage {
|
||||||
|
/**
|
||||||
|
* Option for {@link #getASTTranslationUnit(CodeReader, IScannerInfo, ICodeReaderFactory, IIndex, int, IParserLogService)}
|
||||||
|
* Instructs the parser to skip function and method bodies.
|
||||||
|
*/
|
||||||
|
public final static int OPTION_SKIP_FUNCTION_BODIES= 1;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @deprecated, throws an UnsupportedOperationException
|
||||||
|
*/
|
||||||
final public IASTTranslationUnit getASTTranslationUnit(ITranslationUnit file, int style) throws CoreException {
|
final public IASTTranslationUnit getASTTranslationUnit(ITranslationUnit file, int style) throws CoreException {
|
||||||
throw new UnsupportedOperationException();
|
throw new UnsupportedOperationException();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @deprecated, throws an UnsupportedOperationException
|
||||||
|
*/
|
||||||
final public IASTTranslationUnit getASTTranslationUnit(ITranslationUnit file, ICodeReaderFactory codeReaderFactory,
|
final public IASTTranslationUnit getASTTranslationUnit(ITranslationUnit file, ICodeReaderFactory codeReaderFactory,
|
||||||
int style) throws CoreException {
|
int style) throws CoreException {
|
||||||
throw new UnsupportedOperationException();
|
throw new UnsupportedOperationException();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Construct an AST for the source code provided by <code>reader</code>.
|
||||||
|
* As an option you can supply
|
||||||
|
* @param reader source code to be parsed.
|
||||||
|
* @param scanInfo provides include paths and defined symbols.
|
||||||
|
* @param fileCreator factory that provides CodeReaders for files included
|
||||||
|
* by the source code being parsed.
|
||||||
|
* @param index (optional) index to use to provide support for ambiguity
|
||||||
|
* resolution.
|
||||||
|
* @param options {@link #OPTION_SKIP_FUNCTION_BODIES} or <code>0</code>.
|
||||||
|
* @param log logger
|
||||||
|
* @return an AST for the source code provided by reader.
|
||||||
|
* @throws CoreException
|
||||||
|
*/
|
||||||
|
public IASTTranslationUnit getASTTranslationUnit(CodeReader reader, IScannerInfo scanInfo, ICodeReaderFactory fileCreator, IIndex index, int options, IParserLogService log)
|
||||||
|
throws CoreException {
|
||||||
|
// for backwards compatibility
|
||||||
|
return getASTTranslationUnit(reader, scanInfo, fileCreator, index, log);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,6 +7,7 @@
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* Anton Leherbauer (Wind River Systems) - initial API and implementation
|
* Anton Leherbauer (Wind River Systems) - initial API and implementation
|
||||||
|
* Markus Schorn (Wind River Systems)
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.core.dom.parser.c;
|
package org.eclipse.cdt.core.dom.parser.c;
|
||||||
|
|
||||||
|
@ -88,10 +89,15 @@ public abstract class AbstractCLanguage extends AbstractLanguage implements ICLa
|
||||||
}
|
}
|
||||||
|
|
||||||
public IASTTranslationUnit getASTTranslationUnit(CodeReader reader, IScannerInfo scanInfo,
|
public IASTTranslationUnit getASTTranslationUnit(CodeReader reader, IScannerInfo scanInfo,
|
||||||
ICodeReaderFactory codeReaderFactory, IIndex index, IParserLogService log) throws CoreException {
|
ICodeReaderFactory fileCreator, IIndex index, IParserLogService log) throws CoreException {
|
||||||
|
return getASTTranslationUnit(reader, scanInfo, fileCreator, index, 0, log);
|
||||||
|
}
|
||||||
|
|
||||||
|
public IASTTranslationUnit getASTTranslationUnit(CodeReader reader, IScannerInfo scanInfo,
|
||||||
|
ICodeReaderFactory codeReaderFactory, IIndex index, int options, IParserLogService log) throws CoreException {
|
||||||
|
|
||||||
IScanner scanner= createScanner(reader, scanInfo, codeReaderFactory, log);
|
IScanner scanner= createScanner(reader, scanInfo, codeReaderFactory, log);
|
||||||
ISourceCodeParser parser= createParser(scanner, log, index, false);
|
ISourceCodeParser parser= createParser(scanner, log, index, false, options);
|
||||||
|
|
||||||
// Parse
|
// Parse
|
||||||
IASTTranslationUnit ast= parser.parse();
|
IASTTranslationUnit ast= parser.parse();
|
||||||
|
@ -104,7 +110,7 @@ public abstract class AbstractCLanguage extends AbstractLanguage implements ICLa
|
||||||
IScanner scanner= createScanner(reader, scanInfo, fileCreator, log);
|
IScanner scanner= createScanner(reader, scanInfo, fileCreator, log);
|
||||||
scanner.setContentAssistMode(offset);
|
scanner.setContentAssistMode(offset);
|
||||||
|
|
||||||
ISourceCodeParser parser= createParser(scanner, log, index, true);
|
ISourceCodeParser parser= createParser(scanner, log, index, true, 0);
|
||||||
|
|
||||||
// Run the parse and return the completion node
|
// Run the parse and return the completion node
|
||||||
parser.parse();
|
parser.parse();
|
||||||
|
@ -153,10 +159,20 @@ public abstract class AbstractCLanguage extends AbstractLanguage implements ICLa
|
||||||
* @param log the parser log service
|
* @param log the parser log service
|
||||||
* @param index the index to help resolve bindings
|
* @param index the index to help resolve bindings
|
||||||
* @param forCompletion whether the parser is used for code completion
|
* @param forCompletion whether the parser is used for code completion
|
||||||
|
* @param options for valid options see {@link AbstractLanguage#getASTTranslationUnit(CodeReader, IScannerInfo, ICodeReaderFactory, IIndex, int, IParserLogService)}
|
||||||
* @return an instance of ISourceCodeParser
|
* @return an instance of ISourceCodeParser
|
||||||
*/
|
*/
|
||||||
protected ISourceCodeParser createParser(IScanner scanner, IParserLogService log, IIndex index, boolean forCompletion) {
|
protected ISourceCodeParser createParser(IScanner scanner, IParserLogService log, IIndex index, boolean forCompletion, int options) {
|
||||||
ParserMode mode= forCompletion ? ParserMode.COMPLETION_PARSE : ParserMode.COMPLETE_PARSE;
|
ParserMode mode= null;
|
||||||
|
if (forCompletion) {
|
||||||
|
mode= ParserMode.COMPLETION_PARSE;
|
||||||
|
}
|
||||||
|
else if ((options & OPTION_SKIP_FUNCTION_BODIES) != 0) {
|
||||||
|
mode= ParserMode.STRUCTURAL_PARSE;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
mode= ParserMode.COMPLETE_PARSE;
|
||||||
|
}
|
||||||
return new GNUCSourceParser(scanner, mode, log, getParserExtensionConfiguration(), index);
|
return new GNUCSourceParser(scanner, mode, log, getParserExtensionConfiguration(), index);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -7,6 +7,7 @@
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* Anton Leherbauer (Wind River Systems) - initial API and implementation
|
* Anton Leherbauer (Wind River Systems) - initial API and implementation
|
||||||
|
* Markus Schorn (Wind River Systems)
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.core.dom.parser.cpp;
|
package org.eclipse.cdt.core.dom.parser.cpp;
|
||||||
|
|
||||||
|
@ -87,10 +88,15 @@ public abstract class AbstractCPPLanguage extends AbstractLanguage implements IC
|
||||||
}
|
}
|
||||||
|
|
||||||
public IASTTranslationUnit getASTTranslationUnit(CodeReader reader, IScannerInfo scanInfo,
|
public IASTTranslationUnit getASTTranslationUnit(CodeReader reader, IScannerInfo scanInfo,
|
||||||
ICodeReaderFactory codeReaderFactory, IIndex index, IParserLogService log) throws CoreException {
|
ICodeReaderFactory codeReaderFactory, IIndex index,IParserLogService log) throws CoreException {
|
||||||
|
return getASTTranslationUnit(reader, scanInfo, codeReaderFactory, index, 0, log);
|
||||||
|
}
|
||||||
|
|
||||||
|
public IASTTranslationUnit getASTTranslationUnit(CodeReader reader, IScannerInfo scanInfo,
|
||||||
|
ICodeReaderFactory codeReaderFactory, IIndex index, int options, IParserLogService log) throws CoreException {
|
||||||
|
|
||||||
IScanner scanner= createScanner(reader, scanInfo, codeReaderFactory, log);
|
IScanner scanner= createScanner(reader, scanInfo, codeReaderFactory, log);
|
||||||
ISourceCodeParser parser= createParser(scanner, log, index, false);
|
ISourceCodeParser parser= createParser(scanner, log, index, false, options);
|
||||||
|
|
||||||
// Parse
|
// Parse
|
||||||
IASTTranslationUnit ast= parser.parse();
|
IASTTranslationUnit ast= parser.parse();
|
||||||
|
@ -102,7 +108,7 @@ public abstract class AbstractCPPLanguage extends AbstractLanguage implements IC
|
||||||
IScanner scanner= createScanner(reader, scanInfo, fileCreator, log);
|
IScanner scanner= createScanner(reader, scanInfo, fileCreator, log);
|
||||||
scanner.setContentAssistMode(offset);
|
scanner.setContentAssistMode(offset);
|
||||||
|
|
||||||
ISourceCodeParser parser= createParser(scanner, log, index, true);
|
ISourceCodeParser parser= createParser(scanner, log, index, true, 0);
|
||||||
|
|
||||||
// Run the parse and return the completion node
|
// Run the parse and return the completion node
|
||||||
parser.parse();
|
parser.parse();
|
||||||
|
@ -150,10 +156,20 @@ public abstract class AbstractCPPLanguage extends AbstractLanguage implements IC
|
||||||
* @param log the parser log service
|
* @param log the parser log service
|
||||||
* @param index the index to help resolve bindings
|
* @param index the index to help resolve bindings
|
||||||
* @param forCompletion whether the parser is used for code completion
|
* @param forCompletion whether the parser is used for code completion
|
||||||
|
* @param options for valid options see {@link AbstractLanguage#getASTTranslationUnit(CodeReader, IScannerInfo, ICodeReaderFactory, IIndex, int, IParserLogService)}
|
||||||
* @return an instance of ISourceCodeParser
|
* @return an instance of ISourceCodeParser
|
||||||
*/
|
*/
|
||||||
protected ISourceCodeParser createParser(IScanner scanner, IParserLogService log, IIndex index, boolean forCompletion) {
|
protected ISourceCodeParser createParser(IScanner scanner, IParserLogService log, IIndex index, boolean forCompletion, int options) {
|
||||||
ParserMode mode= forCompletion ? ParserMode.COMPLETION_PARSE : ParserMode.COMPLETE_PARSE;
|
ParserMode mode= null;
|
||||||
|
if (forCompletion) {
|
||||||
|
mode= ParserMode.COMPLETION_PARSE;
|
||||||
|
}
|
||||||
|
else if ((options & OPTION_SKIP_FUNCTION_BODIES) != 0) {
|
||||||
|
mode= ParserMode.STRUCTURAL_PARSE;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
mode= ParserMode.COMPLETE_PARSE;
|
||||||
|
}
|
||||||
return new GNUCPPSourceParser(scanner, mode, log, getParserExtensionConfiguration(), index);
|
return new GNUCPPSourceParser(scanner, mode, log, getParserExtensionConfiguration(), index);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -17,13 +17,22 @@ import java.util.LinkedHashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IASTDeclSpecifier;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTFileLocation;
|
import org.eclipse.cdt.core.dom.ast.IASTFileLocation;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTName;
|
import org.eclipse.cdt.core.dom.ast.IASTName;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IASTNode;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTPreprocessorIncludeStatement;
|
import org.eclipse.cdt.core.dom.ast.IASTPreprocessorIncludeStatement;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTPreprocessorMacroDefinition;
|
import org.eclipse.cdt.core.dom.ast.IASTPreprocessorMacroDefinition;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
|
import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
|
||||||
import org.eclipse.cdt.core.dom.ast.IBinding;
|
import org.eclipse.cdt.core.dom.ast.IBinding;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.ICompositeType;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IEnumeration;
|
||||||
import org.eclipse.cdt.core.dom.ast.IProblemBinding;
|
import org.eclipse.cdt.core.dom.ast.IProblemBinding;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.ITypedef;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassTemplate;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPNamespace;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPNamespaceAlias;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCompositeTypeSpecifier.ICPPASTBaseSpecifier;
|
||||||
import org.eclipse.cdt.core.index.IIndexFile;
|
import org.eclipse.cdt.core.index.IIndexFile;
|
||||||
import org.eclipse.cdt.core.index.IIndexFileLocation;
|
import org.eclipse.cdt.core.index.IIndexFileLocation;
|
||||||
import org.eclipse.cdt.internal.core.index.IIndexFragmentFile;
|
import org.eclipse.cdt.internal.core.index.IIndexFragmentFile;
|
||||||
|
@ -40,12 +49,17 @@ import org.eclipse.core.runtime.IProgressMonitor;
|
||||||
* @since 4.0
|
* @since 4.0
|
||||||
*/
|
*/
|
||||||
abstract public class PDOMWriter {
|
abstract public class PDOMWriter {
|
||||||
|
public static int SKIP_ALL_REFERENCES= -1;
|
||||||
|
public static int SKIP_TYPE_REFERENCES= 1;
|
||||||
|
public static int SKIP_NO_REFERENCES= 0;
|
||||||
|
|
||||||
protected boolean fShowActivity;
|
protected boolean fShowActivity;
|
||||||
protected boolean fShowProblems;
|
protected boolean fShowProblems;
|
||||||
protected IndexerStatistics fStatistics;
|
protected IndexerStatistics fStatistics;
|
||||||
|
|
||||||
private IndexerProgress fInfo= new IndexerProgress();
|
private IndexerProgress fInfo= new IndexerProgress();
|
||||||
|
private int fSkipReferences= SKIP_NO_REFERENCES;
|
||||||
|
|
||||||
public PDOMWriter() {
|
public PDOMWriter() {
|
||||||
fStatistics= new IndexerStatistics();
|
fStatistics= new IndexerStatistics();
|
||||||
}
|
}
|
||||||
|
@ -58,6 +72,14 @@ abstract public class PDOMWriter {
|
||||||
fShowProblems= val;
|
fShowProblems= val;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Determines whether references are skipped or not. Provide one of
|
||||||
|
* {@link #SKIP_ALL_REFERENCES}, {@link #SKIP_TYPE_REFERENCES} or {@link #SKIP_NO_REFERENCES}.
|
||||||
|
*/
|
||||||
|
public void setSkipReferences(int options) {
|
||||||
|
fSkipReferences= options;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called to check whether a translation unit still needs to be updated.
|
* Called to check whether a translation unit still needs to be updated.
|
||||||
* @see #addSymbols(IASTTranslationUnit, IWritableIndex, int, IProgressMonitor)
|
* @see #addSymbols(IASTTranslationUnit, IWritableIndex, int, IProgressMonitor)
|
||||||
|
@ -103,14 +125,23 @@ abstract public class PDOMWriter {
|
||||||
long start= System.currentTimeMillis();
|
long start= System.currentTimeMillis();
|
||||||
ArrayList names= arrayLists[2];
|
ArrayList names= arrayLists[2];
|
||||||
for (int j=0; j<names.size(); j++) {
|
for (int j=0; j<names.size(); j++) {
|
||||||
final IASTName name = ((IASTName[]) names.get(j))[0];
|
final IASTName[] na= (IASTName[]) names.get(j);
|
||||||
|
final IASTName name = na[0];
|
||||||
final IBinding binding= name.resolveBinding();
|
final IBinding binding= name.resolveBinding();
|
||||||
if (binding instanceof IProblemBinding)
|
if (binding instanceof IProblemBinding)
|
||||||
reportProblem((IProblemBinding) binding);
|
reportProblem((IProblemBinding) binding);
|
||||||
else if (name.isReference())
|
else if (name.isReference()) {
|
||||||
|
if (fSkipReferences == SKIP_TYPE_REFERENCES) {
|
||||||
|
if (isTypeReferenceBinding(binding) && !isInheritanceSpec(name)) {
|
||||||
|
na[0]= null;
|
||||||
|
fStatistics.fReferenceCount--;
|
||||||
|
}
|
||||||
|
}
|
||||||
fStatistics.fReferenceCount++;
|
fStatistics.fReferenceCount++;
|
||||||
else
|
}
|
||||||
|
else {
|
||||||
fStatistics.fDeclarationCount++;
|
fStatistics.fDeclarationCount++;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
fStatistics.fResolutionTime += System.currentTimeMillis()-start;
|
fStatistics.fResolutionTime += System.currentTimeMillis()-start;
|
||||||
}
|
}
|
||||||
|
@ -127,7 +158,7 @@ abstract public class PDOMWriter {
|
||||||
IIndexFileLocation path = orderedPaths[i];
|
IIndexFileLocation path = orderedPaths[i];
|
||||||
if (path != null) {
|
if (path != null) {
|
||||||
if (fShowActivity) {
|
if (fShowActivity) {
|
||||||
System.out.println("Indexer: adding " + path.getURI()); //$NON-NLS-1$
|
System.out.println("Indexer: adding " + path.getURI()); //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
IIndexFile file= addToIndex(index, path, symbolMap);
|
IIndexFile file= addToIndex(index, path, symbolMap);
|
||||||
boolean wasRequested= postAddToIndex(path, file);
|
boolean wasRequested= postAddToIndex(path, file);
|
||||||
|
@ -210,10 +241,17 @@ abstract public class PDOMWriter {
|
||||||
// names
|
// names
|
||||||
ast.accept(new IndexerASTVisitor() {
|
ast.accept(new IndexerASTVisitor() {
|
||||||
public void visit(IASTName name, IASTName caller) {
|
public void visit(IASTName name, IASTName caller) {
|
||||||
|
if (fSkipReferences == SKIP_ALL_REFERENCES) {
|
||||||
|
if (name.isReference()) {
|
||||||
|
if (!isInheritanceSpec(name)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// assign a location to anonymous types.
|
// assign a location to anonymous types.
|
||||||
name= PDOMASTAdapter.getAdapterIfAnonymous(name);
|
name= PDOMASTAdapter.getAdapterIfAnonymous(name);
|
||||||
IASTFileLocation nameLoc = name.getFileLocation();
|
IASTFileLocation nameLoc = name.getFileLocation();
|
||||||
|
|
||||||
if (nameLoc != null) {
|
if (nameLoc != null) {
|
||||||
IIndexFileLocation location = findLocation(nameLoc.getFileName());
|
IIndexFileLocation location = findLocation(nameLoc.getFileName());
|
||||||
addToMap(symbolMap, 2, location, new IASTName[]{name, caller});
|
addToMap(symbolMap, 2, location, new IASTName[]{name, caller});
|
||||||
|
@ -223,6 +261,31 @@ abstract public class PDOMWriter {
|
||||||
return (IIndexFileLocation[]) orderedIncludes.toArray(new IIndexFileLocation[orderedIncludes.size()]);
|
return (IIndexFileLocation[]) orderedIncludes.toArray(new IIndexFileLocation[orderedIncludes.size()]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected boolean isInheritanceSpec(IASTName name) {
|
||||||
|
IASTNode parentNode= name.getParent();
|
||||||
|
if (parentNode instanceof ICPPASTBaseSpecifier) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else if (parentNode instanceof IASTDeclSpecifier) {
|
||||||
|
IASTDeclSpecifier ds= (IASTDeclSpecifier) parentNode;
|
||||||
|
return ds.getStorageClass() == IASTDeclSpecifier.sc_typedef;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean isTypeReferenceBinding(IBinding binding) {
|
||||||
|
if (binding instanceof ICompositeType ||
|
||||||
|
binding instanceof IEnumeration ||
|
||||||
|
binding instanceof ITypedef ||
|
||||||
|
binding instanceof ICPPNamespace ||
|
||||||
|
binding instanceof ICPPNamespaceAlias ||
|
||||||
|
binding instanceof ICPPClassTemplate) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
private void reportProblem(IProblemBinding problem) {
|
private void reportProblem(IProblemBinding problem) {
|
||||||
fStatistics.fProblemBindingCount++;
|
fStatistics.fProblemBindingCount++;
|
||||||
if (fShowProblems) {
|
if (fShowProblems) {
|
||||||
|
@ -234,7 +297,6 @@ abstract public class PDOMWriter {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private void addToMap(Map map, int idx, IIndexFileLocation location, Object thing) {
|
private void addToMap(Map map, int idx, IIndexFileLocation location, Object thing) {
|
||||||
List[] lists= (List[]) map.get(location);
|
List[] lists= (List[]) map.get(location);
|
||||||
if (lists != null)
|
if (lists != null)
|
||||||
|
|
|
@ -193,17 +193,19 @@ public class PDOMFile implements IIndexFragmentFile {
|
||||||
PDOMName lastName= null;
|
PDOMName lastName= null;
|
||||||
for (int i = 0; i < names.length; i++) {
|
for (int i = 0; i < names.length; i++) {
|
||||||
IASTName[] name = names[i];
|
IASTName[] name = names[i];
|
||||||
PDOMName caller= (PDOMName) nameCache.get(name[1]);
|
if (name[0] != null) {
|
||||||
PDOMName pdomName = createPDOMName(name[0], caller);
|
PDOMName caller= (PDOMName) nameCache.get(name[1]);
|
||||||
if (pdomName != null) {
|
PDOMName pdomName = createPDOMName(name[0], caller);
|
||||||
nameCache.put(name[0], pdomName);
|
if (pdomName != null) {
|
||||||
if (lastName == null) {
|
nameCache.put(name[0], pdomName);
|
||||||
setFirstName(pdomName);
|
if (lastName == null) {
|
||||||
|
setFirstName(pdomName);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
lastName.setNextInFile(pdomName);
|
||||||
|
}
|
||||||
|
lastName= pdomName;
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
lastName.setNextInFile(pdomName);
|
|
||||||
}
|
|
||||||
lastName= pdomName;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,6 +26,8 @@ public abstract class AbstractPDOMIndexer implements IPDOMIndexer {
|
||||||
public AbstractPDOMIndexer() {
|
public AbstractPDOMIndexer() {
|
||||||
fProperties.put(IndexerPreferences.KEY_INDEX_ALL_FILES, String.valueOf(false));
|
fProperties.put(IndexerPreferences.KEY_INDEX_ALL_FILES, String.valueOf(false));
|
||||||
fProperties.put(IndexerPreferences.KEY_FILES_TO_PARSE_UP_FRONT, ""); //$NON-NLS-1$
|
fProperties.put(IndexerPreferences.KEY_FILES_TO_PARSE_UP_FRONT, ""); //$NON-NLS-1$
|
||||||
|
fProperties.put(IndexerPreferences.KEY_SKIP_ALL_REFERENCES, String.valueOf(false));
|
||||||
|
fProperties.put(IndexerPreferences.KEY_SKIP_TYPE_REFERENCES, String.valueOf(false));
|
||||||
}
|
}
|
||||||
|
|
||||||
public ICProject getProject() {
|
public ICProject getProject() {
|
||||||
|
|
|
@ -43,6 +43,8 @@ public class IndexerPreferences {
|
||||||
public static final String KEY_INDEXER_ID= "indexerId"; //$NON-NLS-1$
|
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_INDEX_ALL_FILES= "indexAllFiles"; //$NON-NLS-1$
|
||||||
public static final String KEY_FILES_TO_PARSE_UP_FRONT= "filesToParseUpFront"; //$NON-NLS-1$
|
public static final String KEY_FILES_TO_PARSE_UP_FRONT= "filesToParseUpFront"; //$NON-NLS-1$
|
||||||
|
public static final String KEY_SKIP_ALL_REFERENCES= "skipReferences"; //$NON-NLS-1$
|
||||||
|
public static final String KEY_SKIP_TYPE_REFERENCES= "skipTypeReferences"; //$NON-NLS-1$
|
||||||
|
|
||||||
private static final String DEFAULT_INDEX_IMPORT_LOCATION = ".settings/cdt-index.zip"; //$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 DEFAULT_FILES_TO_PARSE_UP_FRONT= "stdarg.h, stddef.h, sys/types.h"; //$NON-NLS-1$
|
||||||
|
@ -270,6 +272,8 @@ public class IndexerPreferences {
|
||||||
Preferences prefs= defaultPreferences.node(INDEXER_NODE);
|
Preferences prefs= defaultPreferences.node(INDEXER_NODE);
|
||||||
prefs.put(KEY_INDEXER_ID, IPDOMManager.ID_FAST_INDEXER);
|
prefs.put(KEY_INDEXER_ID, IPDOMManager.ID_FAST_INDEXER);
|
||||||
prefs.putBoolean(KEY_INDEX_ALL_FILES, false);
|
prefs.putBoolean(KEY_INDEX_ALL_FILES, false);
|
||||||
|
prefs.putBoolean(KEY_SKIP_ALL_REFERENCES, false);
|
||||||
|
prefs.putBoolean(KEY_SKIP_TYPE_REFERENCES, false);
|
||||||
prefs.put(KEY_INDEX_IMPORT_LOCATION, DEFAULT_INDEX_IMPORT_LOCATION);
|
prefs.put(KEY_INDEX_IMPORT_LOCATION, DEFAULT_INDEX_IMPORT_LOCATION);
|
||||||
prefs.put(KEY_FILES_TO_PARSE_UP_FRONT, DEFAULT_FILES_TO_PARSE_UP_FRONT);
|
prefs.put(KEY_FILES_TO_PARSE_UP_FRONT, DEFAULT_FILES_TO_PARSE_UP_FRONT);
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,6 +31,7 @@ import org.eclipse.cdt.core.index.IIndexFile;
|
||||||
import org.eclipse.cdt.core.index.IIndexFileLocation;
|
import org.eclipse.cdt.core.index.IIndexFileLocation;
|
||||||
import org.eclipse.cdt.core.index.IIndexInclude;
|
import org.eclipse.cdt.core.index.IIndexInclude;
|
||||||
import org.eclipse.cdt.core.index.IndexLocationFactory;
|
import org.eclipse.cdt.core.index.IndexLocationFactory;
|
||||||
|
import org.eclipse.cdt.core.model.AbstractLanguage;
|
||||||
import org.eclipse.cdt.core.model.CoreModel;
|
import org.eclipse.cdt.core.model.CoreModel;
|
||||||
import org.eclipse.cdt.core.model.CoreModelUtil;
|
import org.eclipse.cdt.core.model.CoreModelUtil;
|
||||||
import org.eclipse.cdt.core.model.ICProject;
|
import org.eclipse.cdt.core.model.ICProject;
|
||||||
|
@ -73,6 +74,12 @@ public abstract class PDOMIndexerTask extends PDOMWriter implements IPDOMIndexer
|
||||||
fIndexer= indexer;
|
fIndexer= indexer;
|
||||||
setShowActivity(checkDebugOption(TRACE_ACTIVITY, TRUE));
|
setShowActivity(checkDebugOption(TRACE_ACTIVITY, TRUE));
|
||||||
setShowProblems(checkDebugOption(TRACE_PROBLEMS, TRUE));
|
setShowProblems(checkDebugOption(TRACE_PROBLEMS, TRUE));
|
||||||
|
if (checkProperty(IndexerPreferences.KEY_SKIP_ALL_REFERENCES)) {
|
||||||
|
setSkipReferences(SKIP_ALL_REFERENCES);
|
||||||
|
}
|
||||||
|
else if (checkProperty(IndexerPreferences.KEY_SKIP_TYPE_REFERENCES)) {
|
||||||
|
setSkipReferences(SKIP_TYPE_REFERENCES);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
final public IPDOMIndexer getIndexer() {
|
final public IPDOMIndexer getIndexer() {
|
||||||
|
@ -112,28 +119,46 @@ public abstract class PDOMIndexerTask extends PDOMWriter implements IPDOMIndexer
|
||||||
* @since 4.0
|
* @since 4.0
|
||||||
*/
|
*/
|
||||||
final protected boolean getIndexAllFiles() {
|
final protected boolean getIndexAllFiles() {
|
||||||
return TRUE.equals(getIndexer().getProperty(IndexerPreferences.KEY_INDEX_ALL_FILES));
|
return checkProperty(IndexerPreferences.KEY_INDEX_ALL_FILES);
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean checkProperty(String key) {
|
||||||
|
return TRUE.equals(getIndexer().getProperty(key));
|
||||||
|
}
|
||||||
|
|
||||||
|
private IASTTranslationUnit createAST(ITranslationUnit tu, int options, IProgressMonitor pm) throws CoreException {
|
||||||
|
IPath path = tu.getLocation();
|
||||||
|
if (path == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
ILanguage language = tu.getLanguage();
|
||||||
|
if (! (language instanceof AbstractLanguage))
|
||||||
|
return null;
|
||||||
|
|
||||||
|
// skip if no scanner info
|
||||||
|
IScannerInfo scanner= tu.getScannerInfo(getIndexAllFiles());
|
||||||
|
if (scanner == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
CodeReader codeReader = tu.getCodeReader();
|
||||||
|
if (codeReader == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return createAST((AbstractLanguage)language, codeReader, scanner, options, pm);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called to create the ast for a translation unit. May return <code>null</code>.
|
* Called to create the ast for a translation unit or a pre-parsed file.
|
||||||
|
* May return <code>null</code>.
|
||||||
* @see #parseTUs(IWritableIndex, int, Collection, Collection, IProgressMonitor)
|
* @see #parseTUs(IWritableIndex, int, Collection, Collection, IProgressMonitor)
|
||||||
* @since 4.0
|
* @since 4.0
|
||||||
*/
|
*/
|
||||||
abstract protected IASTTranslationUnit createAST(ITranslationUnit tu, IProgressMonitor pm) throws CoreException;
|
abstract protected IASTTranslationUnit createAST(AbstractLanguage lang, CodeReader codeReader, IScannerInfo scanInfo, int options, 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
|
* Convenience method for subclasses, parses the files calling out to the methods
|
||||||
* {@link #createAST(ITranslationUnit, IProgressMonitor)},
|
* {@link #createAST(AbstractLanguage, CodeReader, IScannerInfo, int, IProgressMonitor)},
|
||||||
* {@link #needToUpdate(IIndexFileLocation)},
|
* {@link #needToUpdate(IIndexFileLocation)},
|
||||||
* {@link #addSymbols(IASTTranslationUnit, IWritableIndex, int, IProgressMonitor)}
|
* {@link #addSymbols(IASTTranslationUnit, IWritableIndex, int, IProgressMonitor)}
|
||||||
* {@link #postAddToIndex(IIndexFileLocation, IIndexFile)},
|
* {@link #postAddToIndex(IIndexFileLocation, IIndexFile)},
|
||||||
|
@ -142,9 +167,13 @@ public abstract class PDOMIndexerTask extends PDOMWriter implements IPDOMIndexer
|
||||||
* @since 4.0
|
* @since 4.0
|
||||||
*/
|
*/
|
||||||
protected void parseTUs(IWritableIndex index, int readlockCount, Collection sources, Collection headers, IProgressMonitor monitor) throws CoreException, InterruptedException {
|
protected void parseTUs(IWritableIndex index, int readlockCount, Collection sources, Collection headers, IProgressMonitor monitor) throws CoreException, InterruptedException {
|
||||||
|
int options= 0;
|
||||||
|
if (checkProperty(IndexerPreferences.KEY_SKIP_ALL_REFERENCES)) {
|
||||||
|
options |= AbstractLanguage.OPTION_SKIP_FUNCTION_BODIES;
|
||||||
|
}
|
||||||
for (Iterator iter = fFilesUpFront.iterator(); iter.hasNext();) {
|
for (Iterator iter = fFilesUpFront.iterator(); iter.hasNext();) {
|
||||||
String upfront= (String) iter.next();
|
String upfront= (String) iter.next();
|
||||||
parseUpFront(upfront, index, readlockCount, monitor);
|
parseUpFront(upfront, options, index, readlockCount, monitor);
|
||||||
}
|
}
|
||||||
|
|
||||||
// sources first
|
// sources first
|
||||||
|
@ -157,7 +186,7 @@ public abstract class PDOMIndexerTask extends PDOMWriter implements IPDOMIndexer
|
||||||
updateInfo(0,0,-1);
|
updateInfo(0,0,-1);
|
||||||
}
|
}
|
||||||
else if (needToUpdate(ifl)) {
|
else if (needToUpdate(ifl)) {
|
||||||
parseTU(tu, index, readlockCount, monitor);
|
parseTU(tu, options, index, readlockCount, monitor);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -177,7 +206,7 @@ public abstract class PDOMIndexerTask extends PDOMWriter implements IPDOMIndexer
|
||||||
else {
|
else {
|
||||||
ITranslationUnit context= findContext(index, location);
|
ITranslationUnit context= findContext(index, location);
|
||||||
if (context != null) {
|
if (context != null) {
|
||||||
parseTU(context, index, readlockCount, monitor);
|
parseTU(context, options, index, readlockCount, monitor);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -197,7 +226,7 @@ public abstract class PDOMIndexerTask extends PDOMWriter implements IPDOMIndexer
|
||||||
iter.remove();
|
iter.remove();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
parseTU(tu, index, readlockCount, monitor);
|
parseTU(tu, options, index, readlockCount, monitor);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -218,7 +247,7 @@ public abstract class PDOMIndexerTask extends PDOMWriter implements IPDOMIndexer
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private void parseTU(ITranslationUnit tu, IWritableIndex index, int readlockCount, IProgressMonitor pm) throws CoreException, InterruptedException {
|
private void parseTU(ITranslationUnit tu, int options, IWritableIndex index, int readlockCount, IProgressMonitor pm) throws CoreException, InterruptedException {
|
||||||
IPath path= tu.getPath();
|
IPath path= tu.getPath();
|
||||||
try {
|
try {
|
||||||
if (fShowActivity) {
|
if (fShowActivity) {
|
||||||
|
@ -227,7 +256,7 @@ public abstract class PDOMIndexerTask extends PDOMWriter implements IPDOMIndexer
|
||||||
pm.subTask(MessageFormat.format(Messages.PDOMIndexerTask_parsingFileTask,
|
pm.subTask(MessageFormat.format(Messages.PDOMIndexerTask_parsingFileTask,
|
||||||
new Object[]{path.lastSegment(), path.removeLastSegments(1).toString()}));
|
new Object[]{path.lastSegment(), path.removeLastSegments(1).toString()}));
|
||||||
long start= System.currentTimeMillis();
|
long start= System.currentTimeMillis();
|
||||||
IASTTranslationUnit ast= createAST(tu, pm);
|
IASTTranslationUnit ast= createAST(tu, options, pm);
|
||||||
fStatistics.fParsingTime += System.currentTimeMillis()-start;
|
fStatistics.fParsingTime += System.currentTimeMillis()-start;
|
||||||
if (ast != null) {
|
if (ast != null) {
|
||||||
addSymbols(ast, index, readlockCount, pm);
|
addSymbols(ast, index, readlockCount, pm);
|
||||||
|
@ -244,7 +273,7 @@ public abstract class PDOMIndexerTask extends PDOMWriter implements IPDOMIndexer
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void parseUpFront(String file, IWritableIndex index, int readlockCount, IProgressMonitor pm) throws CoreException, InterruptedException {
|
private void parseUpFront(String file, int options, IWritableIndex index, int readlockCount, IProgressMonitor pm) throws CoreException, InterruptedException {
|
||||||
file= file.trim();
|
file= file.trim();
|
||||||
if (file.length() == 0) {
|
if (file.length() == 0) {
|
||||||
return;
|
return;
|
||||||
|
@ -262,8 +291,9 @@ public abstract class PDOMIndexerTask extends PDOMWriter implements IPDOMIndexer
|
||||||
final IProject project = getProject().getProject();
|
final IProject project = getProject().getProject();
|
||||||
IContentType ct= CContentTypes.getContentType(project, file);
|
IContentType ct= CContentTypes.getContentType(project, file);
|
||||||
if (ct != null) {
|
if (ct != null) {
|
||||||
ILanguage lang = LanguageManager.getInstance().getLanguage(ct);
|
ILanguage l = LanguageManager.getInstance().getLanguage(ct);
|
||||||
if (lang != null) {
|
if (l instanceof AbstractLanguage) {
|
||||||
|
AbstractLanguage lang= (AbstractLanguage) l;
|
||||||
IScannerInfoProvider provider= CCorePlugin.getDefault().getScannerInfoProvider(project);
|
IScannerInfoProvider provider= CCorePlugin.getDefault().getScannerInfoProvider(project);
|
||||||
IScannerInfo scanInfo;
|
IScannerInfo scanInfo;
|
||||||
if (provider != null) {
|
if (provider != null) {
|
||||||
|
@ -278,7 +308,7 @@ public abstract class PDOMIndexerTask extends PDOMWriter implements IPDOMIndexer
|
||||||
fDummyFileURI= findLocation(fDummyFileName).getURI();
|
fDummyFileURI= findLocation(fDummyFileName).getURI();
|
||||||
}
|
}
|
||||||
CodeReader codeReader= new CodeReader(fDummyFileName, code.toCharArray());
|
CodeReader codeReader= new CodeReader(fDummyFileName, code.toCharArray());
|
||||||
ast= createAST(lang, codeReader, scanInfo, pm);
|
ast= createAST(lang, codeReader, scanInfo, options, pm);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -387,7 +417,14 @@ public abstract class PDOMIndexerTask extends PDOMWriter implements IPDOMIndexer
|
||||||
System.out.println(name + " " + getProject().getElementName() //$NON-NLS-1$
|
System.out.println(name + " " + getProject().getElementName() //$NON-NLS-1$
|
||||||
+ " (" + info.fCompletedSources + " sources, " //$NON-NLS-1$ //$NON-NLS-2$
|
+ " (" + info.fCompletedSources + " sources, " //$NON-NLS-1$ //$NON-NLS-2$
|
||||||
+ info.fCompletedHeaders + " headers)"); //$NON-NLS-1$
|
+ info.fCompletedHeaders + " headers)"); //$NON-NLS-1$
|
||||||
|
boolean allFiles= getIndexAllFiles();
|
||||||
|
boolean skipRefs= checkProperty(IndexerPreferences.KEY_SKIP_ALL_REFERENCES);
|
||||||
|
boolean skipTypeRefs= skipRefs || checkProperty(IndexerPreferences.KEY_SKIP_TYPE_REFERENCES);
|
||||||
|
System.out.println(name + " Options: " //$NON-NLS-1$
|
||||||
|
+ "parseAllFiles=" + allFiles //$NON-NLS-1$
|
||||||
|
+ ",skipReferences=" + skipRefs //$NON-NLS-1$
|
||||||
|
+ ", skipTypeReferences=" + skipTypeRefs //$NON-NLS-1$
|
||||||
|
+ "."); //$NON-NLS-1$
|
||||||
System.out.println(name + " Timings: " //$NON-NLS-1$
|
System.out.println(name + " Timings: " //$NON-NLS-1$
|
||||||
+ (System.currentTimeMillis() - start) + " total, " //$NON-NLS-1$
|
+ (System.currentTimeMillis() - start) + " total, " //$NON-NLS-1$
|
||||||
+ fStatistics.fParsingTime + " parser, " //$NON-NLS-1$
|
+ fStatistics.fParsingTime + " parser, " //$NON-NLS-1$
|
||||||
|
|
|
@ -25,7 +25,7 @@ import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
|
||||||
import org.eclipse.cdt.core.index.IIndexFile;
|
import org.eclipse.cdt.core.index.IIndexFile;
|
||||||
import org.eclipse.cdt.core.index.IIndexFileLocation;
|
import org.eclipse.cdt.core.index.IIndexFileLocation;
|
||||||
import org.eclipse.cdt.core.index.IndexLocationFactory;
|
import org.eclipse.cdt.core.index.IndexLocationFactory;
|
||||||
import org.eclipse.cdt.core.model.ILanguage;
|
import org.eclipse.cdt.core.model.AbstractLanguage;
|
||||||
import org.eclipse.cdt.core.model.ITranslationUnit;
|
import org.eclipse.cdt.core.model.ITranslationUnit;
|
||||||
import org.eclipse.cdt.core.parser.CodeReader;
|
import org.eclipse.cdt.core.parser.CodeReader;
|
||||||
import org.eclipse.cdt.core.parser.IScannerInfo;
|
import org.eclipse.cdt.core.parser.IScannerInfo;
|
||||||
|
@ -36,7 +36,6 @@ import org.eclipse.cdt.internal.core.index.IndexBasedCodeReaderFactory;
|
||||||
import org.eclipse.cdt.internal.core.index.IndexBasedCodeReaderFactory.FileInfo;
|
import org.eclipse.cdt.internal.core.index.IndexBasedCodeReaderFactory.FileInfo;
|
||||||
import org.eclipse.cdt.internal.core.pdom.indexer.PDOMIndexerTask;
|
import org.eclipse.cdt.internal.core.pdom.indexer.PDOMIndexerTask;
|
||||||
import org.eclipse.core.runtime.CoreException;
|
import org.eclipse.core.runtime.CoreException;
|
||||||
import org.eclipse.core.runtime.IPath;
|
|
||||||
import org.eclipse.core.runtime.IProgressMonitor;
|
import org.eclipse.core.runtime.IProgressMonitor;
|
||||||
|
|
||||||
class PDOMFastIndexerTask extends PDOMIndexerTask {
|
class PDOMFastIndexerTask extends PDOMIndexerTask {
|
||||||
|
@ -128,31 +127,9 @@ class PDOMFastIndexerTask extends PDOMIndexerTask {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected IASTTranslationUnit createAST(ITranslationUnit tu, IProgressMonitor pm) throws CoreException {
|
protected IASTTranslationUnit createAST(AbstractLanguage lang, CodeReader codeReader, IScannerInfo scanInfo, int options, IProgressMonitor pm) throws CoreException {
|
||||||
IPath path = tu.getLocation();
|
|
||||||
if (path == null) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
ILanguage language = tu.getLanguage();
|
|
||||||
if (language == null)
|
|
||||||
return null;
|
|
||||||
|
|
||||||
// skip if no scanner info
|
|
||||||
IScannerInfo scanner= tu.getScannerInfo(getIndexAllFiles());
|
|
||||||
if (scanner == null) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
CodeReader codeReader = tu.getCodeReader();
|
|
||||||
if (codeReader == null) {
|
|
||||||
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
|
// get the AST in a "Fast" way
|
||||||
IASTTranslationUnit ast= lang.getASTTranslationUnit(codeReader, scanInfo, fCodeReaderFactory, fIndex, ParserUtil.getParserLogService());
|
IASTTranslationUnit ast= lang.getASTTranslationUnit(codeReader, scanInfo, fCodeReaderFactory, fIndex, options, ParserUtil.getParserLogService());
|
||||||
if (pm.isCanceled()) {
|
if (pm.isCanceled()) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,7 +25,7 @@ import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
|
||||||
import org.eclipse.cdt.core.index.IIndexFile;
|
import org.eclipse.cdt.core.index.IIndexFile;
|
||||||
import org.eclipse.cdt.core.index.IIndexFileLocation;
|
import org.eclipse.cdt.core.index.IIndexFileLocation;
|
||||||
import org.eclipse.cdt.core.index.IndexLocationFactory;
|
import org.eclipse.cdt.core.index.IndexLocationFactory;
|
||||||
import org.eclipse.cdt.core.model.ILanguage;
|
import org.eclipse.cdt.core.model.AbstractLanguage;
|
||||||
import org.eclipse.cdt.core.model.ITranslationUnit;
|
import org.eclipse.cdt.core.model.ITranslationUnit;
|
||||||
import org.eclipse.cdt.core.parser.CodeReader;
|
import org.eclipse.cdt.core.parser.CodeReader;
|
||||||
import org.eclipse.cdt.core.parser.IScannerInfo;
|
import org.eclipse.cdt.core.parser.IScannerInfo;
|
||||||
|
@ -35,7 +35,6 @@ import org.eclipse.cdt.internal.core.index.IWritableIndex;
|
||||||
import org.eclipse.cdt.internal.core.index.IWritableIndexManager;
|
import org.eclipse.cdt.internal.core.index.IWritableIndexManager;
|
||||||
import org.eclipse.cdt.internal.core.pdom.indexer.PDOMIndexerTask;
|
import org.eclipse.cdt.internal.core.pdom.indexer.PDOMIndexerTask;
|
||||||
import org.eclipse.core.runtime.CoreException;
|
import org.eclipse.core.runtime.CoreException;
|
||||||
import org.eclipse.core.runtime.IPath;
|
|
||||||
import org.eclipse.core.runtime.IProgressMonitor;
|
import org.eclipse.core.runtime.IProgressMonitor;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -110,6 +109,9 @@ class PDOMFullIndexerTask extends PDOMIndexerTask {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setupIndex() throws CoreException {
|
private void setupIndex() throws CoreException {
|
||||||
|
// there is no mechanism to clear dirty files from the cache, so flush it.
|
||||||
|
SavedCodeReaderFactory.getInstance().getCodeReaderCache().flush();
|
||||||
|
|
||||||
fIndex = ((IWritableIndexManager) CCorePlugin.getIndexManager()).getWritableIndex(getProject());
|
fIndex = ((IWritableIndexManager) CCorePlugin.getIndexManager()).getWritableIndex(getProject());
|
||||||
fIndex.resetCacheCounters();
|
fIndex.resetCacheCounters();
|
||||||
}
|
}
|
||||||
|
@ -132,21 +134,9 @@ class PDOMFullIndexerTask extends PDOMIndexerTask {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected IASTTranslationUnit createAST(ITranslationUnit tu, IProgressMonitor pm) throws CoreException {
|
protected IASTTranslationUnit createAST(AbstractLanguage lang, CodeReader codeReader, IScannerInfo scanInfo, int options, IProgressMonitor pm) throws CoreException {
|
||||||
IPath path = tu.getLocation();
|
|
||||||
if (path == null) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
int options= 0;
|
|
||||||
if (!getIndexAllFiles()) {
|
|
||||||
options |= ITranslationUnit.AST_SKIP_IF_NO_BUILD_INFO;
|
|
||||||
}
|
|
||||||
return tu.getAST(null, options);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected IASTTranslationUnit createAST(ILanguage lang, CodeReader codeReader, IScannerInfo scanInfo, IProgressMonitor pm) throws CoreException {
|
|
||||||
SavedCodeReaderFactory codeReaderFactory= SavedCodeReaderFactory.getInstance();
|
SavedCodeReaderFactory codeReaderFactory= SavedCodeReaderFactory.getInstance();
|
||||||
IASTTranslationUnit ast= lang.getASTTranslationUnit(codeReader, scanInfo, codeReaderFactory, null, ParserUtil.getParserLogService());
|
IASTTranslationUnit ast= lang.getASTTranslationUnit(codeReader, scanInfo, codeReaderFactory, null, options, ParserUtil.getParserLogService());
|
||||||
if (pm.isCanceled()) {
|
if (pm.isCanceled()) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,6 +16,8 @@ import java.util.Properties;
|
||||||
import org.eclipse.core.resources.IProject;
|
import org.eclipse.core.resources.IProject;
|
||||||
import org.eclipse.core.runtime.IProgressMonitor;
|
import org.eclipse.core.runtime.IProgressMonitor;
|
||||||
import org.eclipse.swt.SWT;
|
import org.eclipse.swt.SWT;
|
||||||
|
import org.eclipse.swt.events.SelectionAdapter;
|
||||||
|
import org.eclipse.swt.events.SelectionEvent;
|
||||||
import org.eclipse.swt.widgets.Button;
|
import org.eclipse.swt.widgets.Button;
|
||||||
import org.eclipse.swt.widgets.Composite;
|
import org.eclipse.swt.widgets.Composite;
|
||||||
import org.eclipse.swt.widgets.Label;
|
import org.eclipse.swt.widgets.Label;
|
||||||
|
@ -35,6 +37,8 @@ public abstract class AbstractIndexerPage extends AbstractCOptionPage {
|
||||||
|
|
||||||
private Button fAllFiles;
|
private Button fAllFiles;
|
||||||
private Text fFilesToParseUpFront;
|
private Text fFilesToParseUpFront;
|
||||||
|
private Button fSkipReferences;
|
||||||
|
private Button fSkipTypeReferences;
|
||||||
|
|
||||||
protected AbstractIndexerPage() {
|
protected AbstractIndexerPage() {
|
||||||
super();
|
super();
|
||||||
|
@ -51,7 +55,15 @@ public abstract class AbstractIndexerPage extends AbstractCOptionPage {
|
||||||
public void createControl(Composite parent) {
|
public void createControl(Composite parent) {
|
||||||
Composite page = ControlFactory.createComposite(parent, 1);
|
Composite page = ControlFactory.createComposite(parent, 1);
|
||||||
fAllFiles= createAllFilesButton(page);
|
fAllFiles= createAllFilesButton(page);
|
||||||
|
fSkipReferences= createSkipReferencesButton(page);
|
||||||
|
fSkipTypeReferences= createSkipTypeReferencesButton(page);
|
||||||
fFilesToParseUpFront= createParseUpFrontTextField(page);
|
fFilesToParseUpFront= createParseUpFrontTextField(page);
|
||||||
|
|
||||||
|
fSkipReferences.addSelectionListener(new SelectionAdapter() {
|
||||||
|
public void widgetSelected(SelectionEvent e) {
|
||||||
|
updateEnablement();
|
||||||
|
}
|
||||||
|
});
|
||||||
setControl(page);
|
setControl(page);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -65,10 +77,19 @@ public abstract class AbstractIndexerPage extends AbstractCOptionPage {
|
||||||
boolean indexAllFiles= TRUE.equals(properties.get(IndexerPreferences.KEY_INDEX_ALL_FILES));
|
boolean indexAllFiles= TRUE.equals(properties.get(IndexerPreferences.KEY_INDEX_ALL_FILES));
|
||||||
fAllFiles.setSelection(indexAllFiles);
|
fAllFiles.setSelection(indexAllFiles);
|
||||||
}
|
}
|
||||||
|
if (fSkipReferences != null) {
|
||||||
|
boolean skipReferences= TRUE.equals(properties.get(IndexerPreferences.KEY_SKIP_ALL_REFERENCES));
|
||||||
|
fSkipReferences.setSelection(skipReferences);
|
||||||
|
}
|
||||||
|
if (fSkipTypeReferences != null) {
|
||||||
|
boolean skipTypeReferences= TRUE.equals(properties.get(IndexerPreferences.KEY_SKIP_TYPE_REFERENCES));
|
||||||
|
fSkipTypeReferences.setSelection(skipTypeReferences);
|
||||||
|
}
|
||||||
if (fFilesToParseUpFront != null) {
|
if (fFilesToParseUpFront != null) {
|
||||||
String files = getNotNull(properties, IndexerPreferences.KEY_FILES_TO_PARSE_UP_FRONT);
|
String files = getNotNull(properties, IndexerPreferences.KEY_FILES_TO_PARSE_UP_FRONT);
|
||||||
fFilesToParseUpFront.setText(files);
|
fFilesToParseUpFront.setText(files);
|
||||||
}
|
}
|
||||||
|
updateEnablement();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -83,6 +104,12 @@ public abstract class AbstractIndexerPage extends AbstractCOptionPage {
|
||||||
if (fFilesToParseUpFront != null) {
|
if (fFilesToParseUpFront != null) {
|
||||||
props.put(IndexerPreferences.KEY_FILES_TO_PARSE_UP_FRONT, fFilesToParseUpFront.getText());
|
props.put(IndexerPreferences.KEY_FILES_TO_PARSE_UP_FRONT, fFilesToParseUpFront.getText());
|
||||||
}
|
}
|
||||||
|
if (fSkipReferences != null) {
|
||||||
|
props.put(IndexerPreferences.KEY_SKIP_ALL_REFERENCES, String.valueOf(fSkipReferences.getSelection()));
|
||||||
|
}
|
||||||
|
if (fSkipTypeReferences != null) {
|
||||||
|
props.put(IndexerPreferences.KEY_SKIP_TYPE_REFERENCES, String.valueOf(fSkipTypeReferences.getSelection()));
|
||||||
|
}
|
||||||
return props;
|
return props;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -100,10 +127,10 @@ public abstract class AbstractIndexerPage extends AbstractCOptionPage {
|
||||||
throw new UnsupportedOperationException();
|
throw new UnsupportedOperationException();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @deprecated, never called.
|
|
||||||
*/
|
|
||||||
public void updateEnablement() {
|
public void updateEnablement() {
|
||||||
|
if (fSkipReferences != null && fSkipTypeReferences != null) {
|
||||||
|
fSkipTypeReferences.setEnabled(!fSkipReferences.getSelection());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getNotNull(Properties properties, String key) {
|
private String getNotNull(Properties properties, String key) {
|
||||||
|
@ -123,4 +150,12 @@ public abstract class AbstractIndexerPage extends AbstractCOptionPage {
|
||||||
private Button createAllFilesButton(Composite page) {
|
private Button createAllFilesButton(Composite page) {
|
||||||
return ControlFactory.createCheckBox(page, INDEX_ALL_FILES);
|
return ControlFactory.createCheckBox(page, INDEX_ALL_FILES);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private Button createSkipReferencesButton(Composite page) {
|
||||||
|
return ControlFactory.createCheckBox(page, DialogsMessages.AbstractIndexerPage_skipAllReferences);
|
||||||
|
}
|
||||||
|
|
||||||
|
private Button createSkipTypeReferencesButton(Composite page) {
|
||||||
|
return ControlFactory.createCheckBox(page, DialogsMessages.AbstractIndexerPage_skipTypeReferences);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,6 +17,8 @@ public class DialogsMessages extends NLS {
|
||||||
private static final String BUNDLE_NAME = "org.eclipse.cdt.ui.dialogs.DialogsMessages"; //$NON-NLS-1$
|
private static final String BUNDLE_NAME = "org.eclipse.cdt.ui.dialogs.DialogsMessages"; //$NON-NLS-1$
|
||||||
public static String AbstractIndexerPage_indexAllFiles;
|
public static String AbstractIndexerPage_indexAllFiles;
|
||||||
public static String AbstractIndexerPage_indexUpFront;
|
public static String AbstractIndexerPage_indexUpFront;
|
||||||
|
public static String AbstractIndexerPage_skipAllReferences;
|
||||||
|
public static String AbstractIndexerPage_skipTypeReferences;
|
||||||
public static String PreferenceScopeBlock_enableProjectSettings;
|
public static String PreferenceScopeBlock_enableProjectSettings;
|
||||||
public static String PreferenceScopeBlock_preferenceLink;
|
public static String PreferenceScopeBlock_preferenceLink;
|
||||||
public static String PreferenceScopeBlock_storeWithProject;
|
public static String PreferenceScopeBlock_storeWithProject;
|
||||||
|
|
|
@ -12,4 +12,6 @@ PreferenceScopeBlock_enableProjectSettings=Enable project specific settings
|
||||||
PreferenceScopeBlock_storeWithProject=Store settings with project
|
PreferenceScopeBlock_storeWithProject=Store settings with project
|
||||||
PreferenceScopeBlock_preferenceLink=<a>Configure Workspace Settings...</a>
|
PreferenceScopeBlock_preferenceLink=<a>Configure Workspace Settings...</a>
|
||||||
AbstractIndexerPage_indexAllFiles=Index all files (files neither built nor included, also)
|
AbstractIndexerPage_indexAllFiles=Index all files (files neither built nor included, also)
|
||||||
|
AbstractIndexerPage_skipAllReferences=Skip all references (Call Hierarchy and Search will not work)
|
||||||
|
AbstractIndexerPage_skipTypeReferences=Skip type references (Search for type references will not work)
|
||||||
AbstractIndexerPage_indexUpFront=Files to index up-front:
|
AbstractIndexerPage_indexUpFront=Files to index up-front:
|
||||||
|
|
Loading…
Add table
Reference in a new issue