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 55325 Details for
Bug 167190
[search] TypeNameMatchRequestorWrapper causing ClassCastException
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
Possible patch for JDT/Core
v00.txt (text/plain), 11.89 KB, created by
Frederic Fusier
on 2006-12-08 13:26:45 EST
(
hide
)
Description:
Possible patch for JDT/Core
Filename:
MIME Type:
Creator:
Frederic Fusier
Created:
2006-12-08 13:26:45 EST
Size:
11.89 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#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.96 >diff -u -r1.96 JavaSearchBugsTests.java >--- src/org/eclipse/jdt/core/tests/model/JavaSearchBugsTests.java 6 Dec 2006 18:29:05 -0000 1.96 >+++ src/org/eclipse/jdt/core/tests/model/JavaSearchBugsTests.java 8 Dec 2006 18:04:18 -0000 >@@ -26,6 +26,7 @@ > import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants; > import org.eclipse.jdt.internal.core.ClassFile; > import org.eclipse.jdt.internal.core.SourceMethod; >+import org.eclipse.jdt.internal.core.search.AbstractSearchScope; > import org.eclipse.jdt.internal.core.search.indexing.IIndexConstants; > import org.eclipse.jdt.internal.core.search.matching.MatchLocator; > import org.eclipse.jdt.internal.core.search.matching.PatternLocator; >@@ -87,10 +88,11 @@ > class TypeNameMatchCollector extends TypeNameMatchRequestor { > List matches = new ArrayList(); > public void acceptTypeNameMatch(TypeNameMatch match) { >- IType type = match.getType(); >- if (type != null) { >- this.matches.add(type); >- } >+// IType type = match.getType(); >+// if (type != null) { >+// this.matches.add(type); >+// } >+ this.matches.add(match); > } > public int size() { > return this.matches.size(); >@@ -100,14 +102,24 @@ > if (size == 0) return ""; > String[] strings = new String[size]; > for (int i=0; i<size; i++) { >- IType type = (IType) this.matches.get(i); >+ TypeNameMatch match = (TypeNameMatch) this.matches.get(i); >+ IType type = match.getType(); > switch (kind) { > case 1: // fully qualified name >- strings[i] = type.getFullyQualifiedName(); >+ if (type != null) { >+ strings[i] = type.getFullyQualifiedName(); >+ } else { >+ strings[i] = match.getFullyQualifiedName(); >+ } > break; > case 0: > default: >- strings[i] = type.toString(); >+ if (type != null) { >+ strings[i] = type.toString(); >+ } else { >+ strings[i] = match.toString(); >+ } >+ break; > } > } > Arrays.sort(strings); >@@ -7782,4 +7794,42 @@ > "lib/b166348.jar test.Test166348 [No source] EXACT_MATCH" > ); > } >+ >+/** >+ * @bug 167190: [search] TypeNameMatchRequestorWrapper causing ClassCastException >+ * @test Ensure that types are found even when scope is not a {@link org.eclipse.jdt.internal.core.search.JavaSearchScope} >+ * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=167190" >+ */ >+public void testBug167190() throws CoreException, JavaModelException { >+ IJavaSearchScope scope = new AbstractSearchScope() { >+ IJavaSearchScope jsScope = getJavaSearchScopeBugs(); >+ public void processDelta(IJavaElementDelta delta) { >+ // we should have no delta on this test case >+ } >+ public boolean encloses(String resourcePath) { >+ return this.jsScope.encloses(resourcePath); >+ } >+ public boolean encloses(IJavaElement element) { >+ return this.jsScope.encloses(element); >+ } >+ public IPath[] enclosingProjectsAndJars() { >+ return this.jsScope.enclosingProjectsAndJars(); >+ } >+ }; >+ TypeNameMatchCollector requestor = new TypeNameMatchCollector(); >+ new SearchEngine().searchAllTypeNames( >+ null, >+ SearchPattern.R_EXACT_MATCH, >+ "Bug".toCharArray(), >+ SearchPattern.R_PREFIX_MATCH, >+ IJavaSearchConstants.TYPE, >+ scope, >+ requestor, >+ IJavaSearchConstants.WAIT_UNTIL_READY_TO_SEARCH, >+ null); >+ assertSearchResults( >+ "Bug148380", >+ requestor >+ ); >+} > } >\ No newline at end of file >#P org.eclipse.jdt.core >Index: search/org/eclipse/jdt/core/search/TypeNameMatch.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/search/org/eclipse/jdt/core/search/TypeNameMatch.java,v >retrieving revision 1.6 >diff -u -r1.6 TypeNameMatch.java >--- search/org/eclipse/jdt/core/search/TypeNameMatch.java 16 Oct 2006 15:59:27 -0000 1.6 >+++ search/org/eclipse/jdt/core/search/TypeNameMatch.java 8 Dec 2006 18:04:28 -0000 >@@ -108,7 +108,7 @@ > > /** > * Name of the type container using '.' character >- * as separator (e.g. enclosing type names + '.' + simple name). >+ * as separator (e.g. package name + '.' + enclosing type names). > * > * @see #getType() > * @see IMember#getDeclaringType() >@@ -127,7 +127,7 @@ > > /** > * Returns the matched type qualified name using '.' character >- * as separator (e.g. enclosing type names + '.' simple name). >+ * as separator (e.g. enclosing type names + '.' + simple name). > * > * @see #getType() > * @see IType#getTypeQualifiedName(char) >Index: search/org/eclipse/jdt/internal/core/search/JavaSearchScope.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/JavaSearchScope.java,v >retrieving revision 1.53 >diff -u -r1.53 JavaSearchScope.java >--- search/org/eclipse/jdt/internal/core/search/JavaSearchScope.java 17 Nov 2006 12:12:31 -0000 1.53 >+++ search/org/eclipse/jdt/internal/core/search/JavaSearchScope.java 8 Dec 2006 18:04:28 -0000 >@@ -556,10 +556,11 @@ > } > > /** >- * Returns the project path corresponding to a given resource path. >+ * Returns the package fragment root corresponding to a given resource path. > * >- * @param resourcePathString path of the resource >- * @return the project path of the resource >+ * @param resourcePathString path of expected package fragment root. >+ * @return the {@link IPackageFragmentRoot package fragment root} which path >+ * match the given one or <code>null</code> if none was found. > */ > public IPackageFragmentRoot packageFragmentRoot(String resourcePathString) { > int index = -1; >Index: search/org/eclipse/jdt/internal/core/search/TypeNameMatchRequestorWrapper.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/TypeNameMatchRequestorWrapper.java,v >retrieving revision 1.5 >diff -u -r1.5 TypeNameMatchRequestorWrapper.java >--- search/org/eclipse/jdt/internal/core/search/TypeNameMatchRequestorWrapper.java 17 Oct 2006 13:23:17 -0000 1.5 >+++ search/org/eclipse/jdt/internal/core/search/TypeNameMatchRequestorWrapper.java 8 Dec 2006 18:04:28 -0000 >@@ -19,6 +19,7 @@ > import org.eclipse.jdt.core.JavaModelException; > import org.eclipse.jdt.core.compiler.CharOperation; > import org.eclipse.jdt.core.search.IJavaSearchScope; >+import org.eclipse.jdt.core.search.NoTypeNameMatch; > import org.eclipse.jdt.core.search.TypeNameMatchRequestor; > import org.eclipse.jdt.core.search.TypeNameRequestor; > import org.eclipse.jdt.internal.compiler.env.AccessRestriction; >@@ -65,13 +66,17 @@ > > public TypeNameMatchRequestorWrapper(TypeNameMatchRequestor requestor, IJavaSearchScope scope) { > this.requestor = requestor; >- this.scope = scope; >+ this.scope = (scope instanceof JavaSearchScope) ? scope : null; > } > > /* (non-Javadoc) > * @see org.eclipse.jdt.internal.core.search.IRestrictedAccessTypeRequestor#acceptType(int, char[], char[], char[][], java.lang.String, org.eclipse.jdt.internal.compiler.env.AccessRestriction) > */ > public void acceptType(int modifiers, char[] packageName, char[] simpleTypeName, char[][] enclosingTypeNames, String path, AccessRestriction access) { >+ if (this.scope == null) { >+ this.requestor.acceptTypeNameMatch(new NoTypeNameMatch(modifiers, packageName, simpleTypeName, enclosingTypeNames)); >+ return; >+ } > try { > int separatorIndex= path.indexOf(IJavaSearchScope.JAR_FILE_ENTRY_SEPARATOR); > IType type = separatorIndex == -1 >Index: search/org/eclipse/jdt/core/search/NoTypeNameMatch.java >=================================================================== >RCS file: search/org/eclipse/jdt/core/search/NoTypeNameMatch.java >diff -N search/org/eclipse/jdt/core/search/NoTypeNameMatch.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ search/org/eclipse/jdt/core/search/NoTypeNameMatch.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,125 @@ >+/******************************************************************************* >+ * Copyright (c) 2000, 2006 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.jdt.core.search; >+ >+import org.eclipse.jdt.core.IPackageFragmentRoot; >+import org.eclipse.jdt.core.IType; >+ >+public class NoTypeNameMatch extends TypeNameMatch { >+ >+private int modifiers = -1; // store modifiers to avoid java model population >+private char[] packageName; >+private char[] simpleTypeName; >+private char[][] enclosingTypeNames; >+ >+/** >+ * Specific type name match with no type. >+ */ >+public NoTypeNameMatch(int modifiers, char[] packageName, char[] simpleTypeName, char[][] enclosingTypeNames) { >+ this.modifiers = modifiers; >+ this.packageName = packageName; >+ this.simpleTypeName = simpleTypeName; >+ this.enclosingTypeNames = enclosingTypeNames; >+} >+ >+/* (non-Javadoc) >+ * @see org.eclipse.jdt.core.search.TypeNameMatch#getFullyQualifiedName() >+ */ >+public String getFullyQualifiedName() { >+ StringBuffer buffer = new StringBuffer(getTypeContainerName()); >+ if (buffer.length() > 0) buffer.append('.'); >+ buffer.append(this.simpleTypeName); >+ return buffer.toString(); >+} >+ >+/* (non-Javadoc) >+ * @see org.eclipse.jdt.core.search.TypeNameMatch#getModifiers() >+ */ >+public int getModifiers() { >+ return this.modifiers; >+} >+ >+/* (non-Javadoc) >+ * @see org.eclipse.jdt.core.search.TypeNameMatch#getPackageFragmentRoot() >+ */ >+public IPackageFragmentRoot getPackageFragmentRoot() { >+ return null; >+} >+ >+/* (non-Javadoc) >+ * @see org.eclipse.jdt.core.search.TypeNameMatch#getPackageName() >+ */ >+public String getPackageName() { >+ if (this.packageName == null) return null; >+ return new String(this.packageName); >+} >+ >+/* (non-Javadoc) >+ * @see org.eclipse.jdt.core.search.TypeNameMatch#getSimpleTypeName() >+ */ >+public String getSimpleTypeName() { >+ if (this.simpleTypeName == null) return null; >+ return new String(this.simpleTypeName); >+} >+ >+/* (non-Javadoc) >+ * @see org.eclipse.jdt.core.search.TypeNameMatch#getType() >+ */ >+public IType getType() { >+ return null; >+} >+ >+/* (non-Javadoc) >+ * @see org.eclipse.jdt.core.search.TypeNameMatch#getTypeContainerName() >+ */ >+public String getTypeContainerName() { >+ StringBuffer buffer = new StringBuffer(); >+ if (this.packageName != null && this.packageName.length > 0) { >+ buffer.append(packageName); >+ } >+ if (this.enclosingTypeNames != null) { >+ int length = this.enclosingTypeNames.length; >+ for (int i=0; i<length; i++) { >+ if (buffer.length() > 0) buffer.append('.'); >+ buffer.append(this.enclosingTypeNames[i]); >+ } >+ } >+ return buffer.toString(); >+} >+ >+/* (non-Javadoc) >+ * @see org.eclipse.jdt.core.search.TypeNameMatch#getTypeQualifiedName() >+ */ >+public String getTypeQualifiedName() { >+ StringBuffer buffer = new StringBuffer(); >+ if (this.enclosingTypeNames != null) { >+ int length = this.enclosingTypeNames.length; >+ for (int i=0; i<length; i++) { >+ if (i>0) buffer.append('.'); >+ buffer.append(this.enclosingTypeNames[i]); >+ } >+ } >+ if (this.simpleTypeName != null && this.simpleTypeName.length > 0) { >+ if (buffer.length() > 0) buffer.append('.'); >+ buffer.append(this.simpleTypeName); >+ } >+ return buffer.toString(); >+} >+ >+/* (non-Javadoc) >+ * Returns the string of the matched type. >+ * @see java.lang.Object#toString() >+ */ >+public String toString() { >+ return getFullyQualifiedName(); >+} >+ >+}
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 167190
:
55325
|
57615
|
57649