Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohn Camelon2003-07-25 15:21:57 +0000
committerJohn Camelon2003-07-25 15:21:57 +0000
commitee5dac3bd969724276e4e64d44a351bcc7605a81 (patch)
treee0c7a226ee8df0e7a053ff1205916bbd5548fd48 /core/org.eclipse.cdt.core/index
parent8b6f29d3ad700d1d2589421a199f254b15c1a4ac (diff)
downloadorg.eclipse.cdt-ee5dac3bd969724276e4e64d44a351bcc7605a81.tar.gz
org.eclipse.cdt-ee5dac3bd969724276e4e64d44a351bcc7605a81.tar.xz
org.eclipse.cdt-ee5dac3bd969724276e4e64d44a351bcc7605a81.zip
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.
Diffstat (limited to 'core/org.eclipse.cdt.core/index')
-rw-r--r--core/org.eclipse.cdt.core/index/ChangeLog11
-rw-r--r--core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/search/indexing/AbstractIndexer.java75
-rw-r--r--core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/search/indexing/IIndexConstants.java10
-rw-r--r--core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/search/indexing/SourceIndexer.java2
-rw-r--r--core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/search/indexing/SourceIndexerRequestor.java25
5 files changed, 99 insertions, 24 deletions
diff --git a/core/org.eclipse.cdt.core/index/ChangeLog b/core/org.eclipse.cdt.core/index/ChangeLog
index b5aff0b8451..6b6f35ebc22 100644
--- a/core/org.eclipse.cdt.core/index/ChangeLog
+++ b/core/org.eclipse.cdt.core/index/ChangeLog
@@ -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
diff --git a/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/search/indexing/AbstractIndexer.java b/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/search/indexing/AbstractIndexer.java
index fdb0bb0e23e..95eba9c7e6a 100644
--- a/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/search/indexing/AbstractIndexer.java
+++ b/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/search/indexing/AbstractIndexer.java
@@ -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];
diff --git a/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/search/indexing/IIndexConstants.java b/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/search/indexing/IIndexConstants.java
index c7696f87d81..21a9a3b14bb 100644
--- a/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/search/indexing/IIndexConstants.java
+++ b/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/search/indexing/IIndexConstants.java
@@ -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;
diff --git a/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/search/indexing/SourceIndexer.java b/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/search/indexing/SourceIndexer.java
index bf265670f55..dadcb92e928 100644
--- a/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/search/indexing/SourceIndexer.java
+++ b/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/search/indexing/SourceIndexer.java
@@ -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();
}
diff --git a/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/search/indexing/SourceIndexerRequestor.java b/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/search/indexing/SourceIndexerRequestor.java
index bfb4f983fb2..50aa9b3b99f 100644
--- a/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/search/indexing/SourceIndexerRequestor.java
+++ b/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/search/indexing/SourceIndexerRequestor.java
@@ -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());
}
}

Back to the top