disprefer rarely used Object methods

This commit is contained in:
peter
2013-02-03 22:42:57 +01:00
parent aa671e4c3f
commit ac293f3fc7
8 changed files with 14 additions and 12 deletions
@@ -48,12 +48,14 @@ public class KnownElementWeigher extends ProximityWeigher {
final PsiMethod method = (PsiMethod)element;
final PsiClass containingClass = method.getContainingClass();
if (containingClass != null) {
if ("finalize".equals(method.getName()) || "registerNatives".equals(method.getName())) {
String methodName = method.getName();
if ("finalize".equals(methodName) || "registerNatives".equals(methodName) || "getClass".equals(methodName) ||
methodName.startsWith("wait") || methodName.startsWith("notify")) {
if (CommonClassNames.JAVA_LANG_OBJECT.equals(containingClass.getQualifiedName())) {
return -1;
}
}
if ("subSequence".equals(method.getName())) {
if ("subSequence".equals(methodName)) {
if (CommonClassNames.JAVA_LANG_STRING.equals(containingClass.getQualifiedName())) {
return -1;
}
@@ -1,5 +1,5 @@
class Test {
public void foo() {
Runnable r = () -> {<caret>};
Runnable r = () -> {n<caret>};
}
}
@@ -1,5 +1,5 @@
class Test {
public void foo() {
new Thread(() -> <caret>);
new Thread(() -> n<caret>);
}
}
@@ -1,5 +1,5 @@
class Test {
public void foo() {
Runnable r = () -> <caret>
Runnable r = () -> n<caret>
}
}
@@ -74,7 +74,7 @@ public class JavadocCompletionTest extends LightFixtureCompletionTestCase {
public void testSee0() throws Exception {
configureByFile("See0.java");
assertStringItems("foo", "clone", "equals", "getClass", "hashCode", "notify", "notifyAll", "Object", "toString", "wait", "wait", "wait", "finalize", "registerNatives");
myFixture.assertPreferredCompletionItems(0, "foo", "clone", "equals", "hashCode");
}
public void testSee1() throws Exception {
@@ -195,7 +195,7 @@ public class NormalCompletionOrderingTest extends CompletionSortingTestCase {
public void testDeclaredMembersGoFirst() throws Exception {
invokeCompletion(getTestName(false) + ".java");
assertStringItems("fromThis", "overridden", "fromSuper", "equals", "getClass", "hashCode", "notify", "notifyAll", "toString", "wait",
assertStringItems("fromThis", "overridden", "fromSuper", "equals", "hashCode", "toString", "getClass", "notify", "notifyAll", "wait",
"wait", "wait");
}
@@ -95,7 +95,7 @@ public class SmartTypeCompletionOrderingTest extends CompletionSortingTestCase {
}
public void testDontPreferKeywords() throws Throwable {
checkPreferredItems(0, "o1", "foo", "name", "this", "getClass");
checkPreferredItems(0, "o1", "foo", "name", "this");
}
public void testEnumValueOf() throws Throwable {
@@ -129,11 +129,11 @@ public class SmartTypeCompletionOrderingTest extends CompletionSortingTestCase {
}
public void testSmartEquals2() throws Throwable {
checkPreferredItems(0, "foo", "this", "o", "s", "getClass");
checkPreferredItems(0, "foo", "this", "o", "s");
}
public void testSmartEquals3() throws Throwable {
checkPreferredItems(0, "b", "this", "a", "z", "getClass");
checkPreferredItems(0, "b", "this", "a", "z");
}
public void testSmartCollectionsNew() throws Throwable {
@@ -222,7 +222,7 @@ public class SmartTypeCompletionOrderingTest extends CompletionSortingTestCase {
}
public void testFactoryMethodForDefaultType() throws Throwable {
checkPreferredItems(0, "create", "this", "getClass");
checkPreferredItems(0, "create", "this");
}
public void testLocalVarsBeforeClassLiterals() throws Throwable {
@@ -471,7 +471,7 @@ public class SmartTypeCompletionTest extends LightFixtureCompletionTestCase {
public void testVoidExpectedType() throws Throwable {
configureByTestName();
assertStringItems("notify", "notifyAll", "wait", "wait", "wait", "getClass", "equals", "hashCode", "toString");
assertStringItems("notify", "notifyAll", "wait", "wait", "wait", "equals", "hashCode", "toString", "getClass");
type("eq");
assertEquals("equals", assertOneElement(getLookup().getItems()).getLookupString());
select();