Index: search/org/eclipse/jdt/internal/core/search/matching/MatchLocator.java =================================================================== RCS file: /home/eclipse/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/MatchLocator.java,v retrieving revision 1.249.2.2 diff -u -r1.249.2.2 MatchLocator.java --- search/org/eclipse/jdt/internal/core/search/matching/MatchLocator.java 8 Jul 2005 17:06:10 -0000 1.249.2.2 +++ search/org/eclipse/jdt/internal/core/search/matching/MatchLocator.java 2 Aug 2005 19:02:05 -0000 @@ -613,6 +613,22 @@ return createTypeHandle(typeName.substring(0, lastDollar)); } /** + * Creates an IImportDeclaration from the given import statement + */ +protected IJavaElement createPackageDeclarationHandle(CompilationUnitDeclaration unit) { + if (unit.isPackageInfo()) { + char[] packName = CharOperation.concatWith(unit.currentPackage.getImportName(), '.'); + Openable openable = this.currentPossibleMatch.openable; + if (openable instanceof CompilationUnit) { + return ((CompilationUnit) openable).getPackageDeclaration(new String(packName)); + } +// if (openable != null) { +// return openable.getParent(); +// } + } + return createTypeHandle(new String(unit.getMainTypeName())); +} +/** * Creates an IType from the given simple top level type name. */ protected IType createTypeHandle(String simpleTypeName) { @@ -1969,7 +1985,7 @@ for (int i = 0, l = nodes.length; i < l; i++) nodeSet.matchingNodes.removeKey(nodes[i]); } else { - IJavaElement element = createTypeHandle(new String(unit.getMainTypeName())); + IJavaElement element = createPackageDeclarationHandle(unit); for (int i = 0, l = nodes.length; i < l; i++) { ASTNode node = nodes[i]; Integer level = (Integer) nodeSet.matchingNodes.removeKey(node); @@ -1983,7 +1999,7 @@ if (matchedUnitContainer) { ImportReference pkg = unit.currentPackage; if (pkg != null && pkg.annotations != null) { - IJavaElement element = createTypeHandle(new String(unit.getMainTypeName())); + IJavaElement element = createPackageDeclarationHandle(unit); if (element != null) { reportMatching(pkg.annotations, element, null, nodeSet, true, encloses(element)); } Index: search/org/eclipse/jdt/internal/core/search/matching/TypeReferenceLocator.java =================================================================== RCS file: /home/eclipse/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/matching/TypeReferenceLocator.java,v retrieving revision 1.43.2.1 diff -u -r1.43.2.1 TypeReferenceLocator.java --- search/org/eclipse/jdt/internal/core/search/matching/TypeReferenceLocator.java 28 Jun 2005 21:27:27 -0000 1.43.2.1 +++ search/org/eclipse/jdt/internal/core/search/matching/TypeReferenceLocator.java 2 Aug 2005 19:02:06 -0000 @@ -418,7 +418,7 @@ return; } if (refBinding.isLocalType()) { - // see bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=84049 + // see bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=82673 LocalTypeBinding local = (LocalTypeBinding) refBinding; IJavaElement focus = ((InternalSearchPattern)pattern).focus; if (focus != null && local.enclosingMethod != null && focus.getParent().getElementType() == IJavaElement.METHOD) {