true/false should only be preferred after 'return' in smart completion

This commit is contained in:
peter
2014-06-13 15:40:20 +02:00
parent 41d5427cfe
commit 837ec9e77d
2 changed files with 3 additions and 3 deletions
@@ -139,8 +139,8 @@ public class PreferByKindWeigher extends LookupElementWeigher {
if (PsiKeyword.ELSE.equals(keyword) || PsiKeyword.FINALLY.equals(keyword)) {
return MyResult.probableKeyword;
}
if (PsiKeyword.TRUE.equals(keyword) || PsiKeyword.FALSE.equals(keyword)) {
boolean inReturn = PsiTreeUtil.getParentOfType(myPosition, PsiReturnStatement.class, false, PsiMember.class) != null;
if ((PsiKeyword.TRUE.equals(keyword) || PsiKeyword.FALSE.equals(keyword)) && myCompletionType == CompletionType.SMART) {
boolean inReturn = psiElement().withParents(PsiReferenceExpression.class, PsiReturnStatement.class).accepts(myPosition);
return inReturn ? MyResult.probableKeyword : MyResult.normal;
}
if (PsiKeyword.INTERFACE.equals(keyword) && psiElement().afterLeaf("@").accepts(myPosition)) {
@@ -792,7 +792,7 @@ public class ListUtils {
public void testDoubleFalse() throws Throwable {
configureByFile(getTestName(false) + ".java");
assertFirstStringItems("false", "fefefef", "float", "finalize");
assertFirstStringItems("fefefef", "false", "float", "finalize");
}
public void testSameNamedVariableInNestedClasses() throws Throwable {