View | Details | Raw Unified | Return to bug 274466 | Differences between
and this patch

Collapse All | Expand All

(-)codeassist/org/eclipse/jdt/internal/codeassist/CompletionEngine.java (+8 lines)
Lines 3630-3635 Link Here
3630
			addExpectedType(TypeBinding.BOOLEAN, scope);
3630
			addExpectedType(TypeBinding.BOOLEAN, scope);
3631
		} else if (parent instanceof IfStatement) {  
3631
		} else if (parent instanceof IfStatement) {  
3632
			addExpectedType(TypeBinding.BOOLEAN, scope);
3632
			addExpectedType(TypeBinding.BOOLEAN, scope);
3633
		}
3634
		else if (parent instanceof AssertStatement) {
3635
			// https://bugs.eclipse.org/bugs/show_bug.cgi?id=274466
3636
			// If the assertExpression is same as the node , then the assistNode is the conditional part of the assert statement
3637
			AssertStatement assertStatement = (AssertStatement) parent;
3638
			if (assertStatement.assertExpression == node) {
3639
				addExpectedType(TypeBinding.BOOLEAN, scope);
3640
			}
3633
		} else if (parent instanceof ForStatement) {   // astNodeParent set to ForStatement only for the condition  
3641
		} else if (parent instanceof ForStatement) {   // astNodeParent set to ForStatement only for the condition  
3634
			addExpectedType(TypeBinding.BOOLEAN, scope);
3642
			addExpectedType(TypeBinding.BOOLEAN, scope);
3635
3643
(-)src/org/eclipse/jdt/core/tests/model/CompletionTests_1_5.java (+36 lines)
Lines 13744-13748 Link Here
13744
				(R_RESOLVED + R_INTERESTING + R_EXACT_EXPECTED_TYPE + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED) + "}",
13744
				(R_RESOLVED + R_INTERESTING + R_EXACT_EXPECTED_TYPE + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED) + "}",
13745
			requestor.getResults());	
13745
			requestor.getResults());	
13746
}
13746
}
13747
//bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=274466
13748
//Check for boolean methods with higher relevance in assert statement's conditional part
13749
public void test274466() throws JavaModelException {
13750
	this.workingCopies = new ICompilationUnit[2];
13751
	this.workingCopies[0] = getWorkingCopy(
13752
			"/Completion/src/test/Test274466.java",
13753
			"package test;" +
13754
			"public class Test274466 {\n" +
13755
			"	boolean methodReturningBoolean() { return true; }\n" +
13756
			"	Boolean methodReturningBooleanB() { return true; }\n" +			
13757
			"   void methodReturningBlah() { return; }\n" +
13758
			"	int foo(int p) {\n" +
13759
			"     assert methodR : \"Exception Message\";" +
13760
			"	}\n" +
13761
			"}\n");
13762
	this.workingCopies[1] = getWorkingCopy(
13763
			"/Completion/src3/java/lang/Test.java",
13764
			"package java.lang;\n" +
13765
			"public class Boolean {\n" +
13766
			"}");
13767
	
13768
	CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2();
13769
	String str = this.workingCopies[0].getSource();
13770
	String completeBehind = "methodR";
13771
	int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
13772
13773
	this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
13774
	assertResults(
13775
			"methodReturningBlah[METHOD_REF]{methodReturningBlah(), Ltest.Test274466;, ()V, methodReturningBlah, " + 
13776
					(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_NON_RESTRICTED) + "}\n" +
13777
			"methodReturningBooleanB[METHOD_REF]{methodReturningBooleanB(), Ltest.Test274466;, ()Ljava.lang.Boolean;, methodReturningBooleanB, " + 
13778
					(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_EXPECTED_TYPE + R_NON_RESTRICTED) + "}\n" +
13779
			"methodReturningBoolean[METHOD_REF]{methodReturningBoolean(), Ltest.Test274466;, ()Z, methodReturningBoolean, " + 
13780
					(R_DEFAULT + R_RESOLVED + R_INTERESTING + R_CASE + R_UNQUALIFIED + R_EXACT_EXPECTED_TYPE + R_NON_RESTRICTED) + "}",
13781
			requestor.getResults());	
13782
}
13747
13783
13748
}
13784
}

Return to bug 274466