mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
Fix for a problem with DOM indexer, where external header files in translation unit's inclusion tree were not visited.
Optimization from Dave; skipping declarations in already visited external headers.
This commit is contained in:
parent
3d2fcb3aa4
commit
6e8ba9eebb
8 changed files with 94 additions and 112 deletions
|
@ -1,3 +1,16 @@
|
||||||
|
2005-06-07 Vladimir Hirsl
|
||||||
|
Fix for a problem with DOM indexer, where external header files in translation unit's
|
||||||
|
inclusion tree were not visited.
|
||||||
|
Optimization from Dave; skipping declarations in already visited external headers.
|
||||||
|
|
||||||
|
* index/org/eclipse/cdt/internal/core/index/cindexstorage/IndexOutput.java
|
||||||
|
* index/org/eclipse/cdt/internal/core/index/domsourceindexer/CGenerateIndexVisitor.java
|
||||||
|
* index/org/eclipse/cdt/internal/core/index/domsourceindexer/CPPGenerateIndexVisitor.java
|
||||||
|
* index/org/eclipse/cdt/internal/core/index/domsourceindexer/DOMSourceIndexerRunner.java
|
||||||
|
* index/org/eclipse/cdt/internal/core/index/domsourceindexer/IndexEncoderUtil.java
|
||||||
|
* index/org/eclipse/cdt/internal/core/index/domsourceindexer/IndexVisitorUtil.java
|
||||||
|
* index/org/eclipse/cdt/internal/core/index/sourceindexer/SourceIndexer.java
|
||||||
|
|
||||||
2005-06-03 Vladimir Hirsl
|
2005-06-03 Vladimir Hirsl
|
||||||
Fix for PR 93786: DOM Indexer adds local variables to the index
|
Fix for PR 93786: DOM Indexer adds local variables to the index
|
||||||
Other smaller fixes in DOM Indexer domain.
|
Other smaller fixes in DOM Indexer domain.
|
||||||
|
|
|
@ -24,6 +24,7 @@ import org.eclipse.cdt.internal.core.index.sourceindexer.AbstractIndexer;
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public class IndexerOutput implements ICIndexStorageConstants, IIndexerOutput {
|
public class IndexerOutput implements ICIndexStorageConstants, IIndexerOutput {
|
||||||
|
public static int entryCount = 0;
|
||||||
protected InMemoryIndex index;
|
protected InMemoryIndex index;
|
||||||
/**
|
/**
|
||||||
* IndexerOutput constructor comment.
|
* IndexerOutput constructor comment.
|
||||||
|
@ -43,6 +44,7 @@ public class IndexerOutput implements ICIndexStorageConstants, IIndexerOutput {
|
||||||
if (modifiers <=0)
|
if (modifiers <=0)
|
||||||
modifiers = 1;
|
modifiers = 1;
|
||||||
|
|
||||||
|
entryCount++;
|
||||||
index.addRef(
|
index.addRef(
|
||||||
encodeTypeEntry(name, suffix, type),
|
encodeTypeEntry(name, suffix, type),
|
||||||
indexedFileNumber, offset, offsetLength, offsetType, modifiers);
|
indexedFileNumber, offset, offsetLength, offsetType, modifiers);
|
||||||
|
@ -58,7 +60,7 @@ public class IndexerOutput implements ICIndexStorageConstants, IIndexerOutput {
|
||||||
|
|
||||||
if (modifiers <=0)
|
if (modifiers <=0)
|
||||||
modifiers = 1;
|
modifiers = 1;
|
||||||
|
entryCount++;
|
||||||
index.addRef(
|
index.addRef(
|
||||||
encodeEntry(name, meta_kind, ref),
|
encodeEntry(name, meta_kind, ref),
|
||||||
indexedFileNumber, offset, offsetLength, offsetType, modifiers);
|
indexedFileNumber, offset, offsetLength, offsetType, modifiers);
|
||||||
|
|
|
@ -13,6 +13,7 @@ package org.eclipse.cdt.internal.core.index.domsourceindexer;
|
||||||
import org.eclipse.cdt.core.ICLogConstants;
|
import org.eclipse.cdt.core.ICLogConstants;
|
||||||
import org.eclipse.cdt.core.dom.ast.ASTNodeProperty;
|
import org.eclipse.cdt.core.dom.ast.ASTNodeProperty;
|
||||||
import org.eclipse.cdt.core.dom.ast.DOMException;
|
import org.eclipse.cdt.core.dom.ast.DOMException;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IASTDeclaration;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTElaboratedTypeSpecifier;
|
import org.eclipse.cdt.core.dom.ast.IASTElaboratedTypeSpecifier;
|
||||||
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;
|
||||||
|
@ -39,7 +40,7 @@ public class CGenerateIndexVisitor extends CASTVisitor {
|
||||||
private DOMSourceIndexerRunner indexer;
|
private DOMSourceIndexerRunner indexer;
|
||||||
{
|
{
|
||||||
shouldVisitNames = true;
|
shouldVisitNames = true;
|
||||||
// shouldVisitDeclarations = false;
|
shouldVisitDeclarations = true;
|
||||||
// shouldVisitInitializers = false;
|
// shouldVisitInitializers = false;
|
||||||
// shouldVisitParameterDeclarations = false;
|
// shouldVisitParameterDeclarations = false;
|
||||||
// shouldVisitDeclarators = false;
|
// shouldVisitDeclarators = false;
|
||||||
|
@ -59,6 +60,15 @@ public class CGenerateIndexVisitor extends CASTVisitor {
|
||||||
this.indexer = indexer;
|
this.indexer = indexer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.dom.ast.ASTVisitor#visit(org.eclipse.cdt.core.dom.ast.IASTDeclaration)
|
||||||
|
*/
|
||||||
|
public int visit(IASTDeclaration declaration) {
|
||||||
|
if (IndexEncoderUtil.nodeInVisitedExternalHeader(declaration, indexer.getIndexer()))
|
||||||
|
return PROCESS_SKIP;
|
||||||
|
return PROCESS_CONTINUE;
|
||||||
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.cdt.core.dom.ast.ASTVisitor#visit(org.eclipse.cdt.core.dom.ast.IASTName)
|
* @see org.eclipse.cdt.core.dom.ast.ASTVisitor#visit(org.eclipse.cdt.core.dom.ast.IASTName)
|
||||||
*/
|
*/
|
||||||
|
@ -70,15 +80,16 @@ public class CGenerateIndexVisitor extends CASTVisitor {
|
||||||
processName(name);
|
processName(name);
|
||||||
}
|
}
|
||||||
catch (DOMException e) {
|
catch (DOMException e) {
|
||||||
// TODO Auto-generated catch block
|
// TODO remove printStackTrace
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
Util.log(e, e.getProblem().getMessage(), ICLogConstants.CDT);
|
||||||
}
|
}
|
||||||
catch (Exception e) {
|
catch (Exception e) {
|
||||||
// TODO remove
|
// TODO remove printStackTrace
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
Util.log(e, e.toString(), ICLogConstants.CDT);
|
Util.log(e, e.toString(), ICLogConstants.CDT);
|
||||||
}
|
}
|
||||||
return PROCESS_CONTINUE;
|
return PROCESS_CONTINUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
|
|
|
@ -38,6 +38,7 @@ import org.eclipse.cdt.core.dom.ast.IVariable;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.CPPASTVisitor;
|
import org.eclipse.cdt.core.dom.ast.cpp.CPPASTVisitor;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCompositeTypeSpecifier;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCompositeTypeSpecifier;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTElaboratedTypeSpecifier;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTElaboratedTypeSpecifier;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTNamespaceDefinition;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTQualifiedName;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTQualifiedName;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPBase;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPBase;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPBinding;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPBinding;
|
||||||
|
@ -60,7 +61,7 @@ public class CPPGenerateIndexVisitor extends CPPASTVisitor {
|
||||||
|
|
||||||
{
|
{
|
||||||
shouldVisitNames = true;
|
shouldVisitNames = true;
|
||||||
// shouldVisitDeclarations = false;
|
shouldVisitDeclarations = true;
|
||||||
// shouldVisitInitializers = false;
|
// shouldVisitInitializers = false;
|
||||||
// shouldVisitParameterDeclarations = false;
|
// shouldVisitParameterDeclarations = false;
|
||||||
// shouldVisitDeclarators = false;
|
// shouldVisitDeclarators = false;
|
||||||
|
@ -73,7 +74,7 @@ public class CPPGenerateIndexVisitor extends CPPASTVisitor {
|
||||||
shouldVisitProblems = true;
|
shouldVisitProblems = true;
|
||||||
|
|
||||||
// shouldVisitBaseSpecifiers = false;
|
// shouldVisitBaseSpecifiers = false;
|
||||||
// shouldVisitNamespaces = false;
|
shouldVisitNamespaces = true;
|
||||||
// shouldVisitTemplateParameters = false;
|
// shouldVisitTemplateParameters = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -82,7 +83,25 @@ public class CPPGenerateIndexVisitor extends CPPASTVisitor {
|
||||||
this.indexer = indexer;
|
this.indexer = indexer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.dom.ast.cpp.CPPASTVisitor#visit(org.eclipse.cdt.core.dom.ast.cpp.ICPPASTNamespaceDefinition)
|
||||||
|
*/
|
||||||
|
public int visit(ICPPASTNamespaceDefinition namespace) {
|
||||||
|
if (IndexEncoderUtil.nodeInVisitedExternalHeader(namespace, indexer.getIndexer()))
|
||||||
|
return PROCESS_SKIP;
|
||||||
|
return PROCESS_CONTINUE;
|
||||||
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.core.dom.ast.ASTVisitor#visit(org.eclipse.cdt.core.dom.ast.IASTDeclaration)
|
||||||
|
*/
|
||||||
|
public int visit(IASTDeclaration declaration) {
|
||||||
|
if (IndexEncoderUtil.nodeInVisitedExternalHeader(declaration, indexer.getIndexer()))
|
||||||
|
return PROCESS_SKIP;
|
||||||
|
return PROCESS_CONTINUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.cdt.core.dom.ast.ASTVisitor#visit(org.eclipse.cdt.core.dom.ast.IASTName)
|
* @see org.eclipse.cdt.core.dom.ast.ASTVisitor#visit(org.eclipse.cdt.core.dom.ast.IASTName)
|
||||||
*/
|
*/
|
||||||
public int visit(IASTName name) {
|
public int visit(IASTName name) {
|
||||||
|
@ -93,11 +112,12 @@ public class CPPGenerateIndexVisitor extends CPPASTVisitor {
|
||||||
processName(name);
|
processName(name);
|
||||||
}
|
}
|
||||||
catch (DOMException e) {
|
catch (DOMException e) {
|
||||||
// TODO Auto-generated catch block
|
// TODO remove printStackTrace
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
Util.log(e, e.getProblem().getMessage(), ICLogConstants.CDT);
|
||||||
}
|
}
|
||||||
catch (Exception e) {
|
catch (Exception e) {
|
||||||
// TODO remove
|
// TODO remove printStackTrace
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
Util.log(e, e.toString(), ICLogConstants.CDT);
|
Util.log(e, e.toString(), ICLogConstants.CDT);
|
||||||
}
|
}
|
||||||
|
@ -215,7 +235,7 @@ public class CPPGenerateIndexVisitor extends CPPASTVisitor {
|
||||||
addFriendDeclarations(name, (ICPPClassType)binding, indexEntry, fileNumber);
|
addFriendDeclarations(name, (ICPPClassType)binding, indexEntry, fileNumber);
|
||||||
}
|
}
|
||||||
|
|
||||||
indexEntry.serialize(indexer.getOutput());
|
serialize(indexEntry);
|
||||||
}
|
}
|
||||||
else if (binding instanceof IEnumeration) {
|
else if (binding instanceof IEnumeration) {
|
||||||
int modifiers = 0;
|
int modifiers = 0;
|
||||||
|
@ -225,25 +245,25 @@ public class CPPGenerateIndexVisitor extends CPPASTVisitor {
|
||||||
TypeEntry indexEntry = new TypeEntry(IIndex.TYPE_ENUM, entryKind, qualifiedName, modifiers, fileNumber);
|
TypeEntry indexEntry = new TypeEntry(IIndex.TYPE_ENUM, entryKind, qualifiedName, modifiers, fileNumber);
|
||||||
indexEntry.setNameOffset(fileLoc.getNodeOffset(), fileLoc.getNodeLength(), IIndex.OFFSET);
|
indexEntry.setNameOffset(fileLoc.getNodeOffset(), fileLoc.getNodeLength(), IIndex.OFFSET);
|
||||||
|
|
||||||
indexEntry.serialize(indexer.getOutput());
|
serialize(indexEntry);
|
||||||
}
|
}
|
||||||
else if (binding instanceof ITypedef) {
|
else if (binding instanceof ITypedef) {
|
||||||
TypeEntry indexEntry = new TypeEntry(IIndex.TYPE_TYPEDEF, entryKind, qualifiedName, 0, fileNumber);
|
TypeEntry indexEntry = new TypeEntry(IIndex.TYPE_TYPEDEF, entryKind, qualifiedName, 0, fileNumber);
|
||||||
indexEntry.setNameOffset(fileLoc.getNodeOffset(), fileLoc.getNodeLength(), IIndex.OFFSET);
|
indexEntry.setNameOffset(fileLoc.getNodeOffset(), fileLoc.getNodeLength(), IIndex.OFFSET);
|
||||||
|
|
||||||
indexEntry.serialize(indexer.getOutput());
|
serialize(indexEntry);
|
||||||
}
|
}
|
||||||
else if (binding instanceof ICPPNamespace) {
|
else if (binding instanceof ICPPNamespace) {
|
||||||
NamedEntry indexEntry = new NamedEntry(IIndex.NAMESPACE, entryKind, qualifiedName, 0, fileNumber);
|
NamedEntry indexEntry = new NamedEntry(IIndex.NAMESPACE, entryKind, qualifiedName, 0, fileNumber);
|
||||||
indexEntry.setNameOffset(fileLoc.getNodeOffset(), fileLoc.getNodeLength(), IIndex.OFFSET);
|
indexEntry.setNameOffset(fileLoc.getNodeOffset(), fileLoc.getNodeLength(), IIndex.OFFSET);
|
||||||
|
|
||||||
indexEntry.serialize(indexer.getOutput());
|
serialize(indexEntry);
|
||||||
}
|
}
|
||||||
else if (binding instanceof IEnumerator) {
|
else if (binding instanceof IEnumerator) {
|
||||||
NamedEntry indexEntry = new NamedEntry(IIndex.ENUMTOR, entryKind, qualifiedName, 0, fileNumber);
|
NamedEntry indexEntry = new NamedEntry(IIndex.ENUMTOR, entryKind, qualifiedName, 0, fileNumber);
|
||||||
indexEntry.setNameOffset(fileLoc.getNodeOffset(), fileLoc.getNodeLength(), IIndex.OFFSET);
|
indexEntry.setNameOffset(fileLoc.getNodeOffset(), fileLoc.getNodeLength(), IIndex.OFFSET);
|
||||||
|
|
||||||
indexEntry.serialize(indexer.getOutput());
|
serialize(indexEntry);
|
||||||
}
|
}
|
||||||
else if (binding instanceof IField) {
|
else if (binding instanceof IField) {
|
||||||
int modifiers = 0;
|
int modifiers = 0;
|
||||||
|
@ -253,7 +273,7 @@ public class CPPGenerateIndexVisitor extends CPPASTVisitor {
|
||||||
NamedEntry indexEntry = new NamedEntry(IIndex.FIELD, entryKind, qualifiedName, modifiers, fileNumber);
|
NamedEntry indexEntry = new NamedEntry(IIndex.FIELD, entryKind, qualifiedName, modifiers, fileNumber);
|
||||||
indexEntry.setNameOffset(fileLoc.getNodeOffset(), fileLoc.getNodeLength(), IIndex.OFFSET);
|
indexEntry.setNameOffset(fileLoc.getNodeOffset(), fileLoc.getNodeLength(), IIndex.OFFSET);
|
||||||
|
|
||||||
indexEntry.serialize(indexer.getOutput());
|
serialize(indexEntry);
|
||||||
}
|
}
|
||||||
else if (binding instanceof IVariable &&
|
else if (binding instanceof IVariable &&
|
||||||
!(binding instanceof IParameter)) {
|
!(binding instanceof IParameter)) {
|
||||||
|
@ -267,7 +287,7 @@ public class CPPGenerateIndexVisitor extends CPPASTVisitor {
|
||||||
TypeEntry indexEntry = new TypeEntry(IIndex.TYPE_VAR, entryKind, qualifiedName, modifiers, fileNumber);
|
TypeEntry indexEntry = new TypeEntry(IIndex.TYPE_VAR, entryKind, qualifiedName, modifiers, fileNumber);
|
||||||
indexEntry.setNameOffset(fileLoc.getNodeOffset(), fileLoc.getNodeLength(), IIndex.OFFSET);
|
indexEntry.setNameOffset(fileLoc.getNodeOffset(), fileLoc.getNodeLength(), IIndex.OFFSET);
|
||||||
|
|
||||||
indexEntry.serialize(indexer.getOutput());
|
serialize(indexEntry);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (binding instanceof ICPPMethod) {
|
else if (binding instanceof ICPPMethod) {
|
||||||
|
@ -280,7 +300,7 @@ public class CPPGenerateIndexVisitor extends CPPASTVisitor {
|
||||||
indexEntry.setSignature(IndexVisitorUtil.getParameters((IFunction) binding));
|
indexEntry.setSignature(IndexVisitorUtil.getParameters((IFunction) binding));
|
||||||
indexEntry.setReturnType(IndexVisitorUtil.getReturnType((IFunction) binding));
|
indexEntry.setReturnType(IndexVisitorUtil.getReturnType((IFunction) binding));
|
||||||
|
|
||||||
indexEntry.serialize(indexer.getOutput());
|
serialize(indexEntry);
|
||||||
// TODO In case we want to add friend method declarations to index
|
// TODO In case we want to add friend method declarations to index
|
||||||
// if (isFriendDeclaration(name, binding)) {
|
// if (isFriendDeclaration(name, binding)) {
|
||||||
// entryType = IndexerOutputWrapper.FRIEND;
|
// entryType = IndexerOutputWrapper.FRIEND;
|
||||||
|
@ -296,7 +316,7 @@ public class CPPGenerateIndexVisitor extends CPPASTVisitor {
|
||||||
indexEntry.setSignature(IndexVisitorUtil.getParameters((IFunction) binding));
|
indexEntry.setSignature(IndexVisitorUtil.getParameters((IFunction) binding));
|
||||||
indexEntry.setReturnType(IndexVisitorUtil.getReturnType((IFunction) binding));
|
indexEntry.setReturnType(IndexVisitorUtil.getReturnType((IFunction) binding));
|
||||||
|
|
||||||
indexEntry.serialize(indexer.getOutput());
|
serialize(indexEntry);
|
||||||
// TODO In case we want to add friend function declarations to index
|
// TODO In case we want to add friend function declarations to index
|
||||||
// if (isFriendDeclaration(name, binding)) {
|
// if (isFriendDeclaration(name, binding)) {
|
||||||
// entryType = IndexerOutputWrapper.FRIEND;
|
// entryType = IndexerOutputWrapper.FRIEND;
|
||||||
|
@ -312,16 +332,13 @@ public class CPPGenerateIndexVisitor extends CPPASTVisitor {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// if (entryType != null) {
|
}
|
||||||
// IndexerOutputWrapper.addIndexEntry(indexer.getOutput(),
|
|
||||||
// getFullyQualifiedName(binding),
|
/**
|
||||||
// entryType,
|
* @param indexEntry
|
||||||
// entryKind,
|
*/
|
||||||
// fileNumber,
|
private void serialize(IIndexEntry indexEntry) {
|
||||||
// loc.getNodeOffset(),
|
indexEntry.serialize(indexer.getOutput());
|
||||||
// loc.getNodeLength(),
|
|
||||||
// IIndex.OFFSET);
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -41,6 +41,7 @@ import org.eclipse.cdt.core.parser.ParseError;
|
||||||
import org.eclipse.cdt.core.parser.ParserLanguage;
|
import org.eclipse.cdt.core.parser.ParserLanguage;
|
||||||
import org.eclipse.cdt.internal.core.index.IIndex;
|
import org.eclipse.cdt.internal.core.index.IIndex;
|
||||||
import org.eclipse.cdt.internal.core.index.NamedEntry;
|
import org.eclipse.cdt.internal.core.index.NamedEntry;
|
||||||
|
import org.eclipse.cdt.internal.core.index.cindexstorage.IndexerOutput;
|
||||||
import org.eclipse.cdt.internal.core.index.impl.IndexDelta;
|
import org.eclipse.cdt.internal.core.index.impl.IndexDelta;
|
||||||
import org.eclipse.cdt.internal.core.index.sourceindexer.AbstractIndexer;
|
import org.eclipse.cdt.internal.core.index.sourceindexer.AbstractIndexer;
|
||||||
import org.eclipse.cdt.internal.core.index.sourceindexer.SourceIndexer;
|
import org.eclipse.cdt.internal.core.index.sourceindexer.SourceIndexer;
|
||||||
|
@ -59,6 +60,7 @@ import org.eclipse.core.runtime.Path;
|
||||||
public class DOMSourceIndexerRunner extends AbstractIndexer {
|
public class DOMSourceIndexerRunner extends AbstractIndexer {
|
||||||
|
|
||||||
private SourceIndexer indexer;
|
private SourceIndexer indexer;
|
||||||
|
|
||||||
// timing & errors
|
// timing & errors
|
||||||
static int totalParseTime = 0;
|
static int totalParseTime = 0;
|
||||||
static int totalVisitTime = 0;
|
static int totalVisitTime = 0;
|
||||||
|
@ -117,10 +119,6 @@ public class DOMSourceIndexerRunner extends AbstractIndexer {
|
||||||
if (AbstractIndexer.TIMING)
|
if (AbstractIndexer.TIMING)
|
||||||
parseTime = System.currentTimeMillis();
|
parseTime = System.currentTimeMillis();
|
||||||
|
|
||||||
processIncludeDirectives(tu.getDependencyTree());
|
|
||||||
processMacroDefinitions(tu.getMacroDefinitions());
|
|
||||||
processPreprocessorProblems(tu.getPreprocessorProblems());
|
|
||||||
|
|
||||||
ASTVisitor visitor = null;
|
ASTVisitor visitor = null;
|
||||||
if (language == ParserLanguage.CPP) {
|
if (language == ParserLanguage.CPP) {
|
||||||
visitor = new CPPGenerateIndexVisitor(this);
|
visitor = new CPPGenerateIndexVisitor(this);
|
||||||
|
@ -130,6 +128,10 @@ public class DOMSourceIndexerRunner extends AbstractIndexer {
|
||||||
|
|
||||||
tu.accept(visitor);
|
tu.accept(visitor);
|
||||||
|
|
||||||
|
processMacroDefinitions(tu.getMacroDefinitions());
|
||||||
|
processPreprocessorProblems(tu.getPreprocessorProblems());
|
||||||
|
// must be the last step in processing of a translation unit
|
||||||
|
processIncludeDirectives(tu.getDependencyTree());
|
||||||
}
|
}
|
||||||
catch (VirtualMachineError vmErr) {
|
catch (VirtualMachineError vmErr) {
|
||||||
error = vmErr.toString();
|
error = vmErr.toString();
|
||||||
|
@ -161,15 +163,17 @@ public class DOMSourceIndexerRunner extends AbstractIndexer {
|
||||||
}
|
}
|
||||||
errors.put(error, new Integer(((Integer) errors.get(error)).intValue()+1));
|
errors.put(error, new Integer(((Integer) errors.get(error)).intValue()+1));
|
||||||
}
|
}
|
||||||
System.out.println("DOM Indexer - Total Parse Time for " + resourceFile.getName() + ": " + (parseTime - startTime)); //$NON-NLS-1$ //$NON-NLS-2$
|
System.out.print("DOM Indexer - " + resourceFile.getName() + ": " + (parseTime - startTime)); //$NON-NLS-1$ //$NON-NLS-2$
|
||||||
System.out.println("DOM Indexer - Total Visit Time for " + resourceFile.getName() + ": " + (endTime - parseTime)); //$NON-NLS-1$ //$NON-NLS-2$
|
System.out.print("+" + (endTime - parseTime)); //$NON-NLS-1$ //$NON-NLS-2$
|
||||||
totalParseTime += parseTime - startTime;
|
totalParseTime += parseTime - startTime;
|
||||||
totalVisitTime += endTime - parseTime;
|
totalVisitTime += endTime - parseTime;
|
||||||
long currentTime = endTime - startTime;
|
long currentTime = endTime - startTime;
|
||||||
System.out.println("DOM Indexer - Total Index Time for " + resourceFile.getName() + ": " + currentTime); //$NON-NLS-1$ //$NON-NLS-2$
|
System.out.print("=" + currentTime); //$NON-NLS-1$ //$NON-NLS-2$
|
||||||
long tempTotaltime = indexer.getTotalIndexTime() + currentTime;
|
long tempTotaltime = indexer.getTotalIndexTime() + currentTime;
|
||||||
indexer.setTotalIndexTime(tempTotaltime);
|
indexer.setTotalIndexTime(tempTotaltime);
|
||||||
System.out.println("DOM Indexer - Overall Index Time: " + tempTotaltime + "(" + totalParseTime + ", " + totalVisitTime + ") " + errorCount + " errors"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
|
System.out.println(" \t\tOverall " + tempTotaltime + "=" + totalParseTime + "+" + totalVisitTime + " " + errorCount + " errors "); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$
|
||||||
|
System.out.println( "Attempted Entries " + IndexerOutput.entryCount + " Trimed " + SourceIndexer.trimed + " Added " + SourceIndexer.added); //$NON-NLS-1$//$NON-NLS-2$ //$NON-NLS-3$
|
||||||
|
|
||||||
System.out.flush();
|
System.out.flush();
|
||||||
}
|
}
|
||||||
if (AbstractIndexer.VERBOSE){
|
if (AbstractIndexer.VERBOSE){
|
||||||
|
@ -243,7 +247,7 @@ public class DOMSourceIndexerRunner extends AbstractIndexer {
|
||||||
IASTInclusionNode inclusion = inclusions[i];
|
IASTInclusionNode inclusion = inclusions[i];
|
||||||
// Quick check to see if the name is in an already indexed external header file
|
// Quick check to see if the name is in an already indexed external header file
|
||||||
if (IndexEncoderUtil.nodeInVisitedExternalHeader(inclusion.getIncludeDirective(), getIndexer()))
|
if (IndexEncoderUtil.nodeInVisitedExternalHeader(inclusion.getIncludeDirective(), getIndexer()))
|
||||||
return;
|
continue;
|
||||||
|
|
||||||
String include = inclusion.getIncludeDirective().getPath();
|
String include = inclusion.getIncludeDirective().getPath();
|
||||||
|
|
||||||
|
@ -298,7 +302,7 @@ public class DOMSourceIndexerRunner extends AbstractIndexer {
|
||||||
private void processPreprocessorProblems(IASTProblem[] preprocessorProblems) {
|
private void processPreprocessorProblems(IASTProblem[] preprocessorProblems) {
|
||||||
for (int i = 0; i < preprocessorProblems.length; i++) {
|
for (int i = 0; i < preprocessorProblems.length; i++) {
|
||||||
IASTProblem problem = preprocessorProblems[i];
|
IASTProblem problem = preprocessorProblems[i];
|
||||||
// Quick check to see if the macro is in an already indexed external header file
|
// Quick check to see if the problem is in an already indexed external header file
|
||||||
if (IndexEncoderUtil.nodeInVisitedExternalHeader(problem, getIndexer()))
|
if (IndexEncoderUtil.nodeInVisitedExternalHeader(problem, getIndexer()))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
|
|
@ -86,7 +86,7 @@ public class IndexEncoderUtil {
|
||||||
IPath filePath = new Path(fileName);
|
IPath filePath = new Path(fileName);
|
||||||
IPath projectPath = indexer.getProject().getFullPath();
|
IPath projectPath = indexer.getProject().getFullPath();
|
||||||
|
|
||||||
return (CCorePlugin.getWorkspace().getRoot().getFileForLocation(new Path(fileName)) == null) &&
|
return (CCorePlugin.getWorkspace().getRoot().getFileForLocation(filePath) == null) &&
|
||||||
indexer.haveEncounteredHeader(projectPath, filePath, false);
|
indexer.haveEncounteredHeader(projectPath, filePath, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -44,77 +44,6 @@ import org.eclipse.cdt.internal.core.index.IIndex;
|
||||||
public class IndexVisitorUtil {
|
public class IndexVisitorUtil {
|
||||||
private IndexVisitorUtil() {}
|
private IndexVisitorUtil() {}
|
||||||
|
|
||||||
/**
|
|
||||||
* @param declSpec
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
// static int getModifiers(IASTDeclSpecifier declSpec) {
|
|
||||||
// int modifiers = 0;
|
|
||||||
// if (declSpec.isConst()) {
|
|
||||||
// modifiers |= IIndex.constQualifier;
|
|
||||||
// }
|
|
||||||
// else if (declSpec.isVolatile()) {
|
|
||||||
// modifiers |= IIndex.volatileQualifier;
|
|
||||||
// }
|
|
||||||
// if (declSpec.isInline()) {
|
|
||||||
// modifiers |= IIndex.inlineSpecifier;
|
|
||||||
// }
|
|
||||||
// if (declSpec instanceof ICPPASTDeclSpecifier) {
|
|
||||||
// ICPPASTDeclSpecifier cppDeclSpec = (ICPPASTDeclSpecifier) declSpec;
|
|
||||||
// if (cppDeclSpec.isExplicit()) {
|
|
||||||
// modifiers |= IIndex.explicitSpecifier;
|
|
||||||
// }
|
|
||||||
// if (cppDeclSpec.isVirtual()) {
|
|
||||||
// modifiers |= IIndex.virtualSpecifier;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// return modifiers;
|
|
||||||
// }
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param variableBinding
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
// static int getModifiers(IVariable variableBinding) {
|
|
||||||
// int modifiers = 0;
|
|
||||||
// try {
|
|
||||||
// if (variableBinding.isAuto()) {
|
|
||||||
// modifiers |= IIndex.autoSpecifier;
|
|
||||||
// }
|
|
||||||
// else if (variableBinding.isExtern()) {
|
|
||||||
// modifiers |= IIndex.externSpecifier;
|
|
||||||
// }
|
|
||||||
// else if (variableBinding.isRegister()) {
|
|
||||||
// modifiers |= IIndex.registerSpecifier;
|
|
||||||
// }
|
|
||||||
// else if (variableBinding.isStatic()) {
|
|
||||||
// modifiers |= IIndex.staticSpecifier;
|
|
||||||
// }
|
|
||||||
// if (variableBinding instanceof ICPPVariable) {
|
|
||||||
// ICPPVariable cppVariable = (ICPPVariable) variableBinding;
|
|
||||||
// if (cppVariable.isMutable()) {
|
|
||||||
// modifiers |= IIndex.mutableSpecifier;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// if (variableBinding instanceof ICPPMember) {
|
|
||||||
// ICPPMember member = (ICPPMember) variableBinding;
|
|
||||||
// int vis = member.getVisibility();
|
|
||||||
// if (vis == ICPPMember.v_public) {
|
|
||||||
// modifiers |= IIndex.publicAccessSpecifier;
|
|
||||||
// }
|
|
||||||
// else if (vis == ICPPMember.v_private) {
|
|
||||||
// modifiers |= IIndex.privateAccessSpecifier;
|
|
||||||
// }
|
|
||||||
// else if (vis == ICPPMember.v_protected) {
|
|
||||||
// modifiers |= IIndex.protectedAccessSpecifier;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// catch (DOMException e) {
|
|
||||||
// }
|
|
||||||
// return modifiers;
|
|
||||||
// }
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param name
|
* @param name
|
||||||
* @param functionBinding
|
* @param functionBinding
|
||||||
|
|
|
@ -157,6 +157,9 @@ public class SourceIndexer extends AbstractCExtension implements ICDTIndexer {
|
||||||
*
|
*
|
||||||
* Warning: Does not check whether index is consistent (not being used)
|
* Warning: Does not check whether index is consistent (not being used)
|
||||||
*/
|
*/
|
||||||
|
public static int trimed = 0;
|
||||||
|
public static int added = 0;
|
||||||
|
|
||||||
public synchronized boolean haveEncounteredHeader(IPath projectPath, IPath filePath, boolean add) {
|
public synchronized boolean haveEncounteredHeader(IPath projectPath, IPath filePath, boolean add) {
|
||||||
SimpleLookupTable headerTable = indexStorage.getEncounteredHeaders();
|
SimpleLookupTable headerTable = indexStorage.getEncounteredHeaders();
|
||||||
|
|
||||||
|
@ -168,11 +171,14 @@ public class SourceIndexer extends AbstractCExtension implements ICDTIndexer {
|
||||||
headerTable.put(projectPath, headers);
|
headerTable.put(projectPath, headers);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (headers.containsKey(filePath.toOSString()))
|
if (headers.containsKey(filePath.toOSString())) {
|
||||||
|
trimed++;
|
||||||
return true;
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
if (add) {
|
if (add) {
|
||||||
headers.put(filePath.toOSString());
|
headers.put(filePath.toOSString());
|
||||||
|
added++;
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
|
Loading…
Add table
Reference in a new issue