### 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; inull 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 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; i0) 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(); +} + +}