[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
[cdt-patch] Searching for operators (bug43063 & bug 42979) and Parameter references
|
core :
- add parameter references to index
- modify CharOperation.match to allow escaping wildcards
(bug43063)
- modify AbstractIndexer.bestPrefix to handle wildcard escaping in
name (bug43063)
- modify CSearchPattern to handle escaping wildcards (bug43063)
- modify enterFunctionBody and enterMethodBody to fix bug42979
- search for Parameter References
- added setThrowExceptionOnBadCharacterRead to IScanner to help
with wildcard bug43063
tests:
- modified resources/search/classDecl.cpp & include.h to include
some operators
- added testOperators_bug43063_bug42979() to
MethodDeclarationPatternTests
- added testParameterREferences to OtherPatternTests
-Andrew
Index: index/ChangeLog
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/index/ChangeLog,v
retrieving revision 1.18
diff -u -r1.18 ChangeLog
--- index/ChangeLog 15 Sep 2003 17:31:22 -0000 1.18
+++ index/ChangeLog 16 Sep 2003 21:13:07 -0000
@@ -1,3 +1,8 @@
+2003-09-16 Andrew Niefer
+ - add parameter references to index
+ - modify CharOperation.match to allow escaping wildcards (bug43063)
+ - modify AbstractIndexer.bestPrefix to handle wildcard escaping in name (bug43063)
+
2003-09-13 Andrew Niefer
- add Typedefs to index as Types with suffix T (bug42902)
- added addTypedefReference to AbstractIndexer
Index: index/org/eclipse/cdt/internal/core/CharOperation.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/CharOperation.java,v
retrieving revision 1.1
diff -u -r1.1 CharOperation.java
--- index/org/eclipse/cdt/internal/core/CharOperation.java 12 Aug 2003 20:20:04 -0000 1.1
+++ index/org/eclipse/cdt/internal/core/CharOperation.java 16 Sep 2003 21:13:07 -0000
@@ -1530,7 +1530,7 @@
name,
0,
name.length,
- isCaseSensitive);
+ isCaseSensitive, true);
}
/**
* Answers true if the a sub-pattern matches the subpart of the given name, false otherwise.
@@ -1583,7 +1583,21 @@
char[] name,
int nameStart,
int nameEnd,
- boolean isCaseSensitive) {
+ boolean isCaseSensitive){
+
+ return match( pattern, patternStart, patternEnd, name, nameStart, nameEnd, isCaseSensitive, false );
+ }
+
+
+ public static final boolean match(
+ char[] pattern,
+ int patternStart,
+ int patternEnd,
+ char[] name,
+ int nameStart,
+ int nameEnd,
+ boolean isCaseSensitive,
+ boolean allowEscaping) {
if (name == null)
return false; // null name cannot match
@@ -1599,8 +1613,17 @@
/* check first segment */
char patternChar = 0;
- while ((iPattern < patternEnd)
- && (patternChar = pattern[iPattern]) != '*') {
+ boolean isEscaped = false;
+ while ((iPattern < patternEnd) &&
+ ( (patternChar = pattern[iPattern]) != '*' ||
+ (patternChar == '*' && isEscaped) ) ) {
+
+ if( allowEscaping && pattern[iPattern] == '\\' && !isEscaped ){
+ iPattern++;
+ isEscaped = true;
+ continue;
+ } else isEscaped = false;
+
if (iName == nameEnd)
return false;
if (patternChar
@@ -1612,6 +1635,7 @@
}
iName++;
iPattern++;
+ patternChar = 0;
}
/* check sequence of star+segment */
int segmentStart;
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.18
diff -u -r1.18 AbstractIndexer.java
--- index/org/eclipse/cdt/internal/core/search/indexing/AbstractIndexer.java 15 Sep 2003 17:31:23 -0000 1.18
+++ index/org/eclipse/cdt/internal/core/search/indexing/AbstractIndexer.java 16 Sep 2003 21:13:07 -0000
@@ -24,6 +24,7 @@
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;
@@ -118,6 +119,10 @@
this.output.addRef(encodeTypeEntry(variable.getFullyQualifiedName(), VAR, ICSearchConstants.REFERENCES));
}
+ public void addParameterReference( IASTParameterDeclaration parameter ){
+ this.output.addRef( encodeTypeEntry( new String [] { parameter.getName() }, VAR, ICSearchConstants.REFERENCES));
+ }
+
public void addTypedefDeclaration(IASTTypedefDeclaration typedef) {
this.output.addRef(encodeEntry(typedef.getFullyQualifiedName(), TYPEDEF_DECL, TYPEDEF_DECL_LENGTH));
}
@@ -463,7 +468,7 @@
char[] result = null;
int pos = 0;
- int wildPos, starPos, questionPos;
+ int wildPos, starPos = -1, questionPos;
//length of prefix + separator
int length = prefix.length;
@@ -477,7 +482,29 @@
//type name.
name = null;
} else if( matchMode == PATTERN_MATCH && name != null ){
- starPos = CharOperation.indexOf( '*', name );
+ int start = 0;
+
+ char [] temp = new char [ name.length ];
+ boolean isEscaped = false;
+ int tmpIdx = 0;
+ for( int i = 0; i < name.length; i++ ){
+ if( name[i] == '\\' ){
+ if( !isEscaped ){
+ isEscaped = true;
+ continue;
+ }
+ isEscaped = false;
+ } else if( name[i] == '*' && !isEscaped ){
+ starPos = i;
+ break;
+ }
+ temp[ tmpIdx++ ] = name[i];
+ }
+
+ name = new char [ tmpIdx ];
+ System.arraycopy( temp, 0, name, 0, tmpIdx );
+
+ //starPos = CharOperation.indexOf( '*', name );
questionPos = CharOperation.indexOf( '?', name );
if( starPos >= 0 ){
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.18
diff -u -r1.18 SourceIndexerRequestor.java
--- index/org/eclipse/cdt/internal/core/search/indexing/SourceIndexerRequestor.java 15 Sep 2003 22:50:25 -0000 1.18
+++ index/org/eclipse/cdt/internal/core/search/indexing/SourceIndexerRequestor.java 16 Sep 2003 21:13:08 -0000
@@ -39,6 +39,7 @@
import org.eclipse.cdt.core.parser.ast.IASTMethodReference;
import org.eclipse.cdt.core.parser.ast.IASTNamespaceDefinition;
import org.eclipse.cdt.core.parser.ast.IASTNamespaceReference;
+import org.eclipse.cdt.core.parser.ast.IASTParameterDeclaration;
import org.eclipse.cdt.core.parser.ast.IASTParameterReference;
import org.eclipse.cdt.core.parser.ast.IASTTemplateDeclaration;
import org.eclipse.cdt.core.parser.ast.IASTTemplateInstantiation;
@@ -450,7 +451,8 @@
*/
public void acceptParameterReference(IASTParameterReference reference)
{
- // TODO Auto-generated method stub
+ if( reference.getReferencedElement() instanceof IASTParameterDeclaration )
+ indexer.addParameterReference( (IASTParameterDeclaration) reference.getReferencedElement() );
}
}
Index: parser/ChangeLog
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/parser/ChangeLog,v
retrieving revision 1.130
diff -u -r1.130 ChangeLog
--- parser/ChangeLog 16 Sep 2003 15:34:43 -0000 1.130
+++ parser/ChangeLog 16 Sep 2003 21:13:08 -0000
@@ -1,3 +1,6 @@
+2003-09-16 Andrew Niefer
+ - added setThrowExceptionOnBadCharacterRead to IScanner to help with wildcard bug43063
+
2003-09-16 John Camelon
Implement CompleteParse IASTFunction::previouslyDeclared().
Index: parser/org/eclipse/cdt/core/parser/IScanner.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/IScanner.java,v
retrieving revision 1.12
diff -u -r1.12 IScanner.java
--- parser/org/eclipse/cdt/core/parser/IScanner.java 8 Sep 2003 18:10:48 -0000 1.12
+++ parser/org/eclipse/cdt/core/parser/IScanner.java 16 Sep 2003 21:13:08 -0000
@@ -30,7 +30,8 @@
public IToken nextTokenForStringizing() throws ScannerException, EndOfFile;
public void setTokenizingMacroReplacementList(boolean b);
-
+ public void setThrowExceptionOnBadCharacterRead( boolean throwOnBad );
+
public void onParseEnd();
/**
* @param i
Index: parser/org/eclipse/cdt/internal/core/parser/Scanner.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/Scanner.java,v
retrieving revision 1.54
diff -u -r1.54 Scanner.java
--- parser/org/eclipse/cdt/internal/core/parser/Scanner.java 15 Sep 2003 22:50:25 -0000 1.54
+++ parser/org/eclipse/cdt/internal/core/parser/Scanner.java 16 Sep 2003 21:13:09 -0000
@@ -2398,6 +2398,10 @@
language = value;
}
+ public void setThrowExceptionOnBadCharacterRead( boolean throwOnBad ){
+ throwExceptionOnBadCharacterRead = throwOnBad;
+ }
+
private final ISourceElementRequestor requestor;
private IASTFactory astFactory = null;
Index: search/ChangeLog
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/search/ChangeLog,v
retrieving revision 1.24
diff -u -r1.24 ChangeLog
--- search/ChangeLog 15 Sep 2003 17:31:22 -0000 1.24
+++ search/ChangeLog 16 Sep 2003 21:13:09 -0000
@@ -1,3 +1,8 @@
+2003-09-15 Andrew Niefer
+ - modify CSearchPattern to handle escaping wildcards (bug43063)
+ - modify enterFunctionBody and enterMethodBody to fix bug42979
+ - search for Parameter References
+
2003-09-13 Andrew Niefer
-Searching for Typedefs: (bug42902)
- modified setElementInfo in BasicSearchResultCollector
Index: search/org/eclipse/cdt/internal/core/search/matching/CSearchPattern.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/search/org/eclipse/cdt/internal/core/search/matching/CSearchPattern.java,v
retrieving revision 1.21
diff -u -r1.21 CSearchPattern.java
--- search/org/eclipse/cdt/internal/core/search/matching/CSearchPattern.java 15 Sep 2003 17:31:22 -0000 1.21
+++ search/org/eclipse/cdt/internal/core/search/matching/CSearchPattern.java 16 Sep 2003 21:13:09 -0000
@@ -415,6 +415,7 @@
try {
IToken token = ( unusedToken != null ) ? unusedToken : scanner.nextToken();
+ scanner.setThrowExceptionOnBadCharacterRead( true );
boolean lastTokenWasWild = false;
@@ -432,13 +433,26 @@
lastTokenWasWild = true;
} else if( !lastTokenWasWild && name.length() > 0 ) {
name += " ";
+ } else {
+ lastTokenWasWild = false;
}
name += token.getImage();
break;
}
+ token = null;
+ while( token == null ){
+ try{
+ token = scanner.nextToken();
+ } catch ( ScannerException e ){
+ if( e.getErrorCode() == ScannerException.ErrorCode.INVALID_ESCAPE_CHARACTER_SEQUENCE ){
+ if( !lastTokenWasWild ) name += " ";
+ name += "\\";
+ lastTokenWasWild = true;
+ }
+ }
+ }
- token = scanner.nextToken();
}
} catch (EndOfFile e) {
list.addLast( name.toCharArray() );
Index: search/org/eclipse/cdt/internal/core/search/matching/ClassDeclarationPattern.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/search/org/eclipse/cdt/internal/core/search/matching/ClassDeclarationPattern.java,v
retrieving revision 1.13
diff -u -r1.13 ClassDeclarationPattern.java
--- search/org/eclipse/cdt/internal/core/search/matching/ClassDeclarationPattern.java 15 Sep 2003 17:31:22 -0000 1.13
+++ search/org/eclipse/cdt/internal/core/search/matching/ClassDeclarationPattern.java 16 Sep 2003 21:13:09 -0000
@@ -105,15 +105,17 @@
return IMPOSSIBLE_MATCH;
}
- //create char[][] out of full name,
- String [] fullName = ((IASTQualifiedNameElement) node).getFullyQualifiedName();
- char [][] qualName = new char [ fullName.length - 1 ][];
- for( int i = 0; i < fullName.length - 1; i++ ){
- qualName[i] = fullName[i].toCharArray();
- }
- //check containing scopes
- if( !matchQualifications( qualifications, qualName ) ){
- return IMPOSSIBLE_MATCH;
+ if( node instanceof IASTQualifiedNameElement ){
+ //create char[][] out of full name,
+ String [] fullName = ((IASTQualifiedNameElement) node).getFullyQualifiedName();
+ char [][] qualName = new char [ fullName.length - 1 ][];
+ for( int i = 0; i < fullName.length - 1; i++ ){
+ qualName[i] = fullName[i].toCharArray();
+ }
+ //check containing scopes
+ if( !matchQualifications( qualifications, qualName ) ){
+ return IMPOSSIBLE_MATCH;
+ }
}
//check type
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.9
diff -u -r1.9 FieldDeclarationPattern.java
--- search/org/eclipse/cdt/internal/core/search/matching/FieldDeclarationPattern.java 5 Sep 2003 18:31:39 -0000 1.9
+++ search/org/eclipse/cdt/internal/core/search/matching/FieldDeclarationPattern.java 16 Sep 2003 21:13:09 -0000
@@ -20,6 +20,7 @@
import org.eclipse.cdt.core.parser.ast.IASTEnumerator;
import org.eclipse.cdt.core.parser.ast.IASTField;
import org.eclipse.cdt.core.parser.ast.IASTOffsetableNamedElement;
+import org.eclipse.cdt.core.parser.ast.IASTParameterDeclaration;
import org.eclipse.cdt.core.parser.ast.IASTQualifiedNameElement;
import org.eclipse.cdt.core.parser.ast.IASTVariable;
import org.eclipse.cdt.core.search.ICSearchScope;
@@ -64,7 +65,10 @@
} else if ( node instanceof IASTEnumerator ){
if( searchFor != FIELD || !canAccept( limit ) )
return IMPOSSIBLE_MATCH;
- } else return IMPOSSIBLE_MATCH;
+ } else if( node instanceof IASTParameterDeclaration ){
+ if( searchFor != VAR || !canAccept( limit ) )
+ return IMPOSSIBLE_MATCH;
+ } else return IMPOSSIBLE_MATCH;
String nodeName = ((IASTOffsetableNamedElement)node).getName();
@@ -91,17 +95,19 @@
enumeratorFullName[ fullName.length - 1 ] = nodeName;
fullName = enumeratorFullName;
- } else {
+ } else if( node instanceof IASTQualifiedNameElement ){
fullName = ((IASTQualifiedNameElement) node).getFullyQualifiedName();
- }
+ }
- char [][] qualName = new char [ fullName.length - 1 ][];
- for( int i = 0; i < fullName.length - 1; i++ ){
- qualName[i] = fullName[i].toCharArray();
- }
- //check containing scopes
- if( !matchQualifications( qualifications, qualName ) ){
- return IMPOSSIBLE_MATCH;
+ if( fullName != null ){
+ char [][] qualName = new char [ fullName.length - 1 ][];
+ for( int i = 0; i < fullName.length - 1; i++ ){
+ qualName[i] = fullName[i].toCharArray();
+ }
+ //check containing scopes
+ if( !matchQualifications( qualifications, qualName ) ){
+ return IMPOSSIBLE_MATCH;
+ }
}
return ACCURATE_MATCH;
Index: search/org/eclipse/cdt/internal/core/search/matching/MatchLocator.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/search/org/eclipse/cdt/internal/core/search/matching/MatchLocator.java,v
retrieving revision 1.29
diff -u -r1.29 MatchLocator.java
--- search/org/eclipse/cdt/internal/core/search/matching/MatchLocator.java 15 Sep 2003 22:50:25 -0000 1.29
+++ search/org/eclipse/cdt/internal/core/search/matching/MatchLocator.java 16 Sep 2003 21:13:09 -0000
@@ -129,6 +129,14 @@
public void enterCodeBlock(IASTCodeScope scope) { }
public void exitCodeBlock(IASTCodeScope scope) { }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.core.parser.ISourceElementRequestor#acceptParameterReference(org.eclipse.cdt.internal.core.parser.ast.complete.ASTParameterReference)
+ */
+ public void acceptParameterReference(IASTParameterReference reference)
+ {
+ check( REFERENCES, reference );
+ }
public void acceptTypedefDeclaration(IASTTypedefDeclaration typedef){
lastDeclaration = typedef;
@@ -208,13 +216,19 @@
public void enterFunctionBody(IASTFunction function){
lastDeclaration = function;
- check( DECLARATIONS, function );
+
+ if( !function.previouslyDeclared() )
+ check( DECLARATIONS, function );
+
check( DEFINITIONS, function );
pushScope( function );
}
public void enterMethodBody(IASTMethod method) {
lastDeclaration = method;
+ if( !method.previouslyDeclared() )
+ check( DECLARATIONS, method );
+
check( DEFINITIONS, method );
pushScope( method );
}
@@ -471,7 +485,7 @@
if( level != ICSearchPattern.IMPOSSIBLE_MATCH )
{
report( node, level );
- }
+ }
}
private void pushScope( IASTScope scope ){
@@ -509,15 +523,4 @@
public static void verbose(String log) {
System.out.println("(" + Thread.currentThread() + ") " + log);
}
-
- /* (non-Javadoc)
- * @see org.eclipse.cdt.core.parser.ISourceElementRequestor#acceptParameterReference(org.eclipse.cdt.internal.core.parser.ast.complete.ASTParameterReference)
- */
- public void acceptParameterReference(IASTParameterReference reference)
- {
- // TODO Auto-generated method stub
-
- }
-
-
}
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.9
diff -u -r1.9 MethodDeclarationPattern.java
--- search/org/eclipse/cdt/internal/core/search/matching/MethodDeclarationPattern.java 9 Sep 2003 15:46:38 -0000 1.9
+++ search/org/eclipse/cdt/internal/core/search/matching/MethodDeclarationPattern.java 16 Sep 2003 21:13:10 -0000
@@ -79,16 +79,18 @@
return IMPOSSIBLE_MATCH;
}
- //create char[][] out of full name,
- String [] fullName = ((IASTQualifiedNameElement) node).getFullyQualifiedName();
- char [][] qualName = new char [ fullName.length - 1 ][];
- for( int i = 0; i < fullName.length - 1; i++ ){
- qualName[i] = fullName[i].toCharArray();
- }
-
- //check containing scopes
- if( !matchQualifications( qualifications, qualName ) ){
- return IMPOSSIBLE_MATCH;
+ if( node instanceof IASTQualifiedNameElement ){
+ //create char[][] out of full name,
+ String [] fullName = ((IASTQualifiedNameElement) node).getFullyQualifiedName();
+ char [][] qualName = new char [ fullName.length - 1 ][];
+ for( int i = 0; i < fullName.length - 1; i++ ){
+ qualName[i] = fullName[i].toCharArray();
+ }
+
+ //check containing scopes
+ if( !matchQualifications( qualifications, qualName ) ){
+ return IMPOSSIBLE_MATCH;
+ }
}
//parameters
Index: ChangeLog
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core.tests/ChangeLog,v
retrieving revision 1.100
diff -u -r1.100 ChangeLog
--- ChangeLog 16 Sep 2003 17:31:43 -0000 1.100
+++ ChangeLog 16 Sep 2003 21:12:56 -0000
@@ -1,4 +1,9 @@
-2003-09-17 Bogdan Gheorghe
+2003-09-16 Andrew Niefer
+ - modified resources/search/classDecl.cpp & include.h to include some operators
+ - added testOperators_bug43063_bug42979() to MethodDeclarationPatternTests
+ - added testParameterREferences to OtherPatternTests
+
+2003-09-16 Bogdan Gheorghe
Added asserts to all index lookups in IndexManagerTests
Fixed testAddNewFileToIndex
Index: resources/search/classDecl.cpp
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core.tests/resources/search/classDecl.cpp,v
retrieving revision 1.10
diff -u -r1.10 classDecl.cpp
--- resources/search/classDecl.cpp 15 Sep 2003 17:31:17 -0000 1.10
+++ resources/search/classDecl.cpp 16 Sep 2003 21:12:56 -0000
@@ -53,4 +53,12 @@
AClassForFoo foo( AClassForFoo ){
AClassForFoo b;
return b;
+}
+
+Head * Head::operator *= ( int index ){
+ return array[ index ];
+}
+
+Head * Head::operator += ( int index ){
+ return array[ index ];
}
Index: resources/search/include.h
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core.tests/resources/search/include.h,v
retrieving revision 1.1
diff -u -r1.1 include.h
--- resources/search/include.h 1 Aug 2003 19:26:55 -0000 1.1
+++ resources/search/include.h 16 Sep 2003 21:12:56 -0000
@@ -2,6 +2,11 @@
#define INCLUDE_H
class Head {
+ Head * operator *= ( int index );
+ Head * operator * ( int index ){ return array[ index ]; }
+ Head * operator += ( int index );
+
+ Head ** array;
};
#endif
Index: search/org/eclipse/cdt/core/search/tests/FunctionMethodPatternTests.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core.tests/search/org/eclipse/cdt/core/search/tests/FunctionMethodPatternTests.java,v
retrieving revision 1.7
diff -u -r1.7 FunctionMethodPatternTests.java
--- search/org/eclipse/cdt/core/search/tests/FunctionMethodPatternTests.java 9 Sep 2003 15:46:43 -0000 1.7
+++ search/org/eclipse/cdt/core/search/tests/FunctionMethodPatternTests.java 16 Sep 2003 21:12:56 -0000
@@ -16,6 +16,7 @@
import java.util.Set;
import org.eclipse.cdt.core.search.ICSearchPattern;
+import org.eclipse.cdt.core.search.IMatch;
import org.eclipse.cdt.core.search.SearchEngine;
import org.eclipse.cdt.internal.core.CharOperation;
import org.eclipse.cdt.internal.core.search.matching.MethodDeclarationPattern;
@@ -102,5 +103,41 @@
search( workspace, pattern, scope, resultCollector );
matches = resultCollector.getSearchResults();
assertEquals( matches.size(), 1 );
+ }
+
+ public void testOperators_bug43063_bug42979(){
+ ICSearchPattern pattern = SearchEngine.createSearchPattern( "operator \\*", METHOD, DECLARATIONS, true );
+
+ search( workspace, pattern, scope, resultCollector );
+ Set matches = resultCollector.getSearchResults();
+ assertEquals( matches.size(), 1 );
+ IMatch match1 = (IMatch) matches.iterator().next();
+
+ pattern = SearchEngine.createSearchPattern( "operator \\*", METHOD, DEFINITIONS, true );
+ search( workspace, pattern, scope, resultCollector );
+ matches = resultCollector.getSearchResults();
+ assertEquals( matches.size(), 1 );
+ IMatch match2 = (IMatch) matches.iterator().next();
+
+ assertTrue( match1.getStartOffset() == match2.getStartOffset() );
+
+ pattern = SearchEngine.createSearchPattern( "operator \\*=", METHOD, DECLARATIONS, true );
+ search( workspace, pattern, scope, resultCollector );
+ matches = resultCollector.getSearchResults();
+ assertEquals( matches.size(), 1 );
+ match1 = (IMatch) matches.iterator().next();
+
+ pattern = SearchEngine.createSearchPattern( "operator \\*=", METHOD, DEFINITIONS, true );
+ search( workspace, pattern, scope, resultCollector );
+ matches = resultCollector.getSearchResults();
+ assertEquals( matches.size(), 1 );
+ match2 = (IMatch) matches.iterator().next();
+
+ assertTrue( match1.getStartOffset() != match2.getStartOffset() );
+
+ pattern = SearchEngine.createSearchPattern( "operator *", METHOD, DECLARATIONS, true );
+ search( workspace, pattern, scope, resultCollector );
+ matches = resultCollector.getSearchResults();
+ assertEquals( matches.size(), 5 ); //3 in classDecl.cpp, 2 in mail.cpp
}
}
Index: search/org/eclipse/cdt/core/search/tests/OtherPatternTests.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core.tests/search/org/eclipse/cdt/core/search/tests/OtherPatternTests.java,v
retrieving revision 1.12
diff -u -r1.12 OtherPatternTests.java
--- search/org/eclipse/cdt/core/search/tests/OtherPatternTests.java 15 Sep 2003 17:31:17 -0000 1.12
+++ search/org/eclipse/cdt/core/search/tests/OtherPatternTests.java 16 Sep 2003 21:12:56 -0000
@@ -228,4 +228,13 @@
assertTrue( match.getName().equals( "eE" ) );
assertTrue( match.getParentName().equals( "NS3::C" ));
}
+
+ public void testParameterReferences(){
+ ICSearchPattern pattern = SearchEngine.createSearchPattern( "index", VAR, REFERENCES, true );
+
+ search( workspace, pattern, scope, resultCollector );
+
+ Set matches = resultCollector.getSearchResults();
+ assertEquals( matches.size(), 3 );
+ }
}