Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 41862 Details for
Bug 92264
[search] all types names should support patterns for package/enclosing type name
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
Proposed patch
v03.txt (text/plain), 34.05 KB, created by
Frederic Fusier
on 2006-05-18 06:39:50 EDT
(
hide
)
Description:
Proposed patch
Filename:
MIME Type:
Creator:
Frederic Fusier
Created:
2006-05-18 06:39:50 EDT
Size:
34.05 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.jdt.core >Index: search/org/eclipse/jdt/core/search/SearchEngine.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/search/org/eclipse/jdt/core/search/SearchEngine.java,v >retrieving revision 1.130 >diff -u -r1.130 SearchEngine.java >--- search/org/eclipse/jdt/core/search/SearchEngine.java 29 Mar 2006 03:14:01 -0000 1.130 >+++ search/org/eclipse/jdt/core/search/SearchEngine.java 18 May 2006 10:18:55 -0000 >@@ -540,15 +540,92 @@ > > /** > * Searches for all top-level types and member types in the given scope. >- * The search can be selecting specific types (given a package or a type name >- * prefix and match modes). >+ * The search can be selecting specific types (given a package exact full name or >+ * a type name with specific match mode). >+ * >+ * @param packageName the exact package full name of the searched types.<br> >+ * If you want to use a prefix or a wild-carded string for package, you need to use >+ * {@link #searchAllTypeNames(char[], int, char[], int, int, IJavaSearchScope, TypeNameRequestor, int, IProgressMonitor)} method instead. >+ * @param typeName the dot-separated qualified name of the searched type (the qualification include >+ * the enclosing types if the searched type is a member type), or a prefix >+ * for this type, or a wild-carded string for this type. >+ * @param matchRule type name match rule one of >+ * <ul> >+ * <li>{@link SearchPattern#R_EXACT_MATCH} if the package name and type name are the full names >+ * of the searched types.</li> >+ * <li>{@link SearchPattern#R_PREFIX_MATCH} if the package name and type name are prefixes of the names >+ * of the searched types.</li> >+ * <li>{@link SearchPattern#R_PATTERN_MATCH} if the package name and type name contain wild-cards.</li> >+ * <li>{@link SearchPattern#R_CAMELCASE_MATCH} if type name are camel case of the names of the searched types.</li> >+ * </ul> >+ * combined with {@link SearchPattern#R_CASE_SENSITIVE}, >+ * e.g. {@link SearchPattern#R_EXACT_MATCH} | {@link SearchPattern#R_CASE_SENSITIVE} if an exact and case sensitive match is requested, >+ * or {@link SearchPattern#R_PREFIX_MATCH} if a prefix non case sensitive match is requested. >+ * @param searchFor determines the nature of the searched elements >+ * <ul> >+ * <li>{@link IJavaSearchConstants#CLASS}: only look for classes</li> >+ * <li>{@link IJavaSearchConstants#INTERFACE}: only look for interfaces</li> >+ * <li>{@link IJavaSearchConstants#ENUM}: only look for enumeration</li> >+ * <li>{@link IJavaSearchConstants#ANNOTATION_TYPE}: only look for annotation type</li> >+ * <li>{@link IJavaSearchConstants#CLASS_AND_ENUM}: only look for classes and enumerations</li> >+ * <li>{@link IJavaSearchConstants#CLASS_AND_INTERFACE}: only look for classes and interfaces</li> >+ * <li>{@link IJavaSearchConstants#TYPE}: look for all types (ie. classes, interfaces, enum and annotation types)</li> >+ * </ul> >+ * @param scope the scope to search in >+ * @param nameRequestor the requestor that collects the results of the search >+ * @param waitingPolicy one of >+ * <ul> >+ * <li>{@link IJavaSearchConstants#FORCE_IMMEDIATE_SEARCH} if the search should start immediately</li> >+ * <li>{@link IJavaSearchConstants#CANCEL_IF_NOT_READY_TO_SEARCH} if the search should be cancelled if the >+ * underlying indexer has not finished indexing the workspace</li> >+ * <li>{@link IJavaSearchConstants#WAIT_UNTIL_READY_TO_SEARCH} if the search should wait for the >+ * underlying indexer to finish indexing the workspace</li> >+ * </ul> >+ * @param progressMonitor the progress monitor to report progress to, or <code>null</code> if no progress >+ * monitor is provided >+ * @exception JavaModelException if the search failed. Reasons include: >+ * <ul> >+ * <li>the classpath is incorrectly set</li> >+ * </ul> >+ * @since 3.1 >+ */ >+ public void searchAllTypeNames( >+ final char[] packageName, >+ final char[] typeName, >+ final int matchRule, >+ int searchFor, >+ IJavaSearchScope scope, >+ final TypeNameRequestor nameRequestor, >+ int waitingPolicy, >+ IProgressMonitor progressMonitor) throws JavaModelException { >+ >+ TypeNameRequestorWrapper requestorWrapper = new TypeNameRequestorWrapper(nameRequestor); >+ this.basicEngine.searchAllTypeNames(packageName, SearchPattern.R_EXACT_MATCH, typeName, matchRule, searchFor, scope, requestorWrapper, waitingPolicy, progressMonitor); >+ } >+ >+ /** >+ * Searches for all top-level types and member types in the given scope. >+ * The search can be selecting specific types (given a package name using specific match mode >+ * and/or a type name using another specific match mode). > * > * @param packageName the full name of the package of the searched types, or a prefix for this > * package, or a wild-carded string for this package. > * @param typeName the dot-separated qualified name of the searched type (the qualification include > * the enclosing types if the searched type is a member type), or a prefix > * for this type, or a wild-carded string for this type. >- * @param matchRule one of >+ * @param packageMatchRule one of >+ * <ul> >+ * <li>{@link SearchPattern#R_EXACT_MATCH} if the package name and type name are the full names >+ * of the searched types.</li> >+ * <li>{@link SearchPattern#R_PREFIX_MATCH} if the package name and type name are prefixes of the names >+ * of the searched types.</li> >+ * <li>{@link SearchPattern#R_PATTERN_MATCH} if the package name and type name contain wild-cards.</li> >+ * <li>{@link SearchPattern#R_CAMELCASE_MATCH} if type name are camel case of the names of the searched types.</li> >+ * </ul> >+ * combined with {@link SearchPattern#R_CASE_SENSITIVE}, >+ * e.g. {@link SearchPattern#R_EXACT_MATCH} | {@link SearchPattern#R_CASE_SENSITIVE} if an exact and case sensitive match is requested, >+ * or {@link SearchPattern#R_PREFIX_MATCH} if a prefix non case sensitive match is requested. >+ * @param typeMatchRule one of > * <ul> > * <li>{@link SearchPattern#R_EXACT_MATCH} if the package name and type name are the full names > * of the searched types.</li> >@@ -590,8 +667,9 @@ > */ > public void searchAllTypeNames( > final char[] packageName, >+ final int packageMatchRule, > final char[] typeName, >- final int matchRule, >+ final int typeMatchRule, > int searchFor, > IJavaSearchScope scope, > final TypeNameRequestor nameRequestor, >@@ -599,7 +677,7 @@ > IProgressMonitor progressMonitor) throws JavaModelException { > > TypeNameRequestorWrapper requestorWrapper = new TypeNameRequestorWrapper(nameRequestor); >- this.basicEngine.searchAllTypeNames(packageName, typeName, matchRule, searchFor, scope, requestorWrapper, waitingPolicy, progressMonitor); >+ this.basicEngine.searchAllTypeNames(packageName, packageMatchRule, typeName, typeMatchRule, searchFor, scope, requestorWrapper, waitingPolicy, progressMonitor); > } > > /** >@@ -702,7 +780,7 @@ > int waitingPolicy, > IProgressMonitor progressMonitor) throws JavaModelException { > >- this.basicEngine.searchAllTypeNames(packageName, typeName, matchRule, searchFor, scope, new TypeNameRequestorAdapter(nameRequestor), waitingPolicy, progressMonitor); >+ this.basicEngine.searchAllTypeNames(packageName, SearchPattern.R_EXACT_MATCH, typeName, matchRule, searchFor, scope, new TypeNameRequestorAdapter(nameRequestor), waitingPolicy, progressMonitor); > } > > /** >Index: search/org/eclipse/jdt/core/search/SearchPattern.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/search/org/eclipse/jdt/core/search/SearchPattern.java,v >retrieving revision 1.61 >diff -u -r1.61 SearchPattern.java >--- search/org/eclipse/jdt/core/search/SearchPattern.java 9 May 2006 11:11:29 -0000 1.61 >+++ search/org/eclipse/jdt/core/search/SearchPattern.java 18 May 2006 10:18:57 -0000 >@@ -1777,9 +1777,11 @@ > boolean isCaseSensitive = (this.matchRule & R_CASE_SENSITIVE) != 0; > boolean isCamelCase = (this.matchRule & R_CAMELCASE_MATCH) != 0; > int matchMode = this.matchRule & MODE_MASK; >+ boolean emptyPattern = pattern.length == 0; >+ if (matchMode == R_PREFIX_MATCH && emptyPattern) return true; > boolean sameLength = pattern.length == name.length; > boolean canBePrefix = name.length >= pattern.length; >- boolean matchFirstChar = !isCaseSensitive || pattern.length == 0 || (name.length > 0 && pattern[0] == name[0]); >+ boolean matchFirstChar = !isCaseSensitive || emptyPattern || (name.length > 0 && pattern[0] == name[0]); > if (isCamelCase && matchFirstChar && CharOperation.camelCaseMatch(pattern, name)) { > return true; > } >Index: search/org/eclipse/jdt/internal/core/search/BasicSearchEngine.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/BasicSearchEngine.java,v >retrieving revision 1.34 >diff -u -r1.34 BasicSearchEngine.java >--- search/org/eclipse/jdt/internal/core/search/BasicSearchEngine.java 18 Apr 2006 16:28:18 -0000 1.34 >+++ search/org/eclipse/jdt/internal/core/search/BasicSearchEngine.java 18 May 2006 10:18:58 -0000 >@@ -504,6 +504,129 @@ > } > > /** >+ * Searches for all secondary types in the given scope. >+ * The search can be selecting specific types (given a package or a type name >+ * prefix and match modes). >+ */ >+ public void searchAllSecondaryTypeNames( >+ IPackageFragmentRoot[] sourceFolders, >+ final IRestrictedAccessTypeRequestor nameRequestor, >+ boolean waitForIndexes, >+ IProgressMonitor progressMonitor) throws JavaModelException { >+ >+ if (VERBOSE) { >+ Util.verbose("BasicSearchEngine.searchAllSecondaryTypeNames(IPackageFragmentRoot[], IRestrictedAccessTypeRequestor, boolean, IProgressMonitor)"); //$NON-NLS-1$ >+ StringBuffer buffer = new StringBuffer(" - source folders: "); //$NON-NLS-1$ >+ int length = sourceFolders.length; >+ for (int i=0; i<length; i++) { >+ if (i==0) { >+ buffer.append('['); >+ } else { >+ buffer.append(','); >+ } >+ buffer.append(sourceFolders[i].getElementName()); >+ } >+ buffer.append("]\n - waitForIndexes: "); //$NON-NLS-1$ >+ buffer.append(waitForIndexes); >+ Util.verbose(buffer.toString()); >+ } >+ >+ IndexManager indexManager = JavaModelManager.getJavaModelManager().getIndexManager(); >+ final TypeDeclarationPattern pattern = new SecondaryTypeDeclarationPattern(); >+ >+ // Get working copy path(s). Store in a single string in case of only one to optimize comparison in requestor >+ final HashSet workingCopyPaths = new HashSet(); >+ String workingCopyPath = null; >+ ICompilationUnit[] copies = getWorkingCopies(); >+ final int copiesLength = copies == null ? 0 : copies.length; >+ if (copies != null) { >+ if (copiesLength == 1) { >+ workingCopyPath = copies[0].getPath().toString(); >+ } else { >+ for (int i = 0; i < copiesLength; i++) { >+ ICompilationUnit workingCopy = copies[i]; >+ workingCopyPaths.add(workingCopy.getPath().toString()); >+ } >+ } >+ } >+ final String singleWkcpPath = workingCopyPath; >+ >+ // Index requestor >+ IndexQueryRequestor searchRequestor = new IndexQueryRequestor(){ >+ public boolean acceptIndexMatch(String documentPath, SearchPattern indexRecord, SearchParticipant participant, AccessRuleSet access) { >+ // Filter unexpected types >+ TypeDeclarationPattern record = (TypeDeclarationPattern)indexRecord; >+ if (!record.secondary) { >+ return true; // filter maint types >+ } >+ if (record.enclosingTypeNames == IIndexConstants.ONE_ZERO_CHAR) { >+ return true; // filter out local and anonymous classes >+ } >+ switch (copiesLength) { >+ case 0: >+ break; >+ case 1: >+ if (singleWkcpPath.equals(documentPath)) { >+ return true; // fliter out *the* working copy >+ } >+ break; >+ default: >+ if (workingCopyPaths.contains(documentPath)) { >+ return true; // filter out working copies >+ } >+ break; >+ } >+ >+ // Accept document path >+ AccessRestriction accessRestriction = null; >+ if (access != null) { >+ // Compute document relative path >+ int pkgLength = (record.pkg==null || record.pkg.length==0) ? 0 : record.pkg.length+1; >+ int nameLength = record.simpleName==null ? 0 : record.simpleName.length; >+ char[] path = new char[pkgLength+nameLength]; >+ int pos = 0; >+ if (pkgLength > 0) { >+ System.arraycopy(record.pkg, 0, path, pos, pkgLength-1); >+ CharOperation.replace(path, '.', '/'); >+ path[pkgLength-1] = '/'; >+ pos += pkgLength; >+ } >+ if (nameLength > 0) { >+ System.arraycopy(record.simpleName, 0, path, pos, nameLength); >+ pos += nameLength; >+ } >+ // Update access restriction if path is not empty >+ if (pos > 0) { >+ accessRestriction = access.getViolatedRestriction(path); >+ } >+ } >+ nameRequestor.acceptType(record.modifiers, record.pkg, record.simpleName, record.enclosingTypeNames, documentPath, accessRestriction); >+ return true; >+ } >+ }; >+ >+ // add type names from indexes >+ if (progressMonitor != null) { >+ progressMonitor.beginTask(Messages.engine_searching, 100); >+ } >+ try { >+ indexManager.performConcurrentJob( >+ new PatternSearchJob( >+ pattern, >+ getDefaultSearchParticipant(), // Java search only >+ createJavaSearchScope(sourceFolders), >+ searchRequestor), >+ waitForIndexes >+ ? IJavaSearchConstants.WAIT_UNTIL_READY_TO_SEARCH >+ : IJavaSearchConstants.FORCE_IMMEDIATE_SEARCH, >+ progressMonitor == null ? null : new SubProgressMonitor(progressMonitor, 100)); >+ } >+ catch (OperationCanceledException oce) { >+ // do nothing >+ } >+ } >+ >+ /** > * Searches for all top-level types and member types in the given scope. > * The search can be selecting specific types (given a package or a type name > * prefix and match modes). >@@ -513,8 +636,9 @@ > */ > public void searchAllTypeNames( > final char[] packageName, >+ final int packageMatchRule, > final char[] typeName, >- final int matchRule, >+ final int typeMatchRule, > int searchFor, > IJavaSearchScope scope, > final IRestrictedAccessTypeRequestor nameRequestor, >@@ -524,8 +648,9 @@ > if (VERBOSE) { > Util.verbose("BasicSearchEngine.searchAllTypeNames(char[], char[], int, int, IJavaSearchScope, IRestrictedAccessTypeRequestor, int, IProgressMonitor)"); //$NON-NLS-1$ > Util.verbose(" - package name: "+(packageName==null?"null":new String(packageName))); //$NON-NLS-1$ //$NON-NLS-2$ >+ Util.verbose(" - match rule: "+getMatchRuleString(packageMatchRule)); //$NON-NLS-1$ > Util.verbose(" - type name: "+(typeName==null?"null":new String(typeName))); //$NON-NLS-1$ //$NON-NLS-2$ >- Util.verbose(" - match rule: "+getMatchRuleString(matchRule)); //$NON-NLS-1$ >+ Util.verbose(" - match rule: "+getMatchRuleString(typeMatchRule)); //$NON-NLS-1$ > Util.verbose(" - search for: "+searchFor); //$NON-NLS-1$ > Util.verbose(" - scope: "+scope); //$NON-NLS-1$ > } >@@ -533,6 +658,7 @@ > // Return on invalid combination of package and type names > if (packageName == null || packageName.length == 0) { > if (typeName != null && typeName.length == 0) { >+ // TODO (frederic) Throw a JME instead? > if (VERBOSE) { > Util.verbose(" => return no result due to invalid empty values for package and type names!"); //$NON-NLS-1$ > } >@@ -540,6 +666,7 @@ > } > } > >+ // Create pattern > IndexManager indexManager = JavaModelManager.getJavaModelManager().getIndexManager(); > final char typeSuffix; > switch(searchFor){ >@@ -565,12 +692,19 @@ > typeSuffix = IIndexConstants.TYPE_SUFFIX; > break; > } >- final TypeDeclarationPattern pattern = new TypeDeclarationPattern( >- packageName, >- null, // do find member types >- typeName, >- typeSuffix, >- matchRule); >+ final TypeDeclarationPattern pattern = packageMatchRule == SearchPattern.R_EXACT_MATCH >+ ? new TypeDeclarationPattern( >+ packageName, >+ null, >+ typeName, >+ typeSuffix, >+ typeMatchRule) >+ : new QualifiedTypeDeclarationPattern( >+ packageName, >+ packageMatchRule, >+ typeName, >+ typeSuffix, >+ typeMatchRule); > > // Get working copy path(s). Store in a single string in case of only one to optimize comparison in requestor > final HashSet workingCopyPaths = new HashSet(); >@@ -687,7 +821,7 @@ > } else /*if (type.isInterface())*/ { > kind = TypeDeclaration.INTERFACE_DECL; > } >- if (match(typeSuffix, packageName, typeName, matchRule, kind, packageDeclaration, simpleName)) { >+ if (match(typeSuffix, packageName, typeName, typeMatchRule, kind, packageDeclaration, simpleName)) { > nameRequestor.acceptType(type.getFlags(), packageDeclaration, simpleName, enclosingTypeNames, path, null); > } > } >@@ -703,13 +837,13 @@ > return false; // no local/anonymous type > } > public boolean visit(TypeDeclaration typeDeclaration, CompilationUnitScope compilationUnitScope) { >- if (match(typeSuffix, packageName, typeName, matchRule, TypeDeclaration.kind(typeDeclaration.modifiers), packageDeclaration, typeDeclaration.name)) { >+ if (match(typeSuffix, packageName, typeName, typeMatchRule, TypeDeclaration.kind(typeDeclaration.modifiers), packageDeclaration, typeDeclaration.name)) { > nameRequestor.acceptType(typeDeclaration.modifiers, packageDeclaration, typeDeclaration.name, CharOperation.NO_CHAR_CHAR, path, null); > } > return true; > } > public boolean visit(TypeDeclaration memberTypeDeclaration, ClassScope classScope) { >- if (match(typeSuffix, packageName, typeName, matchRule, TypeDeclaration.kind(memberTypeDeclaration.modifiers), packageDeclaration, memberTypeDeclaration.name)) { >+ if (match(typeSuffix, packageName, typeName, typeMatchRule, TypeDeclaration.kind(memberTypeDeclaration.modifiers), packageDeclaration, memberTypeDeclaration.name)) { > // compute encloising type names > TypeDeclaration enclosing = memberTypeDeclaration.enclosingType; > char[][] enclosingTypeNames = CharOperation.NO_CHAR_CHAR; >@@ -740,130 +874,6 @@ > } > > /** >- * Searches for all top-level types and member types in the given scope. >- * The search can be selecting specific types (given a package or a type name >- * prefix and match modes). >- * >- */ >- public void searchAllSecondaryTypeNames( >- IPackageFragmentRoot[] sourceFolders, >- final IRestrictedAccessTypeRequestor nameRequestor, >- boolean waitForIndexes, >- IProgressMonitor progressMonitor) throws JavaModelException { >- >- if (VERBOSE) { >- Util.verbose("BasicSearchEngine.searchAllSecondaryTypeNames(IPackageFragmentRoot[], IRestrictedAccessTypeRequestor, boolean, IProgressMonitor)"); //$NON-NLS-1$ >- StringBuffer buffer = new StringBuffer(" - source folders: "); //$NON-NLS-1$ >- int length = sourceFolders.length; >- for (int i=0; i<length; i++) { >- if (i==0) { >- buffer.append('['); >- } else { >- buffer.append(','); >- } >- buffer.append(sourceFolders[i].getElementName()); >- } >- buffer.append("]\n - waitForIndexes: "); //$NON-NLS-1$ >- buffer.append(waitForIndexes); >- Util.verbose(buffer.toString()); >- } >- >- IndexManager indexManager = JavaModelManager.getJavaModelManager().getIndexManager(); >- final TypeDeclarationPattern pattern = new SecondaryTypeDeclarationPattern(); >- >- // Get working copy path(s). Store in a single string in case of only one to optimize comparison in requestor >- final HashSet workingCopyPaths = new HashSet(); >- String workingCopyPath = null; >- ICompilationUnit[] copies = getWorkingCopies(); >- final int copiesLength = copies == null ? 0 : copies.length; >- if (copies != null) { >- if (copiesLength == 1) { >- workingCopyPath = copies[0].getPath().toString(); >- } else { >- for (int i = 0; i < copiesLength; i++) { >- ICompilationUnit workingCopy = copies[i]; >- workingCopyPaths.add(workingCopy.getPath().toString()); >- } >- } >- } >- final String singleWkcpPath = workingCopyPath; >- >- // Index requestor >- IndexQueryRequestor searchRequestor = new IndexQueryRequestor(){ >- public boolean acceptIndexMatch(String documentPath, SearchPattern indexRecord, SearchParticipant participant, AccessRuleSet access) { >- // Filter unexpected types >- TypeDeclarationPattern record = (TypeDeclarationPattern)indexRecord; >- if (!record.secondary) { >- return true; // filter maint types >- } >- if (record.enclosingTypeNames == IIndexConstants.ONE_ZERO_CHAR) { >- return true; // filter out local and anonymous classes >- } >- switch (copiesLength) { >- case 0: >- break; >- case 1: >- if (singleWkcpPath.equals(documentPath)) { >- return true; // fliter out *the* working copy >- } >- break; >- default: >- if (workingCopyPaths.contains(documentPath)) { >- return true; // filter out working copies >- } >- break; >- } >- >- // Accept document path >- AccessRestriction accessRestriction = null; >- if (access != null) { >- // Compute document relative path >- int pkgLength = (record.pkg==null || record.pkg.length==0) ? 0 : record.pkg.length+1; >- int nameLength = record.simpleName==null ? 0 : record.simpleName.length; >- char[] path = new char[pkgLength+nameLength]; >- int pos = 0; >- if (pkgLength > 0) { >- System.arraycopy(record.pkg, 0, path, pos, pkgLength-1); >- CharOperation.replace(path, '.', '/'); >- path[pkgLength-1] = '/'; >- pos += pkgLength; >- } >- if (nameLength > 0) { >- System.arraycopy(record.simpleName, 0, path, pos, nameLength); >- pos += nameLength; >- } >- // Update access restriction if path is not empty >- if (pos > 0) { >- accessRestriction = access.getViolatedRestriction(path); >- } >- } >- nameRequestor.acceptType(record.modifiers, record.pkg, record.simpleName, record.enclosingTypeNames, documentPath, accessRestriction); >- return true; >- } >- }; >- >- // add type names from indexes >- if (progressMonitor != null) { >- progressMonitor.beginTask(Messages.engine_searching, 100); >- } >- try { >- indexManager.performConcurrentJob( >- new PatternSearchJob( >- pattern, >- getDefaultSearchParticipant(), // Java search only >- createJavaSearchScope(sourceFolders), >- searchRequestor), >- waitForIndexes >- ? IJavaSearchConstants.WAIT_UNTIL_READY_TO_SEARCH >- : IJavaSearchConstants.FORCE_IMMEDIATE_SEARCH, >- progressMonitor == null ? null : new SubProgressMonitor(progressMonitor, 100)); >- } >- catch (OperationCanceledException oce) { >- // do nothing >- } >- } >- >- /** > * Searches for all top-level types and member types in the given scope using a case sensitive exact match > * with the given qualified names and type names. > * >@@ -976,7 +986,7 @@ > accessRestriction = access.getViolatedRestriction(path); > } > } >- nameRequestor.acceptType(record.modifiers, record.getPackageName(), record.simpleName, record.getEnclosingTypeNames(), documentPath, accessRestriction); >+ nameRequestor.acceptType(record.modifiers, record.pkg, record.simpleName, record.enclosingTypeNames, documentPath, accessRestriction); > return true; > } > }; >Index: search/org/eclipse/jdt/internal/core/search/TypeNameRequestorWrapper.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/TypeNameRequestorWrapper.java,v >retrieving revision 1.6 >diff -u -r1.6 TypeNameRequestorWrapper.java >--- search/org/eclipse/jdt/internal/core/search/TypeNameRequestorWrapper.java 21 Mar 2005 10:37:13 -0000 1.6 >+++ search/org/eclipse/jdt/internal/core/search/TypeNameRequestorWrapper.java 18 May 2006 10:18:58 -0000 >@@ -17,8 +17,9 @@ > * Wrapper used to link {@link IRestrictedAccessTypeRequestor} with {@link TypeNameRequestor}. > * This wrapper specifically allows usage of internal method {@link BasicSearchEngine#searchAllTypeNames( > * char[] packageName, >+ * int packageMatchRule, > * char[] typeName, >- * int matchRule, >+ * int typeMatchRule, > * int searchFor, > * org.eclipse.jdt.core.search.IJavaSearchScope scope, > * IRestrictedAccessTypeRequestor nameRequestor, >Index: model/org/eclipse/jdt/internal/core/SearchableEnvironment.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/SearchableEnvironment.java,v >retrieving revision 1.64 >diff -u -r1.64 SearchableEnvironment.java >--- model/org/eclipse/jdt/internal/core/SearchableEnvironment.java 29 Mar 2006 03:08:47 -0000 1.64 >+++ model/org/eclipse/jdt/internal/core/SearchableEnvironment.java 18 May 2006 10:18:54 -0000 >@@ -264,6 +264,7 @@ > if (camelCaseMatch) matchRule |= SearchPattern.R_CAMELCASE_MATCH; > new BasicSearchEngine(this.workingCopies).searchAllTypeNames( > qualification, >+ SearchPattern.R_EXACT_MATCH, > simpleName, > matchRule, // not case sensitive > IJavaSearchConstants.TYPE, >Index: search/org/eclipse/jdt/internal/core/search/matching/QualifiedTypeDeclarationPattern.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/QualifiedTypeDeclarationPattern.java,v >retrieving revision 1.33 >diff -u -r1.33 QualifiedTypeDeclarationPattern.java >--- search/org/eclipse/jdt/internal/core/search/matching/QualifiedTypeDeclarationPattern.java 29 Mar 2006 03:13:59 -0000 1.33 >+++ search/org/eclipse/jdt/internal/core/search/matching/QualifiedTypeDeclarationPattern.java 18 May 2006 10:18:58 -0000 >@@ -17,7 +17,8 @@ > public class QualifiedTypeDeclarationPattern extends TypeDeclarationPattern implements IIndexConstants { > > public char[] qualification; >-public int packageIndex; >+PackageDeclarationPattern packagePattern; >+public int packageIndex = -1; > > public QualifiedTypeDeclarationPattern(char[] qualification, char[] simpleName, char typeSuffix, int matchRule) { > this(matchRule); >@@ -28,6 +29,10 @@ > > ((InternalSearchPattern)this).mustResolve = this.qualification != null || typeSuffix != TYPE_SUFFIX; > } >+public QualifiedTypeDeclarationPattern(char[] qualification, int qualificationMatchRule, char[] simpleName, char typeSuffix, int matchRule) { >+ this(qualification, simpleName, typeSuffix, matchRule); >+ this.packagePattern = new PackageDeclarationPattern(qualification, qualificationMatchRule); >+} > QualifiedTypeDeclarationPattern(int matchRule) { > super(matchRule); > } >@@ -35,22 +40,14 @@ > int slash = CharOperation.indexOf(SEPARATOR, key, 0); > this.simpleName = CharOperation.subarray(key, 0, slash); > >- int start = slash + 1; >- slash = CharOperation.indexOf(SEPARATOR, key, start); >- int secondSlash = CharOperation.indexOf(SEPARATOR, key, slash + 1); >- this.packageIndex = -1; // used to compute package vs. enclosingTypeNames in MultiTypeDeclarationPattern >- if (start + 1 == secondSlash) { >- this.qualification = CharOperation.NO_CHAR; // no package name or enclosingTypeNames >- } else if (slash + 1 == secondSlash) { >- this.qualification = CharOperation.subarray(key, start, slash); // only a package name >- } else if (slash == start) { >- this.qualification = CharOperation.subarray(key, slash + 1, secondSlash); // no package name >- this.packageIndex = 0; >+ int start = ++slash; >+ if (key[start] == SEPARATOR) { >+ this.pkg = CharOperation.NO_CHAR; > } else { >- this.qualification = CharOperation.subarray(key, start, secondSlash); >- this.packageIndex = slash - start; >- this.qualification[this.packageIndex] = '.'; >+ slash = CharOperation.indexOf(SEPARATOR, key, start); >+ this.pkg = internedPackageNames.add(CharOperation.subarray(key, start, slash)); > } >+ this.qualification = this.pkg; > > // Continue key read by the end to decode modifiers > int last = key.length-1; >@@ -60,24 +57,29 @@ > } > this.modifiers = key[last-1] + (key[last]<<16); > decodeModifiers(); >+ >+ // Retrieve enclosing type names >+ start = slash + 1; >+ last -= 2; // position of ending slash >+ if (start == last) { >+ this.enclosingTypeNames = CharOperation.NO_CHAR_CHAR; >+ } else { >+ int length = this.qualification.length; >+ int size = last - start; >+ System.arraycopy(this.qualification, 0, this.qualification = new char[length+1+size], 0, length); >+ this.qualification[length] = '.'; >+ if (last == (start+1) && key[start] == ZERO_CHAR) { >+ this.enclosingTypeNames = ONE_ZERO_CHAR; >+ this.qualification[length+1] = ZERO_CHAR; >+ } else { >+ this.enclosingTypeNames = CharOperation.splitOn('.', key, start, last); >+ System.arraycopy(key, start, this.qualification, length+1, size); >+ } >+ } > } > public SearchPattern getBlankPattern() { > return new QualifiedTypeDeclarationPattern(R_EXACT_MATCH | R_CASE_SENSITIVE); > } >-public char[] getPackageName() { >- if (this.packageIndex == -1) >- return this.qualification; >- return internedPackageNames.add(CharOperation.subarray(this.qualification, 0, this.packageIndex)); >-} >-public char[][] getEnclosingTypeNames() { >- if (this.packageIndex == -1) >- return CharOperation.NO_CHAR_CHAR; >- if (this.packageIndex == 0) >- return CharOperation.splitOn('.', this.qualification); >- >- char[] names = CharOperation.subarray(this.qualification, this.packageIndex + 1, this.qualification.length); >- return CharOperation.splitOn('.', names); >-} > public boolean matchesDecodedKey(SearchPattern decodedPattern) { > QualifiedTypeDeclarationPattern pattern = (QualifiedTypeDeclarationPattern) decodedPattern; > switch(this.typeSuffix) { >@@ -134,7 +136,8 @@ > break; > } > >- return matchesName(this.simpleName, pattern.simpleName) && matchesName(this.qualification, pattern.qualification); >+ return matchesName(this.simpleName, pattern.simpleName) && >+ (this.qualification == null || this.packagePattern == null || this.packagePattern.matchesName(this.qualification, pattern.qualification)); > } > protected StringBuffer print(StringBuffer output) { > switch (this.typeSuffix){ >#P org.eclipse.jdt.core.tests.model >Index: src/org/eclipse/jdt/core/tests/model/JavaSearchBugsTests.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/JavaSearchBugsTests.java,v >retrieving revision 1.76 >diff -u -r1.76 JavaSearchBugsTests.java >--- src/org/eclipse/jdt/core/tests/model/JavaSearchBugsTests.java 25 Apr 2006 11:31:41 -0000 1.76 >+++ src/org/eclipse/jdt/core/tests/model/JavaSearchBugsTests.java 18 May 2006 10:19:09 -0000 >@@ -2859,6 +2859,106 @@ > } > > /** >+ * Bug 92264: [search] all types names should support patterns for package/enclosing type name >+ * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=92264" >+ */ >+public void testBug92264a() throws CoreException { >+ TypeNameRequestor requestor = new SearchTests.SearchTypeNameRequestor(); >+ new SearchEngine().searchAllTypeNames( >+ "*.lang".toCharArray(), >+ SearchPattern.R_PATTERN_MATCH, // case insensitive >+ IIndexConstants.ONE_STAR, >+ SearchPattern.R_PATTERN_MATCH, // case insensitive >+ TYPE, >+ getJavaSearchScopeBugs(), >+ requestor, >+ IJavaSearchConstants.WAIT_UNTIL_READY_TO_SEARCH, >+ null >+ ); >+ assertSearchResults( >+ "Unexpected all type names", >+ "java.lang.CharSequence\n" + >+ "java.lang.Class\n" + >+ "java.lang.CloneNotSupportedException\n" + >+ "java.lang.Comparable\n" + >+ "java.lang.Enum\n" + >+ "java.lang.Error\n" + >+ "java.lang.Exception\n" + >+ "java.lang.IllegalMonitorStateException\n" + >+ "java.lang.InterruptedException\n" + >+ "java.lang.Object\n" + >+ "java.lang.RuntimeException\n" + >+ "java.lang.String\n" + >+ "java.lang.Throwable", >+ requestor); >+} >+public void testBug92264b() throws CoreException { >+ TypeNameRequestor requestor = new SearchTests.SearchTypeNameRequestor(); >+ new SearchEngine().searchAllTypeNames( >+ "*.lang*".toCharArray(), >+ SearchPattern.R_PATTERN_MATCH, // case insensitive >+ "*tion".toCharArray(), >+ SearchPattern.R_PATTERN_MATCH, // case insensitive >+ TYPE, >+ getJavaSearchScopeBugs(), >+ requestor, >+ IJavaSearchConstants.WAIT_UNTIL_READY_TO_SEARCH, >+ null >+ ); >+ assertSearchResults( >+ "Unexpected all type names", >+ "java.lang.CloneNotSupportedException\n" + >+ "java.lang.Exception\n" + >+ "java.lang.IllegalMonitorStateException\n" + >+ "java.lang.InterruptedException\n" + >+ "java.lang.RuntimeException\n" + >+ "java.lang.annotation.Annotation", >+ requestor); >+} >+public void testBug92264c() throws CoreException { >+ TypeNameRequestor requestor = new SearchTests.SearchTypeNameRequestor(); >+ new SearchEngine().searchAllTypeNames( >+ "*.test*".toCharArray(), >+ SearchPattern.R_PATTERN_MATCH, // case insensitive >+ IIndexConstants.ONE_STAR, >+ SearchPattern.R_PATTERN_MATCH, // case insensitive >+ TYPE, >+ getJavaSearchScopeBugs(), >+ requestor, >+ IJavaSearchConstants.WAIT_UNTIL_READY_TO_SEARCH, >+ null >+ ); >+ assertSearchResults( >+ "Unexpected all type names", >+ "Test$Inner\n" + >+ "b124645.test.A_124645\n" + >+ "b124645.test.X_124645\n" + >+ "b127628.Test127628$Member127628\n" + >+ "b95794.Test$Color\n" + >+ "pack.age.Test$Member", >+ requestor); >+} >+public void testBug92264d() throws CoreException { >+ TypeNameRequestor requestor = new SearchTests.SearchTypeNameRequestor(); >+ new SearchEngine().searchAllTypeNames( >+ "b12*".toCharArray(), >+ SearchPattern.R_PATTERN_MATCH, // case insensitive >+ new char[] { 'X' }, >+ SearchPattern.R_PREFIX_MATCH, // case insensitive >+ TYPE, >+ getJavaSearchScopeBugs(), >+ requestor, >+ IJavaSearchConstants.WAIT_UNTIL_READY_TO_SEARCH, >+ null >+ ); >+ assertSearchResults( >+ "Unexpected all type names", >+ "b124645.test.X_124645\n" + >+ "b124645.xy.X_124645", >+ requestor); >+} >+ >+/** > * Bug 92944: [1.5][search] SearchEngine#searchAllTypeNames doesn't honor enum or annotation element kind > * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=92944" > */
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 92264
:
41862
|
41868
|
45087