mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
Added offset and length parameters for index entries.
Refactoring of AbstractIndexer. Moved old parser specific stuff to the appropriate subclass.
This commit is contained in:
parent
cfbadc7405
commit
d7c2d4834e
9 changed files with 891 additions and 775 deletions
|
@ -1,3 +1,16 @@
|
||||||
|
2005-04-08 Vladimir Hirsl
|
||||||
|
Added offset and length parameters for index entries.
|
||||||
|
Refactoring of AbstractIndexer. Moved old parser specific stuff to the appropriate subclass.
|
||||||
|
|
||||||
|
* index/org/eclipse/cdt/internal/core/index/ctagsindexer/CTagsIndexerRunner.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/sourceindexer/AbstractIndexer.java
|
||||||
|
* index/org/eclipse/cdt/internal/core/index/sourceindexer/SourceIndexerRequestor.java
|
||||||
|
* index/org/eclipse/cdt/internal/core/index/sourceindexer/SourceIndexerRunner.java
|
||||||
|
|
||||||
2005-04-05 Vladimir Hirsl
|
2005-04-05 Vladimir Hirsl
|
||||||
Improved filtering of indexer problem markers
|
Improved filtering of indexer problem markers
|
||||||
|
|
||||||
|
|
|
@ -125,9 +125,9 @@ public class CTagsIndexerRunner extends AbstractIndexer {
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.cdt.internal.core.index.sourceindexer.AbstractIndexer#addMarkers(org.eclipse.core.resources.IFile, org.eclipse.core.resources.IFile, java.lang.Object)
|
* @see org.eclipse.cdt.internal.core.index.sourceindexer.AbstractIndexer#addMarkers(org.eclipse.core.resources.IFile, org.eclipse.core.resources.IFile, java.lang.Object, java.lang.Object)
|
||||||
*/
|
*/
|
||||||
protected void addMarkers(IFile tempFile, IFile originator, Object problem) {
|
protected void addMarkers(IFile tempFile, IFile originator, Object problem, Object location) {
|
||||||
// TODO Auto-generated method stub
|
// TODO Auto-generated method stub
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,7 +19,7 @@ import org.eclipse.cdt.core.dom.ast.DOMException;
|
||||||
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;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTNodeLocation;
|
import org.eclipse.cdt.core.dom.ast.IASTNode;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTProblem;
|
import org.eclipse.cdt.core.dom.ast.IASTProblem;
|
||||||
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.ICompositeType;
|
||||||
|
@ -33,6 +33,7 @@ import org.eclipse.cdt.core.dom.ast.ITypedef;
|
||||||
import org.eclipse.cdt.core.dom.ast.IVariable;
|
import org.eclipse.cdt.core.dom.ast.IVariable;
|
||||||
import org.eclipse.cdt.core.dom.ast.c.CASTVisitor;
|
import org.eclipse.cdt.core.dom.ast.c.CASTVisitor;
|
||||||
import org.eclipse.cdt.core.search.ICSearchConstants;
|
import org.eclipse.cdt.core.search.ICSearchConstants;
|
||||||
|
import org.eclipse.cdt.internal.core.index.cindexstorage.ICIndexStorageConstants;
|
||||||
import org.eclipse.cdt.internal.core.search.indexing.IIndexEncodingConstants;
|
import org.eclipse.cdt.internal.core.search.indexing.IIndexEncodingConstants;
|
||||||
import org.eclipse.cdt.internal.core.search.indexing.IIndexEncodingConstants.EntryType;
|
import org.eclipse.cdt.internal.core.search.indexing.IIndexEncodingConstants.EntryType;
|
||||||
import org.eclipse.core.resources.IFile;
|
import org.eclipse.core.resources.IFile;
|
||||||
|
@ -70,15 +71,11 @@ public class CGenerateIndexVisitor extends CASTVisitor {
|
||||||
* @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) {
|
||||||
//Check to see if this reference actually occurs in the file being indexed
|
|
||||||
//or if it occurs in another file
|
|
||||||
int indexFlag = IndexEncoderUtil.calculateIndexFlags(indexer, name);
|
|
||||||
|
|
||||||
// qualified names are going to be handled segment by segment
|
// qualified names are going to be handled segment by segment
|
||||||
// if (name instanceof ICPPASTQualifiedName) return PROCESS_CONTINUE;
|
// if (name instanceof ICPPASTQualifiedName) return PROCESS_CONTINUE;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
processName(name, indexFlag);
|
processName(name);
|
||||||
}
|
}
|
||||||
catch (DOMException e) {
|
catch (DOMException e) {
|
||||||
// TODO Auto-generated catch block
|
// TODO Auto-generated catch block
|
||||||
|
@ -92,60 +89,63 @@ public class CGenerateIndexVisitor extends CASTVisitor {
|
||||||
*/
|
*/
|
||||||
public int visit(IASTProblem problem) {
|
public int visit(IASTProblem problem) {
|
||||||
if (indexer.areProblemMarkersEnabled() && indexer.shouldRecordProblem(problem)){
|
if (indexer.areProblemMarkersEnabled() && indexer.shouldRecordProblem(problem)){
|
||||||
IFile tempFile = resourceFile;
|
// Get the location
|
||||||
|
IASTFileLocation loc = IndexEncoderUtil.getFileLocation(problem);
|
||||||
//If we are in an include file, get the include file
|
processProblem(problem, loc);
|
||||||
IASTNodeLocation[] locs = problem.getNodeLocations();
|
|
||||||
if (locs[0] instanceof IASTFileLocation) {
|
|
||||||
IASTFileLocation fileLoc = (IASTFileLocation) locs[0];
|
|
||||||
String fileName = fileLoc.getFileName();
|
|
||||||
tempFile = CCorePlugin.getWorkspace().getRoot().getFileForLocation(new Path(fileName));
|
|
||||||
}
|
|
||||||
|
|
||||||
if( tempFile != null ){
|
|
||||||
indexer.generateMarkerProblem(tempFile, resourceFile, problem);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return super.visit(problem);
|
return super.visit(problem);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param name
|
* @param name
|
||||||
* @param indexFlag
|
|
||||||
* @throws DOMException
|
* @throws DOMException
|
||||||
*/
|
*/
|
||||||
private void processName(IASTName name, int indexFlag) throws DOMException {
|
private void processName(IASTName name) throws DOMException {
|
||||||
IBinding binding = name.resolveBinding();
|
IBinding binding = name.resolveBinding();
|
||||||
// check for IProblemBinding
|
// check for IProblemBinding
|
||||||
if (binding instanceof IProblemBinding) {
|
if (binding instanceof IProblemBinding) {
|
||||||
IProblemBinding problem = (IProblemBinding) binding;
|
IProblemBinding problem = (IProblemBinding) binding;
|
||||||
if (indexer.areProblemMarkersEnabled() && indexer.shouldRecordProblem(problem)){
|
if (indexer.areProblemMarkersEnabled() && indexer.shouldRecordProblem(problem)){
|
||||||
IFile tempFile = resourceFile;
|
// Get the location
|
||||||
|
IASTFileLocation loc = IndexEncoderUtil.getFileLocation(name);
|
||||||
//If we are in an include file, get the include file
|
processProblem(name, loc);
|
||||||
IASTNodeLocation[] locs = name.getNodeLocations();
|
|
||||||
if (locs[0] instanceof IASTFileLocation) {
|
|
||||||
IASTFileLocation fileLoc = (IASTFileLocation) locs[0];
|
|
||||||
String fileName = fileLoc.getFileName();
|
|
||||||
tempFile = CCorePlugin.getWorkspace().getRoot().getFileForLocation(new Path(fileName));
|
|
||||||
}
|
|
||||||
|
|
||||||
if( tempFile != null ){
|
|
||||||
indexer.generateMarkerProblem(tempFile, resourceFile, problem);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
processNameBinding(name, binding, indexFlag);
|
// Get the location
|
||||||
|
IASTFileLocation loc = IndexEncoderUtil.getFileLocation(name);
|
||||||
|
if (loc != null) {
|
||||||
|
//Check to see if this reference actually occurs in the file being indexed
|
||||||
|
//or if it occurs in another file
|
||||||
|
int indexFlag = IndexEncoderUtil.calculateIndexFlags(indexer, loc);
|
||||||
|
|
||||||
|
processNameBinding(name, binding, loc, indexFlag);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param name
|
||||||
|
*/
|
||||||
|
private void processProblem(IASTNode node, IASTFileLocation loc) {
|
||||||
|
IFile tempFile = resourceFile;
|
||||||
|
//If we are in an include file, get the include file
|
||||||
|
if (loc != null) {
|
||||||
|
String fileName = loc.getFileName();
|
||||||
|
tempFile = CCorePlugin.getWorkspace().getRoot().getFileForLocation(new Path(fileName));
|
||||||
|
if (tempFile != null) {
|
||||||
|
indexer.generateMarkerProblem(tempFile, resourceFile, node, loc);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param name
|
* @param name
|
||||||
* @param binding
|
* @param binding
|
||||||
|
* @param loc
|
||||||
* @param indexFlag
|
* @param indexFlag
|
||||||
* @throws DOMException
|
* @throws DOMException
|
||||||
*/
|
*/
|
||||||
private void processNameBinding(IASTName name, IBinding binding, int fileNumber) throws DOMException {
|
private void processNameBinding(IASTName name, IBinding binding, IASTFileLocation loc, int fileNumber) throws DOMException {
|
||||||
// determine type
|
// determine type
|
||||||
EntryType entryType = null;
|
EntryType entryType = null;
|
||||||
if (binding instanceof ICompositeType) {
|
if (binding instanceof ICompositeType) {
|
||||||
|
@ -183,13 +183,19 @@ public class CGenerateIndexVisitor extends CASTVisitor {
|
||||||
indexer.getOutput().addRef(fileNumber,IndexEncoderUtil.encodeEntry(
|
indexer.getOutput().addRef(fileNumber,IndexEncoderUtil.encodeEntry(
|
||||||
getFullyQualifiedName(name),
|
getFullyQualifiedName(name),
|
||||||
entryType,
|
entryType,
|
||||||
ICSearchConstants.DECLARATIONS));
|
ICSearchConstants.DECLARATIONS),
|
||||||
|
loc.getNodeOffset(),
|
||||||
|
loc.getNodeLength(),
|
||||||
|
ICIndexStorageConstants.OFFSET);
|
||||||
}
|
}
|
||||||
else if (name.isReference()) {
|
else if (name.isReference()) {
|
||||||
indexer.getOutput().addRef(fileNumber, IndexEncoderUtil.encodeEntry(
|
indexer.getOutput().addRef(fileNumber, IndexEncoderUtil.encodeEntry(
|
||||||
getFullyQualifiedName(name),
|
getFullyQualifiedName(name),
|
||||||
entryType,
|
entryType,
|
||||||
ICSearchConstants.REFERENCES));
|
ICSearchConstants.REFERENCES),
|
||||||
|
loc.getNodeOffset(),
|
||||||
|
loc.getNodeLength(),
|
||||||
|
ICIndexStorageConstants.OFFSET);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,7 +16,7 @@ import org.eclipse.cdt.core.dom.ast.DOMException;
|
||||||
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;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTNodeLocation;
|
import org.eclipse.cdt.core.dom.ast.IASTNode;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTProblem;
|
import org.eclipse.cdt.core.dom.ast.IASTProblem;
|
||||||
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.ICompositeType;
|
||||||
|
@ -30,16 +30,16 @@ import org.eclipse.cdt.core.dom.ast.ITypedef;
|
||||||
import org.eclipse.cdt.core.dom.ast.IVariable;
|
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.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.ICPPBinding;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPBinding;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPDelegate;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPDelegate;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPMethod;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPMethod;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPNamespace;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPNamespace;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPUsingDeclaration;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPUsingDeclaration;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCompositeTypeSpecifier.ICPPASTBaseSpecifier;
|
||||||
import org.eclipse.cdt.core.search.ICSearchConstants;
|
import org.eclipse.cdt.core.search.ICSearchConstants;
|
||||||
import org.eclipse.cdt.core.search.ICSearchConstants.LimitTo;
|
import org.eclipse.cdt.core.search.ICSearchConstants.LimitTo;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPBaseClause.CPPBaseProblem;
|
import org.eclipse.cdt.internal.core.index.cindexstorage.ICIndexStorageConstants;
|
||||||
import org.eclipse.cdt.internal.core.search.indexing.IIndexEncodingConstants;
|
import org.eclipse.cdt.internal.core.search.indexing.IIndexEncodingConstants;
|
||||||
import org.eclipse.cdt.internal.core.search.indexing.IIndexEncodingConstants.EntryType;
|
import org.eclipse.cdt.internal.core.search.indexing.IIndexEncodingConstants.EntryType;
|
||||||
import org.eclipse.core.resources.IFile;
|
import org.eclipse.core.resources.IFile;
|
||||||
|
@ -78,15 +78,11 @@ public class CPPGenerateIndexVisitor extends CPPASTVisitor {
|
||||||
* @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) {
|
||||||
//Check to see if this reference actually occurs in the file being indexed
|
|
||||||
//or if it occurs in another file
|
|
||||||
int indexFlag = IndexEncoderUtil.calculateIndexFlags(indexer, name);
|
|
||||||
|
|
||||||
// qualified names are going to be handled segment by segment
|
// qualified names are going to be handled segment by segment
|
||||||
if (name instanceof ICPPASTQualifiedName) return PROCESS_CONTINUE;
|
if (name instanceof ICPPASTQualifiedName) return PROCESS_CONTINUE;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
processName(name, indexFlag);
|
processName(name);
|
||||||
}
|
}
|
||||||
catch (DOMException e) {
|
catch (DOMException e) {
|
||||||
// TODO Auto-generated catch block
|
// TODO Auto-generated catch block
|
||||||
|
@ -99,72 +95,66 @@ public class CPPGenerateIndexVisitor extends CPPASTVisitor {
|
||||||
* @see org.eclipse.cdt.core.dom.ast.ASTVisitor#visit(org.eclipse.cdt.core.dom.ast.IASTProblem)
|
* @see org.eclipse.cdt.core.dom.ast.ASTVisitor#visit(org.eclipse.cdt.core.dom.ast.IASTProblem)
|
||||||
*/
|
*/
|
||||||
public int visit(IASTProblem problem) {
|
public int visit(IASTProblem problem) {
|
||||||
if (indexer.areProblemMarkersEnabled() && indexer.shouldRecordProblem(problem)){
|
if (indexer.areProblemMarkersEnabled() && indexer.shouldRecordProblem(problem)) {
|
||||||
IFile tempFile = resourceFile;
|
// Get the location
|
||||||
|
IASTFileLocation loc = IndexEncoderUtil.getFileLocation(problem);
|
||||||
//If we are in an include file, get the include file
|
processProblem(problem, loc);
|
||||||
IASTNodeLocation[] locs = problem.getNodeLocations();
|
|
||||||
if (locs[0] instanceof IASTFileLocation) {
|
|
||||||
IASTFileLocation fileLoc = (IASTFileLocation) locs[0];
|
|
||||||
String fileName = fileLoc.getFileName();
|
|
||||||
tempFile = CCorePlugin.getWorkspace().getRoot().getFileForLocation(new Path(fileName));
|
|
||||||
}
|
|
||||||
|
|
||||||
if( tempFile != null ){
|
|
||||||
indexer.generateMarkerProblem(tempFile, resourceFile, problem);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return super.visit(problem);
|
return super.visit(problem);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param name
|
* @param name
|
||||||
* @param indexFlag
|
|
||||||
* @throws DOMException
|
* @throws DOMException
|
||||||
*/
|
*/
|
||||||
private void processName(IASTName name, int indexFlag) throws DOMException {
|
private void processName(IASTName name) throws DOMException {
|
||||||
IBinding binding = name.resolveBinding();
|
IBinding binding = name.resolveBinding();
|
||||||
// check for IProblemBinding
|
// check for IProblemBinding
|
||||||
if (binding instanceof IProblemBinding) {
|
if (binding instanceof IProblemBinding) {
|
||||||
IProblemBinding problem = (IProblemBinding) binding;
|
IProblemBinding problem = (IProblemBinding) binding;
|
||||||
if (indexer.areProblemMarkersEnabled() && indexer.shouldRecordProblem(problem)){
|
if (indexer.areProblemMarkersEnabled() && indexer.shouldRecordProblem(problem)){
|
||||||
IFile tempFile = resourceFile;
|
// Get the location
|
||||||
|
IASTFileLocation loc = IndexEncoderUtil.getFileLocation(name);
|
||||||
//If we are in an include file, get the include file
|
processProblem(name, loc);
|
||||||
IASTNodeLocation[] locs = name.getNodeLocations();
|
|
||||||
if (locs[0] instanceof IASTFileLocation) {
|
|
||||||
IASTFileLocation fileLoc = (IASTFileLocation) locs[0];
|
|
||||||
String fileName = fileLoc.getFileName();
|
|
||||||
tempFile = CCorePlugin.getWorkspace().getRoot().getFileForLocation(new Path(fileName));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (tempFile != null) {
|
|
||||||
indexer.generateMarkerProblem(tempFile, resourceFile, name);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
processNameBinding(name, binding, indexFlag, null); // function will determine limitTo
|
// Get the location
|
||||||
|
IASTFileLocation loc = IndexEncoderUtil.getFileLocation(name);
|
||||||
|
if (loc != null) {
|
||||||
|
//Check to see if this reference actually occurs in the file being indexed
|
||||||
|
//or if it occurs in another file
|
||||||
|
int indexFlag = IndexEncoderUtil.calculateIndexFlags(indexer, loc);
|
||||||
|
|
||||||
|
processNameBinding(name, binding, loc, indexFlag, null); // function will determine limitTo
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param name
|
* @param name
|
||||||
* @return
|
|
||||||
*/
|
*/
|
||||||
private char[][] createEnumeratorFullyQualifiedName(IASTName name) {
|
private void processProblem(IASTNode node, IASTFileLocation loc) {
|
||||||
// TODO Auto-generated method stub
|
IFile tempFile = resourceFile;
|
||||||
return null;
|
//If we are in an include file, get the include file
|
||||||
|
if (loc != null) {
|
||||||
|
String fileName = loc.getFileName();
|
||||||
|
tempFile = CCorePlugin.getWorkspace().getRoot().getFileForLocation(new Path(fileName));
|
||||||
|
if (tempFile != null) {
|
||||||
|
indexer.generateMarkerProblem(tempFile, resourceFile, node, loc);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param name
|
* @param name
|
||||||
* @param binding
|
* @param binding
|
||||||
|
* @param loc
|
||||||
* @param indexFlag
|
* @param indexFlag
|
||||||
* @param limitTo
|
* @param limitTo
|
||||||
* @throws DOMException
|
* @throws DOMException
|
||||||
*/
|
*/
|
||||||
private void processNameBinding(IASTName name, IBinding binding, int fileNumber, LimitTo limitTo) throws DOMException {
|
private void processNameBinding(IASTName name, IBinding binding, IASTFileLocation loc, int fileNumber, LimitTo limitTo) throws DOMException {
|
||||||
// determine LimitTo
|
// determine LimitTo
|
||||||
if (limitTo == null) {
|
if (limitTo == null) {
|
||||||
if (name.isDeclaration()) {
|
if (name.isDeclaration()) {
|
||||||
|
@ -181,7 +171,8 @@ public class CPPGenerateIndexVisitor extends CPPASTVisitor {
|
||||||
// determine type
|
// determine type
|
||||||
EntryType entryType = null;
|
EntryType entryType = null;
|
||||||
if (binding instanceof ICompositeType) {
|
if (binding instanceof ICompositeType) {
|
||||||
int compositeKey = ((ICompositeType) binding).getKey();
|
ICompositeType compBinding = (ICompositeType) binding;
|
||||||
|
int compositeKey = compBinding.getKey();
|
||||||
ASTNodeProperty prop = name.getPropertyInParent();
|
ASTNodeProperty prop = name.getPropertyInParent();
|
||||||
switch (compositeKey) {
|
switch (compositeKey) {
|
||||||
case ICPPClassType.k_class:
|
case ICPPClassType.k_class:
|
||||||
|
@ -200,6 +191,7 @@ public class CPPGenerateIndexVisitor extends CPPASTVisitor {
|
||||||
entryType = IIndexEncodingConstants.FWD_UNION;
|
entryType = IIndexEncodingConstants.FWD_UNION;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
addDerivedAndFriendDeclaration(name, compBinding, loc, fileNumber);
|
||||||
}
|
}
|
||||||
else if (binding instanceof IEnumeration)
|
else if (binding instanceof IEnumeration)
|
||||||
entryType = IIndexEncodingConstants.ENUM;
|
entryType = IIndexEncodingConstants.ENUM;
|
||||||
|
@ -216,14 +208,17 @@ public class CPPGenerateIndexVisitor extends CPPASTVisitor {
|
||||||
entryType = IIndexEncodingConstants.VAR;
|
entryType = IIndexEncodingConstants.VAR;
|
||||||
else if (binding instanceof ICPPMethod)
|
else if (binding instanceof ICPPMethod)
|
||||||
entryType = IIndexEncodingConstants.METHOD;
|
entryType = IIndexEncodingConstants.METHOD;
|
||||||
else if (binding instanceof IFunction)
|
else if (binding instanceof IFunction) {
|
||||||
entryType = IIndexEncodingConstants.FUNCTION;
|
entryType = IIndexEncodingConstants.FUNCTION;
|
||||||
|
// TODO In case we want to add friend function declarations to index
|
||||||
|
// addDerivedAndFriendDeclaration(name, binding, loc, fileNumber);
|
||||||
|
}
|
||||||
else if (binding instanceof ICPPUsingDeclaration) {
|
else if (binding instanceof ICPPUsingDeclaration) {
|
||||||
ICPPDelegate[] delegates = ((ICPPUsingDeclaration)binding).getDelegates();
|
ICPPDelegate[] delegates = ((ICPPUsingDeclaration)binding).getDelegates();
|
||||||
for (int i = 0; i < delegates.length; i++) {
|
for (int i = 0; i < delegates.length; i++) {
|
||||||
IBinding orig = delegates[i].getBinding();
|
IBinding orig = delegates[i].getBinding();
|
||||||
processNameBinding(name, orig, fileNumber, ICSearchConstants.REFERENCES); // reference to the original binding
|
processNameBinding(name, orig, loc, fileNumber, ICSearchConstants.REFERENCES); // reference to the original binding
|
||||||
processNameBinding(name, delegates[i], fileNumber, ICSearchConstants.DECLARATIONS); // declaration of the new name
|
processNameBinding(name, delegates[i], loc, fileNumber, ICSearchConstants.DECLARATIONS); // declaration of the new name
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -232,38 +227,71 @@ public class CPPGenerateIndexVisitor extends CPPASTVisitor {
|
||||||
indexer.getOutput().addRef(fileNumber, IndexEncoderUtil.encodeEntry(
|
indexer.getOutput().addRef(fileNumber, IndexEncoderUtil.encodeEntry(
|
||||||
getFullyQualifiedName(binding),
|
getFullyQualifiedName(binding),
|
||||||
entryType,
|
entryType,
|
||||||
limitTo));
|
limitTo),
|
||||||
|
loc.getNodeOffset(),
|
||||||
|
loc.getNodeLength(),
|
||||||
|
ICIndexStorageConstants.OFFSET);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// add base classes and friends
|
/**
|
||||||
if (binding instanceof ICPPClassType &&
|
* @param name
|
||||||
limitTo.equals(ICSearchConstants.DECLARATIONS) &&
|
* @param fileNumber
|
||||||
(IIndexEncodingConstants.CLASS.equals(entryType) ||
|
* @param loc
|
||||||
IIndexEncodingConstants.STRUCT.equals(entryType))) {
|
* @param compBinding
|
||||||
ICPPClassType classBinding = (ICPPClassType) binding;
|
* @throws DOMException
|
||||||
//Get base clauses
|
*/
|
||||||
ICPPBase[] baseClauses = classBinding.getBases();
|
private void addDerivedAndFriendDeclaration(IASTName name, IBinding binding, IASTFileLocation loc, int fileNumber) throws DOMException {
|
||||||
for (int i = 0; i < baseClauses.length; ++i) {
|
ASTNodeProperty prop = name.getPropertyInParent();
|
||||||
if (!(baseClauses[i] instanceof CPPBaseProblem)) {
|
if (binding instanceof ICompositeType) {
|
||||||
ICompositeType baseClass = (ICompositeType) ((ICPPBase)baseClauses[i]).getBaseClass();
|
ICompositeType compBinding = (ICompositeType) binding;
|
||||||
|
int compositeKey = compBinding.getKey();
|
||||||
|
if (compositeKey == ICPPClassType.k_class ||
|
||||||
|
compositeKey == ICompositeType.k_struct) {
|
||||||
|
if (prop == ICPPASTBaseSpecifier.NAME) {
|
||||||
|
// base class
|
||||||
indexer.getOutput().addRef(fileNumber, IndexEncoderUtil.encodeEntry(
|
indexer.getOutput().addRef(fileNumber, IndexEncoderUtil.encodeEntry(
|
||||||
getFullyQualifiedName(baseClass),
|
getFullyQualifiedName(binding),
|
||||||
IIndexEncodingConstants.DERIVED,
|
IIndexEncodingConstants.DERIVED,
|
||||||
ICSearchConstants.DECLARATIONS));
|
ICSearchConstants.DECLARATIONS),
|
||||||
|
loc.getNodeOffset(),
|
||||||
|
loc.getNodeLength(),
|
||||||
|
ICIndexStorageConstants.OFFSET);
|
||||||
}
|
}
|
||||||
}
|
else if (prop == IASTElaboratedTypeSpecifier.TYPE_NAME) {
|
||||||
//Get friends
|
// friend
|
||||||
IBinding[] friendClauses = classBinding.getFriends();
|
|
||||||
for (int i = 0; i < friendClauses.length; ++i) {
|
|
||||||
IBinding friendClause = friendClauses[i];
|
|
||||||
if (friendClause instanceof ICompositeType) {
|
|
||||||
indexer.getOutput().addRef(fileNumber, IndexEncoderUtil.encodeEntry(
|
indexer.getOutput().addRef(fileNumber, IndexEncoderUtil.encodeEntry(
|
||||||
getFullyQualifiedName(friendClause),
|
getFullyQualifiedName(binding),
|
||||||
IIndexEncodingConstants.FRIEND,
|
IIndexEncodingConstants.FRIEND,
|
||||||
ICSearchConstants.DECLARATIONS));
|
ICSearchConstants.DECLARATIONS),
|
||||||
|
loc.getNodeOffset(),
|
||||||
|
loc.getNodeLength(),
|
||||||
|
ICIndexStorageConstants.OFFSET);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// TODO In case we want to add friend function declarations to index
|
||||||
|
// else if (binding instanceof IFunction) {
|
||||||
|
// IFunction funBinding = (IFunction) binding;
|
||||||
|
// if (prop == IASTFunctionDeclarator.DECLARATOR_NAME) {
|
||||||
|
// IASTFunctionDeclarator fDecl = (IASTFunctionDeclarator) name.getParent();
|
||||||
|
// IASTNode fDeclParent = fDecl.getParent();
|
||||||
|
// if (fDeclParent instanceof IASTSimpleDeclaration) {
|
||||||
|
// IASTSimpleDeclaration sDecl = (IASTSimpleDeclaration) fDeclParent;
|
||||||
|
// IASTDeclSpecifier declSpec = sDecl.getDeclSpecifier();
|
||||||
|
// if (declSpec instanceof ICPPASTSimpleDeclSpecifier) {
|
||||||
|
// ICPPASTSimpleDeclSpecifier fDeclSpec = (ICPPASTSimpleDeclSpecifier) declSpec;
|
||||||
|
// if (fDeclSpec.isFriend()) {
|
||||||
|
// // friend
|
||||||
|
// indexer.getOutput().addRef(fileNumber, IndexEncoderUtil.encodeEntry(
|
||||||
|
// getFullyQualifiedName(binding),
|
||||||
|
// IIndexEncodingConstants.FRIEND,
|
||||||
|
// ICSearchConstants.DECLARATIONS));
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -12,27 +12,31 @@ package org.eclipse.cdt.internal.core.index.domsourceindexer;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.core.CCorePlugin;
|
||||||
import org.eclipse.cdt.core.ICLogConstants;
|
import org.eclipse.cdt.core.ICLogConstants;
|
||||||
import org.eclipse.cdt.core.dom.CDOM;
|
import org.eclipse.cdt.core.dom.CDOM;
|
||||||
import org.eclipse.cdt.core.dom.IASTServiceProvider.UnsupportedDialectException;
|
import org.eclipse.cdt.core.dom.IASTServiceProvider.UnsupportedDialectException;
|
||||||
import org.eclipse.cdt.core.dom.ast.ASTVisitor;
|
import org.eclipse.cdt.core.dom.ast.ASTVisitor;
|
||||||
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.IASTNodeLocation;
|
|
||||||
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.IASTProblem;
|
import org.eclipse.cdt.core.dom.ast.IASTProblem;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
|
import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
|
||||||
import org.eclipse.cdt.core.dom.ast.IProblemBinding;
|
import org.eclipse.cdt.core.dom.ast.IProblemBinding;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit.IDependencyTree;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit.IDependencyTree.IASTInclusionNode;
|
||||||
import org.eclipse.cdt.core.index.IIndexDelta;
|
import org.eclipse.cdt.core.index.IIndexDelta;
|
||||||
import org.eclipse.cdt.core.model.CoreModel;
|
import org.eclipse.cdt.core.model.CoreModel;
|
||||||
import org.eclipse.cdt.core.model.ICModelMarker;
|
import org.eclipse.cdt.core.model.ICModelMarker;
|
||||||
import org.eclipse.cdt.core.parser.ParseError;
|
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.core.search.ICSearchConstants;
|
import org.eclipse.cdt.core.search.ICSearchConstants;
|
||||||
|
import org.eclipse.cdt.internal.core.index.cindexstorage.ICIndexStorageConstants;
|
||||||
import org.eclipse.cdt.internal.core.index.cindexstorage.IndexedFileEntry;
|
import org.eclipse.cdt.internal.core.index.cindexstorage.IndexedFileEntry;
|
||||||
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;
|
||||||
|
@ -40,9 +44,9 @@ import org.eclipse.cdt.internal.core.index.sourceindexer.SourceIndexer;
|
||||||
import org.eclipse.cdt.internal.core.search.indexing.IIndexEncodingConstants;
|
import org.eclipse.cdt.internal.core.search.indexing.IIndexEncodingConstants;
|
||||||
import org.eclipse.core.resources.IFile;
|
import org.eclipse.core.resources.IFile;
|
||||||
import org.eclipse.core.resources.IMarker;
|
import org.eclipse.core.resources.IMarker;
|
||||||
import org.eclipse.core.resources.IProject;
|
|
||||||
import org.eclipse.core.resources.IResource;
|
import org.eclipse.core.resources.IResource;
|
||||||
import org.eclipse.core.runtime.CoreException;
|
import org.eclipse.core.runtime.CoreException;
|
||||||
|
import org.eclipse.core.runtime.IPath;
|
||||||
import org.eclipse.core.runtime.Path;
|
import org.eclipse.core.runtime.Path;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -54,6 +58,11 @@ public class DOMSourceIndexerRunner extends AbstractIndexer {
|
||||||
|
|
||||||
private IFile resourceFile;
|
private IFile resourceFile;
|
||||||
private SourceIndexer indexer;
|
private SourceIndexer indexer;
|
||||||
|
// timing & errors
|
||||||
|
static int totalParseTime = 0;
|
||||||
|
static int totalVisitTime = 0;
|
||||||
|
static int errorCount = 0;
|
||||||
|
static Map errors = new HashMap();
|
||||||
|
|
||||||
public DOMSourceIndexerRunner(IFile resource, SourceIndexer indexer) {
|
public DOMSourceIndexerRunner(IFile resource, SourceIndexer indexer) {
|
||||||
this.resourceFile = resource;
|
this.resourceFile = resource;
|
||||||
|
@ -70,7 +79,7 @@ public class DOMSourceIndexerRunner extends AbstractIndexer {
|
||||||
|
|
||||||
protected void indexFile(IFile file) throws IOException {
|
protected void indexFile(IFile file) throws IOException {
|
||||||
// Add the name of the file to the index
|
// Add the name of the file to the index
|
||||||
IndexedFileEntry indFile =output.addIndexedFile(file.getFullPath().toString());
|
IndexedFileEntry indFile = output.addIndexedFile(file.getFullPath().toString());
|
||||||
|
|
||||||
int problems = indexer.indexProblemsEnabled(resourceFile.getProject());
|
int problems = indexer.indexProblemsEnabled(resourceFile.getProject());
|
||||||
setProblemMarkersEnabled(problems);
|
setProblemMarkersEnabled(problems);
|
||||||
|
@ -80,9 +89,9 @@ public class DOMSourceIndexerRunner extends AbstractIndexer {
|
||||||
ParserLanguage language = CoreModel.hasCCNature(resourceFile.getProject()) ?
|
ParserLanguage language = CoreModel.hasCCNature(resourceFile.getProject()) ?
|
||||||
ParserLanguage.CPP : ParserLanguage.C;
|
ParserLanguage.CPP : ParserLanguage.C;
|
||||||
IASTTranslationUnit tu = null;
|
IASTTranslationUnit tu = null;
|
||||||
try {
|
|
||||||
long startTime = 0, parseTime = 0, endTime = 0;
|
long startTime = 0, parseTime = 0, endTime = 0;
|
||||||
|
String error = null;
|
||||||
|
try {
|
||||||
if (AbstractIndexer.TIMING)
|
if (AbstractIndexer.TIMING)
|
||||||
startTime = System.currentTimeMillis();
|
startTime = System.currentTimeMillis();
|
||||||
|
|
||||||
|
@ -92,9 +101,7 @@ public class DOMSourceIndexerRunner extends AbstractIndexer {
|
||||||
if (AbstractIndexer.TIMING)
|
if (AbstractIndexer.TIMING)
|
||||||
parseTime = System.currentTimeMillis();
|
parseTime = System.currentTimeMillis();
|
||||||
|
|
||||||
// TODO Use new method to get ordered include directives instead of
|
processIncludeDirectives(tu.getDependencyTree());
|
||||||
// IASTTranslationUnit.getIncludeDirectives
|
|
||||||
processIncludeDirectives(tu.getIncludeDirectives());
|
|
||||||
processMacroDefinitions(tu.getMacroDefinitions());
|
processMacroDefinitions(tu.getMacroDefinitions());
|
||||||
|
|
||||||
ASTVisitor visitor = null;
|
ASTVisitor visitor = null;
|
||||||
|
@ -106,37 +113,51 @@ public class DOMSourceIndexerRunner extends AbstractIndexer {
|
||||||
|
|
||||||
tu.accept(visitor);
|
tu.accept(visitor);
|
||||||
|
|
||||||
if (AbstractIndexer.TIMING){
|
}
|
||||||
|
catch (VirtualMachineError vmErr) {
|
||||||
|
error = vmErr.toString();
|
||||||
|
if (vmErr instanceof OutOfMemoryError) {
|
||||||
|
org.eclipse.cdt.internal.core.model.Util.log(null, "Out Of Memory error: " + vmErr.getMessage() + " on File: " + resourceFile.getName(), ICLogConstants.CDT); //$NON-NLS-1$ //$NON-NLS-2$
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (ParseError e) {
|
||||||
|
error = e.toString();
|
||||||
|
org.eclipse.cdt.internal.core.model.Util.log(null, "Parser Timeout on File: " + resourceFile.getName(), ICLogConstants.CDT); //$NON-NLS-1$
|
||||||
|
}
|
||||||
|
catch (UnsupportedDialectException e) {
|
||||||
|
error = e.toString();
|
||||||
|
org.eclipse.cdt.internal.core.model.Util.log(null, "Unsupported C/C++ dialect on File: " + resourceFile.getName(), ICLogConstants.CDT); //$NON-NLS-1$
|
||||||
|
}
|
||||||
|
catch (Exception ex) {
|
||||||
|
error = ex.toString();
|
||||||
|
if (ex instanceof IOException)
|
||||||
|
throw (IOException) ex;
|
||||||
|
}
|
||||||
|
finally {
|
||||||
|
if (AbstractIndexer.TIMING) {
|
||||||
endTime = System.currentTimeMillis();
|
endTime = System.currentTimeMillis();
|
||||||
|
if (error != null) {
|
||||||
|
errorCount++;
|
||||||
|
System.out.print(error + ':' + resourceFile.getName() + ':');
|
||||||
|
if (!errors.containsKey(error)) {
|
||||||
|
errors.put(error, new Integer(0));
|
||||||
|
}
|
||||||
|
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.println("DOM Indexer - Total Parse Time for " + 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.println("DOM Indexer - Total Visit Time for " + resourceFile.getName() + ": " + (endTime - parseTime)); //$NON-NLS-1$ //$NON-NLS-2$
|
||||||
|
totalParseTime += parseTime - startTime;
|
||||||
|
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.println("DOM Indexer - Total Index Time for " + resourceFile.getName() + ": " + 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); //$NON-NLS-1$
|
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.flush();
|
System.out.flush();
|
||||||
}
|
}
|
||||||
if (AbstractIndexer.VERBOSE){
|
if (AbstractIndexer.VERBOSE){
|
||||||
AbstractIndexer.verbose("DOM AST TRAVERSAL FINISHED " + resourceFile.getName().toString()); //$NON-NLS-1$
|
AbstractIndexer.verbose("DOM AST TRAVERSAL FINISHED " + resourceFile.getName().toString()); //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
}
|
|
||||||
catch ( VirtualMachineError vmErr){
|
|
||||||
if (vmErr instanceof OutOfMemoryError){
|
|
||||||
org.eclipse.cdt.internal.core.model.Util.log(null, "Out Of Memory error: " + vmErr.getMessage() + " on File: " + resourceFile.getName(), ICLogConstants.CDT); //$NON-NLS-1$ //$NON-NLS-2$
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (ParseError e){
|
|
||||||
org.eclipse.cdt.internal.core.model.Util.log(null, "Parser Timeout on File: " + resourceFile.getName(), ICLogConstants.CDT); //$NON-NLS-1$
|
|
||||||
}
|
|
||||||
catch (UnsupportedDialectException e) {
|
|
||||||
org.eclipse.cdt.internal.core.model.Util.log(null, "Unsupported C/C++ dialect on File: " + resourceFile.getName(), ICLogConstants.CDT); //$NON-NLS-1$
|
|
||||||
}
|
|
||||||
catch (Exception ex) {
|
|
||||||
if (ex instanceof IOException)
|
|
||||||
throw (IOException) ex;
|
|
||||||
}
|
|
||||||
finally{
|
|
||||||
// if the user disable problem reporting since we last checked, don't report the collected problems
|
// if the user disable problem reporting since we last checked, don't report the collected problems
|
||||||
if (areProblemMarkersEnabled()) {
|
if (areProblemMarkersEnabled()) {
|
||||||
reportProblems();
|
reportProblems();
|
||||||
|
@ -153,37 +174,47 @@ public class DOMSourceIndexerRunner extends AbstractIndexer {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param includeDirectives
|
* @param tree
|
||||||
*/
|
*/
|
||||||
private void processIncludeDirectives(IASTPreprocessorIncludeStatement[] includeDirectives) {
|
private void processIncludeDirectives(IDependencyTree tree) {
|
||||||
IProject resourceProject = resourceFile.getProject();
|
|
||||||
for (int i = 0; i < includeDirectives.length; i++) {
|
|
||||||
String include = includeDirectives[i].getPath();
|
|
||||||
// TODO reimplement when ordered collection becomes available
|
|
||||||
// getOutput().addIncludeRef(include);
|
|
||||||
// // where is this header file included
|
|
||||||
// IASTNodeLocation[] locations = includeDirectives[i].getNodeLocations();
|
|
||||||
// for (int j = 0; j < locations.length; j++) {
|
|
||||||
// if (locations[j] instanceof IASTFileLocation) {
|
|
||||||
// IASTFileLocation fileLocation = (IASTFileLocation) locations[j];
|
|
||||||
// String parent = fileLocation.getFileName();
|
|
||||||
// /* Check to see if this is a header file */
|
|
||||||
// ICFileType type = CCorePlugin.getDefault().getFileType(resourceProject, parent);
|
|
||||||
//
|
|
||||||
// if (type.isHeader()) {
|
|
||||||
// getOutput().addRelatives(include, parent);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
int fileNumber = getOutput().getIndexedFile(
|
int fileNumber = getOutput().getIndexedFile(
|
||||||
getResourceFile().getFullPath().toString()).getFileID();
|
getResourceFile().getFullPath().toString()).getFileID();
|
||||||
getOutput().addRef(fileNumber,IndexEncoderUtil.encodeEntry(
|
|
||||||
|
processNestedInclusions(fileNumber, tree.getInclusions(), null);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param fileNumber
|
||||||
|
* @param inclusions
|
||||||
|
* @param parent
|
||||||
|
*/
|
||||||
|
private void processNestedInclusions(int fileNumber, IASTInclusionNode[] inclusions, IASTInclusionNode parent) {
|
||||||
|
for (int i = 0; i < inclusions.length; i++) {
|
||||||
|
IASTInclusionNode inclusion = inclusions[i];
|
||||||
|
String include = inclusion.getIncludeDirective().getPath();
|
||||||
|
|
||||||
|
if (areProblemMarkersEnabled()) {
|
||||||
|
IPath newPath = new Path(include);
|
||||||
|
IFile tempFile = CCorePlugin.getWorkspace().getRoot().getFileForLocation(newPath);
|
||||||
|
if (tempFile != null) {
|
||||||
|
//File is in the workspace
|
||||||
|
requestRemoveMarkers(tempFile, resourceFile);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
getOutput().addIncludeRef(fileNumber, include);
|
||||||
|
getOutput().addRelatives(fileNumber, include,
|
||||||
|
(parent != null) ? parent.getIncludeDirective().getPath() : null);
|
||||||
|
getOutput().addRef(fileNumber, IndexEncoderUtil.encodeEntry(
|
||||||
new char[][] {include.toCharArray()},
|
new char[][] {include.toCharArray()},
|
||||||
IIndexEncodingConstants.INCLUDE,
|
IIndexEncodingConstants.INCLUDE,
|
||||||
ICSearchConstants.REFERENCES));
|
ICSearchConstants.REFERENCES));
|
||||||
|
|
||||||
/* See if this file has been encountered before */
|
/* See if this file has been encountered before */
|
||||||
indexer.haveEncounteredHeader(resourceProject.getFullPath(),new Path(include));
|
indexer.haveEncounteredHeader(resourceFile.getProject().getFullPath(), new Path(include));
|
||||||
|
|
||||||
|
// recurse
|
||||||
|
processNestedInclusions(fileNumber, inclusion.getNestedInclusions(), inclusion);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -193,44 +224,40 @@ public class DOMSourceIndexerRunner extends AbstractIndexer {
|
||||||
private void processMacroDefinitions(IASTPreprocessorMacroDefinition[] macroDefinitions) {
|
private void processMacroDefinitions(IASTPreprocessorMacroDefinition[] macroDefinitions) {
|
||||||
for (int i = 0; i < macroDefinitions.length; i++) {
|
for (int i = 0; i < macroDefinitions.length; i++) {
|
||||||
IASTName macro = macroDefinitions[i].getName();
|
IASTName macro = macroDefinitions[i].getName();
|
||||||
int fileNumber = IndexEncoderUtil.calculateIndexFlags(this, macro);
|
// Get the location
|
||||||
|
IASTFileLocation loc = IndexEncoderUtil.getFileLocation(macro);
|
||||||
|
int fileNumber = IndexEncoderUtil.calculateIndexFlags(this, loc);
|
||||||
getOutput().addRef(fileNumber, IndexEncoderUtil.encodeEntry(
|
getOutput().addRef(fileNumber, IndexEncoderUtil.encodeEntry(
|
||||||
new char[][] {macro.toCharArray()},
|
new char[][] {macro.toCharArray()},
|
||||||
IIndexEncodingConstants.MACRO,
|
IIndexEncodingConstants.MACRO,
|
||||||
ICSearchConstants.DECLARATIONS));
|
ICSearchConstants.DECLARATIONS),
|
||||||
|
loc.getNodeOffset(),
|
||||||
|
loc.getNodeLength(),
|
||||||
|
ICIndexStorageConstants.OFFSET);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.cdt.internal.core.index.sourceindexer.AbstractIndexer#addMarkers(org.eclipse.core.resources.IFile, org.eclipse.core.resources.IFile, java.lang.Object)
|
* @see org.eclipse.cdt.internal.core.index.sourceindexer.AbstractIndexer#addMarkers(org.eclipse.core.resources.IFile, org.eclipse.core.resources.IFile, java.lang.Object, java.lang.Object)
|
||||||
*/
|
*/
|
||||||
protected void addMarkers(IFile tempFile, IFile originator, Object problem) {
|
protected void addMarkers(IFile tempFile, IFile originator, Object problem, Object location) {
|
||||||
String fileName;
|
String fileName;
|
||||||
int sourceLineNumber = -1;
|
int sourceLineNumber = -1;
|
||||||
String errorMessage = ""; //$NON-NLS-1$
|
String errorMessage = ""; //$NON-NLS-1$
|
||||||
IASTNodeLocation location = null;
|
|
||||||
|
|
||||||
if (problem instanceof IASTProblem) {
|
if (problem instanceof IASTProblem) {
|
||||||
IASTProblem astProblem = (IASTProblem) problem;
|
IASTProblem astProblem = (IASTProblem) problem;
|
||||||
errorMessage = astProblem.getMessage();
|
errorMessage = astProblem.getMessage();
|
||||||
location = astProblem.getNodeLocations()[0];
|
|
||||||
}
|
}
|
||||||
else if (problem instanceof IASTName) { // semantic error specified in IProblemBinding
|
else if (problem instanceof IASTName) { // semantic error specified in IProblemBinding
|
||||||
IASTName name = (IASTName) problem;
|
IASTName name = (IASTName) problem;
|
||||||
if (name.resolveBinding() instanceof IProblemBinding) {
|
if (name.resolveBinding() instanceof IProblemBinding) {
|
||||||
IProblemBinding problemBinding = (IProblemBinding) name.resolveBinding();
|
IProblemBinding problemBinding = (IProblemBinding) name.resolveBinding();
|
||||||
errorMessage = problemBinding.getMessage();
|
errorMessage = problemBinding.getMessage();
|
||||||
location = name.getNodeLocations()[0];
|
|
||||||
IASTNode node = problemBinding.getASTNode();
|
|
||||||
// if (node != null && !name.equals(node)) {
|
|
||||||
// // TODO may require further processing - looking at the IProblemBinding id
|
|
||||||
// location = node.getNodeLocations()[0];
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (location != null) {
|
if (location != null && location instanceof IASTFileLocation) {
|
||||||
if (location instanceof IASTFileLocation) {
|
|
||||||
IASTFileLocation fileLoc = (IASTFileLocation) location;
|
IASTFileLocation fileLoc = (IASTFileLocation) location;
|
||||||
fileName = fileLoc.getFileName();
|
fileName = fileLoc.getFileName();
|
||||||
try {
|
try {
|
||||||
|
@ -263,11 +290,11 @@ public class DOMSourceIndexerRunner extends AbstractIndexer {
|
||||||
IMarker marker = tempFile.createMarker(ICModelMarker.INDEXER_MARKER);
|
IMarker marker = tempFile.createMarker(ICModelMarker.INDEXER_MARKER);
|
||||||
int start = fileLoc.getNodeOffset();
|
int start = fileLoc.getNodeOffset();
|
||||||
int end = start + fileLoc.getNodeLength();
|
int end = start + fileLoc.getNodeLength();
|
||||||
// marker.setAttribute(IMarker.LOCATION, iProblem.getSourceLineNumber());
|
marker.setAttribute(IMarker.LOCATION, fileLoc.getStartingLineNumber());
|
||||||
marker.setAttribute(IMarker.LOCATION, 1);
|
marker.setAttribute(IMarker.LOCATION, 1);
|
||||||
marker.setAttribute(IMarker.MESSAGE, INDEXER_MARKER_PREFIX + errorMessage);
|
marker.setAttribute(IMarker.MESSAGE, INDEXER_MARKER_PREFIX + errorMessage);
|
||||||
marker.setAttribute(IMarker.SEVERITY, IMarker.SEVERITY_WARNING);
|
marker.setAttribute(IMarker.SEVERITY, IMarker.SEVERITY_WARNING);
|
||||||
// marker.setAttribute(IMarker.LINE_NUMBER, iProblem.getSourceLineNumber());
|
marker.setAttribute(IMarker.LINE_NUMBER, fileLoc.getStartingLineNumber());
|
||||||
marker.setAttribute(IMarker.LINE_NUMBER, 1);
|
marker.setAttribute(IMarker.LINE_NUMBER, 1);
|
||||||
marker.setAttribute(IMarker.CHAR_START, start);
|
marker.setAttribute(IMarker.CHAR_START, start);
|
||||||
marker.setAttribute(IMarker.CHAR_END, end);
|
marker.setAttribute(IMarker.CHAR_END, end);
|
||||||
|
@ -279,7 +306,6 @@ public class DOMSourceIndexerRunner extends AbstractIndexer {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public boolean shouldRecordProblem(IASTProblem problem) {
|
public boolean shouldRecordProblem(IASTProblem problem) {
|
||||||
boolean preprocessor = (getProblemMarkersEnabled() & SourceIndexer.PREPROCESSOR_PROBLEMS_BIT ) != 0;
|
boolean preprocessor = (getProblemMarkersEnabled() & SourceIndexer.PREPROCESSOR_PROBLEMS_BIT ) != 0;
|
||||||
|
@ -305,4 +331,19 @@ public class DOMSourceIndexerRunner extends AbstractIndexer {
|
||||||
return (getProblemMarkersEnabled() & SourceIndexer.SEMANTIC_PROBLEMS_BIT) != 0;
|
return (getProblemMarkersEnabled() & SourceIndexer.SEMANTIC_PROBLEMS_BIT) != 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public static void printErrors() {
|
||||||
|
if (AbstractIndexer.TIMING) {
|
||||||
|
totalParseTime = 0;
|
||||||
|
totalVisitTime = 0;
|
||||||
|
System.out.println("Errors during indexing"); //$NON-NLS-1$
|
||||||
|
for (Iterator i = errors.keySet().iterator(); i.hasNext(); ) {
|
||||||
|
String error = (String) i.next();;
|
||||||
|
System.out.println(error + " : " + ((Integer) errors.get(error)).toString()); //$NON-NLS-1$
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,7 +12,7 @@ package org.eclipse.cdt.internal.core.index.domsourceindexer;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.CCorePlugin;
|
import org.eclipse.cdt.core.CCorePlugin;
|
||||||
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.IASTNode;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTNodeLocation;
|
import org.eclipse.cdt.core.dom.ast.IASTNodeLocation;
|
||||||
import org.eclipse.cdt.core.search.ICSearchConstants;
|
import org.eclipse.cdt.core.search.ICSearchConstants;
|
||||||
import org.eclipse.cdt.core.search.ICSearchConstants.LimitTo;
|
import org.eclipse.cdt.core.search.ICSearchConstants.LimitTo;
|
||||||
|
@ -26,6 +26,10 @@ import org.eclipse.core.runtime.Path;
|
||||||
public class IndexEncoderUtil {
|
public class IndexEncoderUtil {
|
||||||
|
|
||||||
public static final char[] encodeEntry(char[][] elementName, EntryType entryType, LimitTo encodeType) {
|
public static final char[] encodeEntry(char[][] elementName, EntryType entryType, LimitTo encodeType) {
|
||||||
|
// Temporarily
|
||||||
|
if (elementName == null) {
|
||||||
|
return "NPE".toCharArray(); //$NON-NLS-1$
|
||||||
|
}
|
||||||
int pos, nameLength = 0;
|
int pos, nameLength = 0;
|
||||||
for (int i=0; i < elementName.length; i++){
|
for (int i=0; i < elementName.length; i++){
|
||||||
char[] namePart = elementName[i];
|
char[] namePart = elementName[i];
|
||||||
|
@ -64,7 +68,7 @@ public class IndexEncoderUtil {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int calculateIndexFlags(DOMSourceIndexerRunner indexer, IASTName name) {
|
public static int calculateIndexFlags(DOMSourceIndexerRunner indexer, IASTFileLocation loc) {
|
||||||
int fileNum= 0;
|
int fileNum= 0;
|
||||||
|
|
||||||
//Initialize the file number to be the file number for the file that triggerd
|
//Initialize the file number to be the file number for the file that triggerd
|
||||||
|
@ -77,14 +81,7 @@ public class IndexEncoderUtil {
|
||||||
if (mainIndexFile != null)
|
if (mainIndexFile != null)
|
||||||
fileNum = mainIndexFile.getFileID();
|
fileNum = mainIndexFile.getFileID();
|
||||||
|
|
||||||
String fileName = null;
|
String fileName = loc.getFileName();
|
||||||
IASTNodeLocation[] nameLocations = name.getNodeLocations();
|
|
||||||
if (nameLocations.length > 0) {
|
|
||||||
if (nameLocations[0] instanceof IASTFileLocation) {
|
|
||||||
fileName = ((IASTFileLocation) nameLocations[0]).getFileName();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (fileName != null) {
|
if (fileName != null) {
|
||||||
IFile tempFile = CCorePlugin.getWorkspace().getRoot().getFileForLocation(new Path(fileName));
|
IFile tempFile = CCorePlugin.getWorkspace().getRoot().getFileForLocation(new Path(fileName));
|
||||||
String filePath = ""; //$NON-NLS-1$
|
String filePath = ""; //$NON-NLS-1$
|
||||||
|
@ -127,4 +124,23 @@ public class IndexEncoderUtil {
|
||||||
return fileNum;
|
return fileNum;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param name
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public static IASTFileLocation getFileLocation(IASTNode node) {
|
||||||
|
IASTFileLocation fileLoc = null;
|
||||||
|
|
||||||
|
IASTNodeLocation[] locs = node.getNodeLocations();
|
||||||
|
if (locs.length == 1) {
|
||||||
|
if (locs[0] instanceof IASTFileLocation) {
|
||||||
|
fileLoc = (IASTFileLocation) locs[0];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (locs.length > 1) {
|
||||||
|
fileLoc = node.getTranslationUnit().flattenLocationsToFile(locs);
|
||||||
|
}
|
||||||
|
return fileLoc;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,29 +22,11 @@ import org.eclipse.cdt.core.CCorePlugin;
|
||||||
import org.eclipse.cdt.core.filetype.ICFileType;
|
import org.eclipse.cdt.core.filetype.ICFileType;
|
||||||
import org.eclipse.cdt.core.filetype.ICFileTypeConstants;
|
import org.eclipse.cdt.core.filetype.ICFileTypeConstants;
|
||||||
import org.eclipse.cdt.core.model.ICModelMarker;
|
import org.eclipse.cdt.core.model.ICModelMarker;
|
||||||
import org.eclipse.cdt.core.parser.ast.ASTClassKind;
|
|
||||||
import org.eclipse.cdt.core.parser.ast.ASTNotImplementedException;
|
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTBaseSpecifier;
|
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTClassSpecifier;
|
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTElaboratedTypeSpecifier;
|
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTEnumerationSpecifier;
|
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTEnumerator;
|
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTField;
|
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTFunction;
|
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTInclusion;
|
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTMacro;
|
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTMethod;
|
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTNamespaceDefinition;
|
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTParameterDeclaration;
|
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTTypeSpecifier;
|
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTTypedefDeclaration;
|
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTVariable;
|
|
||||||
import org.eclipse.cdt.core.search.ICSearchConstants;
|
import org.eclipse.cdt.core.search.ICSearchConstants;
|
||||||
import org.eclipse.cdt.internal.core.CharOperation;
|
import org.eclipse.cdt.internal.core.CharOperation;
|
||||||
import org.eclipse.cdt.internal.core.Util;
|
import org.eclipse.cdt.internal.core.Util;
|
||||||
import org.eclipse.cdt.internal.core.index.IIndexer;
|
import org.eclipse.cdt.internal.core.index.IIndexer;
|
||||||
import org.eclipse.cdt.internal.core.index.IIndexerOutput;
|
import org.eclipse.cdt.internal.core.index.IIndexerOutput;
|
||||||
import org.eclipse.cdt.internal.core.index.cindexstorage.ICIndexStorageConstants;
|
|
||||||
import org.eclipse.cdt.internal.core.search.indexing.IIndexConstants;
|
import org.eclipse.cdt.internal.core.search.indexing.IIndexConstants;
|
||||||
import org.eclipse.cdt.internal.core.search.indexing.IndexManager;
|
import org.eclipse.cdt.internal.core.search.indexing.IndexManager;
|
||||||
import org.eclipse.core.resources.IFile;
|
import org.eclipse.core.resources.IFile;
|
||||||
|
@ -59,18 +41,6 @@ import org.eclipse.core.runtime.jobs.Job;
|
||||||
|
|
||||||
public abstract class AbstractIndexer implements IIndexer,IIndexConstants, ICSearchConstants {
|
public abstract class AbstractIndexer implements IIndexer,IIndexConstants, ICSearchConstants {
|
||||||
|
|
||||||
final static int CLASS = 1;
|
|
||||||
final static int STRUCT = 2;
|
|
||||||
final static int UNION = 3;
|
|
||||||
final static int ENUM = 4;
|
|
||||||
final static int VAR = 5;
|
|
||||||
final static int TYPEDEF = 6;
|
|
||||||
final static int DERIVED = 7;
|
|
||||||
final static int FRIEND = 8;
|
|
||||||
final static int FWD_CLASS = 9;
|
|
||||||
final static int FWD_STRUCT = 10;
|
|
||||||
final static int FWD_UNION = 11;
|
|
||||||
|
|
||||||
public static boolean VERBOSE = false;
|
public static boolean VERBOSE = false;
|
||||||
public static boolean TIMING = false;
|
public static boolean TIMING = false;
|
||||||
|
|
||||||
|
@ -96,496 +66,6 @@ public abstract class AbstractIndexer implements IIndexer,IIndexConstants, ICSea
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void addClassSpecifier(IASTClassSpecifier classSpecification, int fileNumber){
|
|
||||||
|
|
||||||
if (classSpecification.getClassKind().equals(ASTClassKind.CLASS))
|
|
||||||
{
|
|
||||||
//Get base clauses
|
|
||||||
Iterator baseClauses = classSpecification.getBaseClauses();
|
|
||||||
while (baseClauses.hasNext()){
|
|
||||||
IASTBaseSpecifier baseSpec = (IASTBaseSpecifier) baseClauses.next();
|
|
||||||
try {
|
|
||||||
IASTTypeSpecifier typeSpec = baseSpec.getParentClassSpecifier();
|
|
||||||
if (typeSpec instanceof IASTClassSpecifier){
|
|
||||||
IASTClassSpecifier baseClassSpec = (IASTClassSpecifier) typeSpec;
|
|
||||||
char[][] baseFullyQualifiedName = baseClassSpec.getFullyQualifiedNameCharArrays();
|
|
||||||
int offset = baseClassSpec.getNameOffset();
|
|
||||||
int offsetLength = baseClassSpec.getNameEndOffset() - offset;
|
|
||||||
this.output.addRef(fileNumber, encodeTypeEntry(baseFullyQualifiedName,DERIVED,ICSearchConstants.DECLARATIONS), offset,offsetLength, ICIndexStorageConstants.OFFSET);
|
|
||||||
}
|
|
||||||
} catch (ASTNotImplementedException e) {}
|
|
||||||
}
|
|
||||||
|
|
||||||
//Get friends
|
|
||||||
Iterator friends = classSpecification.getFriends();
|
|
||||||
while (friends.hasNext()){
|
|
||||||
Object decl = friends.next();
|
|
||||||
if (decl instanceof IASTClassSpecifier){
|
|
||||||
IASTClassSpecifier friendClassSpec = (IASTClassSpecifier) decl;
|
|
||||||
char[][] baseFullyQualifiedName = friendClassSpec.getFullyQualifiedNameCharArrays();
|
|
||||||
int offset = friendClassSpec.getNameOffset();
|
|
||||||
int offsetLength = friendClassSpec.getNameEndOffset() - offset;
|
|
||||||
this.output.addRef(fileNumber, encodeTypeEntry(baseFullyQualifiedName,FRIEND,ICSearchConstants.DECLARATIONS),offset, offsetLength, ICIndexStorageConstants.OFFSET);
|
|
||||||
}
|
|
||||||
else if (decl instanceof IASTElaboratedTypeSpecifier){
|
|
||||||
IASTElaboratedTypeSpecifier friendClassSpec = (IASTElaboratedTypeSpecifier) decl;
|
|
||||||
char[][] baseFullyQualifiedName = friendClassSpec.getFullyQualifiedNameCharArrays();
|
|
||||||
int offset = friendClassSpec.getNameOffset();
|
|
||||||
int offsetLength = friendClassSpec.getNameEndOffset() - offset;
|
|
||||||
this.output.addRef(fileNumber, encodeTypeEntry(baseFullyQualifiedName,FRIEND,ICSearchConstants.DECLARATIONS), offset, offsetLength, ICIndexStorageConstants.OFFSET);
|
|
||||||
}
|
|
||||||
else if (decl instanceof IASTFunction){
|
|
||||||
|
|
||||||
}
|
|
||||||
else if (decl instanceof IASTMethod){
|
|
||||||
//
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
int offset = classSpecification.getNameOffset();
|
|
||||||
int offsetLength = classSpecification.getNameEndOffset() - offset;
|
|
||||||
this.output.addRef(fileNumber, encodeTypeEntry(classSpecification.getFullyQualifiedNameCharArrays(),CLASS, ICSearchConstants.DECLARATIONS),offset, offsetLength, ICIndexStorageConstants.OFFSET);
|
|
||||||
}
|
|
||||||
else if (classSpecification.getClassKind().equals(ASTClassKind.STRUCT))
|
|
||||||
{
|
|
||||||
//Get base clauses
|
|
||||||
Iterator i = classSpecification.getBaseClauses();
|
|
||||||
while (i.hasNext()){
|
|
||||||
IASTBaseSpecifier baseSpec = (IASTBaseSpecifier) i.next();
|
|
||||||
try {
|
|
||||||
IASTTypeSpecifier typeSpec = baseSpec.getParentClassSpecifier();
|
|
||||||
if (typeSpec instanceof IASTClassSpecifier){
|
|
||||||
IASTClassSpecifier baseClassSpec = (IASTClassSpecifier) typeSpec;
|
|
||||||
char[][] baseFullyQualifiedName = baseClassSpec.getFullyQualifiedNameCharArrays();
|
|
||||||
int offset = baseClassSpec.getNameOffset();
|
|
||||||
int offsetLength = baseClassSpec.getNameEndOffset() - offset;
|
|
||||||
this.output.addRef(fileNumber, encodeTypeEntry(baseFullyQualifiedName,DERIVED,ICSearchConstants.DECLARATIONS),offset, offsetLength, ICIndexStorageConstants.OFFSET);
|
|
||||||
}
|
|
||||||
} catch (ASTNotImplementedException e) {}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Get friends
|
|
||||||
Iterator friends = classSpecification.getFriends();
|
|
||||||
while (friends.hasNext()){
|
|
||||||
Object decl = friends.next();
|
|
||||||
if (decl instanceof IASTClassSpecifier){
|
|
||||||
IASTClassSpecifier friendClassSpec = (IASTClassSpecifier) decl;
|
|
||||||
char[][] baseFullyQualifiedName = friendClassSpec.getFullyQualifiedNameCharArrays();
|
|
||||||
int offset = friendClassSpec.getNameOffset();
|
|
||||||
int offsetLength = friendClassSpec.getNameEndOffset() - offset;
|
|
||||||
this.output.addRef(fileNumber, encodeTypeEntry(baseFullyQualifiedName,FRIEND,ICSearchConstants.DECLARATIONS),offset,offsetLength, ICIndexStorageConstants.OFFSET);
|
|
||||||
}
|
|
||||||
else if (decl instanceof IASTElaboratedTypeSpecifier){
|
|
||||||
IASTElaboratedTypeSpecifier friendClassSpec = (IASTElaboratedTypeSpecifier) decl;
|
|
||||||
char[][] baseFullyQualifiedName = friendClassSpec.getFullyQualifiedNameCharArrays();
|
|
||||||
int offset = friendClassSpec.getNameOffset();
|
|
||||||
int offsetLength = friendClassSpec.getNameEndOffset() - offset;
|
|
||||||
this.output.addRef(fileNumber, encodeTypeEntry(baseFullyQualifiedName,FRIEND,ICSearchConstants.DECLARATIONS),offset,offsetLength, ICIndexStorageConstants.OFFSET);
|
|
||||||
}
|
|
||||||
else if (decl instanceof IASTFunction){
|
|
||||||
|
|
||||||
}
|
|
||||||
else if (decl instanceof IASTMethod){
|
|
||||||
//
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
int offset = classSpecification.getNameOffset();
|
|
||||||
int offsetLength = classSpecification.getNameEndOffset() - offset;
|
|
||||||
this.output.addRef(fileNumber, encodeTypeEntry(classSpecification.getFullyQualifiedNameCharArrays(),STRUCT, ICSearchConstants.DECLARATIONS),offset,offsetLength, ICIndexStorageConstants.OFFSET);
|
|
||||||
}
|
|
||||||
else if (classSpecification.getClassKind().equals(ASTClassKind.UNION))
|
|
||||||
{
|
|
||||||
int offset = classSpecification.getNameOffset();
|
|
||||||
int offsetLength = classSpecification.getNameEndOffset() - offset;
|
|
||||||
this.output.addRef(fileNumber, encodeTypeEntry(classSpecification.getFullyQualifiedNameCharArrays(),UNION, ICSearchConstants.DECLARATIONS),offset,offsetLength, ICIndexStorageConstants.OFFSET);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void addEnumerationSpecifier(IASTEnumerationSpecifier enumeration, int fileNumber) {
|
|
||||||
|
|
||||||
int offset = enumeration.getNameOffset();
|
|
||||||
int offsetLength = enumeration.getNameEndOffset() - offset;
|
|
||||||
this.output.addRef(fileNumber, encodeTypeEntry(enumeration.getFullyQualifiedNameCharArrays(), ENUM, ICSearchConstants.DECLARATIONS),offset,offsetLength, ICIndexStorageConstants.OFFSET);
|
|
||||||
|
|
||||||
Iterator i = enumeration.getEnumerators();
|
|
||||||
while (i.hasNext())
|
|
||||||
{
|
|
||||||
IASTEnumerator en = (IASTEnumerator) i.next();
|
|
||||||
char[][] enumeratorFullName =
|
|
||||||
createEnumeratorFullyQualifiedName(en);
|
|
||||||
|
|
||||||
offset = en.getNameOffset();
|
|
||||||
offsetLength = en.getNameEndOffset() - offset;
|
|
||||||
this.output.addRef(fileNumber, encodeEntry( enumeratorFullName, ENUMTOR_DECL, ENUMTOR_DECL_LENGTH ),offset,offsetLength, ICIndexStorageConstants.OFFSET);
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
protected char[][] createEnumeratorFullyQualifiedName(IASTEnumerator en) {
|
|
||||||
char[] name = en.getNameCharArray();
|
|
||||||
IASTEnumerationSpecifier parent = en.getOwnerEnumerationSpecifier();
|
|
||||||
char[][] parentName = parent.getFullyQualifiedNameCharArrays();
|
|
||||||
|
|
||||||
//See spec 7.2-10, the the scope of the enumerator is the same level as the enumeration
|
|
||||||
char[][] enumeratorFullName = new char[parentName.length][];
|
|
||||||
|
|
||||||
System.arraycopy( parentName, 0, enumeratorFullName, 0, parentName.length);
|
|
||||||
enumeratorFullName[ parentName.length - 1 ] = name;
|
|
||||||
return enumeratorFullName;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void addEnumeratorReference(IASTEnumerator enumerator, int fileNumber) {
|
|
||||||
|
|
||||||
int offset = enumerator.getNameOffset();
|
|
||||||
int offsetLength = enumerator.getNameEndOffset() - offset;
|
|
||||||
this.output.addRef(fileNumber, encodeEntry(createEnumeratorFullyQualifiedName(enumerator),ENUMTOR_REF,ENUMTOR_REF_LENGTH),offset,offsetLength, ICIndexStorageConstants.OFFSET);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void addMacro(IASTMacro macro, int fileNumber) {
|
|
||||||
char[][] macroName = new char[][] { macro.getNameCharArray() };
|
|
||||||
int offset = macro.getNameOffset();
|
|
||||||
int offsetLength = macro.getNameEndOffset() - offset;
|
|
||||||
this.output.addRef(fileNumber, encodeEntry(macroName,MACRO_DECL,MACRO_DECL_LENGTH), offset,offsetLength, ICIndexStorageConstants.OFFSET);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void addEnumerationReference(IASTEnumerationSpecifier enumeration, int fileNumber) {
|
|
||||||
int offset = enumeration.getNameOffset();
|
|
||||||
int offsetLength = enumeration.getNameEndOffset() - offset;
|
|
||||||
this.output.addRef(fileNumber, encodeTypeEntry(enumeration.getFullyQualifiedNameCharArrays(), ENUM, ICSearchConstants.REFERENCES), offset,offsetLength, ICIndexStorageConstants.OFFSET);
|
|
||||||
}
|
|
||||||
public void addVariable(IASTVariable variable, int fileNumber) {
|
|
||||||
int offset = variable.getNameOffset();
|
|
||||||
int offsetLength = variable.getNameEndOffset() - offset;
|
|
||||||
this.output.addRef(fileNumber, encodeTypeEntry(variable.getFullyQualifiedNameCharArrays(), VAR, ICSearchConstants.DECLARATIONS), offset,offsetLength, ICIndexStorageConstants.OFFSET);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void addVariableReference(IASTVariable variable, int fileNumber) {
|
|
||||||
int offset = variable.getNameOffset();
|
|
||||||
int offsetLength = variable.getNameEndOffset() - offset;
|
|
||||||
this.output.addRef(fileNumber, encodeTypeEntry(variable.getFullyQualifiedNameCharArrays(), VAR, ICSearchConstants.REFERENCES),offset, offsetLength, ICIndexStorageConstants.OFFSET);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void addParameterReference( IASTParameterDeclaration parameter, int fileNumber ){
|
|
||||||
int offset = parameter.getNameOffset();
|
|
||||||
int offsetLength = parameter.getNameEndOffset() - offset;
|
|
||||||
this.output.addRef(fileNumber,encodeTypeEntry( new char[][] { parameter.getNameCharArray() }, VAR, ICSearchConstants.REFERENCES), offset, offsetLength, ICIndexStorageConstants.OFFSET);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void addTypedefDeclaration(IASTTypedefDeclaration typedef, int fileNumber) {
|
|
||||||
int offset = typedef.getNameOffset();
|
|
||||||
int offsetLength = typedef.getNameEndOffset() - offset;
|
|
||||||
this.output.addRef(fileNumber,encodeEntry(typedef.getFullyQualifiedNameCharArrays(), TYPEDEF_DECL, TYPEDEF_DECL_LENGTH),offset,offsetLength, ICIndexStorageConstants.OFFSET);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void addFieldDeclaration(IASTField field, int fileNumber) {
|
|
||||||
int offset = field.getNameOffset();
|
|
||||||
int offsetLength = field.getNameEndOffset() - offset;
|
|
||||||
this.output.addRef(fileNumber, encodeEntry(field.getFullyQualifiedNameCharArrays(),FIELD_DECL,FIELD_DECL_LENGTH),offset,offsetLength, ICIndexStorageConstants.OFFSET);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void addFieldReference(IASTField field, int fileNumber) {
|
|
||||||
int offset = field.getNameOffset();
|
|
||||||
int offsetLength = field.getNameEndOffset() - offset;
|
|
||||||
this.output.addRef(fileNumber, encodeEntry(field.getFullyQualifiedNameCharArrays(),FIELD_REF,FIELD_REF_LENGTH),offset,offsetLength, ICIndexStorageConstants.OFFSET);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void addMethodDeclaration(IASTMethod method, int fileNumber) {
|
|
||||||
int offset = method.getNameOffset();
|
|
||||||
int offsetLength = method.getNameEndOffset() - offset;
|
|
||||||
this.output.addRef(fileNumber, encodeEntry(method.getFullyQualifiedNameCharArrays(),METHOD_DECL,METHOD_DECL_LENGTH),offset,offsetLength, ICIndexStorageConstants.OFFSET);
|
|
||||||
|
|
||||||
Iterator i=method.getParameters();
|
|
||||||
while (i.hasNext()){
|
|
||||||
Object parm = i.next();
|
|
||||||
if (parm instanceof IASTParameterDeclaration){
|
|
||||||
IASTParameterDeclaration parmDecl = (IASTParameterDeclaration) parm;
|
|
||||||
offset = parmDecl.getNameOffset();
|
|
||||||
offsetLength = parmDecl.getNameEndOffset() - offset;
|
|
||||||
this.output.addRef(fileNumber, encodeTypeEntry(new char[][]{parmDecl.getNameCharArray()}, VAR, ICSearchConstants.DECLARATIONS),offset,offsetLength, ICIndexStorageConstants.OFFSET);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void addMethodReference(IASTMethod method, int fileNumber) {
|
|
||||||
int offset = method.getNameOffset();
|
|
||||||
int offsetLength = method.getNameEndOffset() - offset;
|
|
||||||
this.output.addRef(fileNumber, encodeEntry(method.getFullyQualifiedNameCharArrays(),METHOD_REF,METHOD_REF_LENGTH),offset,offsetLength, ICIndexStorageConstants.OFFSET);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void addElaboratedForwardDeclaration(IASTElaboratedTypeSpecifier elaboratedType, int fileNumber) {
|
|
||||||
int offset = elaboratedType.getNameOffset();
|
|
||||||
int offsetLength = elaboratedType.getNameEndOffset() - offset;
|
|
||||||
|
|
||||||
if (elaboratedType.getClassKind().equals(ASTClassKind.CLASS))
|
|
||||||
{
|
|
||||||
this.output.addRef(fileNumber,encodeTypeEntry(elaboratedType.getFullyQualifiedNameCharArrays(),FWD_CLASS, ICSearchConstants.DECLARATIONS),offset,offsetLength, ICIndexStorageConstants.OFFSET);
|
|
||||||
}
|
|
||||||
else if (elaboratedType.getClassKind().equals(ASTClassKind.STRUCT))
|
|
||||||
{
|
|
||||||
this.output.addRef(fileNumber,encodeTypeEntry(elaboratedType.getFullyQualifiedNameCharArrays(),FWD_STRUCT, ICSearchConstants.DECLARATIONS),offset,offsetLength, ICIndexStorageConstants.OFFSET);
|
|
||||||
}
|
|
||||||
else if (elaboratedType.getClassKind().equals(ASTClassKind.UNION))
|
|
||||||
{
|
|
||||||
this.output.addRef(fileNumber,encodeTypeEntry(elaboratedType.getFullyQualifiedNameCharArrays(),FWD_UNION, ICSearchConstants.DECLARATIONS),offset,offsetLength, ICIndexStorageConstants.OFFSET);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void addConstructorDeclaration(){
|
|
||||||
|
|
||||||
}
|
|
||||||
public void addConstructorReference(){
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public void addMemberDeclaration(){
|
|
||||||
|
|
||||||
}
|
|
||||||
public void addMemberReference(){
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public void addFunctionDeclaration(IASTFunction function, int fileNumber){
|
|
||||||
int offset = function.getNameOffset();
|
|
||||||
int offsetLength = function.getNameEndOffset() - offset;
|
|
||||||
|
|
||||||
this.output.addRef(fileNumber, encodeEntry(function.getFullyQualifiedNameCharArrays(),FUNCTION_DECL,FUNCTION_DECL_LENGTH),offset,offsetLength, ICIndexStorageConstants.OFFSET);
|
|
||||||
|
|
||||||
Iterator i=function.getParameters();
|
|
||||||
while (i.hasNext()){
|
|
||||||
Object parm = i.next();
|
|
||||||
if (parm instanceof IASTParameterDeclaration){
|
|
||||||
IASTParameterDeclaration parmDecl = (IASTParameterDeclaration) parm;
|
|
||||||
offset = parmDecl.getNameOffset();
|
|
||||||
offsetLength = parmDecl.getNameEndOffset() - offset;
|
|
||||||
this.output.addRef(fileNumber, encodeTypeEntry(new char[][]{parmDecl.getNameCharArray()}, VAR, ICSearchConstants.DECLARATIONS),offset,offsetLength, ICIndexStorageConstants.OFFSET);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void addFunctionReference(IASTFunction function, int fileNumber){
|
|
||||||
int offset = function.getNameOffset();
|
|
||||||
int offsetLength = function.getNameEndOffset() - offset;
|
|
||||||
this.output.addRef(fileNumber, encodeEntry(function.getFullyQualifiedNameCharArrays(),FUNCTION_REF,FUNCTION_REF_LENGTH),offset,offsetLength, ICIndexStorageConstants.OFFSET);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void addNameReference(){
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public void addNamespaceDefinition(IASTNamespaceDefinition namespace, int fileNumber){
|
|
||||||
int offset = namespace.getNameOffset();
|
|
||||||
int offsetLength = namespace.getNameEndOffset() - offset;
|
|
||||||
this.output.addRef(fileNumber, encodeEntry(namespace.getFullyQualifiedNameCharArrays(),NAMESPACE_DECL,NAMESPACE_DECL_LENGTH),offset,offsetLength, ICIndexStorageConstants.OFFSET);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void addNamespaceReference(IASTNamespaceDefinition namespace, int fileNumber) {
|
|
||||||
int offset = namespace.getNameOffset();
|
|
||||||
int offsetLength = namespace.getNameEndOffset() - offset;
|
|
||||||
this.output.addRef(fileNumber, encodeEntry(namespace.getFullyQualifiedNameCharArrays(),NAMESPACE_REF,NAMESPACE_REF_LENGTH),offset,offsetLength, ICIndexStorageConstants.OFFSET);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void addTypedefReference( IASTTypedefDeclaration typedef, int fileNumber ){
|
|
||||||
int offset = typedef.getNameOffset();
|
|
||||||
int offsetLength = typedef.getNameEndOffset() - offset;
|
|
||||||
this.output.addRef(fileNumber,encodeTypeEntry( typedef.getFullyQualifiedNameCharArrays(), TYPEDEF, ICSearchConstants.REFERENCES),offset, offsetLength, ICIndexStorageConstants.OFFSET);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void addSuperTypeReference(int modifiers, char[] packageName, char[] typeName, char[][] enclosingTypeNames, char classOrInterface, char[] superTypeName, char superClassOrInterface){
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public void addTypeReference(char[] typeName){
|
|
||||||
//this.output.addRef(CharOperation.concat(TYPE_REF, CharOperation.lastSegment(typeName, '.')));
|
|
||||||
}
|
|
||||||
|
|
||||||
public void addClassReference(IASTTypeSpecifier reference, int fileNumber){
|
|
||||||
char[][] fullyQualifiedName = null;
|
|
||||||
ASTClassKind classKind = null;
|
|
||||||
int offset=0;
|
|
||||||
int offsetLength=1;
|
|
||||||
|
|
||||||
if (reference instanceof IASTClassSpecifier){
|
|
||||||
IASTClassSpecifier classRef = (IASTClassSpecifier) reference;
|
|
||||||
fullyQualifiedName = classRef.getFullyQualifiedNameCharArrays();
|
|
||||||
classKind = classRef.getClassKind();
|
|
||||||
offset=classRef.getNameOffset();
|
|
||||||
offsetLength=classRef.getNameEndOffset() - offset;
|
|
||||||
}
|
|
||||||
else if (reference instanceof IASTElaboratedTypeSpecifier){
|
|
||||||
IASTElaboratedTypeSpecifier typeRef = (IASTElaboratedTypeSpecifier) reference;
|
|
||||||
fullyQualifiedName = typeRef.getFullyQualifiedNameCharArrays();
|
|
||||||
classKind = typeRef.getClassKind();
|
|
||||||
offset=typeRef.getNameOffset();
|
|
||||||
offsetLength=typeRef.getNameEndOffset()-offset;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (classKind.equals(ASTClassKind.CLASS))
|
|
||||||
{
|
|
||||||
this.output.addRef(fileNumber, encodeTypeEntry(fullyQualifiedName,CLASS, ICSearchConstants.REFERENCES),offset,offsetLength, ICIndexStorageConstants.OFFSET);
|
|
||||||
}
|
|
||||||
else if (classKind.equals(ASTClassKind.STRUCT))
|
|
||||||
{
|
|
||||||
this.output.addRef(fileNumber, encodeTypeEntry(fullyQualifiedName,STRUCT,ICSearchConstants.REFERENCES),offset,offsetLength, ICIndexStorageConstants.OFFSET);
|
|
||||||
}
|
|
||||||
else if (classKind.equals(ASTClassKind.UNION))
|
|
||||||
{
|
|
||||||
this.output.addRef(fileNumber, encodeTypeEntry(fullyQualifiedName,UNION,ICSearchConstants.REFERENCES),offset,offsetLength, ICIndexStorageConstants.OFFSET);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
public void addForwardClassReference(IASTTypeSpecifier reference, int fileNumber){
|
|
||||||
char[][] fullyQualifiedName = null;
|
|
||||||
ASTClassKind classKind = null;
|
|
||||||
int offset=0;
|
|
||||||
int offsetLength=1;
|
|
||||||
if (reference instanceof IASTElaboratedTypeSpecifier){
|
|
||||||
IASTElaboratedTypeSpecifier typeRef = (IASTElaboratedTypeSpecifier) reference;
|
|
||||||
fullyQualifiedName = typeRef.getFullyQualifiedNameCharArrays();
|
|
||||||
classKind = typeRef.getClassKind();
|
|
||||||
offset=typeRef.getNameOffset();
|
|
||||||
offsetLength=typeRef.getNameEndOffset() - offset;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (classKind == null)
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (classKind.equals(ASTClassKind.CLASS))
|
|
||||||
{
|
|
||||||
this.output.addRef(fileNumber, encodeTypeEntry(fullyQualifiedName,FWD_CLASS, ICSearchConstants.REFERENCES),offset,offsetLength, ICIndexStorageConstants.OFFSET);
|
|
||||||
}
|
|
||||||
else if (classKind.equals(ASTClassKind.STRUCT))
|
|
||||||
{
|
|
||||||
this.output.addRef(fileNumber, encodeTypeEntry(fullyQualifiedName,FWD_STRUCT,ICSearchConstants.REFERENCES),offset,offsetLength, ICIndexStorageConstants.OFFSET);
|
|
||||||
}
|
|
||||||
else if (classKind.equals(ASTClassKind.UNION))
|
|
||||||
{
|
|
||||||
this.output.addRef(fileNumber, encodeTypeEntry(fullyQualifiedName,FWD_UNION,ICSearchConstants.REFERENCES),offset,offsetLength, ICIndexStorageConstants.OFFSET);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* Type entries are encoded as follow: 'typeDecl/' ('C' | 'S' | 'U' | 'E' ) '/' TypeName ['/' Qualifier]*
|
|
||||||
*/
|
|
||||||
protected static final char[] encodeTypeEntry( char[][] fullTypeName, int typeType, LimitTo encodeType){
|
|
||||||
|
|
||||||
int pos = 0, nameLength = 0;
|
|
||||||
for (int i=0; i<fullTypeName.length; i++){
|
|
||||||
char[] namePart = fullTypeName[i];
|
|
||||||
nameLength+= namePart.length;
|
|
||||||
}
|
|
||||||
|
|
||||||
char [] result = null;
|
|
||||||
if( encodeType == REFERENCES ){
|
|
||||||
//char[] has to be of size - [type decl length + length of the name + separators + letter]
|
|
||||||
result = new char[TYPE_REF_LENGTH + nameLength + fullTypeName.length + 1 ];
|
|
||||||
System.arraycopy(TYPE_REF, 0, result, 0, pos = TYPE_REF_LENGTH);
|
|
||||||
|
|
||||||
} else if( encodeType == DECLARATIONS ){
|
|
||||||
//char[] has to be of size - [type decl length + length of the name + separators + letter]
|
|
||||||
result = new char[TYPE_DECL_LENGTH + nameLength + fullTypeName.length + 1 ];
|
|
||||||
System.arraycopy(TYPE_DECL, 0, result, 0, pos = TYPE_DECL_LENGTH);
|
|
||||||
}
|
|
||||||
switch (typeType)
|
|
||||||
{
|
|
||||||
case(CLASS):
|
|
||||||
result[pos++] = CLASS_SUFFIX;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case(STRUCT):
|
|
||||||
result[pos++] = STRUCT_SUFFIX;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case(UNION):
|
|
||||||
result[pos++] = UNION_SUFFIX;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case(ENUM):
|
|
||||||
result[pos++] = ENUM_SUFFIX;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case (VAR):
|
|
||||||
result[pos++] = VAR_SUFFIX;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case (TYPEDEF):
|
|
||||||
result[pos++] = TYPEDEF_SUFFIX;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case(DERIVED):
|
|
||||||
result[pos++]= DERIVED_SUFFIX;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case(FRIEND):
|
|
||||||
result[pos++]=FRIEND_SUFFIX;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case(FWD_CLASS):
|
|
||||||
result[pos++]=FWD_CLASS_SUFFIX;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case (FWD_STRUCT):
|
|
||||||
result[pos++]=FWD_STRUCT_SUFFIX;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case (FWD_UNION):
|
|
||||||
result[pos++]=FWD_UNION_SUFFIX;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
result[pos++] = SEPARATOR;
|
|
||||||
//Encode in the following manner
|
|
||||||
// [typeDecl info]/[typeName]/[qualifiers]
|
|
||||||
if (fullTypeName.length > 0){
|
|
||||||
//Extract the name first
|
|
||||||
char [] tempName = fullTypeName[fullTypeName.length-1];
|
|
||||||
System.arraycopy(tempName, 0, result, pos, tempName.length);
|
|
||||||
pos += tempName.length;
|
|
||||||
}
|
|
||||||
//Extract the qualifiers
|
|
||||||
for (int i=fullTypeName.length - 2; i >= 0; i--){
|
|
||||||
result[pos++] = SEPARATOR;
|
|
||||||
char [] tempName = fullTypeName[i];
|
|
||||||
System.arraycopy(tempName, 0, result, pos, tempName.length);
|
|
||||||
pos+=tempName.length;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (AbstractIndexer.VERBOSE)
|
|
||||||
AbstractIndexer.verbose(new String(result));
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* Namespace entries are encoded as follow: '[prefix]/' TypeName ['/' Qualifier]*
|
|
||||||
*/
|
|
||||||
protected static final char[] encodeEntry(char[][] elementName, char[] prefix, int prefixSize){
|
|
||||||
int pos, nameLength = 0;
|
|
||||||
for (int i=0; i<elementName.length; i++){
|
|
||||||
char[] namePart = elementName[i];
|
|
||||||
nameLength+= namePart.length;
|
|
||||||
}
|
|
||||||
//char[] has to be of size - [type length + length of the name (including qualifiers) +
|
|
||||||
//separators (need one less than fully qualified name length)
|
|
||||||
char[] result = new char[prefixSize + nameLength + elementName.length - 1 ];
|
|
||||||
System.arraycopy(prefix, 0, result, 0, pos = prefix.length);
|
|
||||||
if (elementName.length > 0){
|
|
||||||
//Extract the name first
|
|
||||||
char [] tempName = elementName[elementName.length-1];
|
|
||||||
System.arraycopy(tempName, 0, result, pos, tempName.length);
|
|
||||||
pos += tempName.length;
|
|
||||||
}
|
|
||||||
//Extract the qualifiers
|
|
||||||
for (int i=elementName.length - 2; i>=0; i--){
|
|
||||||
result[pos++] = SEPARATOR;
|
|
||||||
char [] tempName = elementName[i];
|
|
||||||
System.arraycopy(tempName, 0, result, pos, tempName.length);
|
|
||||||
pos+=tempName.length;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (AbstractIndexer.VERBOSE)
|
|
||||||
AbstractIndexer.verbose(new String(result));
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the file types being indexed.
|
* Returns the file types being indexed.
|
||||||
*/
|
*/
|
||||||
|
@ -926,19 +406,6 @@ public abstract class AbstractIndexer implements IIndexer,IIndexConstants, ICSea
|
||||||
return bestPrefix( prefix, (char)0, incName, null, matchMode, isCaseSenstive );
|
return bestPrefix( prefix, (char)0, incName, null, matchMode, isCaseSenstive );
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addInclude(IASTInclusion inclusion, IASTInclusion parent, int fileNumber){
|
|
||||||
this.output.addIncludeRef(fileNumber, inclusion.getFullFileName());
|
|
||||||
this.output.addRelatives(fileNumber, inclusion.getFullFileName(),(parent != null ) ? parent.getFullFileName() : null);
|
|
||||||
|
|
||||||
//Add Dep Table entry
|
|
||||||
char[][] incName = new char[1][];
|
|
||||||
incName[0] = inclusion.getFullFileName().toCharArray();
|
|
||||||
//TODO: Kludge! Get rid of BOGUS entry - need to restructure Dep Tree to use reference indexes
|
|
||||||
int BOGUS_ENTRY = 1;
|
|
||||||
this.output.addRef(fileNumber, encodeEntry(incName, INCLUDE_REF, INCLUDE_REF_LENGTH));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
abstract private class Problem {
|
abstract private class Problem {
|
||||||
public IFile file;
|
public IFile file;
|
||||||
|
@ -950,11 +417,13 @@ public abstract class AbstractIndexer implements IIndexer,IIndexConstants, ICSea
|
||||||
|
|
||||||
abstract public boolean isAddProblem();
|
abstract public boolean isAddProblem();
|
||||||
abstract public Object getProblem();
|
abstract public Object getProblem();
|
||||||
|
abstract public Object getLocation();
|
||||||
}
|
}
|
||||||
|
|
||||||
private class AddMarkerProblem extends Problem {
|
private class AddMarkerProblem extends Problem {
|
||||||
private Object problem;
|
private Object problem;
|
||||||
public AddMarkerProblem(IFile file, IFile orig, Object problem) {
|
private Object location;
|
||||||
|
public AddMarkerProblem(IFile file, IFile orig, Object problem, Object location) {
|
||||||
super( file, orig );
|
super( file, orig );
|
||||||
this.problem = problem;
|
this.problem = problem;
|
||||||
}
|
}
|
||||||
|
@ -964,6 +433,9 @@ public abstract class AbstractIndexer implements IIndexer,IIndexConstants, ICSea
|
||||||
public Object getProblem(){
|
public Object getProblem(){
|
||||||
return problem;
|
return problem;
|
||||||
}
|
}
|
||||||
|
public Object getLocation() {
|
||||||
|
return location;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private class RemoveMarkerProblem extends Problem {
|
private class RemoveMarkerProblem extends Problem {
|
||||||
|
@ -976,6 +448,9 @@ public abstract class AbstractIndexer implements IIndexer,IIndexConstants, ICSea
|
||||||
public Object getProblem() {
|
public Object getProblem() {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
public Object getLocation() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Problem markers ******************************
|
// Problem markers ******************************
|
||||||
|
@ -999,9 +474,10 @@ public abstract class AbstractIndexer implements IIndexer,IIndexConstants, ICSea
|
||||||
* @param tempFile - not null
|
* @param tempFile - not null
|
||||||
* @param resourceFile
|
* @param resourceFile
|
||||||
* @param problem
|
* @param problem
|
||||||
|
* @param location
|
||||||
*/
|
*/
|
||||||
public void generateMarkerProblem(IFile tempFile, IFile resourceFile, Object problem) {
|
public void generateMarkerProblem(IFile tempFile, IFile resourceFile, Object problem, Object location) {
|
||||||
Problem tempProblem = new AddMarkerProblem(tempFile, resourceFile, problem);
|
Problem tempProblem = new AddMarkerProblem(tempFile, resourceFile, problem, location);
|
||||||
if (problemsMap.containsKey(tempFile)) {
|
if (problemsMap.containsKey(tempFile)) {
|
||||||
List list = (List) problemsMap.get(tempFile);
|
List list = (List) problemsMap.get(tempFile);
|
||||||
list.add(tempProblem);
|
list.add(tempProblem);
|
||||||
|
@ -1098,14 +574,14 @@ public abstract class AbstractIndexer implements IIndexer,IIndexConstants, ICSea
|
||||||
while (i.hasNext()) {
|
while (i.hasNext()) {
|
||||||
Problem prob = (Problem) i.next();
|
Problem prob = (Problem) i.next();
|
||||||
if (prob.isAddProblem()) {
|
if (prob.isAddProblem()) {
|
||||||
addMarkers(prob.file, prob.originator, prob.getProblem());
|
addMarkers(prob.file, prob.originator, prob.getProblem(), prob.getLocation());
|
||||||
} else {
|
} else {
|
||||||
removeMarkers(prob.file, prob.originator);
|
removeMarkers(prob.file, prob.originator);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
abstract protected void addMarkers(IFile tempFile, IFile originator, Object problem);
|
abstract protected void addMarkers(IFile tempFile, IFile originator, Object problem, Object location);
|
||||||
|
|
||||||
public void removeMarkers(IFile resource, IFile originator) {
|
public void removeMarkers(IFile resource, IFile originator) {
|
||||||
if (originator == null) {
|
if (originator == null) {
|
||||||
|
|
|
@ -118,7 +118,7 @@ public class SourceIndexerRequestor implements ISourceElementRequestor, IIndexCo
|
||||||
}
|
}
|
||||||
|
|
||||||
if( tempFile != null ){
|
if( tempFile != null ){
|
||||||
indexer.generateMarkerProblem(tempFile, resourceFile, problem);
|
indexer.generateMarkerProblem(tempFile, resourceFile, problem, null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -18,6 +18,7 @@ package org.eclipse.cdt.internal.core.index.sourceindexer;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Iterator;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.CCorePlugin;
|
import org.eclipse.cdt.core.CCorePlugin;
|
||||||
import org.eclipse.cdt.core.ICLogConstants;
|
import org.eclipse.cdt.core.ICLogConstants;
|
||||||
|
@ -35,6 +36,25 @@ import org.eclipse.cdt.core.parser.ParserLanguage;
|
||||||
import org.eclipse.cdt.core.parser.ParserMode;
|
import org.eclipse.cdt.core.parser.ParserMode;
|
||||||
import org.eclipse.cdt.core.parser.ParserUtil;
|
import org.eclipse.cdt.core.parser.ParserUtil;
|
||||||
import org.eclipse.cdt.core.parser.ScannerInfo;
|
import org.eclipse.cdt.core.parser.ScannerInfo;
|
||||||
|
import org.eclipse.cdt.core.parser.ast.ASTClassKind;
|
||||||
|
import org.eclipse.cdt.core.parser.ast.ASTNotImplementedException;
|
||||||
|
import org.eclipse.cdt.core.parser.ast.IASTBaseSpecifier;
|
||||||
|
import org.eclipse.cdt.core.parser.ast.IASTClassSpecifier;
|
||||||
|
import org.eclipse.cdt.core.parser.ast.IASTElaboratedTypeSpecifier;
|
||||||
|
import org.eclipse.cdt.core.parser.ast.IASTEnumerationSpecifier;
|
||||||
|
import org.eclipse.cdt.core.parser.ast.IASTEnumerator;
|
||||||
|
import org.eclipse.cdt.core.parser.ast.IASTField;
|
||||||
|
import org.eclipse.cdt.core.parser.ast.IASTFunction;
|
||||||
|
import org.eclipse.cdt.core.parser.ast.IASTInclusion;
|
||||||
|
import org.eclipse.cdt.core.parser.ast.IASTMacro;
|
||||||
|
import org.eclipse.cdt.core.parser.ast.IASTMethod;
|
||||||
|
import org.eclipse.cdt.core.parser.ast.IASTNamespaceDefinition;
|
||||||
|
import org.eclipse.cdt.core.parser.ast.IASTParameterDeclaration;
|
||||||
|
import org.eclipse.cdt.core.parser.ast.IASTTypeSpecifier;
|
||||||
|
import org.eclipse.cdt.core.parser.ast.IASTTypedefDeclaration;
|
||||||
|
import org.eclipse.cdt.core.parser.ast.IASTVariable;
|
||||||
|
import org.eclipse.cdt.core.search.ICSearchConstants;
|
||||||
|
import org.eclipse.cdt.internal.core.index.cindexstorage.ICIndexStorageConstants;
|
||||||
import org.eclipse.cdt.internal.core.index.cindexstorage.IndexedFileEntry;
|
import org.eclipse.cdt.internal.core.index.cindexstorage.IndexedFileEntry;
|
||||||
import org.eclipse.cdt.internal.core.index.impl.IndexDelta;
|
import org.eclipse.cdt.internal.core.index.impl.IndexDelta;
|
||||||
import org.eclipse.core.resources.IFile;
|
import org.eclipse.core.resources.IFile;
|
||||||
|
@ -58,6 +78,18 @@ import org.eclipse.core.runtime.Path;
|
||||||
*/
|
*/
|
||||||
public class SourceIndexerRunner extends AbstractIndexer {
|
public class SourceIndexerRunner extends AbstractIndexer {
|
||||||
|
|
||||||
|
final static int CLASS = 1;
|
||||||
|
final static int STRUCT = 2;
|
||||||
|
final static int UNION = 3;
|
||||||
|
final static int ENUM = 4;
|
||||||
|
final static int VAR = 5;
|
||||||
|
final static int TYPEDEF = 6;
|
||||||
|
final static int DERIVED = 7;
|
||||||
|
final static int FRIEND = 8;
|
||||||
|
final static int FWD_CLASS = 9;
|
||||||
|
final static int FWD_STRUCT = 10;
|
||||||
|
final static int FWD_UNION = 11;
|
||||||
|
|
||||||
IFile resourceFile;
|
IFile resourceFile;
|
||||||
private SourceIndexer indexer;
|
private SourceIndexer indexer;
|
||||||
|
|
||||||
|
@ -179,9 +211,9 @@ public class SourceIndexerRunner extends AbstractIndexer {
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.cdt.internal.core.index.sourceindexer.AbstractIndexer#addMarkers(org.eclipse.core.resources.IFile, org.eclipse.core.resources.IFile, java.lang.Object)
|
* @see org.eclipse.cdt.internal.core.index.sourceindexer.AbstractIndexer#addMarkers(org.eclipse.core.resources.IFile, org.eclipse.core.resources.IFile, java.lang.Object, java.lang.Object)
|
||||||
*/
|
*/
|
||||||
protected void addMarkers(IFile tempFile, IFile originator, Object problem) {
|
protected void addMarkers(IFile tempFile, IFile originator, Object problem, Object location) {
|
||||||
if (problem instanceof IProblem) {
|
if (problem instanceof IProblem) {
|
||||||
IProblem iProblem = (IProblem) problem;
|
IProblem iProblem = (IProblem) problem;
|
||||||
|
|
||||||
|
@ -229,4 +261,508 @@ public class SourceIndexerRunner extends AbstractIndexer {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void addClassSpecifier(IASTClassSpecifier classSpecification, int fileNumber){
|
||||||
|
|
||||||
|
if (classSpecification.getClassKind().equals(ASTClassKind.CLASS))
|
||||||
|
{
|
||||||
|
//Get base clauses
|
||||||
|
Iterator baseClauses = classSpecification.getBaseClauses();
|
||||||
|
while (baseClauses.hasNext()){
|
||||||
|
IASTBaseSpecifier baseSpec = (IASTBaseSpecifier) baseClauses.next();
|
||||||
|
try {
|
||||||
|
IASTTypeSpecifier typeSpec = baseSpec.getParentClassSpecifier();
|
||||||
|
if (typeSpec instanceof IASTClassSpecifier){
|
||||||
|
IASTClassSpecifier baseClassSpec = (IASTClassSpecifier) typeSpec;
|
||||||
|
char[][] baseFullyQualifiedName = baseClassSpec.getFullyQualifiedNameCharArrays();
|
||||||
|
int offset = baseClassSpec.getNameOffset();
|
||||||
|
int offsetLength = baseClassSpec.getNameEndOffset() - offset;
|
||||||
|
output.addRef(fileNumber, encodeTypeEntry(baseFullyQualifiedName,DERIVED,ICSearchConstants.DECLARATIONS), offset,offsetLength, ICIndexStorageConstants.OFFSET);
|
||||||
|
}
|
||||||
|
} catch (ASTNotImplementedException e) {}
|
||||||
|
}
|
||||||
|
|
||||||
|
//Get friends
|
||||||
|
Iterator friends = classSpecification.getFriends();
|
||||||
|
while (friends.hasNext()){
|
||||||
|
Object decl = friends.next();
|
||||||
|
if (decl instanceof IASTClassSpecifier){
|
||||||
|
IASTClassSpecifier friendClassSpec = (IASTClassSpecifier) decl;
|
||||||
|
char[][] baseFullyQualifiedName = friendClassSpec.getFullyQualifiedNameCharArrays();
|
||||||
|
int offset = friendClassSpec.getNameOffset();
|
||||||
|
int offsetLength = friendClassSpec.getNameEndOffset() - offset;
|
||||||
|
output.addRef(fileNumber, encodeTypeEntry(baseFullyQualifiedName,FRIEND,ICSearchConstants.DECLARATIONS),offset, offsetLength, ICIndexStorageConstants.OFFSET);
|
||||||
|
}
|
||||||
|
else if (decl instanceof IASTElaboratedTypeSpecifier){
|
||||||
|
IASTElaboratedTypeSpecifier friendClassSpec = (IASTElaboratedTypeSpecifier) decl;
|
||||||
|
char[][] baseFullyQualifiedName = friendClassSpec.getFullyQualifiedNameCharArrays();
|
||||||
|
int offset = friendClassSpec.getNameOffset();
|
||||||
|
int offsetLength = friendClassSpec.getNameEndOffset() - offset;
|
||||||
|
output.addRef(fileNumber, encodeTypeEntry(baseFullyQualifiedName,FRIEND,ICSearchConstants.DECLARATIONS), offset, offsetLength, ICIndexStorageConstants.OFFSET);
|
||||||
|
}
|
||||||
|
else if (decl instanceof IASTFunction){
|
||||||
|
|
||||||
|
}
|
||||||
|
else if (decl instanceof IASTMethod){
|
||||||
|
//
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
int offset = classSpecification.getNameOffset();
|
||||||
|
int offsetLength = classSpecification.getNameEndOffset() - offset;
|
||||||
|
output.addRef(fileNumber, encodeTypeEntry(classSpecification.getFullyQualifiedNameCharArrays(),CLASS, ICSearchConstants.DECLARATIONS),offset, offsetLength, ICIndexStorageConstants.OFFSET);
|
||||||
|
}
|
||||||
|
else if (classSpecification.getClassKind().equals(ASTClassKind.STRUCT))
|
||||||
|
{
|
||||||
|
//Get base clauses
|
||||||
|
Iterator i = classSpecification.getBaseClauses();
|
||||||
|
while (i.hasNext()){
|
||||||
|
IASTBaseSpecifier baseSpec = (IASTBaseSpecifier) i.next();
|
||||||
|
try {
|
||||||
|
IASTTypeSpecifier typeSpec = baseSpec.getParentClassSpecifier();
|
||||||
|
if (typeSpec instanceof IASTClassSpecifier){
|
||||||
|
IASTClassSpecifier baseClassSpec = (IASTClassSpecifier) typeSpec;
|
||||||
|
char[][] baseFullyQualifiedName = baseClassSpec.getFullyQualifiedNameCharArrays();
|
||||||
|
int offset = baseClassSpec.getNameOffset();
|
||||||
|
int offsetLength = baseClassSpec.getNameEndOffset() - offset;
|
||||||
|
output.addRef(fileNumber, encodeTypeEntry(baseFullyQualifiedName,DERIVED,ICSearchConstants.DECLARATIONS),offset, offsetLength, ICIndexStorageConstants.OFFSET);
|
||||||
|
}
|
||||||
|
} catch (ASTNotImplementedException e) {}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get friends
|
||||||
|
Iterator friends = classSpecification.getFriends();
|
||||||
|
while (friends.hasNext()){
|
||||||
|
Object decl = friends.next();
|
||||||
|
if (decl instanceof IASTClassSpecifier){
|
||||||
|
IASTClassSpecifier friendClassSpec = (IASTClassSpecifier) decl;
|
||||||
|
char[][] baseFullyQualifiedName = friendClassSpec.getFullyQualifiedNameCharArrays();
|
||||||
|
int offset = friendClassSpec.getNameOffset();
|
||||||
|
int offsetLength = friendClassSpec.getNameEndOffset() - offset;
|
||||||
|
output.addRef(fileNumber, encodeTypeEntry(baseFullyQualifiedName,FRIEND,ICSearchConstants.DECLARATIONS),offset,offsetLength, ICIndexStorageConstants.OFFSET);
|
||||||
|
}
|
||||||
|
else if (decl instanceof IASTElaboratedTypeSpecifier){
|
||||||
|
IASTElaboratedTypeSpecifier friendClassSpec = (IASTElaboratedTypeSpecifier) decl;
|
||||||
|
char[][] baseFullyQualifiedName = friendClassSpec.getFullyQualifiedNameCharArrays();
|
||||||
|
int offset = friendClassSpec.getNameOffset();
|
||||||
|
int offsetLength = friendClassSpec.getNameEndOffset() - offset;
|
||||||
|
output.addRef(fileNumber, encodeTypeEntry(baseFullyQualifiedName,FRIEND,ICSearchConstants.DECLARATIONS),offset,offsetLength, ICIndexStorageConstants.OFFSET);
|
||||||
|
}
|
||||||
|
else if (decl instanceof IASTFunction){
|
||||||
|
|
||||||
|
}
|
||||||
|
else if (decl instanceof IASTMethod){
|
||||||
|
//
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int offset = classSpecification.getNameOffset();
|
||||||
|
int offsetLength = classSpecification.getNameEndOffset() - offset;
|
||||||
|
output.addRef(fileNumber, encodeTypeEntry(classSpecification.getFullyQualifiedNameCharArrays(),STRUCT, ICSearchConstants.DECLARATIONS),offset,offsetLength, ICIndexStorageConstants.OFFSET);
|
||||||
|
}
|
||||||
|
else if (classSpecification.getClassKind().equals(ASTClassKind.UNION))
|
||||||
|
{
|
||||||
|
int offset = classSpecification.getNameOffset();
|
||||||
|
int offsetLength = classSpecification.getNameEndOffset() - offset;
|
||||||
|
output.addRef(fileNumber, encodeTypeEntry(classSpecification.getFullyQualifiedNameCharArrays(),UNION, ICSearchConstants.DECLARATIONS),offset,offsetLength, ICIndexStorageConstants.OFFSET);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addEnumerationSpecifier(IASTEnumerationSpecifier enumeration, int fileNumber) {
|
||||||
|
|
||||||
|
int offset = enumeration.getNameOffset();
|
||||||
|
int offsetLength = enumeration.getNameEndOffset() - offset;
|
||||||
|
output.addRef(fileNumber, encodeTypeEntry(enumeration.getFullyQualifiedNameCharArrays(), ENUM, ICSearchConstants.DECLARATIONS),offset,offsetLength, ICIndexStorageConstants.OFFSET);
|
||||||
|
|
||||||
|
Iterator i = enumeration.getEnumerators();
|
||||||
|
while (i.hasNext())
|
||||||
|
{
|
||||||
|
IASTEnumerator en = (IASTEnumerator) i.next();
|
||||||
|
char[][] enumeratorFullName =
|
||||||
|
createEnumeratorFullyQualifiedName(en);
|
||||||
|
|
||||||
|
offset = en.getNameOffset();
|
||||||
|
offsetLength = en.getNameEndOffset() - offset;
|
||||||
|
output.addRef(fileNumber, encodeEntry( enumeratorFullName, ENUMTOR_DECL, ENUMTOR_DECL_LENGTH ),offset,offsetLength, ICIndexStorageConstants.OFFSET);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected char[][] createEnumeratorFullyQualifiedName(IASTEnumerator en) {
|
||||||
|
char[] name = en.getNameCharArray();
|
||||||
|
IASTEnumerationSpecifier parent = en.getOwnerEnumerationSpecifier();
|
||||||
|
char[][] parentName = parent.getFullyQualifiedNameCharArrays();
|
||||||
|
|
||||||
|
//See spec 7.2-10, the the scope of the enumerator is the same level as the enumeration
|
||||||
|
char[][] enumeratorFullName = new char[parentName.length][];
|
||||||
|
|
||||||
|
System.arraycopy( parentName, 0, enumeratorFullName, 0, parentName.length);
|
||||||
|
enumeratorFullName[ parentName.length - 1 ] = name;
|
||||||
|
return enumeratorFullName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addEnumeratorReference(IASTEnumerator enumerator, int fileNumber) {
|
||||||
|
|
||||||
|
int offset = enumerator.getNameOffset();
|
||||||
|
int offsetLength = enumerator.getNameEndOffset() - offset;
|
||||||
|
output.addRef(fileNumber, encodeEntry(createEnumeratorFullyQualifiedName(enumerator),ENUMTOR_REF,ENUMTOR_REF_LENGTH),offset,offsetLength, ICIndexStorageConstants.OFFSET);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addMacro(IASTMacro macro, int fileNumber) {
|
||||||
|
char[][] macroName = new char[][] { macro.getNameCharArray() };
|
||||||
|
int offset = macro.getNameOffset();
|
||||||
|
int offsetLength = macro.getNameEndOffset() - offset;
|
||||||
|
output.addRef(fileNumber, encodeEntry(macroName,MACRO_DECL,MACRO_DECL_LENGTH), offset,offsetLength, ICIndexStorageConstants.OFFSET);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addEnumerationReference(IASTEnumerationSpecifier enumeration, int fileNumber) {
|
||||||
|
int offset = enumeration.getNameOffset();
|
||||||
|
int offsetLength = enumeration.getNameEndOffset() - offset;
|
||||||
|
output.addRef(fileNumber, encodeTypeEntry(enumeration.getFullyQualifiedNameCharArrays(), ENUM, ICSearchConstants.REFERENCES), offset,offsetLength, ICIndexStorageConstants.OFFSET);
|
||||||
|
}
|
||||||
|
public void addVariable(IASTVariable variable, int fileNumber) {
|
||||||
|
int offset = variable.getNameOffset();
|
||||||
|
int offsetLength = variable.getNameEndOffset() - offset;
|
||||||
|
output.addRef(fileNumber, encodeTypeEntry(variable.getFullyQualifiedNameCharArrays(), VAR, ICSearchConstants.DECLARATIONS), offset,offsetLength, ICIndexStorageConstants.OFFSET);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addVariableReference(IASTVariable variable, int fileNumber) {
|
||||||
|
int offset = variable.getNameOffset();
|
||||||
|
int offsetLength = variable.getNameEndOffset() - offset;
|
||||||
|
output.addRef(fileNumber, encodeTypeEntry(variable.getFullyQualifiedNameCharArrays(), VAR, ICSearchConstants.REFERENCES),offset, offsetLength, ICIndexStorageConstants.OFFSET);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addParameterReference( IASTParameterDeclaration parameter, int fileNumber ){
|
||||||
|
int offset = parameter.getNameOffset();
|
||||||
|
int offsetLength = parameter.getNameEndOffset() - offset;
|
||||||
|
output.addRef(fileNumber,encodeTypeEntry( new char[][] { parameter.getNameCharArray() }, VAR, ICSearchConstants.REFERENCES), offset, offsetLength, ICIndexStorageConstants.OFFSET);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addTypedefDeclaration(IASTTypedefDeclaration typedef, int fileNumber) {
|
||||||
|
int offset = typedef.getNameOffset();
|
||||||
|
int offsetLength = typedef.getNameEndOffset() - offset;
|
||||||
|
output.addRef(fileNumber,encodeEntry(typedef.getFullyQualifiedNameCharArrays(), TYPEDEF_DECL, TYPEDEF_DECL_LENGTH),offset,offsetLength, ICIndexStorageConstants.OFFSET);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addFieldDeclaration(IASTField field, int fileNumber) {
|
||||||
|
int offset = field.getNameOffset();
|
||||||
|
int offsetLength = field.getNameEndOffset() - offset;
|
||||||
|
output.addRef(fileNumber, encodeEntry(field.getFullyQualifiedNameCharArrays(),FIELD_DECL,FIELD_DECL_LENGTH),offset,offsetLength, ICIndexStorageConstants.OFFSET);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addFieldReference(IASTField field, int fileNumber) {
|
||||||
|
int offset = field.getNameOffset();
|
||||||
|
int offsetLength = field.getNameEndOffset() - offset;
|
||||||
|
output.addRef(fileNumber, encodeEntry(field.getFullyQualifiedNameCharArrays(),FIELD_REF,FIELD_REF_LENGTH),offset,offsetLength, ICIndexStorageConstants.OFFSET);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addMethodDeclaration(IASTMethod method, int fileNumber) {
|
||||||
|
int offset = method.getNameOffset();
|
||||||
|
int offsetLength = method.getNameEndOffset() - offset;
|
||||||
|
output.addRef(fileNumber, encodeEntry(method.getFullyQualifiedNameCharArrays(),METHOD_DECL,METHOD_DECL_LENGTH),offset,offsetLength, ICIndexStorageConstants.OFFSET);
|
||||||
|
|
||||||
|
Iterator i=method.getParameters();
|
||||||
|
while (i.hasNext()){
|
||||||
|
Object parm = i.next();
|
||||||
|
if (parm instanceof IASTParameterDeclaration){
|
||||||
|
IASTParameterDeclaration parmDecl = (IASTParameterDeclaration) parm;
|
||||||
|
offset = parmDecl.getNameOffset();
|
||||||
|
offsetLength = parmDecl.getNameEndOffset() - offset;
|
||||||
|
output.addRef(fileNumber, encodeTypeEntry(new char[][]{parmDecl.getNameCharArray()}, VAR, ICSearchConstants.DECLARATIONS),offset,offsetLength, ICIndexStorageConstants.OFFSET);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addMethodReference(IASTMethod method, int fileNumber) {
|
||||||
|
int offset = method.getNameOffset();
|
||||||
|
int offsetLength = method.getNameEndOffset() - offset;
|
||||||
|
output.addRef(fileNumber, encodeEntry(method.getFullyQualifiedNameCharArrays(),METHOD_REF,METHOD_REF_LENGTH),offset,offsetLength, ICIndexStorageConstants.OFFSET);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addElaboratedForwardDeclaration(IASTElaboratedTypeSpecifier elaboratedType, int fileNumber) {
|
||||||
|
int offset = elaboratedType.getNameOffset();
|
||||||
|
int offsetLength = elaboratedType.getNameEndOffset() - offset;
|
||||||
|
|
||||||
|
if (elaboratedType.getClassKind().equals(ASTClassKind.CLASS))
|
||||||
|
{
|
||||||
|
output.addRef(fileNumber,encodeTypeEntry(elaboratedType.getFullyQualifiedNameCharArrays(),FWD_CLASS, ICSearchConstants.DECLARATIONS),offset,offsetLength, ICIndexStorageConstants.OFFSET);
|
||||||
|
}
|
||||||
|
else if (elaboratedType.getClassKind().equals(ASTClassKind.STRUCT))
|
||||||
|
{
|
||||||
|
output.addRef(fileNumber,encodeTypeEntry(elaboratedType.getFullyQualifiedNameCharArrays(),FWD_STRUCT, ICSearchConstants.DECLARATIONS),offset,offsetLength, ICIndexStorageConstants.OFFSET);
|
||||||
|
}
|
||||||
|
else if (elaboratedType.getClassKind().equals(ASTClassKind.UNION))
|
||||||
|
{
|
||||||
|
output.addRef(fileNumber,encodeTypeEntry(elaboratedType.getFullyQualifiedNameCharArrays(),FWD_UNION, ICSearchConstants.DECLARATIONS),offset,offsetLength, ICIndexStorageConstants.OFFSET);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addConstructorDeclaration(){
|
||||||
|
|
||||||
|
}
|
||||||
|
public void addConstructorReference(){
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addMemberDeclaration(){
|
||||||
|
|
||||||
|
}
|
||||||
|
public void addMemberReference(){
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addFunctionDeclaration(IASTFunction function, int fileNumber){
|
||||||
|
int offset = function.getNameOffset();
|
||||||
|
int offsetLength = function.getNameEndOffset() - offset;
|
||||||
|
|
||||||
|
output.addRef(fileNumber, encodeEntry(function.getFullyQualifiedNameCharArrays(),FUNCTION_DECL,FUNCTION_DECL_LENGTH),offset,offsetLength, ICIndexStorageConstants.OFFSET);
|
||||||
|
|
||||||
|
Iterator i=function.getParameters();
|
||||||
|
while (i.hasNext()){
|
||||||
|
Object parm = i.next();
|
||||||
|
if (parm instanceof IASTParameterDeclaration){
|
||||||
|
IASTParameterDeclaration parmDecl = (IASTParameterDeclaration) parm;
|
||||||
|
offset = parmDecl.getNameOffset();
|
||||||
|
offsetLength = parmDecl.getNameEndOffset() - offset;
|
||||||
|
output.addRef(fileNumber, encodeTypeEntry(new char[][]{parmDecl.getNameCharArray()}, VAR, ICSearchConstants.DECLARATIONS),offset,offsetLength, ICIndexStorageConstants.OFFSET);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addFunctionReference(IASTFunction function, int fileNumber){
|
||||||
|
int offset = function.getNameOffset();
|
||||||
|
int offsetLength = function.getNameEndOffset() - offset;
|
||||||
|
output.addRef(fileNumber, encodeEntry(function.getFullyQualifiedNameCharArrays(),FUNCTION_REF,FUNCTION_REF_LENGTH),offset,offsetLength, ICIndexStorageConstants.OFFSET);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addNameReference(){
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addNamespaceDefinition(IASTNamespaceDefinition namespace, int fileNumber){
|
||||||
|
int offset = namespace.getNameOffset();
|
||||||
|
int offsetLength = namespace.getNameEndOffset() - offset;
|
||||||
|
output.addRef(fileNumber, encodeEntry(namespace.getFullyQualifiedNameCharArrays(),NAMESPACE_DECL,NAMESPACE_DECL_LENGTH),offset,offsetLength, ICIndexStorageConstants.OFFSET);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addNamespaceReference(IASTNamespaceDefinition namespace, int fileNumber) {
|
||||||
|
int offset = namespace.getNameOffset();
|
||||||
|
int offsetLength = namespace.getNameEndOffset() - offset;
|
||||||
|
output.addRef(fileNumber, encodeEntry(namespace.getFullyQualifiedNameCharArrays(),NAMESPACE_REF,NAMESPACE_REF_LENGTH),offset,offsetLength, ICIndexStorageConstants.OFFSET);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addTypedefReference( IASTTypedefDeclaration typedef, int fileNumber ){
|
||||||
|
int offset = typedef.getNameOffset();
|
||||||
|
int offsetLength = typedef.getNameEndOffset() - offset;
|
||||||
|
output.addRef(fileNumber,encodeTypeEntry( typedef.getFullyQualifiedNameCharArrays(), TYPEDEF, ICSearchConstants.REFERENCES),offset, offsetLength, ICIndexStorageConstants.OFFSET);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void addSuperTypeReference(int modifiers, char[] packageName, char[] typeName, char[][] enclosingTypeNames, char classOrInterface, char[] superTypeName, char superClassOrInterface){
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addTypeReference(char[] typeName){
|
||||||
|
//output.addRef(CharOperation.concat(TYPE_REF, CharOperation.lastSegment(typeName, '.')));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addClassReference(IASTTypeSpecifier reference, int fileNumber){
|
||||||
|
char[][] fullyQualifiedName = null;
|
||||||
|
ASTClassKind classKind = null;
|
||||||
|
int offset=0;
|
||||||
|
int offsetLength=1;
|
||||||
|
|
||||||
|
if (reference instanceof IASTClassSpecifier){
|
||||||
|
IASTClassSpecifier classRef = (IASTClassSpecifier) reference;
|
||||||
|
fullyQualifiedName = classRef.getFullyQualifiedNameCharArrays();
|
||||||
|
classKind = classRef.getClassKind();
|
||||||
|
offset=classRef.getNameOffset();
|
||||||
|
}
|
||||||
|
else if (reference instanceof IASTElaboratedTypeSpecifier){
|
||||||
|
IASTElaboratedTypeSpecifier typeRef = (IASTElaboratedTypeSpecifier) reference;
|
||||||
|
fullyQualifiedName = typeRef.getFullyQualifiedNameCharArrays();
|
||||||
|
classKind = typeRef.getClassKind();
|
||||||
|
offset=typeRef.getNameOffset();
|
||||||
|
offsetLength=typeRef.getNameEndOffset()-offset;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (classKind.equals(ASTClassKind.CLASS))
|
||||||
|
{
|
||||||
|
output.addRef(fileNumber, encodeTypeEntry(fullyQualifiedName,CLASS, ICSearchConstants.REFERENCES),offset,offsetLength, ICIndexStorageConstants.OFFSET);
|
||||||
|
}
|
||||||
|
else if (classKind.equals(ASTClassKind.STRUCT))
|
||||||
|
{
|
||||||
|
output.addRef(fileNumber, encodeTypeEntry(fullyQualifiedName,STRUCT,ICSearchConstants.REFERENCES),offset,offsetLength, ICIndexStorageConstants.OFFSET);
|
||||||
|
}
|
||||||
|
else if (classKind.equals(ASTClassKind.UNION))
|
||||||
|
{
|
||||||
|
output.addRef(fileNumber, encodeTypeEntry(fullyQualifiedName,UNION,ICSearchConstants.REFERENCES),offset,offsetLength, ICIndexStorageConstants.OFFSET);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addForwardClassReference(IASTTypeSpecifier reference, int fileNumber){
|
||||||
|
char[][] fullyQualifiedName = null;
|
||||||
|
ASTClassKind classKind = null;
|
||||||
|
int offset=0;
|
||||||
|
int offsetLength=1;
|
||||||
|
if (reference instanceof IASTElaboratedTypeSpecifier){
|
||||||
|
IASTElaboratedTypeSpecifier typeRef = (IASTElaboratedTypeSpecifier) reference;
|
||||||
|
fullyQualifiedName = typeRef.getFullyQualifiedNameCharArrays();
|
||||||
|
classKind = typeRef.getClassKind();
|
||||||
|
offset=typeRef.getNameOffset();
|
||||||
|
offsetLength=typeRef.getNameEndOffset() - offset;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (classKind == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (classKind.equals(ASTClassKind.CLASS))
|
||||||
|
{
|
||||||
|
output.addRef(fileNumber, encodeTypeEntry(fullyQualifiedName,FWD_CLASS, ICSearchConstants.REFERENCES),offset,offsetLength, ICIndexStorageConstants.OFFSET);
|
||||||
|
}
|
||||||
|
else if (classKind.equals(ASTClassKind.STRUCT))
|
||||||
|
{
|
||||||
|
output.addRef(fileNumber, encodeTypeEntry(fullyQualifiedName,FWD_STRUCT,ICSearchConstants.REFERENCES),offset,offsetLength, ICIndexStorageConstants.OFFSET);
|
||||||
|
}
|
||||||
|
else if (classKind.equals(ASTClassKind.UNION))
|
||||||
|
{
|
||||||
|
output.addRef(fileNumber, encodeTypeEntry(fullyQualifiedName,FWD_UNION,ICSearchConstants.REFERENCES),offset,offsetLength, ICIndexStorageConstants.OFFSET);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addInclude(IASTInclusion inclusion, IASTInclusion parent, int fileNumber){
|
||||||
|
this.output.addIncludeRef(fileNumber, inclusion.getFullFileName());
|
||||||
|
this.output.addRelatives(fileNumber, inclusion.getFullFileName(),(parent != null ) ? parent.getFullFileName() : null);
|
||||||
|
|
||||||
|
//Add Dep Table entry
|
||||||
|
char[][] incName = new char[1][];
|
||||||
|
incName[0] = inclusion.getFullFileName().toCharArray();
|
||||||
|
//TODO: Kludge! Get rid of BOGUS entry - need to restructure Dep Tree to use reference indexes
|
||||||
|
int BOGUS_ENTRY = 1;
|
||||||
|
this.output.addRef(fileNumber, encodeEntry(incName, INCLUDE_REF, INCLUDE_REF_LENGTH),1,1, ICIndexStorageConstants.LINE);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Type entries are encoded as follow: 'typeDecl/' ('C' | 'S' | 'U' | 'E' ) '/' TypeName ['/' Qualifier]*
|
||||||
|
*/
|
||||||
|
protected static final char[] encodeTypeEntry( char[][] fullTypeName, int typeType, LimitTo encodeType){
|
||||||
|
|
||||||
|
int pos = 0, nameLength = 0;
|
||||||
|
for (int i=0; i<fullTypeName.length; i++){
|
||||||
|
char[] namePart = fullTypeName[i];
|
||||||
|
nameLength+= namePart.length;
|
||||||
|
}
|
||||||
|
|
||||||
|
char [] result = null;
|
||||||
|
if( encodeType == REFERENCES ){
|
||||||
|
//char[] has to be of size - [type decl length + length of the name + separators + letter]
|
||||||
|
result = new char[TYPE_REF_LENGTH + nameLength + fullTypeName.length + 1 ];
|
||||||
|
System.arraycopy(TYPE_REF, 0, result, 0, pos = TYPE_REF_LENGTH);
|
||||||
|
|
||||||
|
} else if( encodeType == DECLARATIONS ){
|
||||||
|
//char[] has to be of size - [type decl length + length of the name + separators + letter]
|
||||||
|
result = new char[TYPE_DECL_LENGTH + nameLength + fullTypeName.length + 1 ];
|
||||||
|
System.arraycopy(TYPE_DECL, 0, result, 0, pos = TYPE_DECL_LENGTH);
|
||||||
|
}
|
||||||
|
switch (typeType)
|
||||||
|
{
|
||||||
|
case(CLASS):
|
||||||
|
result[pos++] = CLASS_SUFFIX;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case(STRUCT):
|
||||||
|
result[pos++] = STRUCT_SUFFIX;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case(UNION):
|
||||||
|
result[pos++] = UNION_SUFFIX;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case(ENUM):
|
||||||
|
result[pos++] = ENUM_SUFFIX;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case (VAR):
|
||||||
|
result[pos++] = VAR_SUFFIX;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case (TYPEDEF):
|
||||||
|
result[pos++] = TYPEDEF_SUFFIX;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case(DERIVED):
|
||||||
|
result[pos++]= DERIVED_SUFFIX;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case(FRIEND):
|
||||||
|
result[pos++]=FRIEND_SUFFIX;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case(FWD_CLASS):
|
||||||
|
result[pos++]=FWD_CLASS_SUFFIX;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case (FWD_STRUCT):
|
||||||
|
result[pos++]=FWD_STRUCT_SUFFIX;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case (FWD_UNION):
|
||||||
|
result[pos++]=FWD_UNION_SUFFIX;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
result[pos++] = SEPARATOR;
|
||||||
|
//Encode in the following manner
|
||||||
|
// [typeDecl info]/[typeName]/[qualifiers]
|
||||||
|
if (fullTypeName.length > 0){
|
||||||
|
//Extract the name first
|
||||||
|
char [] tempName = fullTypeName[fullTypeName.length-1];
|
||||||
|
System.arraycopy(tempName, 0, result, pos, tempName.length);
|
||||||
|
pos += tempName.length;
|
||||||
|
}
|
||||||
|
//Extract the qualifiers
|
||||||
|
for (int i=fullTypeName.length - 2; i >= 0; i--){
|
||||||
|
result[pos++] = SEPARATOR;
|
||||||
|
char [] tempName = fullTypeName[i];
|
||||||
|
System.arraycopy(tempName, 0, result, pos, tempName.length);
|
||||||
|
pos+=tempName.length;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (AbstractIndexer.VERBOSE)
|
||||||
|
AbstractIndexer.verbose(new String(result));
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Namespace entries are encoded as follow: '[prefix]/' TypeName ['/' Qualifier]*
|
||||||
|
*/
|
||||||
|
protected static final char[] encodeEntry(char[][] elementName, char[] prefix, int prefixSize){
|
||||||
|
int pos, nameLength = 0;
|
||||||
|
for (int i=0; i<elementName.length; i++){
|
||||||
|
char[] namePart = elementName[i];
|
||||||
|
nameLength+= namePart.length;
|
||||||
|
}
|
||||||
|
//char[] has to be of size - [type length + length of the name (including qualifiers) +
|
||||||
|
//separators (need one less than fully qualified name length)
|
||||||
|
char[] result = new char[prefixSize + nameLength + elementName.length - 1 ];
|
||||||
|
System.arraycopy(prefix, 0, result, 0, pos = prefix.length);
|
||||||
|
if (elementName.length > 0){
|
||||||
|
//Extract the name first
|
||||||
|
char [] tempName = elementName[elementName.length-1];
|
||||||
|
System.arraycopy(tempName, 0, result, pos, tempName.length);
|
||||||
|
pos += tempName.length;
|
||||||
|
}
|
||||||
|
//Extract the qualifiers
|
||||||
|
for (int i=elementName.length - 2; i>=0; i--){
|
||||||
|
result[pos++] = SEPARATOR;
|
||||||
|
char [] tempName = elementName[i];
|
||||||
|
System.arraycopy(tempName, 0, result, pos, tempName.length);
|
||||||
|
pos+=tempName.length;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (AbstractIndexer.VERBOSE)
|
||||||
|
AbstractIndexer.verbose(new String(result));
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue