### 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.395 diff -u -r1.395 CompletionEngine.java --- codeassist/org/eclipse/jdt/internal/codeassist/CompletionEngine.java 27 Apr 2009 09:38:22 -0000 1.395 +++ codeassist/org/eclipse/jdt/internal/codeassist/CompletionEngine.java 14 May 2009 05:49:13 -0000 @@ -3630,6 +3630,14 @@ addExpectedType(TypeBinding.BOOLEAN, scope); } else if (parent instanceof IfStatement) { addExpectedType(TypeBinding.BOOLEAN, scope); + } + else if (parent instanceof AssertStatement) { + // https://bugs.eclipse.org/bugs/show_bug.cgi?id=274466 + // If the assertExpression is same as the node , then the assistNode is the conditional part of the assert statement + AssertStatement assertStatement = (AssertStatement) parent; + if (assertStatement.assertExpression == node) { + addExpectedType(TypeBinding.BOOLEAN, scope); + } } else if (parent instanceof ForStatement) { // astNodeParent set to ForStatement only for the condition addExpectedType(TypeBinding.BOOLEAN, scope); #P org.eclipse.jdt.core.tests.model Index: src/org/eclipse/jdt/core/tests/model/CompletionTests_1_5.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/CompletionTests_1_5.java,v retrieving revision 1.115 diff -u -r1.115 CompletionTests_1_5.java --- src/org/eclipse/jdt/core/tests/model/CompletionTests_1_5.java 28 Apr 2009 17:46:11 -0000 1.115 +++ src/org/eclipse/jdt/core/tests/model/CompletionTests_1_5.java 14 May 2009 05:49:23 -0000 @@ -13744,5 +13744,41 @@ (R_RESOLVED + R_INTERESTING + R_EXACT_EXPECTED_TYPE + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED) + "}", requestor.getResults()); } +//bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=274466 +//Check for boolean methods with higher relevance in assert statement's conditional part +public void test274466() throws JavaModelException { + this.workingCopies = new ICompilationUnit[2]; + this.workingCopies[0] = getWorkingCopy( + "/Completion/src/test/Test274466.java", + "package test;" + + "public class Test274466 {\n" + + " boolean methodReturningBoolean() { return true; }\n" + + " Boolean methodReturningBooleanB() { return true; }\n" + + " void methodReturningBlah() { return; }\n" + + " int foo(int p) {\n" + + " assert methodR : \"Exception Message\";" + + " }\n" + + "}\n"); + this.workingCopies[1] = getWorkingCopy( + "/Completion/src3/java/lang/Test.java", + "package java.lang;\n" + + "public class Boolean {\n" + + "}"); + + CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(); + String str = this.workingCopies[0].getSource(); + String completeBehind = "methodR"; + int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length(); + + this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner); + assertResults( + "methodReturningBlah[METHOD_REF]{methodReturningBlah(), Ltest.Test274466;, ()V, methodReturningBlah, " + + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED) + "}\n" + + "methodReturningBooleanB[METHOD_REF]{methodReturningBooleanB(), Ltest.Test274466;, ()Ljava.lang.Boolean;, methodReturningBooleanB, " + + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_EXPECTED_TYPE + R_NON_RESTRICTED) + "}\n" + + "methodReturningBoolean[METHOD_REF]{methodReturningBoolean(), Ltest.Test274466;, ()Z, methodReturningBoolean, " + + (R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_EXACT_EXPECTED_TYPE + R_NON_RESTRICTED) + "}", + requestor.getResults()); +} }