prefer return

This commit is contained in:
peter
2011-02-28 18:29:30 +01:00
parent 1ab20cc964
commit 5c6c1da682
3 changed files with 20 additions and 1 deletions
@@ -33,6 +33,7 @@ public class PreferLocalVariablesLiteralsAndAnnoMethodsWeigher extends LookupEle
enum MyResult {
annoMethod,
returnKeyword,
localOrParameter,
superMethodParameters,
normal,
@@ -42,9 +43,13 @@ public class PreferLocalVariablesLiteralsAndAnnoMethodsWeigher extends LookupEle
@NotNull
@Override
public Comparable weigh(@NotNull LookupElement item) {
public MyResult weigh(@NotNull LookupElement item) {
final Object object = item.getObject();
if (object instanceof PsiKeyword && PsiKeyword.RETURN.equals(((PsiKeyword)object).getText())) {
return MyResult.returnKeyword;
}
if (object instanceof PsiLocalVariable || object instanceof PsiParameter || object instanceof PsiThisExpression) {
return MyResult.localOrParameter;
}
@@ -0,0 +1,10 @@
public class Test {
void rMethod() {}
int foo(int rParam) {
Object rLocal;
r<caret>
}
}
@@ -209,4 +209,8 @@ public class NormalCompletionOrderingTest extends CompletionSortingTestCase {
checkPreferredItems(0, "Zoo");
}
public void testPreferReturn() {
checkPreferredItems(0, "return", "rLocal", "rParam", "rMethod");
}
}