### Eclipse Workspace Patch 1.0 #P org.eclipse.jdt.core Index: codeassist/org/eclipse/jdt/internal/codeassist/CompletionEngine.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/CompletionEngine.java,v retrieving revision 1.316 diff -u -r1.316 CompletionEngine.java --- codeassist/org/eclipse/jdt/internal/codeassist/CompletionEngine.java 26 Jan 2007 10:41:27 -0000 1.316 +++ codeassist/org/eclipse/jdt/internal/codeassist/CompletionEngine.java 12 Feb 2007 14:12:57 -0000 @@ -2318,9 +2318,13 @@ return; if (this.options.checkVisibility) { - if (invocationType != null && !exceptionType.canBeSeenBy(receiverType, invocationType)) { - return; - } else if(invocationType == null && !exceptionType.canBeSeenBy(this.unitScope.fPackage)) { + if (invocationType != null) { + if (receiverType != null) { + if (!exceptionType.canBeSeenBy(receiverType, invocationType)) return; + } else { + if (!exceptionType.canBeSeenBy(exceptionType, invocationType)) return; + } + } else if(!exceptionType.canBeSeenBy(this.unitScope.fPackage)) { return; } } @@ -6347,10 +6351,10 @@ int typeLength = token.length; SourceTypeBinding[] types = this.unitScope.topLevelTypes; - for (int i = 0, length = types.length; i < length; i++) { + next : for (int i = 0, length = types.length; i < length; i++) { SourceTypeBinding sourceType = types[i]; - if(isForbidden(sourceType)) continue; + if(isForbidden(sourceType)) continue next; if(proposeAllMemberTypes && sourceType != outerInvocationType) { @@ -6365,22 +6369,28 @@ typesFound); } - if (sourceType.sourceName == CompletionParser.FAKE_TYPE_NAME) continue; - if (sourceType.sourceName == TypeConstants.PACKAGE_INFO_NAME) continue; + if (sourceType.sourceName == CompletionParser.FAKE_TYPE_NAME) continue next; + if (sourceType.sourceName == TypeConstants.PACKAGE_INFO_NAME) continue next; - if (typeLength > sourceType.sourceName.length) continue; + if (typeLength > sourceType.sourceName.length) continue next; if (!CharOperation.prefixEquals(token, sourceType.sourceName, false) && !(this.options.camelCaseMatch && CharOperation.camelCaseMatch(token, sourceType.sourceName))) continue; + for (int j = typesFound.size; --j >= 0;) { + ReferenceBinding otherType = (ReferenceBinding) typesFound.elementAt(j); + + if (sourceType == otherType) continue next; + } + this.knownTypes.put(CharOperation.concat(sourceType.qualifiedPackageName(), sourceType.sourceName(), '.'), this); if(this.assistNodeIsClass) { - if(!sourceType.isClass()) continue; + if(!sourceType.isClass()) continue next; } else if(this.assistNodeIsInterface) { - if(!sourceType.isInterface() && !sourceType.isAnnotationType()) continue; + if(!sourceType.isInterface() && !sourceType.isAnnotationType()) continue next; } else if (this.assistNodeIsAnnotation) { - if(!sourceType.isAnnotationType()) continue; + if(!sourceType.isAnnotationType()) continue next; } int relevance = computeBaseRelevance(); #P org.eclipse.jdt.core.tests.model Index: src/org/eclipse/jdt/core/tests/model/CompletionTests.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/CompletionTests.java,v retrieving revision 1.142 diff -u -r1.142 CompletionTests.java --- src/org/eclipse/jdt/core/tests/model/CompletionTests.java 24 Jan 2007 16:27:41 -0000 1.142 +++ src/org/eclipse/jdt/core/tests/model/CompletionTests.java 12 Feb 2007 14:13:07 -0000 @@ -1114,6 +1114,48 @@ "IZZBException[TYPE_REF]{IZZBException, test, Ltest.IZZBException;, null, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_EXCEPTION + R_NON_RESTRICTED) + "}", requestor.getResults()); } +public void testCatchClauseExceptionRef14() throws JavaModelException { + + this.workingCopies = new ICompilationUnit[1]; + this.workingCopies[0] = getWorkingCopy( + "/Completion/src/test/Test.java", + "package test;"+ + "public class Test {\n" + + " public void throwing() throws IZZException {}\n" + + " public void foo() {\n" + + " try {\n" + + " throwing();\n" + + " }\n" + + " catch (IZZAException e) {\n" + + " }\n" + + " catch (IZZ) {\n" + + " }\n" + + " }" + + "}" + + "class IZZAException extends Exception {\n" + + "}" + + "class IZZException extends Exception {\n" + + "}\n"); + + IJavaProject project = this.workingCopies[0].getJavaProject(); + String visibilityCheck = project.getOption(JavaCore.CODEASSIST_VISIBILITY_CHECK, true); + + try { + project.setOption(JavaCore.CODEASSIST_VISIBILITY_CHECK, JavaCore.ENABLED); + + CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true); + String str = this.workingCopies[0].getSource(); + String completeBehind = "(IZZ"; + int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length(); + this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner); + + assertResults( + "IZZException[TYPE_REF]{IZZException, test, Ltest.IZZException;, null, null, " + (R_DEFAULT + R_INTERESTING + R_CASE + R_EXACT_EXPECTED_TYPE + R_UNQUALIFIED + R_EXCEPTION + R_NON_RESTRICTED) + "}", + requestor.getResults()); + } finally { + project.setOption(JavaCore.CODEASSIST_VISIBILITY_CHECK, visibilityCheck); + } +} /* * https://bugs.eclipse.org/bugs/show_bug.cgi?id=65737 */