Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[cdt-patch] Indexer patch


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.

Bogdan

Index: index/ChangeLog
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/index/ChangeLog,v
retrieving revision 1.6
diff -u -r1.6 ChangeLog
--- index/ChangeLog	24 Jul 2003 21:43:47 -0000	1.6
+++ index/ChangeLog	25 Jul 2003 14:56:33 -0000
@@ -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
Index: index/org/eclipse/cdt/internal/core/search/indexing/AbstractIndexer.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/search/indexing/AbstractIndexer.java,v
retrieving revision 1.7
diff -u -r1.7 AbstractIndexer.java
--- index/org/eclipse/cdt/internal/core/search/indexing/AbstractIndexer.java	24 Jul 2003 21:43:47 -0000	1.7
+++ index/org/eclipse/cdt/internal/core/search/indexing/AbstractIndexer.java	25 Jul 2003 14:56:34 -0000
@@ -14,7 +14,9 @@
 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.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 @@
 
 		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 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 @@
 		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 @@
 		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 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 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 @@
 	/**
 	 * 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];
Index: index/org/eclipse/cdt/internal/core/search/indexing/IIndexConstants.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/search/indexing/IIndexConstants.java,v
retrieving revision 1.4
diff -u -r1.4 IIndexConstants.java
--- index/org/eclipse/cdt/internal/core/search/indexing/IIndexConstants.java	24 Jul 2003 21:43:47 -0000	1.4
+++ index/org/eclipse/cdt/internal/core/search/indexing/IIndexConstants.java	25 Jul 2003 14:56:34 -0000
@@ -19,11 +19,15 @@
 	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 @@
 	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;
Index: index/org/eclipse/cdt/internal/core/search/indexing/SourceIndexer.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/search/indexing/SourceIndexer.java,v
retrieving revision 1.4
diff -u -r1.4 SourceIndexer.java
--- index/org/eclipse/cdt/internal/core/search/indexing/SourceIndexer.java	18 Jul 2003 16:39:22 -0000	1.4
+++ index/org/eclipse/cdt/internal/core/search/indexing/SourceIndexer.java	25 Jul 2003 14:56:34 -0000
@@ -60,7 +60,7 @@
 		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();
 		}
Index: index/org/eclipse/cdt/internal/core/search/indexing/SourceIndexerRequestor.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/search/indexing/SourceIndexerRequestor.java,v
retrieving revision 1.7
diff -u -r1.7 SourceIndexerRequestor.java
--- index/org/eclipse/cdt/internal/core/search/indexing/SourceIndexerRequestor.java	21 Jul 2003 21:14:06 -0000	1.7
+++ index/org/eclipse/cdt/internal/core/search/indexing/SourceIndexerRequestor.java	25 Jul 2003 14:56:34 -0000
@@ -272,6 +272,9 @@
 	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 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());
 	}
 }
Index: search/ChangeLog
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/search/ChangeLog,v
retrieving revision 1.7
diff -u -r1.7 ChangeLog
--- search/ChangeLog	24 Jul 2003 21:43:47 -0000	1.7
+++ search/ChangeLog	25 Jul 2003 14:56:34 -0000
@@ -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.
Index: search/org/eclipse/cdt/internal/core/search/IIndexSearchRequestor.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/search/org/eclipse/cdt/internal/core/search/IIndexSearchRequestor.java,v
retrieving revision 1.1
diff -u -r1.1 IIndexSearchRequestor.java
--- search/org/eclipse/cdt/internal/core/search/IIndexSearchRequestor.java	11 Jul 2003 22:12:35 -0000	1.1
+++ search/org/eclipse/cdt/internal/core/search/IIndexSearchRequestor.java	25 Jul 2003 14:56:35 -0000
@@ -46,7 +46,7 @@
  * 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 @@
  * 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);
+
 }
Index: search/org/eclipse/cdt/internal/core/search/PathCollector.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/search/org/eclipse/cdt/internal/core/search/PathCollector.java,v
retrieving revision 1.1
diff -u -r1.1 PathCollector.java
--- search/org/eclipse/cdt/internal/core/search/PathCollector.java	11 Jul 2003 22:12:35 -0000	1.1
+++ search/org/eclipse/cdt/internal/core/search/PathCollector.java	25 Jul 2003 14:56:35 -0000
@@ -66,9 +66,15 @@
 		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);
 	}
@@ -105,6 +111,24 @@
 		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.
 	 */
 	public IFile[] getFiles(IWorkspace workspace) {
@@ -128,4 +152,7 @@
 		}
 		return result;
 	}
+
+	
+
 }
Index: search/org/eclipse/cdt/internal/core/search/matching/FieldDeclarationPattern.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/search/org/eclipse/cdt/internal/core/search/matching/FieldDeclarationPattern.java,v
retrieving revision 1.3
diff -u -r1.3 FieldDeclarationPattern.java
--- search/org/eclipse/cdt/internal/core/search/matching/FieldDeclarationPattern.java	24 Jul 2003 21:43:47 -0000	1.3
+++ search/org/eclipse/cdt/internal/core/search/matching/FieldDeclarationPattern.java	25 Jul 2003 14:56:35 -0000
@@ -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;
 
 
@@ -87,6 +93,19 @@
 				this.decodedQualifications[ i ] = temp[ temp.length - i - 1 ];
 			}
 		}
+	}
+	
+	/* (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() {
Index: search/org/eclipse/cdt/internal/core/search/matching/FunctionDeclarationPattern.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/search/org/eclipse/cdt/internal/core/search/matching/FunctionDeclarationPattern.java,v
retrieving revision 1.3
diff -u -r1.3 FunctionDeclarationPattern.java
--- search/org/eclipse/cdt/internal/core/search/matching/FunctionDeclarationPattern.java	24 Jul 2003 21:43:47 -0000	1.3
+++ search/org/eclipse/cdt/internal/core/search/matching/FunctionDeclarationPattern.java	25 Jul 2003 14:56:35 -0000
@@ -25,6 +25,7 @@
 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 @@
 	 * @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)
Index: search/org/eclipse/cdt/internal/core/search/matching/MethodDeclarationPattern.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/search/org/eclipse/cdt/internal/core/search/matching/MethodDeclarationPattern.java,v
retrieving revision 1.3
diff -u -r1.3 MethodDeclarationPattern.java
--- search/org/eclipse/cdt/internal/core/search/matching/MethodDeclarationPattern.java	24 Jul 2003 21:43:47 -0000	1.3
+++ search/org/eclipse/cdt/internal/core/search/matching/MethodDeclarationPattern.java	25 Jul 2003 14:56:35 -0000
@@ -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;
 
 /**
@@ -98,5 +104,15 @@
 		}
 		
 		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);
+			}
+		}
 	}
 }
Index: search/org/eclipse/cdt/internal/core/search/matching/NamespaceDeclarationPattern.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/search/org/eclipse/cdt/internal/core/search/matching/NamespaceDeclarationPattern.java,v
retrieving revision 1.3
diff -u -r1.3 NamespaceDeclarationPattern.java
--- search/org/eclipse/cdt/internal/core/search/matching/NamespaceDeclarationPattern.java	24 Jul 2003 21:43:47 -0000	1.3
+++ search/org/eclipse/cdt/internal/core/search/matching/NamespaceDeclarationPattern.java	25 Jul 2003 14:56:35 -0000
@@ -20,6 +20,7 @@
 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 @@
 	 * @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)
Index: search/org/eclipse/cdt/internal/core/search/matching/VariableDeclarationPattern.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/search/org/eclipse/cdt/internal/core/search/matching/VariableDeclarationPattern.java,v
retrieving revision 1.3
diff -u -r1.3 VariableDeclarationPattern.java
--- search/org/eclipse/cdt/internal/core/search/matching/VariableDeclarationPattern.java	24 Jul 2003 21:43:47 -0000	1.3
+++ search/org/eclipse/cdt/internal/core/search/matching/VariableDeclarationPattern.java	25 Jul 2003 14:56:35 -0000
@@ -21,6 +21,7 @@
 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 @@
 	 * @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)
Index: ChangeLog
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core.tests/ChangeLog,v
retrieving revision 1.34
diff -u -r1.34 ChangeLog
--- ChangeLog	25 Jul 2003 00:35:42 -0000	1.34
+++ ChangeLog	25 Jul 2003 14:57:01 -0000
@@ -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). 
Index: indexer/org/eclipse/cdt/core/indexer/tests/IndexManagerTests.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core.tests/indexer/org/eclipse/cdt/core/indexer/tests/IndexManagerTests.java,v
retrieving revision 1.6
diff -u -r1.6 IndexManagerTests.java
--- indexer/org/eclipse/cdt/core/indexer/tests/IndexManagerTests.java	24 Jul 2003 14:20:11 -0000	1.6
+++ indexer/org/eclipse/cdt/core/indexer/tests/IndexManagerTests.java	25 Jul 2003 14:57:01 -0000
@@ -51,7 +51,7 @@
 	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 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 @@
 		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 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");
Index: resources/indexer/reftest.cpp
===================================================================
RCS file: resources/indexer/reftest.cpp
diff -N resources/indexer/reftest.cpp
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ resources/indexer/reftest.cpp	25 Jul 2003 14:57:01 -0000
@@ -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;
\ No newline at end of file

Back to the top