### Eclipse Workspace Patch 1.0 #P org.eclipse.jdt.core Index: compiler/org/eclipse/jdt/internal/compiler/lookup/Scope.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/Scope.java,v retrieving revision 1.366 diff -u -r1.366 Scope.java --- compiler/org/eclipse/jdt/internal/compiler/lookup/Scope.java 9 Feb 2010 05:14:15 -0000 1.366 +++ compiler/org/eclipse/jdt/internal/compiler/lookup/Scope.java 5 Mar 2010 08:26:54 -0000 @@ -880,6 +880,19 @@ ? memberType.canBeSeenBy(getCurrentPackage()) : memberType.canBeSeenBy(enclosingType, enclosingReceiverType)) return memberType; + // maybe some type in the compilation unit is extending some class in some package + // and the selection is for some protected inner class of that superclass + // https://bugs.eclipse.org/bugs/show_bug.cgi?id=235658 + if (enclosingReceiverType == null && this instanceof CompilationUnitScope) { + TypeDeclaration[] types = ((CompilationUnitScope)this).referenceContext.types; + if (types != null) { + for (int i = 0; i < types.length; i++) { + if (memberType.canBeSeenBy(enclosingType, types[i].binding)) { + return memberType; + } + } + } + } return new ProblemReferenceBinding(new char[][]{typeName}, memberType, ProblemReasons.NotVisible); } return null; #P org.eclipse.jdt.core.tests.model Index: src/org/eclipse/jdt/core/tests/model/ResolveTests.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/ResolveTests.java,v retrieving revision 1.90 diff -u -r1.90 ResolveTests.java --- src/org/eclipse/jdt/core/tests/model/ResolveTests.java 29 Oct 2008 15:56:34 -0000 1.90 +++ src/org/eclipse/jdt/core/tests/model/ResolveTests.java 5 Mar 2010 08:27:26 -0000 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2008 IBM Corporation and others. + * Copyright (c) 2000, 2010 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 @@ -12,10 +12,20 @@ import java.io.IOException; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.jdt.core.*; +import junit.framework.Test; -import junit.framework.*; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.jdt.core.IClassFile; +import org.eclipse.jdt.core.ICompilationUnit; +import org.eclipse.jdt.core.IJavaElement; +import org.eclipse.jdt.core.IJavaProject; +import org.eclipse.jdt.core.ILocalVariable; +import org.eclipse.jdt.core.IMethod; +import org.eclipse.jdt.core.ISourceRange; +import org.eclipse.jdt.core.IType; +import org.eclipse.jdt.core.JavaCore; +import org.eclipse.jdt.core.JavaModelException; +import org.eclipse.jdt.core.WorkingCopyOwner; public class ResolveTests extends AbstractJavaModelTests { ICompilationUnit wc = null; @@ -2546,5 +2556,38 @@ elements ); } +// https://bugs.eclipse.org/bugs/show_bug.cgi?id=235658 +// To verify that "open declaration" works for a protected interface, which is +// an inner type of an extending class's superclass. +public void testInterfaceX() throws JavaModelException { + this.workingCopies = new ICompilationUnit[3]; + this.workingCopies[0] = getWorkingCopy( + "/Resolve/src/test/Bug.java", + "package test;\n"+ + "public class Bug {\n" + + " void foo() {}\n" + + " protected interface Proto {}\n" + + "}\n"); + + this.workingCopies[1] = getWorkingCopy( + "/Resolve/src/test/p1/Type.java", + "package test.p1;\n" + + "import test.Bug;\n" + + "import test.Bug.*\n"+ + "public class Type extends Bug implements Proto {\n" + + " public Type(int i) {}\n" + + "}\n"); + + String str = this.workingCopies[1].getSource(); + int start = str.lastIndexOf("Proto"); + int length = "Proto".length(); + IJavaElement[] elements = this.workingCopies[1].codeSelect(start, length, this.wcOwner); + + assertElementsEqual( + "Unexpected elements", + "Proto [in Bug [in [Working copy] Bug.java [in test [in src [in Resolve]]]]]", + elements + ); +} }