mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-13 09:19:13 +07:00
prefer return
This commit is contained in:
+6
-1
@@ -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>
|
||||
}
|
||||
|
||||
}
|
||||
+4
@@ -209,4 +209,8 @@ public class NormalCompletionOrderingTest extends CompletionSortingTestCase {
|
||||
checkPreferredItems(0, "Zoo");
|
||||
}
|
||||
|
||||
public void testPreferReturn() {
|
||||
checkPreferredItems(0, "return", "rLocal", "rParam", "rMethod");
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user