mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-06-06 17:26:01 +02:00
Patch for Bogdan Gheorghe.
This patch adds type refs, function refs, method refs, fireld refs and namespace refs to the index and changes the parser mode to complete parse.
This commit is contained in:
parent
8b6f29d3ad
commit
ee5dac3bd9
17 changed files with 310 additions and 39 deletions
|
@ -1,3 +1,6 @@
|
|||
2003-07-25 Bogdan Gheorghe
|
||||
Added new indexer test for refs
|
||||
|
||||
2003-07-24 John Camelon
|
||||
Updated CompleteParseASTTests for Method/Field updates.
|
||||
Fixed TortureTest's parser mode switch (was always QuickParsing).
|
||||
|
|
|
@ -51,7 +51,7 @@ public class IndexManagerTests extends TestCase {
|
|||
IProject testProject;
|
||||
NullProgressMonitor monitor;
|
||||
IndexManager indexManager;
|
||||
public static final int TIMEOUT = 1500;
|
||||
public static final int TIMEOUT = 10000;
|
||||
/**
|
||||
* Constructor for IndexManagerTest.
|
||||
* @param name
|
||||
|
@ -84,10 +84,10 @@ public class IndexManagerTests extends TestCase {
|
|||
}
|
||||
|
||||
public static Test suite() {
|
||||
//TestSuite suite = new TestSuite();
|
||||
//suite.addTest(new IndexManagerTests("testDependencyTree"));
|
||||
//return suite;
|
||||
return new TestSuite(IndexManagerTests.class);
|
||||
TestSuite suite = new TestSuite();
|
||||
suite.addTest(new IndexManagerTests("testRefs"));
|
||||
return suite;
|
||||
//return new TestSuite(IndexManagerTests.class);
|
||||
}
|
||||
/*
|
||||
* Utils
|
||||
|
@ -282,6 +282,8 @@ public class IndexManagerTests extends TestCase {
|
|||
IIndex ind = indexManager.getIndex(testProjectPath,true,true);
|
||||
assertTrue("Index exists for project",ind != null);
|
||||
|
||||
IEntryResult[] typerefreesults = ind.queryEntries(IIndexConstants.TYPE_REF);
|
||||
|
||||
String [] typeDeclEntryResultModel ={"EntryResult: word=typeDecl/C/Mail/Y/X/Z, refs={ 1 }","EntryResult: word=typeDecl/C/Unknown/Y/X/Z, refs={ 1 }","EntryResult: word=typeDecl/C/container/Y/X/Z, refs={ 1 }","EntryResult: word=typeDecl/C/first_class/Y/X/Z, refs={ 1 }","EntryResult: word=typeDecl/C/postcard/Y/X/Z, refs={ 1 }","EntryResult: word=typeDecl/E/test/Y/X/Z, refs={ 1 }","EntryResult: word=typeDecl/V/x/Z, refs={ 1 }"};
|
||||
IEntryResult[] typedeclresults =ind.queryEntries(IIndexConstants.TYPE_DECL);
|
||||
|
||||
|
@ -349,6 +351,75 @@ public class IndexManagerTests extends TestCase {
|
|||
}
|
||||
}
|
||||
|
||||
public void testRefs() throws Exception{
|
||||
//Add a new file to the project, give it some time to index
|
||||
importFile("reftest.cpp","resources/indexer/reftest.cpp");
|
||||
//Enable indexing on the created project
|
||||
//By doing this, we force the Index Manager to indexAll()
|
||||
indexManager = CCorePlugin.getDefault().getCoreModel().getIndexManager();
|
||||
indexManager.setEnabled(testProject,true);
|
||||
Thread.sleep(TIMEOUT);
|
||||
//Make sure project got added to index
|
||||
IPath testProjectPath = testProject.getFullPath();
|
||||
IIndex ind = indexManager.getIndex(testProjectPath,true,true);
|
||||
assertTrue("Index exists for project",ind != null);
|
||||
|
||||
String [] typeRefEntryResultModel ={"EntryResult: word=typeRef/C/C/B/A, refs={ 1 }", "EntryResult: word=typeRef/E/e1/B/A, refs={ 1 }", "EntryResult: word=typeRef/V/x/B/A, refs={ 1 }"};
|
||||
IEntryResult[] typerefresults = ind.queryEntries(IIndexConstants.TYPE_REF);
|
||||
|
||||
if (typerefresults.length != typeRefEntryResultModel.length)
|
||||
fail("Entry Result length different from model for typeRef");
|
||||
|
||||
for (int i=0;i<typerefresults.length; i++)
|
||||
{
|
||||
assertEquals(typeRefEntryResultModel[i],typerefresults[i].toString());
|
||||
}
|
||||
|
||||
String [] funRefEntryResultModel ={"EntryResult: word=functionRef/something/A, refs={ 1 }"};
|
||||
IEntryResult[] funRefresults = ind.queryEntries(IIndexConstants.FUNCTION_REF);
|
||||
|
||||
if (funRefresults.length != funRefEntryResultModel.length)
|
||||
fail("Entry Result length different from model for funcRef");
|
||||
|
||||
for (int i=0;i<funRefresults.length; i++)
|
||||
{
|
||||
assertEquals(funRefEntryResultModel[i],funRefresults[i].toString());
|
||||
}
|
||||
|
||||
String [] namespaceRefResultModel = {"EntryResult: word=namespaceRef/A, refs={ 1 }", "EntryResult: word=namespaceRef/B/A, refs={ 1 }"};
|
||||
IEntryResult[] namespacerefresults = ind.queryEntries(IIndexConstants.NAMESPACE_REF);
|
||||
|
||||
if (namespacerefresults.length != namespaceRefResultModel.length)
|
||||
fail("Entry Result length different from model for namespaceRef");
|
||||
|
||||
for (int i=0;i<namespacerefresults.length; i++)
|
||||
{
|
||||
assertEquals(namespaceRefResultModel[i],namespacerefresults[i].toString());
|
||||
}
|
||||
|
||||
String [] fieldRefResultModel = {"EntryResult: word=fieldRef/y/C/B/A, refs={ 1 }"};
|
||||
IEntryResult[] fieldrefresults = ind.queryEntries(IIndexConstants.FIELD_REF);
|
||||
|
||||
if (fieldrefresults.length != fieldRefResultModel.length)
|
||||
fail("Entry Result length different from model for fieldRef");
|
||||
|
||||
for (int i=0;i<fieldrefresults.length; i++)
|
||||
{
|
||||
assertEquals(fieldRefResultModel[i],fieldrefresults[i].toString());
|
||||
}
|
||||
|
||||
String [] methodRefResultModel = {"EntryResult: word=methodRef/bar/C/B/A, refs={ 1 }"};
|
||||
IEntryResult[] methodrefresults = ind.queryEntries(IIndexConstants.METHOD_REF);
|
||||
|
||||
if (methodrefresults.length != methodRefResultModel.length)
|
||||
fail("Entry Result length different from model for methodRef");
|
||||
|
||||
for (int i=0;i<methodrefresults.length; i++)
|
||||
{
|
||||
assertEquals(methodRefResultModel[i],methodrefresults[i].toString());
|
||||
}
|
||||
}
|
||||
|
||||
public void testDependencyTree() throws Exception{
|
||||
//Add a file to the project
|
||||
IFile depTest = importFile("DepTest.cpp","resources/dependency/DepTest.cpp");
|
||||
|
|
|
@ -0,0 +1,20 @@
|
|||
namespace A
|
||||
{
|
||||
int something(void);
|
||||
namespace B
|
||||
{
|
||||
enum e1{dude1,dude2};
|
||||
int x;
|
||||
class C
|
||||
{ static int y = 5;
|
||||
static int bar(void);
|
||||
};
|
||||
}
|
||||
}
|
||||
using namespace A::B;
|
||||
using A::B::x;
|
||||
using A::B::C;
|
||||
using A::B::C::y;
|
||||
using A::B::C::bar;
|
||||
using A::something;
|
||||
using A::B::e1;
|
|
@ -1,3 +1,14 @@
|
|||
2003-07-25 Bogdan Gheorghe
|
||||
- Changed parser to COMPLETE mode
|
||||
- Added functionRef, methodRef, typeRef, namespaceRef, fieldRef
|
||||
|
||||
Modified:
|
||||
* index/org/eclipse/cdt/internal/core/search/indexing/AbstractIndexer.java
|
||||
* index/org/eclipse/cdt/internal/core/search/indexing/IIndexConstants.java
|
||||
* index/org/eclipse/cdt/internal/core/search/indexing/SourceIndexer.java
|
||||
* index/org/eclipse/cdt/internal/core/search/indexing/SourceIndexerRequestor.java
|
||||
|
||||
|
||||
2003-07-24 Andrew Niefer
|
||||
- added TYPE_ALL, FUNCTION_ALL, METHOD_ALL, NAMESPACE_ALL, FIELD_ALL constants to IIndexConstants
|
||||
- modified AbstractIndexer prefix functions to properly handle searching for all occurences
|
||||
|
|
|
@ -14,7 +14,9 @@ package org.eclipse.cdt.internal.core.search.indexing;
|
|||
import java.io.IOException;
|
||||
import java.util.Iterator;
|
||||
|
||||
import org.eclipse.cdt.core.parser.ISourceElementCallbackDelegate;
|
||||
import org.eclipse.cdt.core.parser.ast.ASTClassKind;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTClassReference;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTClassSpecifier;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTEnumerationSpecifier;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTEnumerator;
|
||||
|
@ -22,6 +24,7 @@ import org.eclipse.cdt.core.parser.ast.IASTField;
|
|||
import org.eclipse.cdt.core.parser.ast.IASTFunction;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTMethod;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTNamespaceDefinition;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTNamespaceReference;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTTypedefDeclaration;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTVariable;
|
||||
import org.eclipse.cdt.core.search.ICSearchConstants;
|
||||
|
@ -47,20 +50,20 @@ public abstract class AbstractIndexer implements IIndexer, IIndexConstants, ICSe
|
|||
|
||||
if (classSpecification.getClassKind().equals(ASTClassKind.CLASS))
|
||||
{
|
||||
this.output.addRef(encodeTypeEntry(classSpecification.getFullyQualifiedName(),CLASS));
|
||||
this.output.addRef(encodeTypeEntry(classSpecification.getFullyQualifiedName(),CLASS, ICSearchConstants.DECLARATIONS));
|
||||
}
|
||||
else if (classSpecification.getClassKind().equals(ASTClassKind.STRUCT))
|
||||
{
|
||||
this.output.addRef(encodeTypeEntry(classSpecification.getFullyQualifiedName(),STRUCT));
|
||||
this.output.addRef(encodeTypeEntry(classSpecification.getFullyQualifiedName(),STRUCT, ICSearchConstants.DECLARATIONS));
|
||||
}
|
||||
else if (classSpecification.getClassKind().equals(ASTClassKind.UNION))
|
||||
{
|
||||
this.output.addRef(encodeTypeEntry(classSpecification.getFullyQualifiedName(),UNION));
|
||||
this.output.addRef(encodeTypeEntry(classSpecification.getFullyQualifiedName(),UNION, ICSearchConstants.DECLARATIONS));
|
||||
}
|
||||
}
|
||||
|
||||
public void addEnumerationSpecifier(IASTEnumerationSpecifier enumeration) {
|
||||
this.output.addRef(encodeTypeEntry(enumeration.getFullyQualifiedName(), ENUM));
|
||||
this.output.addRef(encodeTypeEntry(enumeration.getFullyQualifiedName(), ENUM, ICSearchConstants.DECLARATIONS));
|
||||
|
||||
Iterator i = enumeration.getEnumerators();
|
||||
while (i.hasNext())
|
||||
|
@ -78,12 +81,19 @@ public abstract class AbstractIndexer implements IIndexer, IIndexConstants, ICSe
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
public void addEnumerationReference(IASTEnumerationSpecifier enumeration) {
|
||||
this.output.addRef(encodeTypeEntry(enumeration.getFullyQualifiedName(), ENUM, ICSearchConstants.REFERENCES));
|
||||
}
|
||||
public void addVariable(IASTVariable variable) {
|
||||
|
||||
this.output.addRef(encodeTypeEntry(variable.getFullyQualifiedName(), VAR));
|
||||
this.output.addRef(encodeTypeEntry(variable.getFullyQualifiedName(), VAR, ICSearchConstants.DECLARATIONS));
|
||||
}
|
||||
|
||||
public void addVariableReference(IASTVariable variable) {
|
||||
|
||||
this.output.addRef(encodeTypeEntry(variable.getFullyQualifiedName(), VAR, ICSearchConstants.REFERENCES));
|
||||
}
|
||||
|
||||
public void addTypedefDeclaration(IASTTypedefDeclaration typedef) {
|
||||
this.output.addRef(encodeEntry(typedef.getFullyQualifiedName(), TYPEDEF_DECL, TYPEDEF_DECL_LENGTH));
|
||||
}
|
||||
|
@ -92,10 +102,18 @@ public abstract class AbstractIndexer implements IIndexer, IIndexConstants, ICSe
|
|||
this.output.addRef(encodeEntry(field.getFullyQualifiedName(),FIELD_DECL,FIELD_DECL_LENGTH));
|
||||
}
|
||||
|
||||
public void addFieldReference(IASTField field) {
|
||||
this.output.addRef(encodeEntry(field.getFullyQualifiedName(),FIELD_REF,FIELD_REF_LENGTH));
|
||||
}
|
||||
|
||||
public void addMethodDeclaration(IASTMethod method) {
|
||||
this.output.addRef(encodeEntry(method.getFullyQualifiedName(),METHOD_DECL,METHOD_DECL_LENGTH));
|
||||
}
|
||||
|
||||
public void addMethodReference(IASTMethod method) {
|
||||
this.output.addRef(encodeEntry(method.getFullyQualifiedName(),METHOD_REF,METHOD_REF_LENGTH));
|
||||
}
|
||||
|
||||
public void addConstructorDeclaration(){
|
||||
|
||||
}
|
||||
|
@ -114,8 +132,8 @@ public abstract class AbstractIndexer implements IIndexer, IIndexConstants, ICSe
|
|||
this.output.addRef(encodeEntry(function.getFullyQualifiedName(),FUNCTION_DECL,FUNCTION_DECL_LENGTH));
|
||||
}
|
||||
|
||||
public void addFunctionReference(){
|
||||
|
||||
public void addFunctionReference(IASTFunction function){
|
||||
this.output.addRef(encodeEntry(function.getFullyQualifiedName(),FUNCTION_REF,FUNCTION_REF_LENGTH));
|
||||
}
|
||||
|
||||
public void addNameReference(){
|
||||
|
@ -125,6 +143,10 @@ public abstract class AbstractIndexer implements IIndexer, IIndexConstants, ICSe
|
|||
public void addNamespaceDefinition(IASTNamespaceDefinition namespace){
|
||||
this.output.addRef(encodeEntry(namespace.getFullyQualifiedName(),NAMESPACE_DECL,NAMESPACE_DECL_LENGTH));
|
||||
}
|
||||
|
||||
public void addNamespaceReference(IASTNamespaceDefinition namespace) {
|
||||
this.output.addRef(encodeEntry(namespace.getFullyQualifiedName(),NAMESPACE_REF,NAMESPACE_REF_LENGTH));
|
||||
}
|
||||
|
||||
private void addSuperTypeReference(int modifiers, char[] packageName, char[] typeName, char[][] enclosingTypeNames, char classOrInterface, char[] superTypeName, char superClassOrInterface){
|
||||
|
||||
|
@ -133,18 +155,43 @@ public abstract class AbstractIndexer implements IIndexer, IIndexConstants, ICSe
|
|||
public void addTypeReference(char[] typeName){
|
||||
//this.output.addRef(CharOperation.concat(TYPE_REF, CharOperation.lastSegment(typeName, '.')));
|
||||
}
|
||||
|
||||
public void addClassReference(IASTClassSpecifier reference){
|
||||
if (reference.getClassKind().equals(ASTClassKind.CLASS))
|
||||
{
|
||||
this.output.addRef(encodeTypeEntry(reference.getFullyQualifiedName(),CLASS, ICSearchConstants.REFERENCES));
|
||||
}
|
||||
else if (reference.getClassKind().equals(ASTClassKind.STRUCT))
|
||||
{
|
||||
this.output.addRef(encodeTypeEntry(reference.getFullyQualifiedName(),STRUCT,ICSearchConstants.REFERENCES));
|
||||
}
|
||||
else if (reference.getClassKind().equals(ASTClassKind.UNION))
|
||||
{
|
||||
this.output.addRef(encodeTypeEntry(reference.getFullyQualifiedName(),UNION,ICSearchConstants.REFERENCES));
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Type entries are encoded as follow: 'typeDecl/' ('C' | 'S' | 'U' | 'E' ) '/' TypeName ['/' Qualifier]*
|
||||
*/
|
||||
protected static final char[] encodeTypeEntry( String [] fullTypeName, int typeType) {
|
||||
int pos, nameLength = 0;
|
||||
protected static final char[] encodeTypeEntry( String [] fullTypeName, int typeType, LimitTo encodeType){
|
||||
|
||||
int pos = 0, nameLength = 0;
|
||||
for (int i=0; i<fullTypeName.length; i++){
|
||||
String namePart = fullTypeName[i];
|
||||
nameLength+= namePart.length();
|
||||
}
|
||||
//char[] has to be of size - [type decl length + length of the name + separators + letter]
|
||||
char[] result = new char[TYPE_DECL_LENGTH + nameLength + fullTypeName.length + 1 ];
|
||||
System.arraycopy(TYPE_DECL, 0, result, 0, pos = TYPE_DECL_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):
|
||||
|
@ -188,7 +235,7 @@ public abstract class AbstractIndexer implements IIndexer, IIndexConstants, ICSe
|
|||
/**
|
||||
* Namespace entries are encoded as follow: '[prefix]/' TypeName ['/' Qualifier]*
|
||||
*/
|
||||
protected static final char[] encodeEntry(String[] elementName, char[] prefix, int prefixSize) {
|
||||
protected static final char[] encodeEntry(String[] elementName, char[] prefix, int prefixSize){
|
||||
int pos, nameLength = 0;
|
||||
for (int i=0; i<elementName.length; i++){
|
||||
String namePart = elementName[i];
|
||||
|
|
|
@ -19,11 +19,15 @@ public interface IIndexConstants {
|
|||
char[] REF= "ref/".toCharArray(); //$NON-NLS-1$
|
||||
|
||||
char[] TYPE_REF= "typeRef/".toCharArray(); //$NON-NLS-1$
|
||||
int TYPE_REF_LENGTH = 8;
|
||||
|
||||
char[] TYPE_DECL = "typeDecl/".toCharArray(); //$NON-NLS-1$
|
||||
char[] TYPE_ALL = "type".toCharArray(); //$NON-NLS-1$
|
||||
int TYPE_DECL_LENGTH = 9;
|
||||
|
||||
char[] FUNCTION_REF= "functionRef/".toCharArray(); //$NON-NLS-1$
|
||||
int FUNCTION_REF_LENGTH=12;
|
||||
|
||||
char[] FUNCTION_DECL= "functionDecl/".toCharArray(); //$NON-NLS-1$
|
||||
char[] FUNCTION_ALL= "function".toCharArray(); //$NON-NLS-1$
|
||||
int FUNCTION_DECL_LENGTH = 13;
|
||||
|
@ -32,17 +36,23 @@ public interface IIndexConstants {
|
|||
char[] CONSTRUCTOR_DECL= "constructorDecl/".toCharArray(); //$NON-NLS-1$
|
||||
|
||||
char[] NAMESPACE_REF= "namespaceRef/".toCharArray(); //$NON-NLS-1$
|
||||
int NAMESPACE_REF_LENGTH=13;
|
||||
|
||||
char[] NAMESPACE_DECL= "namespaceDecl/".toCharArray(); //$NON-NLS-1$
|
||||
char[] NAMESPACE_ALL = "namespace".toCharArray(); //$NON-NLS-1$
|
||||
int NAMESPACE_DECL_LENGTH = 14;
|
||||
|
||||
|
||||
char[] FIELD_REF= "fieldRef/".toCharArray(); //$NON-NLS-1$
|
||||
int FIELD_REF_LENGTH=9;
|
||||
|
||||
char[] FIELD_DECL= "fieldDecl/".toCharArray(); //$NON-NLS-1$
|
||||
char[] FIELD_ALL= "field".toCharArray(); //$NON-NLS-1$
|
||||
int FIELD_DECL_LENGTH = 10;
|
||||
|
||||
char[] METHOD_REF= "methodRef/".toCharArray(); //$NON-NLS-1$
|
||||
int METHOD_REF_LENGTH = 10;
|
||||
|
||||
char[] METHOD_DECL= "methodDecl/".toCharArray(); //$NON-NLS-1$
|
||||
char[] METHOD_ALL= "method".toCharArray(); //$NON-NLS-1$
|
||||
int METHOD_DECL_LENGTH = 11;
|
||||
|
|
|
@ -60,7 +60,7 @@ public class SourceIndexer extends AbstractIndexer {
|
|||
SourceIndexerRequestor requestor = new SourceIndexerRequestor(this, document);
|
||||
IParser parser = ParserFactory.createParser(
|
||||
ParserFactory.createScanner( new StringReader( document.getStringContent() ), document.getName(), new ScannerInfo(), ParserMode.QUICK_PARSE, requestor ),
|
||||
requestor, ParserMode.QUICK_PARSE);
|
||||
requestor, ParserMode.COMPLETE_PARSE);
|
||||
try{
|
||||
parser.parse();
|
||||
}
|
||||
|
|
|
@ -272,6 +272,9 @@ public class SourceIndexerRequestor implements ISourceElementRequestor, IIndexCo
|
|||
public void acceptClassReference(IASTClassReference reference) {
|
||||
// TODO Auto-generated method stub
|
||||
//System.out.println("acceptClassReference");
|
||||
if (reference.getReferencedElement() instanceof IASTClassSpecifier)
|
||||
indexer.addClassReference((IASTClassSpecifier)reference.getReferencedElement());
|
||||
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
|
@ -374,41 +377,45 @@ public class SourceIndexerRequestor implements ISourceElementRequestor, IIndexCo
|
|||
*/
|
||||
public void acceptNamespaceReference(IASTNamespaceReference reference) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
if (reference.getReferencedElement() instanceof IASTNamespaceDefinition)
|
||||
indexer.addNamespaceReference((IASTNamespaceDefinition)reference.getReferencedElement());
|
||||
}
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.parser.ISourceElementRequestor#acceptEnumerationReference(org.eclipse.cdt.core.parser.ast.IASTEnumerationReference)
|
||||
*/
|
||||
public void acceptEnumerationReference(IASTEnumerationReference reference) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
if (reference.getReferencedElement() instanceof IASTEnumerationSpecifier)
|
||||
indexer.addEnumerationReference((IASTEnumerationSpecifier) reference.getReferencedElement());
|
||||
}
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.parser.ISourceElementRequestor#acceptVariableReference(org.eclipse.cdt.core.parser.ast.IASTVariableReference)
|
||||
*/
|
||||
public void acceptVariableReference(IASTVariableReference reference) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
if (reference.getReferencedElement() instanceof IASTVariable)
|
||||
indexer.addVariableReference((IASTVariable)reference.getReferencedElement());
|
||||
|
||||
}
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.parser.ISourceElementRequestor#acceptFunctionReference(org.eclipse.cdt.core.parser.ast.IASTFunctionReference)
|
||||
*/
|
||||
public void acceptFunctionReference(IASTFunctionReference reference) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
if (reference.getReferencedElement() instanceof IASTFunction)
|
||||
indexer.addFunctionReference((IASTFunction) reference.getReferencedElement());
|
||||
}
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.parser.ISourceElementRequestor#acceptFieldReference(org.eclipse.cdt.core.parser.ast.IASTFieldReference)
|
||||
*/
|
||||
public void acceptFieldReference(IASTFieldReference reference) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
if (reference.getReferencedElement() instanceof IASTField)
|
||||
indexer.addFieldReference((IASTField) reference.getReferencedElement());
|
||||
}
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.parser.ISourceElementRequestor#acceptMethodReference(org.eclipse.cdt.core.parser.ast.IASTMethodReference)
|
||||
*/
|
||||
public void acceptMethodReference(IASTMethodReference reference) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
if (reference.getReferencedElement() instanceof IASTMethod)
|
||||
indexer.addMethodReference((IASTMethod) reference.getReferencedElement());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -152,7 +152,7 @@ public class Parser implements IParser
|
|||
|
||||
compilationUnit.enterScope( requestor );
|
||||
IToken lastBacktrack = null;
|
||||
IToken checkToken;
|
||||
IToken checkToken = null;
|
||||
while (true)
|
||||
{
|
||||
try
|
||||
|
@ -192,7 +192,11 @@ public class Parser implements IParser
|
|||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
// we've done the best we can
|
||||
try {
|
||||
failParse();
|
||||
} catch (EndOfFile e1) {
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
compilationUnit.exitScope( requestor );
|
||||
|
|
|
@ -1,3 +1,7 @@
|
|||
2003-07-25 Bogdan Gheorghe
|
||||
- Added refs to PathCollector
|
||||
- Filled in feedIndexRequestor for the new search patterns
|
||||
|
||||
2003-07-24 Andrew Niefer
|
||||
- Implemented decodeIndexEntry & matchIndexEntry for all patterns
|
||||
- changed MatchLocator to use a COMPLETE_PARSE.
|
||||
|
|
|
@ -46,7 +46,7 @@ void acceptFieldReference(String resourcePath, char[] fieldName);
|
|||
* Accepts the declaration of a method in the compilation unit with the given resource path.
|
||||
* The method is declared with a given method name and number of arguments.
|
||||
*/
|
||||
void acceptMethodDeclaration(String resourcePath, char[] methodName, int parameterCount);
|
||||
void acceptMethodDeclaration(String resourcePath, char[] methodName, int parameterCount, char[][] enclosingTypeNames);
|
||||
/**
|
||||
* Accepts the reference to a method in the compilation unit with the given resource path.
|
||||
* The method is referenced using the given selector and a number of arguments.
|
||||
|
@ -66,4 +66,18 @@ void acceptSuperTypeReference(String resourcePath, char[] qualification, char[]
|
|||
* Note that the resource path can be null if the search query doesn't require it.
|
||||
*/
|
||||
void acceptTypeReference(String resourcePath, char[] typeName);
|
||||
/**
|
||||
* Accepts the declaration of a namespace in the compilation unit with the given resource path.
|
||||
*/
|
||||
void acceptNamespaceDeclaration(String resourcePath, char[] typeName, char[][] enclosingTypeNames);
|
||||
/**
|
||||
* Accepts the declaration of a function in the compilation unit with the given resource path.
|
||||
* The function is declared with a given function name and number of arguments.
|
||||
*/
|
||||
void acceptFunctionDeclaration(String resourcePath, char[] methodName, int parameterCount);
|
||||
|
||||
void acceptVariableDeclaration(String resourcePath, char[] simpleTypeName);
|
||||
|
||||
void acceptFieldDeclaration(String resourcePath, char[] simpleTypeName, char[][] enclosingTypeNames);
|
||||
|
||||
}
|
|
@ -65,10 +65,16 @@ import org.eclipse.core.runtime.Path;
|
|||
|
||||
this.paths.add(resourcePath);
|
||||
}
|
||||
/**
|
||||
* @see IIndexSearchRequestor
|
||||
*/
|
||||
public void acceptFunctionDeclaration(String resourcePath, char[] methodName, int parameterCount) {
|
||||
this.paths.add(resourcePath);
|
||||
}
|
||||
/**
|
||||
* @see IIndexSearchRequestor
|
||||
*/
|
||||
public void acceptMethodDeclaration(String resourcePath, char[] methodName, int parameterCount) {
|
||||
public void acceptMethodDeclaration(String resourcePath, char[] methodName, int parameterCount, char[][] enclosingTypeNames) {
|
||||
|
||||
this.paths.add(resourcePath);
|
||||
}
|
||||
|
@ -104,6 +110,24 @@ import org.eclipse.core.runtime.Path;
|
|||
public void acceptTypeReference(String resourcePath, char[] typeName) {
|
||||
this.paths.add(resourcePath);
|
||||
}
|
||||
/**
|
||||
* @see IIndexSearchRequestor
|
||||
*/
|
||||
public void acceptNamespaceDeclaration(String resourcePath, char[] typeName, char[][] enclosingTypeNames) {
|
||||
this.paths.add(resourcePath);
|
||||
}
|
||||
/**
|
||||
* @see IIndexSearchRequestor
|
||||
*/
|
||||
public void acceptVariableDeclaration(String resourcePath, char[] simpleTypeName) {
|
||||
this.paths.add(resourcePath);
|
||||
}
|
||||
/**
|
||||
* @see IIndexSearchRequestor
|
||||
*/
|
||||
public void acceptFieldDeclaration(String resourcePath, char[] simpleTypeName, char[][] enclosingTypeNames) {
|
||||
this.paths.add(resourcePath);
|
||||
}
|
||||
/**
|
||||
* Returns the files that correspond to the paths that have been collected.
|
||||
*/
|
||||
|
@ -128,4 +152,7 @@ import org.eclipse.core.runtime.Path;
|
|||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -13,11 +13,17 @@
|
|||
*/
|
||||
package org.eclipse.cdt.internal.core.search.matching;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import org.eclipse.cdt.core.parser.ISourceElementCallbackDelegate;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTField;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTQualifiedNameElement;
|
||||
import org.eclipse.cdt.core.search.ICSearchScope;
|
||||
import org.eclipse.cdt.internal.core.index.IEntryResult;
|
||||
import org.eclipse.cdt.internal.core.index.impl.IndexInput;
|
||||
import org.eclipse.cdt.internal.core.index.impl.IndexedFile;
|
||||
import org.eclipse.cdt.internal.core.search.CharOperation;
|
||||
import org.eclipse.cdt.internal.core.search.IIndexSearchRequestor;
|
||||
import org.eclipse.cdt.internal.core.search.indexing.AbstractIndexer;
|
||||
|
||||
|
||||
|
@ -88,6 +94,19 @@ public class FieldDeclarationPattern extends VariableDeclarationPattern {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.internal.core.search.matching.CSearchPattern#feedIndexRequestor(org.eclipse.cdt.internal.core.search.IIndexSearchRequestor, int, int[], org.eclipse.cdt.internal.core.index.impl.IndexInput, org.eclipse.cdt.core.search.ICSearchScope)
|
||||
*/
|
||||
public void feedIndexRequestor(IIndexSearchRequestor requestor, int detailLevel, int[] references, IndexInput input, ICSearchScope scope) throws IOException {
|
||||
for (int i = 0, max = references.length; i < max; i++) {
|
||||
IndexedFile file = input.getIndexedFile(references[i]);
|
||||
String path;
|
||||
if (file != null && scope.encloses(path =file.getPath())) {
|
||||
requestor.acceptFieldDeclaration(path, decodedSimpleName,decodedQualifications);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected boolean matchIndexEntry() {
|
||||
/* check simple name matches */
|
||||
|
|
|
@ -25,6 +25,7 @@ import org.eclipse.cdt.core.parser.ast.IASTTypeSpecifier;
|
|||
import org.eclipse.cdt.core.search.ICSearchScope;
|
||||
import org.eclipse.cdt.internal.core.index.IEntryResult;
|
||||
import org.eclipse.cdt.internal.core.index.impl.IndexInput;
|
||||
import org.eclipse.cdt.internal.core.index.impl.IndexedFile;
|
||||
import org.eclipse.cdt.internal.core.search.CharOperation;
|
||||
import org.eclipse.cdt.internal.core.search.IIndexSearchRequestor;
|
||||
import org.eclipse.cdt.internal.core.search.indexing.AbstractIndexer;
|
||||
|
@ -105,8 +106,13 @@ public class FunctionDeclarationPattern extends CSearchPattern {
|
|||
* @see org.eclipse.cdt.internal.core.search.matching.CSearchPattern#feedIndexRequestor(org.eclipse.cdt.internal.core.search.IIndexSearchRequestor, int, int[], org.eclipse.cdt.internal.core.index.impl.IndexInput, org.eclipse.cdt.core.search.ICSearchScope)
|
||||
*/
|
||||
public void feedIndexRequestor(IIndexSearchRequestor requestor, int detailLevel, int[] references, IndexInput input, ICSearchScope scope) throws IOException {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
for (int i = 0, max = references.length; i < max; i++) {
|
||||
IndexedFile file = input.getIndexedFile(references[i]);
|
||||
String path;
|
||||
if (file != null && scope.encloses(path =file.getPath())) {
|
||||
requestor.acceptFunctionDeclaration(path, decodedSimpleName, parameterNames.length);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
|
|
|
@ -13,10 +13,16 @@
|
|||
*/
|
||||
package org.eclipse.cdt.internal.core.search.matching;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import org.eclipse.cdt.core.parser.ISourceElementCallbackDelegate;
|
||||
import org.eclipse.cdt.core.parser.ast.*;
|
||||
import org.eclipse.cdt.core.search.ICSearchScope;
|
||||
import org.eclipse.cdt.internal.core.index.IEntryResult;
|
||||
import org.eclipse.cdt.internal.core.index.impl.IndexInput;
|
||||
import org.eclipse.cdt.internal.core.index.impl.IndexedFile;
|
||||
import org.eclipse.cdt.internal.core.search.CharOperation;
|
||||
import org.eclipse.cdt.internal.core.search.IIndexSearchRequestor;
|
||||
import org.eclipse.cdt.internal.core.search.indexing.AbstractIndexer;
|
||||
|
||||
/**
|
||||
|
@ -99,4 +105,14 @@ public class MethodDeclarationPattern extends FunctionDeclarationPattern {
|
|||
|
||||
return true;
|
||||
}
|
||||
|
||||
public void feedIndexRequestor(IIndexSearchRequestor requestor, int detailLevel, int[] references, IndexInput input, ICSearchScope scope) throws IOException {
|
||||
for (int i = 0, max = references.length; i < max; i++) {
|
||||
IndexedFile file = input.getIndexedFile(references[i]);
|
||||
String path;
|
||||
if (file != null && scope.encloses(path =file.getPath())) {
|
||||
requestor.acceptMethodDeclaration(path, decodedSimpleName, parameterNames.length, decodedQualifications);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,6 +20,7 @@ import org.eclipse.cdt.core.parser.ast.IASTNamespaceDefinition;
|
|||
import org.eclipse.cdt.core.search.ICSearchScope;
|
||||
import org.eclipse.cdt.internal.core.index.IEntryResult;
|
||||
import org.eclipse.cdt.internal.core.index.impl.IndexInput;
|
||||
import org.eclipse.cdt.internal.core.index.impl.IndexedFile;
|
||||
import org.eclipse.cdt.internal.core.search.CharOperation;
|
||||
import org.eclipse.cdt.internal.core.search.IIndexSearchRequestor;
|
||||
import org.eclipse.cdt.internal.core.search.indexing.AbstractIndexer;
|
||||
|
@ -83,8 +84,13 @@ public class NamespaceDeclarationPattern extends CSearchPattern {
|
|||
* @see org.eclipse.cdt.internal.core.search.matching.CSearchPattern#feedIndexRequestor(org.eclipse.cdt.internal.core.search.IIndexSearchRequestor, int, int[], org.eclipse.cdt.internal.core.index.impl.IndexInput, org.eclipse.cdt.core.search.ICSearchScope)
|
||||
*/
|
||||
public void feedIndexRequestor(IIndexSearchRequestor requestor, int detailLevel, int[] references, IndexInput input, ICSearchScope scope) throws IOException {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
for (int i = 0, max = references.length; i < max; i++) {
|
||||
IndexedFile file = input.getIndexedFile(references[i]);
|
||||
String path;
|
||||
if (file != null && scope.encloses(path =file.getPath())) {
|
||||
requestor.acceptNamespaceDeclaration(path, decodedSimpleName, decodedContainingTypes);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
|
|
|
@ -21,6 +21,7 @@ import org.eclipse.cdt.core.parser.ast.IASTVariable;
|
|||
import org.eclipse.cdt.core.search.ICSearchScope;
|
||||
import org.eclipse.cdt.internal.core.index.IEntryResult;
|
||||
import org.eclipse.cdt.internal.core.index.impl.IndexInput;
|
||||
import org.eclipse.cdt.internal.core.index.impl.IndexedFile;
|
||||
import org.eclipse.cdt.internal.core.search.CharOperation;
|
||||
import org.eclipse.cdt.internal.core.search.IIndexSearchRequestor;
|
||||
import org.eclipse.cdt.internal.core.search.indexing.AbstractIndexer;
|
||||
|
@ -67,8 +68,13 @@ public class VariableDeclarationPattern extends CSearchPattern {
|
|||
* @see org.eclipse.cdt.internal.core.search.matching.CSearchPattern#feedIndexRequestor(org.eclipse.cdt.internal.core.search.IIndexSearchRequestor, int, int[], org.eclipse.cdt.internal.core.index.impl.IndexInput, org.eclipse.cdt.core.search.ICSearchScope)
|
||||
*/
|
||||
public void feedIndexRequestor(IIndexSearchRequestor requestor, int detailLevel, int[] references, IndexInput input, ICSearchScope scope) throws IOException {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
for (int i = 0, max = references.length; i < max; i++) {
|
||||
IndexedFile file = input.getIndexedFile(references[i]);
|
||||
String path;
|
||||
if (file != null && scope.encloses(path =file.getPath())) {
|
||||
requestor.acceptVariableDeclaration(path, decodedSimpleName);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
|
|
Loading…
Add table
Reference in a new issue