mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
completion sorting tests -> community
This commit is contained in:
+17
@@ -0,0 +1,17 @@
|
||||
public class Foo {
|
||||
{
|
||||
if (Bar.<caret>)
|
||||
}
|
||||
}
|
||||
|
||||
class Bar {
|
||||
|
||||
public static void voidMethod() {}
|
||||
public static boolean booleanMethod() {}
|
||||
public static final boolean BOOLEAN = true;
|
||||
public static final Object AN_OBJECT = "";
|
||||
|
||||
public static class Inner {}
|
||||
|
||||
|
||||
}
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
public class Foo {
|
||||
{
|
||||
Bar.<caret>
|
||||
}
|
||||
}
|
||||
|
||||
class Bar {
|
||||
|
||||
public static void voidMethod() {}
|
||||
public static boolean booleanMethod() {}
|
||||
public static final boolean BOOLEAN = true;
|
||||
public static final Object AN_OBJECT = "";
|
||||
|
||||
public static class Inner {}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
public class Aaaaaaa {
|
||||
private final String aaa;
|
||||
|
||||
Aaaaaaa(String aabbb) {
|
||||
aaa = true ? null : aa<caret>
|
||||
}
|
||||
|
||||
}
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
public class Aaaaaaa {
|
||||
private final String aaa;
|
||||
|
||||
Aaaaaaa(Object aabbb) {
|
||||
aaa = true ? null : aa<caret>
|
||||
}
|
||||
|
||||
}
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
class Foo {
|
||||
|
||||
void register(int registrar) {
|
||||
regi<caret>
|
||||
}
|
||||
|
||||
}
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
class Foo {
|
||||
|
||||
int register() {
|
||||
re<caret>
|
||||
}
|
||||
|
||||
}
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
public class ServiceManager {
|
||||
|
||||
public static <T> T getService(Class<T> serviceClass) {
|
||||
}
|
||||
|
||||
public static <T> T getService(Project project, Class<T> serviceClass) {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
class Foo {
|
||||
String getFoo() {
|
||||
return ServiceManager.<caret>
|
||||
}
|
||||
|
||||
}
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
public class Beda {
|
||||
{
|
||||
Object clsLoader;
|
||||
cL<caret>
|
||||
}
|
||||
}
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
@interface Anno {
|
||||
String value();
|
||||
String name();
|
||||
}
|
||||
|
||||
@Anno(<caret>)
|
||||
class Foo {}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
class Foo {
|
||||
String getName() {}
|
||||
Foo getNameIdentifier() {}
|
||||
}
|
||||
|
||||
class Bar {
|
||||
void foo() {
|
||||
Foo f;
|
||||
if ("abc".equals(f.getN<caret>))
|
||||
}
|
||||
}
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
public class MyFirstTestClassFoo {
|
||||
|
||||
void foo(int a) {}
|
||||
void foo() {}
|
||||
void foo(int a, int b) {}
|
||||
void fox(int a) {}
|
||||
|
||||
{
|
||||
new MyFirstTestClassFoo().fo<caret>
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
class Foo {
|
||||
void bar() {}
|
||||
void foo() {}
|
||||
}
|
||||
|
||||
class Bar extends Foo {
|
||||
void foo() {
|
||||
super.<caret>
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
class Foo {
|
||||
boolean zoo(String s) {
|
||||
return f<caret>
|
||||
}
|
||||
}
|
||||
+1
@@ -0,0 +1 @@
|
||||
<p<caret>
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
class Foo {
|
||||
String fooLongButOfDefaultType() {}
|
||||
Foo foo() {}
|
||||
}
|
||||
|
||||
class Bar {
|
||||
void foo() {
|
||||
Foo f;
|
||||
if ("abc".equals(f.fo<caret>))
|
||||
}
|
||||
}
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
class Foo {
|
||||
void foo(String s) {}
|
||||
{
|
||||
foo("aaa".sub<caret>)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
class Foo {
|
||||
{
|
||||
Object classLoader;
|
||||
Object classBeforeLoader;
|
||||
cL<caret>
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
class Foo {
|
||||
{
|
||||
Object classLoader;
|
||||
Object classLoader2;
|
||||
cL<caret>
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
public abstract class Foo {
|
||||
|
||||
void foo(Boolean value);
|
||||
|
||||
{
|
||||
boolean b;
|
||||
foo(<caret>)
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
public class Foo {
|
||||
|
||||
public Class<? extends String> foo() {
|
||||
return <caret>
|
||||
}
|
||||
}
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
class Foo {
|
||||
{
|
||||
Object _o;
|
||||
Bar b;
|
||||
if (_o instanceof Goo) {
|
||||
Goo g = <caret>
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class Goo {
|
||||
|
||||
}
|
||||
|
||||
class Bar extends Goo {
|
||||
|
||||
}
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
public class Foo {
|
||||
|
||||
{
|
||||
String name;
|
||||
Object o1;
|
||||
Foo foo;
|
||||
|
||||
Object o = <caret>
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
enum MyEnum {
|
||||
FOO, BAR;
|
||||
}
|
||||
|
||||
public class Foo {
|
||||
|
||||
{
|
||||
MyEnum e;
|
||||
MyEnum e1 = <caret>
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
enum MyEnum {
|
||||
FOO, BAR;
|
||||
}
|
||||
|
||||
public class Foo {
|
||||
|
||||
MyEnum bar() {}
|
||||
|
||||
MyEnum foo() {
|
||||
MyEnum e;
|
||||
return <caret>
|
||||
}
|
||||
}
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
interface MyProcessor<T> {
|
||||
void execute(T t);
|
||||
}
|
||||
|
||||
class Proc1<T> implements MyProcessor<T> { public void execute(T t) {}}
|
||||
|
||||
class Foo {
|
||||
MyProcessor<Foo> p = new <caret>
|
||||
}
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
import java.util.*;
|
||||
|
||||
public class Foo {
|
||||
|
||||
{
|
||||
Map<Pair<Object, Object>, Object> map;
|
||||
map.get(<caret>)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class Pair<A, B> {
|
||||
Pair(A a, B b) {}
|
||||
|
||||
static <A,B> Pair<A,B> create(A a, B b) {}
|
||||
}
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
class Foo {
|
||||
String myFoo;
|
||||
String myBar;
|
||||
|
||||
String getFoo() {
|
||||
return my<caret>
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
class Smth {}
|
||||
class Button extends Smth {}
|
||||
class ButtonBase extends Button {}
|
||||
|
||||
class Foo {
|
||||
Foo foo(String s) {
|
||||
Smth s = new B<caret>
|
||||
}
|
||||
}
|
||||
+21
@@ -0,0 +1,21 @@
|
||||
package zzzzz;
|
||||
|
||||
public class Foo {
|
||||
{
|
||||
class InnerGoo extends Goo{}
|
||||
|
||||
Goo g = new <caret>
|
||||
}
|
||||
|
||||
class Bar extends Goo {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class Goo {
|
||||
|
||||
}
|
||||
|
||||
class AGoo extends Goo {}
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
|
||||
public class FooBean3 extends JComponent {
|
||||
|
||||
JComponent foo(int a) {
|
||||
}
|
||||
|
||||
public void setFooBean239(String fooBean239) {
|
||||
String name;
|
||||
PopupMenu b;
|
||||
add(<caret>)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
|
||||
public class FooBean3 extends JComponent {
|
||||
|
||||
{
|
||||
add(new <caret>)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
public class Foo {
|
||||
public void getAbc() {
|
||||
if(<caret>)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
public class Foo {
|
||||
public boolean getAbc() {
|
||||
return <caret>
|
||||
}
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
class Foo {
|
||||
|
||||
Foo bar() { }
|
||||
Foo goo() { }
|
||||
|
||||
void foo(Foo param) {
|
||||
Foo foo;
|
||||
Foo zzz = <caret>
|
||||
}
|
||||
|
||||
}
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
public class Foo {
|
||||
|
||||
{
|
||||
Class<Foo> local;
|
||||
Class<? extends Foo> f = <caret>
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class Bar extends Foo {}
|
||||
@@ -0,0 +1,16 @@
|
||||
public class FooBar {
|
||||
|
||||
class Xxx {}
|
||||
|
||||
Xxx foo() { }
|
||||
Xxx bar() { }
|
||||
Xxx goo() { }
|
||||
|
||||
void aaa(Xxx a) {}
|
||||
|
||||
{
|
||||
new FooBar().aaa( new FooBar().<caret> );
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
public class Foo<T> {
|
||||
|
||||
T foo() {}
|
||||
|
||||
<V> V bar() {}
|
||||
|
||||
{
|
||||
Foo<String> o;
|
||||
String a = o.<caret>
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
interface List {
|
||||
void add();
|
||||
}
|
||||
|
||||
class ArrayList implements List {
|
||||
public void add() {}
|
||||
}
|
||||
|
||||
class OtherList extends ArrayList {}
|
||||
|
||||
class Foo {
|
||||
{
|
||||
ArrayList l = new <caret>
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
|
||||
public class Foo extends JComponent {
|
||||
|
||||
public Component foo() {
|
||||
return new <caret>
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
public class MyRunnable implements Runnable {
|
||||
|
||||
private class MyAnotherRunnable extends MyRunnable {}
|
||||
|
||||
Runnable foo() {
|
||||
return new <caret>
|
||||
}
|
||||
}
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
interface Bar {}
|
||||
class Goo {}
|
||||
|
||||
abstract class Foo {
|
||||
void foo(Bar f);
|
||||
|
||||
void foo(Foo f);
|
||||
|
||||
void foo(Goo f);
|
||||
|
||||
|
||||
{
|
||||
|
||||
foo((<caret>))
|
||||
}
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
class Foo {
|
||||
|
||||
void register(Foo param) {
|
||||
|
||||
}
|
||||
|
||||
void foo(Foo param) {
|
||||
param.register(<caret>)
|
||||
}
|
||||
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
class Foo {
|
||||
|
||||
void register(Foo param) {
|
||||
|
||||
}
|
||||
|
||||
void foo(Foo param) {
|
||||
register(<caret>)
|
||||
}
|
||||
|
||||
}
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
class Foo {
|
||||
private static final Foo A_PRIVATE;
|
||||
@Deprecated public static final Foo B_DEPRECATED;
|
||||
public static final Foo C_NORMAL;
|
||||
|
||||
}
|
||||
|
||||
class Bar {
|
||||
{
|
||||
Foo a = <caret>
|
||||
}
|
||||
}
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
public class A {
|
||||
private A myDelegate;
|
||||
|
||||
public void method(String abc, String xyz) {
|
||||
myDelegate.method(abc, <caret>);
|
||||
}
|
||||
}
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
class Foo {
|
||||
String myVersion;
|
||||
String getVersion();
|
||||
String getSelectedVersion();
|
||||
String calculateVersion();
|
||||
{
|
||||
String version = <caret>
|
||||
}
|
||||
}
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
import javax.swing.JPanel;
|
||||
|
||||
public class FooBean3 extends javax.swing.JComponent {
|
||||
|
||||
{
|
||||
add(new <caret>)
|
||||
}
|
||||
}
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
public class ZZZZZZ {
|
||||
public String getTitle() { }
|
||||
private static String getVersionString(int a) {}
|
||||
|
||||
public String getDefaultVersion() {
|
||||
return <caret>
|
||||
}
|
||||
}
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
public class FooBean3 extends javax.swing.JComponent {
|
||||
|
||||
{
|
||||
add(new <caret>)
|
||||
}
|
||||
|
||||
private class NestedClass extends FooBean3 {}
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
class Foo {
|
||||
Foo foo(int i, String s) {
|
||||
|
||||
}
|
||||
|
||||
Foo foo(String s) {
|
||||
String a;
|
||||
int b;
|
||||
return foo(<caret>)
|
||||
}
|
||||
}
|
||||
+24
@@ -0,0 +1,24 @@
|
||||
class T {
|
||||
I myLastI;
|
||||
I getLastI() { return myLastI; }
|
||||
|
||||
void setLastI(I a) {
|
||||
myLastI = <caret>
|
||||
}
|
||||
}
|
||||
|
||||
class I {
|
||||
static final I _1 = new I();
|
||||
static final I _2a = new I();
|
||||
static final I _3a = new I();
|
||||
static final I _4a = new I();
|
||||
static final I _5a = new I();
|
||||
static final I _6a = new I();
|
||||
static final I _7a = new I();
|
||||
static final I _8a = new I();
|
||||
static final I _9a = new I();
|
||||
|
||||
static I valueOf(String sth) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
class Foo {
|
||||
boolean foo;
|
||||
boolean bar;
|
||||
|
||||
{
|
||||
foo(f<caret>)
|
||||
}
|
||||
|
||||
void foo(boolean foo, boolean bar) {
|
||||
}
|
||||
|
||||
}
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
public class Foo {
|
||||
|
||||
{
|
||||
String s;
|
||||
Object o;
|
||||
java.util.List<String> list;
|
||||
list.contains(<caret>)
|
||||
}
|
||||
|
||||
}
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
public abstract class Foo {
|
||||
|
||||
private class Bar extends Foo {}
|
||||
|
||||
{
|
||||
java.util.List<Foo> list;
|
||||
list.contains(new <caret>)
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
public class Foo {
|
||||
|
||||
{
|
||||
String s;
|
||||
Object o;
|
||||
new String().equals(<caret>)
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
public class Foo {
|
||||
|
||||
{
|
||||
String s;
|
||||
Foo foo;
|
||||
Object o;
|
||||
new Foo().equals(<caret>)
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
public class Foo {
|
||||
|
||||
{
|
||||
String a;
|
||||
Foo b;
|
||||
Object z;
|
||||
equals(<caret>)
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
public abstract class Foo {
|
||||
|
||||
private class Bar extends Foo {}
|
||||
|
||||
{
|
||||
new Foo().equals(new <caret>)
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
public abstract class Foo {
|
||||
|
||||
{
|
||||
this.equals(new <caret>)
|
||||
}
|
||||
|
||||
}
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
class Foo {
|
||||
java.util.List<Foo> p = new <caret>
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
class Foo {
|
||||
String getAttributeValue(String s);
|
||||
String getNamespace();
|
||||
}
|
||||
|
||||
class Bar {
|
||||
String getAttribute() {
|
||||
Foo f;
|
||||
return f.<caret>
|
||||
}
|
||||
}
|
||||
+97
@@ -0,0 +1,97 @@
|
||||
/*
|
||||
* Copyright (c) 2000-2005 by JetBrains s.r.o. All Rights Reserved.
|
||||
* Use is subject to license terms.
|
||||
*/
|
||||
package com.intellij.codeInsight.completion;
|
||||
|
||||
import com.intellij.JavaTestUtil;
|
||||
import com.intellij.codeInsight.lookup.LookupElement;
|
||||
import com.intellij.codeInsight.lookup.LookupManager;
|
||||
import com.intellij.codeInsight.lookup.impl.LookupImpl;
|
||||
import com.intellij.openapi.projectRoots.Sdk;
|
||||
import com.intellij.openapi.projectRoots.impl.JavaSdkImpl;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author peter
|
||||
*/
|
||||
public abstract class CompletionSortingTestCase extends LightCompletionTestCase {
|
||||
@SuppressWarnings({"JUnitTestCaseWithNonTrivialConstructors"})
|
||||
protected CompletionSortingTestCase(CompletionType type) {
|
||||
setType(type);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getTestDataPath() {
|
||||
return JavaTestUtil.getJavaTestDataPath();
|
||||
}
|
||||
|
||||
|
||||
protected void tearDown() throws Exception {
|
||||
LookupManager.getInstance(getProject()).hideActiveLookup();
|
||||
super.tearDown();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Sdk getProjectJDK() {
|
||||
return JavaSdkImpl.getMockJdk15("java 1.5");
|
||||
}
|
||||
|
||||
protected abstract String getBasePath();
|
||||
|
||||
protected void checkPreferredItems(final int selected, final String... expected) throws Exception {
|
||||
invokeCompletion(getBasePath() + "/" + getTestName(false) + ".java");
|
||||
assertPreferredItems(selected, expected);
|
||||
}
|
||||
|
||||
protected static void assertPreferredItems(final int selected, final String... expected) {
|
||||
final LookupImpl lookup = getLookup();
|
||||
final JList list = lookup.getList();
|
||||
final List<LookupElement> model = lookup.getItems();
|
||||
final List<String> actual = new ArrayList<String>();
|
||||
final int count = lookup.getPreferredItemsCount();
|
||||
for (int i = 0; i < count; i++) {
|
||||
actual.add(model.get(i).getLookupString());
|
||||
}
|
||||
if (!actual.equals(Arrays.asList(expected))) {
|
||||
final List<String> strings = new ArrayList<String>();
|
||||
for (int i = 0; i < model.size(); i++) {
|
||||
final LookupElement item = model.get(i);
|
||||
strings.add(item.getLookupString() + Arrays.toString(item.getUserData(CompletionLookupArranger.WEIGHT)));
|
||||
if (i == count - 1) {
|
||||
strings.add("---");
|
||||
}
|
||||
}
|
||||
assertOrderedEquals(strings, expected);
|
||||
}
|
||||
assertEquals(selected, list.getSelectedIndex());
|
||||
}
|
||||
|
||||
protected LookupImpl invokeCompletion(final String filePath) throws Exception {
|
||||
configureByFile(filePath);
|
||||
return getLookup();
|
||||
}
|
||||
|
||||
protected static void incUseCount(final LookupImpl lookup, final int index) {
|
||||
imitateItemSelection(lookup, index);
|
||||
refreshSorting(lookup);
|
||||
}
|
||||
|
||||
protected static void refreshSorting(final LookupImpl lookup) {
|
||||
for (final LookupElement item : lookup.getItems()) {
|
||||
item.putUserData(CompletionLookupArranger.WEIGHT, null);
|
||||
item.putUserData(CompletionLookupArranger.RELEVANCE_KEY, null);
|
||||
}
|
||||
lookup.resort();
|
||||
}
|
||||
|
||||
protected static void imitateItemSelection(final LookupImpl lookup, final int index) {
|
||||
final LookupElement item = lookup.getItems().get(index);
|
||||
lookup.setCurrentItem(item);
|
||||
lookup.getLookupModel().itemSelected(item, lookup);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,197 @@
|
||||
package com.intellij.codeInsight.completion;
|
||||
|
||||
import com.intellij.JavaTestUtil;
|
||||
import com.intellij.codeInsight.CodeInsightSettings;
|
||||
import com.intellij.codeInsight.lookup.LookupElement;
|
||||
|
||||
/**
|
||||
* Created by IntelliJ IDEA.
|
||||
* User: ik
|
||||
* Date: 21.01.2003
|
||||
* Time: 16:31:32
|
||||
* To change this template use Options | File Templates.
|
||||
*/
|
||||
public class DotTest extends LightCompletionTestCase {
|
||||
|
||||
@Override
|
||||
protected String getTestDataPath() {
|
||||
return JavaTestUtil.getJavaTestDataPath();
|
||||
}
|
||||
|
||||
public void testInstance() throws Exception {
|
||||
configureByFile("/codeInsight/completion/dot/Dot1.java");
|
||||
|
||||
assertEquals("", myPrefix);
|
||||
assertNotNull(myItems);
|
||||
int index = 0;
|
||||
for (final LookupElement myItem : myItems) {
|
||||
if ("a".equals(myItem.getLookupString()) || "foo".equals(myItem.getLookupString())) {
|
||||
index++;
|
||||
}
|
||||
|
||||
}
|
||||
assertEquals(2, index);
|
||||
}
|
||||
|
||||
public void testClass() throws Exception {
|
||||
configureByFile("/codeInsight/completion/dot/Dot2.java");
|
||||
|
||||
assertEquals("", myPrefix);
|
||||
assertNotNull(myItems);
|
||||
int index = 0;
|
||||
for (final LookupElement myItem : myItems) {
|
||||
if ("a".equals(myItem.getLookupString()) || "foo".equals(myItem.getLookupString())) {
|
||||
index++;
|
||||
}
|
||||
|
||||
}
|
||||
assertEquals(2, index);
|
||||
}
|
||||
|
||||
public void testAnonymous() throws Exception {
|
||||
configureByFile("/codeInsight/completion/dot/Dot3.java");
|
||||
|
||||
assertEquals("", myPrefix);
|
||||
assertNotNull(myItems);
|
||||
int index = 0;
|
||||
for (final LookupElement myItem : myItems) {
|
||||
if ("a".equals(myItem.getLookupString()) || "foo".equals(myItem.getLookupString())) {
|
||||
index++;
|
||||
}
|
||||
|
||||
}
|
||||
assertEquals(2, index);
|
||||
}
|
||||
|
||||
public void testShowStatic() throws Exception {
|
||||
CodeInsightSettings settings = CodeInsightSettings.getInstance();
|
||||
boolean oldSetting = settings.SHOW_STATIC_AFTER_INSTANCE;
|
||||
settings.SHOW_STATIC_AFTER_INSTANCE = false;
|
||||
configureByFile("/codeInsight/completion/dot/Dot4.java");
|
||||
settings.SHOW_STATIC_AFTER_INSTANCE = oldSetting;
|
||||
assertEquals("", myPrefix);
|
||||
assertNotNull(myItems);
|
||||
int index = 0;
|
||||
for (final LookupElement myItem : myItems) {
|
||||
if ("a".equals(myItem.getLookupString()) || "foo".equals(myItem.getLookupString())) {
|
||||
index++;
|
||||
}
|
||||
|
||||
}
|
||||
assertEquals(1, index);
|
||||
}
|
||||
|
||||
public void testImports() throws Exception {
|
||||
configureByFile("/codeInsight/completion/dot/Dot5.java");
|
||||
|
||||
assertNotNull(myItems);
|
||||
int index = 0;
|
||||
|
||||
for (final LookupElement myItem : myItems) {
|
||||
if ("util".equals(myItem.getLookupString()) || "lang".equals(myItem.getLookupString())) {
|
||||
index++;
|
||||
}
|
||||
|
||||
}
|
||||
assertEquals(2, index);
|
||||
}
|
||||
|
||||
public void testArrayElement() throws Exception {
|
||||
configureByFile("/codeInsight/completion/dot/Dot6.java");
|
||||
|
||||
assertNotNull(myItems);
|
||||
int index = 0;
|
||||
|
||||
for (final LookupElement myItem : myItems) {
|
||||
if ("toString".equals(myItem.getLookupString()) || "substring".equals(myItem.getLookupString())) {
|
||||
index++;
|
||||
}
|
||||
}
|
||||
assertEquals(3, index);
|
||||
}
|
||||
|
||||
public void testArray() throws Exception {
|
||||
configureByFile("/codeInsight/completion/dot/Dot7.java");
|
||||
|
||||
assertNotNull(myItems);
|
||||
int index = 0;
|
||||
|
||||
for (final LookupElement myItem : myItems) {
|
||||
if ("length".equals(myItem.getLookupString()) || "clone".equals(myItem.getLookupString())) {
|
||||
index++;
|
||||
}
|
||||
|
||||
}
|
||||
assertEquals(2, index);
|
||||
}
|
||||
|
||||
public void testDuplicatesFromInherance() throws Exception {
|
||||
configureByFile("/codeInsight/completion/dot/Dot8.java");
|
||||
|
||||
assertNotNull(myItems);
|
||||
int index = 0;
|
||||
|
||||
for (final LookupElement myItem : myItems) {
|
||||
if ("toString".equals(myItem.getLookupString())) {
|
||||
index++;
|
||||
}
|
||||
}
|
||||
assertEquals(1, index);
|
||||
}
|
||||
|
||||
public void testConstructorExclusion() throws Exception {
|
||||
configureByFile("/codeInsight/completion/dot/Dot9.java");
|
||||
|
||||
assertNotNull(myItems);
|
||||
int index = 0;
|
||||
|
||||
for (final LookupElement myItem : myItems) {
|
||||
if ("A".equals(myItem.getLookupString())) {
|
||||
index++;
|
||||
}
|
||||
}
|
||||
assertEquals(0, index);
|
||||
}
|
||||
|
||||
public void testPrimitiveArray() throws Exception {
|
||||
configureByFile("/codeInsight/completion/dot/Dot10.java");
|
||||
|
||||
assertNotNull(myItems);
|
||||
int index = 0;
|
||||
|
||||
for (final LookupElement myItem : myItems) {
|
||||
if ("clone".equals(myItem.getLookupString()) || "length".equals(myItem.getLookupString())) {
|
||||
index++;
|
||||
}
|
||||
}
|
||||
assertEquals(2, index);
|
||||
}
|
||||
|
||||
public void testThisExpression() throws Exception {
|
||||
configureByFile("/codeInsight/completion/dot/Dot11.java");
|
||||
|
||||
assertNotNull(myItems);
|
||||
int index = 0;
|
||||
|
||||
for (final LookupElement myItem : myItems) {
|
||||
if ("foo1".equals(myItem.getLookupString()) || "foo".equals(myItem.getLookupString())) {
|
||||
index++;
|
||||
}
|
||||
}
|
||||
assertEquals(2, index);
|
||||
}
|
||||
|
||||
public void testSuperExpression() throws Exception {
|
||||
configureByFile("/codeInsight/completion/dot/Dot12.java");
|
||||
|
||||
assertNotNull(myItems);
|
||||
int index = 0;
|
||||
|
||||
for (final LookupElement myItem : myItems) {
|
||||
if ("foo1".equals(myItem.getLookupString()) || "foo".equals(myItem.getLookupString())) {
|
||||
index++;
|
||||
}
|
||||
}
|
||||
assertEquals(1, index);
|
||||
}
|
||||
}
|
||||
+240
@@ -0,0 +1,240 @@
|
||||
package com.intellij.codeInsight.completion;
|
||||
|
||||
import com.intellij.JavaTestUtil;
|
||||
import com.intellij.openapi.roots.LanguageLevelProjectExtension;
|
||||
import com.intellij.pom.java.LanguageLevel;
|
||||
import com.intellij.psi.codeStyle.CodeStyleSettingsManager;
|
||||
|
||||
/**
|
||||
* Created by IntelliJ IDEA.
|
||||
* User: ik
|
||||
* Date: 20.02.2003
|
||||
* Time: 15:49:56
|
||||
* To change this template use Options | File Templates.
|
||||
*/
|
||||
public class KeywordCompletionTest extends LightCompletionTestCase {
|
||||
private static final String BASE_PATH = "/codeInsight/completion/keywords";
|
||||
|
||||
@Override
|
||||
protected String getTestDataPath() {
|
||||
return JavaTestUtil.getJavaTestDataPath();
|
||||
}
|
||||
|
||||
public void testModifiersFileScope_1() throws Exception {
|
||||
configureByFile(BASE_PATH + "/fileScope-1.java");
|
||||
testByCount(7, "package", "public", "private", "import", "final", "class", "interface", "abstract", null);
|
||||
}
|
||||
|
||||
private static final String[] ourClassScopeKeywords =
|
||||
new String[]{"public", "private", "protected", "import", "final", "class", "interface", "abstract", "enum", null};
|
||||
|
||||
public void testModifiersFileScope_2() throws Exception {
|
||||
configureByFile(BASE_PATH + "/fileScope-2.java");
|
||||
testByCount(7, ourClassScopeKeywords);
|
||||
}
|
||||
|
||||
public void testModifiersClassScope_1() throws Exception {
|
||||
configureByFile(BASE_PATH + "/classScope-1.java");
|
||||
testByCount(5, ourClassScopeKeywords);
|
||||
}
|
||||
|
||||
public void testModifiersClassScope_2() throws Exception {
|
||||
configureByFile(BASE_PATH + "/classScope-2.java");
|
||||
testByCount(4, ourClassScopeKeywords);
|
||||
}
|
||||
|
||||
public void testModifiersClassScope_3() throws Exception {
|
||||
configureByFile(BASE_PATH + "/classScope-3.java");
|
||||
testByCount(0, ourClassScopeKeywords);
|
||||
}
|
||||
|
||||
public void testAfterAnnotations() throws Exception {
|
||||
configureByFile(BASE_PATH + "/afterAnnotations.java");
|
||||
testByCount(6, "public", "final", "class", "interface", "abstract", "enum", null);
|
||||
}
|
||||
|
||||
public void testExtends_1() throws Exception {
|
||||
configureByFile(BASE_PATH + "/extends-1.java");
|
||||
testByCount(2, "extends", "implements", null);
|
||||
}
|
||||
|
||||
public void testExtends_2() throws Exception {
|
||||
configureByFile(BASE_PATH + "/extends-2.java");
|
||||
testByCount(1, "extends", "implements", "AAA", "BBB", "instanceof");
|
||||
}
|
||||
|
||||
public void testExtends_3() throws Exception {
|
||||
configureByFile(BASE_PATH + "/extends-3.java");
|
||||
testByCount(2, "extends", "implements", "AAA", "BBB", "CCC", "instanceof");
|
||||
}
|
||||
|
||||
public void testExtends_4() throws Exception {
|
||||
configureByFile(BASE_PATH + "/extends-4.java");
|
||||
testByCount(2, "extends", "implements", "AAA", "BBB", "CCC", "instanceof");
|
||||
}
|
||||
|
||||
public void testExtends_5() throws Exception {
|
||||
configureByFile(BASE_PATH + "/extends-5.java");
|
||||
testByCount(1, "extends", "implements", "AAA", "BBB", "CCC", "instanceof");
|
||||
}
|
||||
|
||||
public void testExtends_6() throws Exception {
|
||||
configureByFile(BASE_PATH + "/extends-6.java");
|
||||
testByCount(1, "extends", "implements", "AAA", "BBB", "CCC", "instanceof");
|
||||
}
|
||||
|
||||
public void testExtends_7() throws Exception {
|
||||
configureByFile(BASE_PATH + "/extends-7.java");
|
||||
checkResultByFile(BASE_PATH + "/extends-7-result.java");
|
||||
}
|
||||
|
||||
public void testExtends_8() throws Exception {
|
||||
configureByFile(BASE_PATH + "/extends-8.java");
|
||||
checkResultByFile(BASE_PATH + "/extends-8-result.java");
|
||||
}
|
||||
|
||||
public void testExtends_9() throws Exception {
|
||||
configureByFile(BASE_PATH + "/extends-9.java");
|
||||
checkResultByFile(BASE_PATH + "/extends-9-result.java");
|
||||
}
|
||||
|
||||
public void testExtends_10() throws Exception {
|
||||
configureByFile(BASE_PATH + "/extends-10.java");
|
||||
checkResultByFile(BASE_PATH + "/extends-10-result.java");
|
||||
}
|
||||
|
||||
public void testExtends_11() throws Exception {
|
||||
configureByFile(BASE_PATH + "/extends-11.java");
|
||||
checkResultByFile(BASE_PATH + "/extends-11-result.java");
|
||||
}
|
||||
|
||||
public void testExtends_12() throws Exception {
|
||||
final LanguageLevel level = LanguageLevelProjectExtension.getInstance(getJavaFacade().getProject()).getLanguageLevel();
|
||||
try {
|
||||
LanguageLevelProjectExtension.getInstance(getJavaFacade().getProject()).setLanguageLevel(LanguageLevel.JDK_1_5);
|
||||
configureByFile(BASE_PATH + "/extends-12.java");
|
||||
checkResultByFile(BASE_PATH + "/extends-12-result.java");
|
||||
}
|
||||
finally {
|
||||
LanguageLevelProjectExtension.getInstance(getJavaFacade().getProject()).setLanguageLevel(level);
|
||||
}
|
||||
}
|
||||
|
||||
public void testSynchronized_1() throws Exception {
|
||||
configureByFile(BASE_PATH + "/synchronized-1.java");
|
||||
checkResultByFile(BASE_PATH + "/synchronized-1-result.java");
|
||||
}
|
||||
|
||||
public void testSynchronized_2() throws Exception {
|
||||
CodeStyleSettingsManager.getSettings(getProject()).SPACE_BEFORE_SYNCHRONIZED_PARENTHESES = false;
|
||||
configureByFile(BASE_PATH + "/synchronized-2.java");
|
||||
checkResultByFile(BASE_PATH + "/synchronized-2-result.java");
|
||||
}
|
||||
|
||||
public void testModifiersClassScope() throws Exception{
|
||||
configureByFile(BASE_PATH + "/classScope-4.java");
|
||||
testByCount(10, "package", "public", "private", "protected", "transient", "volatile", "static", "import", "final", "class", "interface",
|
||||
"abstract");
|
||||
}
|
||||
|
||||
public void testMethodThrows() throws Exception{
|
||||
configureByFile(BASE_PATH + "/methodScope-1.java");
|
||||
testByCount(1, "throws");
|
||||
}
|
||||
|
||||
public void testModifiersInMethodScope_1() throws Exception{
|
||||
configureByFile(BASE_PATH + "/methodScope-2.java");
|
||||
testByCount(1, "final", "public", "static", "volatile", "abstract");
|
||||
}
|
||||
|
||||
public void testModifiersInMethodScope_2() throws Exception{
|
||||
configureByFile(BASE_PATH + "/methodScope-3.java");
|
||||
testByCount(1, "final", "public", "static", "volatile", "abstract", "throws", "instanceof");
|
||||
}
|
||||
|
||||
public void testModifiersInMethodScope_3() throws Exception{
|
||||
configureByFile(BASE_PATH + "/methodScope-4.java");
|
||||
testByCount(6, "final", "try", "for", "while", "return", "throw");
|
||||
}
|
||||
|
||||
public void testModifiersInMethodScope_5() throws Exception{
|
||||
configureByFile(BASE_PATH + "/methodScope-5.java");
|
||||
checkResultByFile(BASE_PATH + "/methodScope-5-out.java");
|
||||
}
|
||||
|
||||
public void testExtendsInCastTypeParameters() throws Throwable { doTest(); }
|
||||
public void testExtendsWithRightContextInClassTypeParameters() throws Throwable { doTest(); }
|
||||
|
||||
public void testExtraBracketAfterFinally() throws Throwable { doTest(); }
|
||||
public void testExtraBracketAfterFinally1() throws Throwable { doTest(); }
|
||||
|
||||
public void testTrueInVariableDeclaration() throws Throwable { doTest(); }
|
||||
public void testNullInIf() throws Throwable { doTest(); }
|
||||
|
||||
public void testExtendsInMethodParameters() throws Throwable { doTest(); }
|
||||
|
||||
private void doTest() throws Exception {
|
||||
configureByFile(BASE_PATH + "/" + getTestName(false) + ".java");
|
||||
checkResultByFile(BASE_PATH + "/" + getTestName(false) + "-out.java");
|
||||
}
|
||||
|
||||
public void testInstanceOf_1() throws Exception{
|
||||
configureByFile(BASE_PATH + "/instanceof-1.java");
|
||||
checkResultByFile(BASE_PATH + "/instanceof-1-result.java");
|
||||
//testByCount(new String[]{"instanceof"}, 1);
|
||||
}
|
||||
|
||||
public void testInstanceOf_2() throws Exception{
|
||||
configureByFile(BASE_PATH + "/instanceof-2.java");
|
||||
checkResultByFile(BASE_PATH + "/instanceof-2-result.java");
|
||||
//testByCount(new String[]{"instanceof"}, 1);
|
||||
}
|
||||
|
||||
public void testInstanceOf_3() throws Exception{
|
||||
configureByFile(BASE_PATH + "/instanceof-3.java");
|
||||
checkResultByFile(BASE_PATH + "/instanceof-3-result.java");
|
||||
//testByCount(new String[]{"instanceof"}, 1);
|
||||
}
|
||||
|
||||
public void testCatchFinally() throws Exception{
|
||||
configureByFile(BASE_PATH + "/catch-1.java");
|
||||
testByCount(2, "catch", "finally");
|
||||
}
|
||||
|
||||
public void testSuper1() throws Exception{
|
||||
configureByFile(BASE_PATH + "/super-1.java");
|
||||
testByCount(1, "super");
|
||||
}
|
||||
|
||||
public void testSuper2() throws Exception{
|
||||
configureByFile(BASE_PATH + "/super-2.java");
|
||||
testByCount(0, "super");
|
||||
}
|
||||
|
||||
public void testContinue() throws Exception{
|
||||
configureByFile(BASE_PATH + "/continue.java");
|
||||
checkResultByFile(BASE_PATH + "/continue_after.java");
|
||||
}
|
||||
|
||||
public void testThrowsOnSeparateLine() throws Exception{
|
||||
configureByFile(BASE_PATH + "/throwsOnSeparateLine.java");
|
||||
checkResultByFile(BASE_PATH + "/throwsOnSeparateLine_after.java");
|
||||
}
|
||||
|
||||
public void testDefaultInAnno() throws Exception{
|
||||
configureByFile(BASE_PATH + "/" + getTestName(true) + ".java");
|
||||
checkResultByFile(BASE_PATH + "/" + getTestName(true) + "_after.java");
|
||||
}
|
||||
|
||||
public void testTryInExpression() throws Throwable {
|
||||
configureByFile(BASE_PATH + "/" + getTestName(true) + ".java");
|
||||
assertStringItems("toString", "this");
|
||||
}
|
||||
|
||||
public void testNull() throws Exception{
|
||||
configureByFile(BASE_PATH + "/NullInMethodCall.java");
|
||||
checkResultByFile(BASE_PATH + "/NullInMethodCall_After.java");
|
||||
configureByFile(BASE_PATH + "/NullInMethodCall2.java");
|
||||
checkResultByFile(BASE_PATH + "/NullInMethodCall2_After.java");
|
||||
}
|
||||
}
|
||||
+115
@@ -0,0 +1,115 @@
|
||||
/*
|
||||
* Copyright (c) 2000-2007 JetBrains s.r.o. All Rights Reserved.
|
||||
*/
|
||||
|
||||
package com.intellij.codeInsight.completion;
|
||||
|
||||
import com.intellij.codeInsight.lookup.impl.LookupImpl;
|
||||
import com.intellij.codeInsight.CodeInsightSettings;
|
||||
import com.intellij.psi.PsiMethod;
|
||||
|
||||
@SuppressWarnings({"ALL"})
|
||||
public class NormalCompletionOrderingTest extends CompletionSortingTestCase {
|
||||
private static final String BASE_PATH = "/codeInsight/completion/normalSorting";
|
||||
|
||||
public NormalCompletionOrderingTest() {
|
||||
super(CompletionType.BASIC);
|
||||
}
|
||||
|
||||
protected String getBasePath() {
|
||||
return BASE_PATH;
|
||||
}
|
||||
|
||||
public void testDontPreferRecursiveMethod() throws Throwable {
|
||||
checkPreferredItems(0, "registrar", "register");
|
||||
}
|
||||
|
||||
public void testDontPreferRecursiveMethod2() throws Throwable {
|
||||
checkPreferredItems(0, "return", "register");
|
||||
}
|
||||
|
||||
public void testPreferAnnotationMethods() throws Throwable {
|
||||
checkPreferredItems(0, "name", "value", "Foo", "Anno");
|
||||
}
|
||||
|
||||
public void testPreferSuperMethods() throws Throwable {
|
||||
checkPreferredItems(0, "foo", "bar");
|
||||
}
|
||||
|
||||
public void testSubstringVsSubSequence() throws Throwable {
|
||||
checkPreferredItems(0, "substring", "substring", "subSequence");
|
||||
}
|
||||
|
||||
public void testReturnF() throws Throwable {
|
||||
checkPreferredItems(0, "false", "finalize");
|
||||
}
|
||||
|
||||
public void testPreferDefaultTypeToExpected() throws Throwable {
|
||||
checkPreferredItems(0, "getName", "getNameIdentifier");
|
||||
}
|
||||
|
||||
public void testShorterPrefixesGoFirst() throws Throwable {
|
||||
final LookupImpl lookup = invokeCompletion(getBasePath() + "/" + getTestName(false) + ".html");
|
||||
assertPreferredItems(0, "p", "param", "pre");
|
||||
incUseCount(lookup, 2);
|
||||
assertPreferredItems(0, "p", "pre", "param");
|
||||
}
|
||||
|
||||
public void testShorterShouldBePreselected() throws Throwable {
|
||||
checkPreferredItems(0, "foo", "fooLongButOfDefaultType");
|
||||
}
|
||||
|
||||
public void testGenericMethodsWithBoundParametersAreStillBetterThanClassLiteral() throws Throwable {
|
||||
checkPreferredItems(0, "getService", "getService", "class");
|
||||
}
|
||||
|
||||
public void testUppercaseMatters() throws Throwable {
|
||||
final int old = CodeInsightSettings.getInstance().COMPLETION_CASE_SENSITIVE;
|
||||
try {
|
||||
CodeInsightSettings.getInstance().COMPLETION_CASE_SENSITIVE = CodeInsightSettings.FIRST_LETTER;
|
||||
checkPreferredItems(0, "classLoader", "classBeforeLoader", "clone", "class");
|
||||
}
|
||||
finally {
|
||||
CodeInsightSettings.getInstance().COMPLETION_CASE_SENSITIVE = old;
|
||||
}
|
||||
}
|
||||
|
||||
public void testUppercaseMatters2() throws Throwable {
|
||||
final int old = CodeInsightSettings.getInstance().COMPLETION_CASE_SENSITIVE;
|
||||
try {
|
||||
CodeInsightSettings.getInstance().COMPLETION_CASE_SENSITIVE = CodeInsightSettings.ALL;
|
||||
checkPreferredItems(0, "classLoader", "classLoader2");
|
||||
}
|
||||
finally {
|
||||
CodeInsightSettings.getInstance().COMPLETION_CASE_SENSITIVE = old;
|
||||
}
|
||||
}
|
||||
|
||||
public void testHonorUppercaseLetters() throws Throwable {
|
||||
checkPreferredItems(0, "clsLoader", "clone", "class");
|
||||
}
|
||||
|
||||
public void testClassStaticMembersInVoidContext() throws Throwable {
|
||||
checkPreferredItems(0, "booleanMethod", "voidMethod", "AN_OBJECT", "BOOLEAN", "Inner");
|
||||
}
|
||||
|
||||
public void testClassStaticMembersInBooleanContext() throws Throwable {
|
||||
checkPreferredItems(0, "booleanMethod", "voidMethod", "BOOLEAN", "AN_OBJECT", "Inner");
|
||||
}
|
||||
|
||||
public void testDispreferDeclared() throws Throwable {
|
||||
checkPreferredItems(0, "aabbb", "aaa");
|
||||
}
|
||||
|
||||
public void testDispreferDeclaredOfExpectedType() throws Throwable {
|
||||
checkPreferredItems(0, "aabbb", "aaa");
|
||||
}
|
||||
|
||||
public void testPreferLessParameters() throws Throwable {
|
||||
checkPreferredItems(0, "foo", "foo", "foo", "fox");
|
||||
assertEquals(0, ((PsiMethod)myItems[0].getObject()).getParameterList().getParametersCount());
|
||||
assertEquals(1, ((PsiMethod)myItems[1].getObject()).getParameterList().getParametersCount());
|
||||
assertEquals(2, ((PsiMethod)myItems[2].getObject()).getParameterList().getParametersCount());
|
||||
}
|
||||
|
||||
}
|
||||
+243
@@ -0,0 +1,243 @@
|
||||
/*
|
||||
* Copyright (c) 2000-2007 JetBrains s.r.o. All Rights Reserved.
|
||||
*/
|
||||
|
||||
package com.intellij.codeInsight.completion;
|
||||
|
||||
import com.intellij.codeInsight.lookup.impl.LookupImpl;
|
||||
import com.intellij.openapi.projectRoots.Sdk;
|
||||
import com.intellij.openapi.projectRoots.impl.JavaSdkImpl;
|
||||
import com.intellij.psi.statistics.StatisticsManager;
|
||||
|
||||
@SuppressWarnings({"ALL"})
|
||||
public class SmartTypeCompletionOrderingTest extends CompletionSortingTestCase {
|
||||
private static final String BASE_PATH = "/codeInsight/completion/smartTypeSorting";
|
||||
|
||||
public SmartTypeCompletionOrderingTest() {
|
||||
super(CompletionType.SMART);
|
||||
}
|
||||
|
||||
public void testJComponentAdd() throws Throwable {
|
||||
checkPreferredItems(0, "name", "b", "fooBean239", "this", "getName");
|
||||
}
|
||||
|
||||
public void testJComponentAddNew() throws Throwable {
|
||||
//there's no PopupMenu in mock jdk
|
||||
checkPreferredItems(2, "Component", "String", "FooBean3", "Container", "JComponent");
|
||||
}
|
||||
|
||||
public void testJComponentAddNewWithStats() throws Throwable {
|
||||
//there's no PopupMenu in mock jdk
|
||||
final LookupImpl lookup = invokeCompletion(BASE_PATH + "/JComponentAddNew.java");
|
||||
assertPreferredItems(2, "Component", "String", "FooBean3", "Container", "JComponent");
|
||||
incUseCount(lookup, 3); //Container
|
||||
assertPreferredItems(2, "Component", "String", "Container", "FooBean3", "JComponent");
|
||||
imitateItemSelection(lookup, 3); //FooBean3
|
||||
for (int i = 0; i < StatisticsManager.OBLIVION_THRESHOLD; i++) {
|
||||
imitateItemSelection(lookup, 2); //Container
|
||||
}
|
||||
refreshSorting(lookup);
|
||||
assertPreferredItems(0, "Container", "FooBean3", "JComponent", "Frame", "Window");
|
||||
}
|
||||
|
||||
public void testMethodStats() throws Throwable {
|
||||
final LookupImpl lookup = invokeCompletion(BASE_PATH + "/" + getTestName(false) + ".java");
|
||||
assertPreferredItems(0, "bar", "foo", "goo");
|
||||
incUseCount(lookup, 2);
|
||||
assertPreferredItems(0, "goo", "bar", "foo");
|
||||
}
|
||||
|
||||
public void testNewRunnable() throws Throwable {
|
||||
checkPreferredItems(0, "Runnable", "MyAnotherRunnable", "MyRunnable", "Thread");
|
||||
}
|
||||
|
||||
public void testNewComponent() throws Throwable {
|
||||
checkPreferredItems(1, "Component", "Foo", "Container", "JComponent");
|
||||
}
|
||||
|
||||
public void testClassLiteral() throws Throwable {
|
||||
checkPreferredItems(0, "String.class");
|
||||
}
|
||||
|
||||
public void testMethodsWithSubstitutableReturnType() throws Throwable {
|
||||
checkPreferredItems(0, "foo", "toString", "bar");
|
||||
}
|
||||
|
||||
public void testDontPreferKeywords() throws Throwable {
|
||||
checkPreferredItems(0, "o1", "foo", "name", "this", "getClass");
|
||||
}
|
||||
|
||||
public void testEnumValueOf() throws Throwable {
|
||||
checkPreferredItems(0, "e", "MyEnum.BAR", "MyEnum.FOO", "MyEnum.valueOf", "Enum.valueOf");
|
||||
}
|
||||
|
||||
public void testEnumValueOf2() throws Throwable {
|
||||
checkPreferredItems(0, "e", "MyEnum.BAR", "MyEnum.FOO", "bar", "MyEnum.valueOf");
|
||||
}
|
||||
|
||||
public void testPreferMatchedWords() throws Throwable {
|
||||
checkPreferredItems(0, "getVersionString", "getTitle");
|
||||
}
|
||||
|
||||
public void testPreferImportedClasses() throws Throwable {
|
||||
//there's no PopupMenu in mock jdk
|
||||
checkPreferredItems(2, "Component", "String", "FooBean3", "JPanel", "Container");
|
||||
}
|
||||
|
||||
public void testPreferNestedClasses() throws Throwable {
|
||||
//there's no PopupMenu in mock jdk
|
||||
checkPreferredItems(2, "Component", "String", "FooBean3", "NestedClass", "Container");
|
||||
}
|
||||
|
||||
public void testSmartCollections() throws Throwable {
|
||||
checkPreferredItems(0, "s");
|
||||
}
|
||||
|
||||
public void testSmartEquals() throws Throwable {
|
||||
checkPreferredItems(0, "s");
|
||||
}
|
||||
|
||||
public void testSmartEquals2() throws Throwable {
|
||||
checkPreferredItems(0, "foo", "this", "o", "s", "getClass");
|
||||
}
|
||||
|
||||
public void testSmartEquals3() throws Throwable {
|
||||
checkPreferredItems(0, "b", "this", "a", "z", "getClass");
|
||||
}
|
||||
|
||||
public void testSmartCollectionsNew() throws Throwable {
|
||||
checkPreferredItems(1, "Foo", "Bar");
|
||||
}
|
||||
|
||||
public void testSmartEqualsNew() throws Throwable {
|
||||
checkPreferredItems(1, "Foo", "Bar");
|
||||
}
|
||||
|
||||
public void testSmartEqualsNew2() throws Throwable {
|
||||
checkPreferredItems(0, "Foo");
|
||||
}
|
||||
|
||||
public void testBooleanValueOf() throws Throwable {
|
||||
checkPreferredItems(0, "b", "Boolean.valueOf", "Boolean.valueOf", "Boolean.FALSE", "Boolean.TRUE");
|
||||
}
|
||||
|
||||
public void testXmlTagGetAttribute() throws Throwable {
|
||||
checkPreferredItems(0, "getAttributeValue", "getNamespace", "toString");
|
||||
}
|
||||
|
||||
public void testPreferFieldsToMethods() throws Throwable {
|
||||
checkPreferredItems(0, "myVersion", "getVersion", "getSelectedVersion", "calculateVersion");
|
||||
}
|
||||
|
||||
public void testPreferParametersToGetters() throws Throwable {
|
||||
checkPreferredItems(0, "a", "getLastI");
|
||||
}
|
||||
|
||||
public void testExpectedInterfaceShouldGoFirst() throws Throwable {
|
||||
checkPreferredItems(0, "MyProcessor<Foo>", "Proc1<Foo>");
|
||||
}
|
||||
|
||||
public void testStatisticsAffectsNonPreferableExpectedItems() throws Throwable {
|
||||
final LookupImpl lookup = invokeCompletion(BASE_PATH + "/" + getTestName(false) + ".java");
|
||||
assertPreferredItems(1, "List<Foo>", "AbstractList<Foo>", "AbstractSequentialList<Foo>", "ArrayList<Foo>");
|
||||
incUseCount(lookup, 0);
|
||||
assertPreferredItems(1, "List<Foo>", "AbstractList<Foo>", "AbstractSequentialList<Foo>", "ArrayList<Foo>");
|
||||
incUseCount(lookup, 0);
|
||||
assertPreferredItems(0, "List<Foo>", "AbstractList<Foo>", "AbstractSequentialList<Foo>", "ArrayList<Foo>");
|
||||
}
|
||||
|
||||
public void testPreferNonRecursiveMethodParams() throws Throwable {
|
||||
checkPreferredItems(0, "b", "s", "a", "hashCode");
|
||||
}
|
||||
|
||||
public void testPreferDelegatingMethodParams() throws Throwable {
|
||||
//there's no PopupMenu in mock jdk
|
||||
final LookupImpl lookup = invokeCompletion(BASE_PATH + "/" + getTestName(false) + ".java");
|
||||
assertPreferredItems(0, "xyz", "abc");
|
||||
incUseCount(lookup, 1);
|
||||
assertPreferredItems(0, "xyz", "abc");
|
||||
}
|
||||
|
||||
public void testGwtButtons() throws Throwable {
|
||||
checkPreferredItems(0, "Button", "ButtonBase");
|
||||
}
|
||||
|
||||
public void testNewArrayList() throws Throwable {
|
||||
checkPreferredItems(0, "ArrayList", "OtherList");
|
||||
}
|
||||
|
||||
public void testPassingQualifierToMethodCall() throws Throwable {
|
||||
checkPreferredItems(0, "this", "param");
|
||||
}
|
||||
|
||||
public void testPassingThisToUnqualifiedMethodCall() throws Throwable {
|
||||
checkPreferredItems(0, "param", "this");
|
||||
}
|
||||
|
||||
public void testPreferAccessibleMembers() throws Throwable {
|
||||
checkPreferredItems(0, "Foo.C_NORMAL", "Foo.B_DEPRECATED");
|
||||
}
|
||||
|
||||
public void testNoSkippingInSmartCast() throws Throwable {
|
||||
checkPreferredItems(0, "Foo", "Bar", "Goo");
|
||||
}
|
||||
|
||||
public void testLiteralInReturn() throws Throwable {
|
||||
checkPreferredItems(0, "false", "true", "equals");
|
||||
}
|
||||
|
||||
public void testLiteralInIf() throws Throwable {
|
||||
checkPreferredItems(0, "equals", "false", "true");
|
||||
}
|
||||
|
||||
public void testFactoryMethodForDefaultType() throws Throwable {
|
||||
checkPreferredItems(0, "Pair.create", "map", "this", "getClass");
|
||||
}
|
||||
|
||||
public void testLocalVarsBeforeClassLiterals() throws Throwable {
|
||||
checkPreferredItems(0, "local", "Foo.class", "Bar.class");
|
||||
}
|
||||
|
||||
public void testDontPreferCasted() throws Throwable {
|
||||
checkPreferredItems(0, "b", "_o");
|
||||
}
|
||||
|
||||
public void testInnerClassesProximity() throws Throwable {
|
||||
checkPreferredItems(0, "Goo", "InnerGoo", "Bar", "AGoo");
|
||||
}
|
||||
|
||||
public void testLocalVariablesOutweighStats() throws Throwable {
|
||||
final LookupImpl lookup = invokeCompletion(BASE_PATH + "/" + getTestName(false) + ".java");
|
||||
assertPreferredItems(0, "foo", "param", "this", "bar", "goo");
|
||||
incUseCount(lookup, 4);
|
||||
assertPreferredItems(0, "foo", "param", "this", "goo", "bar");
|
||||
for (int i = 0; i < StatisticsManager.OBLIVION_THRESHOLD; i++) {
|
||||
imitateItemSelection(lookup, 3); //goo
|
||||
}
|
||||
refreshSorting(lookup);
|
||||
assertPreferredItems(0, "foo", "param", "this", "goo", "bar");
|
||||
}
|
||||
|
||||
public void testPreferredByNameDontChangeStatistics() throws Throwable {
|
||||
final LookupImpl lookup = invokeCompletion(BASE_PATH + "/" + getTestName(false) + ".java");
|
||||
assertPreferredItems(0, "foo", "false");
|
||||
lookup.finishLookup(',');
|
||||
complete();
|
||||
assertPreferredItems(0, "bar", "foo", "equals", "false", "true");
|
||||
}
|
||||
|
||||
public void testFieldNameOutweighsStats() throws Throwable {
|
||||
final LookupImpl lookup = invokeCompletion(BASE_PATH + "/" + getTestName(false) + ".java");
|
||||
assertPreferredItems(0, "myFoo", "myBar");
|
||||
incUseCount(lookup, 1); //myBar
|
||||
assertPreferredItems(0, "myFoo", "myBar");
|
||||
}
|
||||
|
||||
protected String getBasePath() {
|
||||
return BASE_PATH;
|
||||
}
|
||||
|
||||
protected Sdk getTestProjectJdk() {
|
||||
return JavaSdkImpl.getMockJdk15("java 1.5");
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user