prefer local variables over NULL_PSI_ELEMENT in smart completion

This commit is contained in:
peter
2017-06-07 12:09:52 +02:00
parent d937be6504
commit b8588d2006
4 changed files with 31 additions and 9 deletions

View File

@@ -0,0 +1,14 @@
class Usage {
void foo(PsiMethod method) {
PsiUtil.ensureValid(<caret>);
}
}
class PsiUtil {
static final PsiElement NULL_PSI_ELEMENT;
static void ensureValid(PsiElement e) {}
}
interface PsiElement {}
interface PsiMethod extends PsiElement {}

View File

@@ -324,7 +324,7 @@ class SmartTypeCompletionOrderingTest extends CompletionSortingTestCase {
}
void testPreferLocalOverThis() {
checkPreferredItems 0, 'value', 'hashCode', 'this'
checkPreferredItems 0, 'value', 'this', 'hashCode'
}
void testGetLogger() {
@@ -340,7 +340,7 @@ class SmartTypeCompletionOrderingTest extends CompletionSortingTestCase {
}
void testPreferLocalWildcardClassOverObject() {
checkPreferredItems 0, 'type', 'forName', 'forName', 'Object.class'
checkPreferredItems 0, 'type', 'Object.class', 'forName', 'forName'
}
void testPreferStringsInStringConcatenation() {
@@ -369,6 +369,10 @@ class SmartTypeCompletionOrderingTest extends CompletionSortingTestCase {
assert LookupElementPresentation.renderElement(items[1]).itemText == 'BiMap.builder'
}
void testPreferExpectedLocalOverExactlyDefaultMember() {
checkPreferredItems 0, 'method', 'PsiUtil.NULL_PSI_ELEMENT'
}
@Override
protected String getBasePath() {
return JavaTestUtil.getRelativeJavaTestDataPath() + BASE_PATH

View File

@@ -833,7 +833,7 @@ public class SmartTypeCompletionTest extends LightFixtureCompletionTestCase {
}
public void testNoClassLiteral() throws Exception {
doActionTest();
assertStringItems("forName", "forName", "Object.class", "getClass");
assertStringItems("Object.class", "getClass", "forName", "forName");
}
public void testClassLiteralInAnno2() throws Throwable {