mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-08-26 15:27:45 +07:00
method chains completion
This commit is contained in:
+31
@@ -0,0 +1,31 @@
|
||||
import java.jang.String;
|
||||
|
||||
/**
|
||||
* @author Dmitry Batkovich <dmitry.batkovich@jetbrains.com>
|
||||
*/
|
||||
|
||||
|
||||
|
||||
class PsiElement {
|
||||
PsiFile getContainingFile() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
class PsiFile {
|
||||
VirtualFile getVirtualFile() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
class VirtualFile {}
|
||||
|
||||
|
||||
public class TestCompletion {
|
||||
|
||||
PsiElement e;
|
||||
|
||||
public void method() {
|
||||
VirtualFile vf = <caret>
|
||||
}
|
||||
}
|
||||
+30
@@ -0,0 +1,30 @@
|
||||
/**
|
||||
* @author Dmitry Batkovich <dmitry.batkovich@jetbrains.com>
|
||||
*/
|
||||
public class TestIndex {
|
||||
|
||||
public void statMethod(PsiElement e) {
|
||||
e.getContainingFile().getVirtualFile();
|
||||
e.getContainingFile().getVirtualFile();
|
||||
e.getContainingFile().getVirtualFile();
|
||||
e.getContainingFile().getVirtualFile();
|
||||
e.getContainingFile().getVirtualFile();
|
||||
e.getContainingFile().getVirtualFile();
|
||||
e.getContainingFile().getVirtualFile();
|
||||
e.getContainingFile().getVirtualFile();
|
||||
}
|
||||
}
|
||||
|
||||
class PsiElement {
|
||||
PsiFile getContainingFile() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
class PsiFile {
|
||||
VirtualFile getVirtualFile() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
class VirtualFile {}
|
||||
+36
@@ -0,0 +1,36 @@
|
||||
import java.jang.String;
|
||||
|
||||
/**
|
||||
* @author Dmitry Batkovich <dmitry.batkovich@jetbrains.com>
|
||||
*/
|
||||
|
||||
|
||||
|
||||
interface PsiFile extends PsiElement {
|
||||
}
|
||||
|
||||
interface PsiElement {
|
||||
PsiElement findElementAt(int position);
|
||||
}
|
||||
|
||||
class PsiManager {
|
||||
static PsiManager getInstance(Project p) {
|
||||
return null;
|
||||
}
|
||||
|
||||
PsiFile findFile(VirtualFile vf) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
interface VirtualFile {}
|
||||
|
||||
interface Project {}
|
||||
|
||||
|
||||
public class TestCompletion {
|
||||
|
||||
public void method() {
|
||||
PsiElement e = <caret>
|
||||
}
|
||||
}
|
||||
+38
@@ -0,0 +1,38 @@
|
||||
/**
|
||||
* @author Dmitry Batkovich <dmitry.batkovich@jetbrains.com>
|
||||
*/
|
||||
public class TestIndex {
|
||||
PsiElement e;
|
||||
|
||||
public void statMethod() {
|
||||
e = PsiManager.getInstance(null).findFile(null).findElementAt(0);
|
||||
e = PsiManager.getInstance(null).findFile(null).findElementAt(0);
|
||||
e = PsiManager.getInstance(null).findFile(null).findElementAt(0);
|
||||
e = PsiManager.getInstance(null).findFile(null).findElementAt(0);
|
||||
e = PsiManager.getInstance(null).findFile(null).findElementAt(0);
|
||||
e = PsiManager.getInstance(null).findFile(null).findElementAt(0);
|
||||
e = PsiManager.getInstance(null).findFile(null).findElementAt(0);
|
||||
e = PsiManager.getInstance(null).findFile(null).findElementAt(0);
|
||||
}
|
||||
}
|
||||
|
||||
interface PsiFile extends PsiElement {
|
||||
}
|
||||
|
||||
interface PsiElement {
|
||||
PsiElement findElementAt(int position);
|
||||
}
|
||||
|
||||
class PsiManager {
|
||||
static PsiManager getInstance(Project p) {
|
||||
return null;
|
||||
}
|
||||
|
||||
PsiFile findFile(VirtualFile vf) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
interface VirtualFile {}
|
||||
|
||||
interface Project {}
|
||||
+43
@@ -0,0 +1,43 @@
|
||||
import java.jang.String;
|
||||
|
||||
/**
|
||||
* @author Dmitry Batkovich <dmitry.batkovich@jetbrains.com>
|
||||
*/
|
||||
|
||||
class Project {
|
||||
Object o;
|
||||
|
||||
void setObject(Object o) {
|
||||
this.o = o;
|
||||
}
|
||||
|
||||
<T> Object getObject(Class<T> tClass) {
|
||||
return o;
|
||||
}
|
||||
}
|
||||
|
||||
class Manager {
|
||||
|
||||
Project p1;
|
||||
|
||||
Manager(Project p1) {
|
||||
this.p1 = p1;
|
||||
}
|
||||
|
||||
static Manager getManager(Project project) {
|
||||
return (Manager) project.getObject(Manager.class);
|
||||
}
|
||||
|
||||
Project getProject() {
|
||||
return p1;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public class TestCompletion {
|
||||
|
||||
public void method() {
|
||||
Manager m = <caret>;
|
||||
Project p = m.getProject();
|
||||
}
|
||||
}
|
||||
+61
@@ -0,0 +1,61 @@
|
||||
public class TestIndex {
|
||||
|
||||
Manager manager = new Manager(new Project());
|
||||
|
||||
public void statMethod() {
|
||||
manager.getProject();
|
||||
manager.getProject();
|
||||
manager.getProject();
|
||||
manager.getProject();
|
||||
manager.getProject();
|
||||
manager.getProject();
|
||||
manager.getProject();
|
||||
}
|
||||
}
|
||||
|
||||
class TestIndex2 {
|
||||
|
||||
Project p2 = new Project();
|
||||
|
||||
public void statMethod() {
|
||||
Manager.getManager(p2);
|
||||
Manager.getManager(p2);
|
||||
Manager.getManager(p2);
|
||||
Manager.getManager(p2);
|
||||
Manager.getManager(p2);
|
||||
Manager.getManager(p2);
|
||||
Manager.getManager(p2);
|
||||
Manager.getManager(p2);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class Project {
|
||||
Object o;
|
||||
|
||||
void setObject(Object o) {
|
||||
this.o = o;
|
||||
}
|
||||
|
||||
<T> Object getObject(Class<T> tClass) {
|
||||
return o;
|
||||
}
|
||||
}
|
||||
|
||||
class Manager {
|
||||
|
||||
Project p1;
|
||||
|
||||
Manager(Project p1) {
|
||||
this.p1 = p1;
|
||||
}
|
||||
|
||||
static Manager getManager(Project project) {
|
||||
return (Manager) project.getObject(Manager.class);
|
||||
}
|
||||
|
||||
Project getProject() {
|
||||
return p1;
|
||||
}
|
||||
|
||||
}
|
||||
+42
@@ -0,0 +1,42 @@
|
||||
import java.jang.String;
|
||||
|
||||
/**
|
||||
* @author Dmitry Batkovich <dmitry.batkovich@jetbrains.com>
|
||||
*/
|
||||
|
||||
class Project {
|
||||
Object o;
|
||||
|
||||
void setObject(Object o) {
|
||||
this.o = o;
|
||||
}
|
||||
|
||||
<T> Object getObject(Class<T> tClass) {
|
||||
return o;
|
||||
}
|
||||
}
|
||||
|
||||
class Manager {
|
||||
|
||||
Project p1;
|
||||
|
||||
Manager(Project p1) {
|
||||
this.p1 = p1;
|
||||
}
|
||||
|
||||
static Manager getManager(Project project) {
|
||||
return (Manager) project.getObject(Manager.class);
|
||||
}
|
||||
|
||||
Project getProject() {
|
||||
return p1;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public class TestCompletion {
|
||||
|
||||
public void method() {
|
||||
Manager m = <caret>;
|
||||
}
|
||||
}
|
||||
+61
@@ -0,0 +1,61 @@
|
||||
public class TestIndex {
|
||||
|
||||
Manager manager = new Manager(new Project());
|
||||
|
||||
public void statMethod() {
|
||||
manager.getProject();
|
||||
manager.getProject();
|
||||
manager.getProject();
|
||||
manager.getProject();
|
||||
manager.getProject();
|
||||
manager.getProject();
|
||||
manager.getProject();
|
||||
}
|
||||
}
|
||||
|
||||
class TestIndex2 {
|
||||
|
||||
Project p2 = new Project();
|
||||
|
||||
public void statMethod() {
|
||||
Manager.getManager(p2);
|
||||
Manager.getManager(p2);
|
||||
Manager.getManager(p2);
|
||||
Manager.getManager(p2);
|
||||
Manager.getManager(p2);
|
||||
Manager.getManager(p2);
|
||||
Manager.getManager(p2);
|
||||
Manager.getManager(p2);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class Project {
|
||||
Object o;
|
||||
|
||||
void setObject(Object o) {
|
||||
this.o = o;
|
||||
}
|
||||
|
||||
<T> Object getObject(Class<T> tClass) {
|
||||
return o;
|
||||
}
|
||||
}
|
||||
|
||||
class Manager {
|
||||
|
||||
Project p1;
|
||||
|
||||
Manager(Project p1) {
|
||||
this.p1 = p1;
|
||||
}
|
||||
|
||||
static Manager getManager(Project project) {
|
||||
return (Manager) project.getObject(Manager.class);
|
||||
}
|
||||
|
||||
Project getProject() {
|
||||
return p1;
|
||||
}
|
||||
|
||||
}
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
/**
|
||||
* @author Dmitry Batkovich <dmitry.batkovich@jetbrains.com>
|
||||
*/
|
||||
|
||||
class PsiElement {
|
||||
public PsiElement getPrevSibling() {
|
||||
return null;
|
||||
}
|
||||
public PsiElement getParent() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public class TestCompletion {
|
||||
public void method(PsiElement e) {
|
||||
PsiElement anotherElement = <caret>
|
||||
}
|
||||
}
|
||||
+25
@@ -0,0 +1,25 @@
|
||||
/**
|
||||
* @author Dmitry Batkovich <dmitry.batkovich@jetbrains.com>
|
||||
*/
|
||||
public class TestIndex {
|
||||
|
||||
public void statMethod(PsiElement e) {
|
||||
e.getParent();
|
||||
e.getParent();
|
||||
e.getParent();
|
||||
e.getParent();
|
||||
e.getPrevSibling();
|
||||
e.getPrevSibling();
|
||||
e.getPrevSibling();
|
||||
e.getPrevSibling();
|
||||
}
|
||||
}
|
||||
|
||||
class PsiElement {
|
||||
public PsiElement getPrevSibling() {
|
||||
return null;
|
||||
}
|
||||
public PsiElement getParent() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
+22
@@ -0,0 +1,22 @@
|
||||
import java.jang.String;
|
||||
|
||||
/**
|
||||
* @author Dmitry Batkovich <dmitry.batkovich@jetbrains.com>
|
||||
*/
|
||||
|
||||
interface Project {}
|
||||
|
||||
interface PsiElement {
|
||||
Project getProject();
|
||||
}
|
||||
|
||||
public class TestCompletion {
|
||||
|
||||
private PsiElement getMyElement() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public void method() {
|
||||
Project p = <caret>
|
||||
}
|
||||
}
|
||||
+22
@@ -0,0 +1,22 @@
|
||||
/**
|
||||
* @author Dmitry Batkovich <dmitry.batkovich@jetbrains.com>
|
||||
*/
|
||||
public class TestIndex {
|
||||
|
||||
public void statMethod(PsiElement e) {
|
||||
e.getProject();
|
||||
e.getProject();
|
||||
e.getProject();
|
||||
e.getProject();
|
||||
e.getProject();
|
||||
e.getProject();
|
||||
e.getProject();
|
||||
e.getProject();
|
||||
}
|
||||
}
|
||||
|
||||
interface Project {}
|
||||
|
||||
interface PsiElement {
|
||||
Project getProject();
|
||||
}
|
||||
+23
@@ -0,0 +1,23 @@
|
||||
import java.jang.String;
|
||||
|
||||
/**
|
||||
* @author Dmitry Batkovich <dmitry.batkovich@jetbrains.com>
|
||||
*/
|
||||
|
||||
|
||||
class JarFile {
|
||||
class JarEntry {
|
||||
}
|
||||
|
||||
JarEntry getEntry() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public class TestCompletion {
|
||||
|
||||
public void method(JarFile j) {
|
||||
JarFile.JarEntry e = <caret>
|
||||
}
|
||||
}
|
||||
+26
@@ -0,0 +1,26 @@
|
||||
/**
|
||||
* @author Dmitry Batkovich <dmitry.batkovich@jetbrains.com>
|
||||
*/
|
||||
public class TestIndex {
|
||||
|
||||
public void statMethod(JarFile f) {
|
||||
f.getEntry();
|
||||
f.getEntry();
|
||||
f.getEntry();
|
||||
f.getEntry();
|
||||
f.getEntry();
|
||||
f.getEntry();
|
||||
f.getEntry();
|
||||
f.getEntry();
|
||||
}
|
||||
}
|
||||
|
||||
class JarFile {
|
||||
class JarEntry {
|
||||
}
|
||||
|
||||
JarEntry getEntry() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
import java.jang.String;
|
||||
|
||||
|
||||
interface PsiElement {
|
||||
PsiClass getContainingClass();
|
||||
}
|
||||
|
||||
interface PsiClass extends PsiElement {}
|
||||
|
||||
public class TestCompletion {
|
||||
|
||||
public void method(PsiElement e) {
|
||||
int j = 1 + method123(<caret>);
|
||||
}
|
||||
|
||||
public int method123(PsiClass c) {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
+22
@@ -0,0 +1,22 @@
|
||||
/**
|
||||
* @author Dmitry Batkovich <dmitry.batkovich@jetbrains.com>
|
||||
*/
|
||||
public class TestIndex {
|
||||
|
||||
public void statMethod(PsiElement e) {
|
||||
e.getContainingClass();
|
||||
e.getContainingClass();
|
||||
e.getContainingClass();
|
||||
e.getContainingClass();
|
||||
e.getContainingClass();
|
||||
e.getContainingClass();
|
||||
e.getContainingClass();
|
||||
e.getContainingClass();
|
||||
}
|
||||
}
|
||||
|
||||
interface PsiElement {
|
||||
PsiClass getContainingClass();
|
||||
}
|
||||
|
||||
interface PsiClass extends PsiElement {}
|
||||
+25
@@ -0,0 +1,25 @@
|
||||
/**
|
||||
* @author Dmitry Batkovich <dmitry.batkovich@jetbrains.com>
|
||||
*/
|
||||
|
||||
|
||||
class PsiMethod implements PsiElement {
|
||||
}
|
||||
|
||||
interface PsiElement {
|
||||
}
|
||||
|
||||
class PsiClass {
|
||||
public PsiMethod findMethodByName(String methodName) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public class TestCompletion {
|
||||
|
||||
PsiClass c;
|
||||
|
||||
public void method() {
|
||||
PsiElement element = <caret>
|
||||
}
|
||||
}
|
||||
+24
@@ -0,0 +1,24 @@
|
||||
/**
|
||||
* @author Dmitry Batkovich <dmitry.batkovich@jetbrains.com>
|
||||
*/
|
||||
public class TestIndex {
|
||||
|
||||
public void statMethod(PsiClass c) {
|
||||
c.findMethodByName("asd");
|
||||
c.findMethodByName("asd");
|
||||
c.findMethodByName("asd");
|
||||
c.findMethodByName("asd");
|
||||
}
|
||||
}
|
||||
|
||||
class PsiMethod implements PsiElement {
|
||||
}
|
||||
|
||||
interface PsiElement {
|
||||
}
|
||||
|
||||
class PsiClass {
|
||||
public PsiMethod findMethodByName(String methodName) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
+27
@@ -0,0 +1,27 @@
|
||||
import java.jang.String;
|
||||
|
||||
/**
|
||||
* @author Dmitry Batkovich <dmitry.batkovich@jetbrains.com>
|
||||
*/
|
||||
|
||||
|
||||
class ElementFactory {
|
||||
PsiClassType createType(PsiClass c, Object obj) {
|
||||
return null;
|
||||
}
|
||||
|
||||
PsiClassType createType(PsiClass c) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
class PsiClassType {}
|
||||
|
||||
class PsiClass {}
|
||||
|
||||
public class TestCompletion {
|
||||
|
||||
public void method(ElementFactory f) {
|
||||
PsiClassType t = <caret>
|
||||
}
|
||||
}
|
||||
+32
@@ -0,0 +1,32 @@
|
||||
import java.lang.Object;
|
||||
|
||||
/**
|
||||
* @author Dmitry Batkovich <dmitry.batkovich@jetbrains.com>
|
||||
*/
|
||||
public class TestIndex {
|
||||
|
||||
public void statMethod(ElementFactory ef) {
|
||||
ef.createType(null);
|
||||
ef.createType(null);
|
||||
ef.createType(null);
|
||||
ef.createType(null);
|
||||
ef.createType(null, null);
|
||||
ef.createType(null, null);
|
||||
ef.createType(null, null);
|
||||
ef.createType(null, null);
|
||||
}
|
||||
}
|
||||
|
||||
class ElementFactory {
|
||||
PsiClassType createType(PsiClass c, Object obj) {
|
||||
return null;
|
||||
}
|
||||
|
||||
PsiClassType createType(PsiClass c) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
class PsiClassType {}
|
||||
|
||||
class PsiClass {}
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
import java.jang.String;
|
||||
|
||||
/**
|
||||
* @author Dmitry Batkovich <dmitry.batkovich@jetbrains.com>
|
||||
*/
|
||||
|
||||
class PsiManager {
|
||||
Project getProject() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
class Project {}
|
||||
|
||||
public class TestCompletion {
|
||||
|
||||
public void method() {
|
||||
Project p = <caret>
|
||||
}
|
||||
}
|
||||
+51
@@ -0,0 +1,51 @@
|
||||
|
||||
//
|
||||
// if component obtained in implicit way
|
||||
//
|
||||
|
||||
public class TestIndex {
|
||||
|
||||
|
||||
//
|
||||
// simple test for spring like configuration
|
||||
//
|
||||
|
||||
private PsiManager a;
|
||||
|
||||
public void setA(PsiManager a) {
|
||||
this.a = a;
|
||||
}
|
||||
|
||||
void m() {
|
||||
a.getProject();
|
||||
a.getProject();
|
||||
}
|
||||
|
||||
void b() {
|
||||
a.getProject();
|
||||
}
|
||||
|
||||
void c() {
|
||||
a.getProject();
|
||||
}
|
||||
|
||||
void c22() {
|
||||
a.getProject();
|
||||
}
|
||||
|
||||
void c11() {
|
||||
a.getProject();
|
||||
}
|
||||
|
||||
void c1() {
|
||||
a.getProject();
|
||||
}
|
||||
}
|
||||
|
||||
class PsiManager {
|
||||
Project getProject() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
class Project {}
|
||||
|
||||
+24
@@ -0,0 +1,24 @@
|
||||
/**
|
||||
* @author Dmitry Batkovich <dmitry.batkovich@jetbrains.com>
|
||||
*/
|
||||
|
||||
class PsiManager {
|
||||
Project getProject() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
interface Project {
|
||||
VirtualFile getBaseDir();
|
||||
}
|
||||
|
||||
class VirtualFile {
|
||||
}
|
||||
|
||||
public class TestCompletion {
|
||||
PsiManager m;
|
||||
|
||||
public void method(Project p) {
|
||||
VirtualFile projectBaseDir = <caret>
|
||||
}
|
||||
}
|
||||
+29
@@ -0,0 +1,29 @@
|
||||
/**
|
||||
* @author Dmitry Batkovich <dmitry.batkovich@jetbrains.com>
|
||||
*/
|
||||
public class TestIndex {
|
||||
|
||||
public void statMethod(PsiManager m) {
|
||||
m.getProject().getBaseDir();
|
||||
m.getProject().getBaseDir();
|
||||
m.getProject().getBaseDir();
|
||||
m.getProject().getBaseDir();
|
||||
m.getProject().getBaseDir();
|
||||
m.getProject().getBaseDir();
|
||||
m.getProject().getBaseDir();
|
||||
m.getProject().getBaseDir();
|
||||
}
|
||||
}
|
||||
|
||||
class PsiManager {
|
||||
Project getProject() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
interface Project {
|
||||
VirtualFile getBaseDir();
|
||||
}
|
||||
|
||||
class VirtualFile {
|
||||
}
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
/**
|
||||
* @author Dmitry Batkovich <dmitry.batkovich@jetbrains.com>
|
||||
*/
|
||||
|
||||
class Element {
|
||||
public Project getProject() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
class Project {
|
||||
}
|
||||
|
||||
public class TestCompletion {
|
||||
public void method(Element e) {
|
||||
Project project = <caret>
|
||||
}
|
||||
}
|
||||
+25
@@ -0,0 +1,25 @@
|
||||
/**
|
||||
* @author Dmitry Batkovich <dmitry.batkovich@jetbrains.com>
|
||||
*/
|
||||
public class TestIndex {
|
||||
|
||||
public void statMethod(Element e) {
|
||||
e.getProject();
|
||||
e.getProject();
|
||||
e.getProject();
|
||||
e.getProject();
|
||||
e.getProject();
|
||||
e.getProject();
|
||||
e.getProject();
|
||||
e.getProject();
|
||||
}
|
||||
}
|
||||
|
||||
class Element {
|
||||
public Project getProject() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
class Project {
|
||||
}
|
||||
+53
@@ -0,0 +1,53 @@
|
||||
import java.jang.String;
|
||||
|
||||
class B {
|
||||
C getC() {
|
||||
return null;
|
||||
}
|
||||
|
||||
static B b = new B();
|
||||
|
||||
static B getB1() {
|
||||
return b;
|
||||
}
|
||||
static B getB2() {
|
||||
return b;
|
||||
}
|
||||
static B getB3() {
|
||||
return b;
|
||||
}
|
||||
static B getB4() {
|
||||
return b;
|
||||
}
|
||||
static B getB5() {
|
||||
return b;
|
||||
}
|
||||
static B getB6() {
|
||||
return b;
|
||||
}
|
||||
static B getB7() {
|
||||
return b;
|
||||
}
|
||||
static B getB8() {
|
||||
return b;
|
||||
}
|
||||
static B getB9() {
|
||||
return b;
|
||||
}
|
||||
static B getB10() {
|
||||
return b;
|
||||
}
|
||||
static B getB11() {
|
||||
return b;
|
||||
}
|
||||
}
|
||||
|
||||
class C {}
|
||||
|
||||
public class TestCompletion {
|
||||
|
||||
public void method() {
|
||||
C c = <caret>
|
||||
}
|
||||
|
||||
}
|
||||
+104
@@ -0,0 +1,104 @@
|
||||
/**
|
||||
* @author Dmitry Batkovich <dmitry.batkovich@jetbrains.com>
|
||||
*/
|
||||
public class TestIndex {
|
||||
|
||||
public void statMethod1() {
|
||||
B.getB1().getC();
|
||||
B.getB1().getC();
|
||||
B.getB1().getC();
|
||||
}
|
||||
public void statMethod2() {
|
||||
B.getB2().getC();
|
||||
B.getB2().getC();
|
||||
B.getB2().getC();
|
||||
}
|
||||
public void statMethod3() {
|
||||
B.getB3().getC();
|
||||
B.getB3().getC();
|
||||
B.getB3().getC();
|
||||
}
|
||||
public void statMethod4() {
|
||||
B.getB4().getC();
|
||||
B.getB4().getC();
|
||||
B.getB4().getC();
|
||||
}
|
||||
public void statMethod5() {
|
||||
B.getB5().getC();
|
||||
B.getB5().getC();
|
||||
B.getB5().getC();
|
||||
}
|
||||
public void statMethod6() {
|
||||
B.getB6().getC();
|
||||
B.getB6().getC();
|
||||
B.getB6().getC();
|
||||
}
|
||||
public void statMethod7() {
|
||||
B.getB7().getC();
|
||||
B.getB7().getC();
|
||||
B.getB7().getC();
|
||||
}
|
||||
public void statMethod8() {
|
||||
B.getB8().getC();
|
||||
B.getB8().getC();
|
||||
B.getB8().getC();
|
||||
}
|
||||
public void statMethod9() {
|
||||
B.getB9().getC();
|
||||
B.getB9().getC();
|
||||
B.getB9().getC();
|
||||
}
|
||||
public void statMethod10() {
|
||||
B.getB10().getC();
|
||||
B.getB10().getC();
|
||||
B.getB10().getC();
|
||||
}
|
||||
public void statMethod11() {
|
||||
B.getB11().getC();
|
||||
B.getB11().getC();
|
||||
B.getB11().getC();
|
||||
}
|
||||
}
|
||||
class B {
|
||||
C getC() {
|
||||
return null;
|
||||
}
|
||||
|
||||
static B b = new B();
|
||||
|
||||
static B getB1() {
|
||||
return b;
|
||||
}
|
||||
static B getB2() {
|
||||
return b;
|
||||
}
|
||||
static B getB3() {
|
||||
return b;
|
||||
}
|
||||
static B getB4() {
|
||||
return b;
|
||||
}
|
||||
static B getB5() {
|
||||
return b;
|
||||
}
|
||||
static B getB6() {
|
||||
return b;
|
||||
}
|
||||
static B getB7() {
|
||||
return b;
|
||||
}
|
||||
static B getB8() {
|
||||
return b;
|
||||
}
|
||||
static B getB9() {
|
||||
return b;
|
||||
}
|
||||
static B getB10() {
|
||||
return b;
|
||||
}
|
||||
static B getB11() {
|
||||
return b;
|
||||
}
|
||||
}
|
||||
|
||||
class C {}
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
import java.jang.String;
|
||||
|
||||
interface PsiManager {
|
||||
Project getProject();
|
||||
}
|
||||
|
||||
interface Project {}
|
||||
|
||||
public class TestCompletion {
|
||||
void m() {
|
||||
PsiManager psiManager = null;
|
||||
Project p = psiManager.getProject()
|
||||
}
|
||||
}
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
import java.jang.String;
|
||||
|
||||
interface PsiManager {
|
||||
Project getProject();
|
||||
}
|
||||
|
||||
interface Project {}
|
||||
|
||||
public class TestCompletion {
|
||||
void m() {
|
||||
Project p = <caret>
|
||||
}
|
||||
}
|
||||
+41
@@ -0,0 +1,41 @@
|
||||
/*
|
||||
* Copyright 2000-2013 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @author Dmitry Batkovich <dmitry.batkovich@jetbrains.com>
|
||||
*/
|
||||
import java.lang.String;
|
||||
|
||||
public class TestIndex {
|
||||
|
||||
PsiManager m;
|
||||
|
||||
void m() {
|
||||
m.getProject();
|
||||
m.getProject();
|
||||
m.getProject();
|
||||
m.getProject();
|
||||
m.getProject();
|
||||
m.getProject();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
interface PsiManager {
|
||||
Project getProject();
|
||||
}
|
||||
|
||||
interface Project {}
|
||||
+26
@@ -0,0 +1,26 @@
|
||||
import java.jang.String;
|
||||
|
||||
class JavaPsiFacade {
|
||||
static JavaPsiFacade getInstance() {
|
||||
return null;
|
||||
}
|
||||
|
||||
PsiClass findClass() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
interface PsiElement {
|
||||
PsiClass getContainingClass();
|
||||
}
|
||||
|
||||
interface PsiClass extends PsiElement {
|
||||
}
|
||||
|
||||
public class TestCompletion {
|
||||
|
||||
public void method(PsiElement e) {
|
||||
PsiClass c = JavaPsiFacade.getInstance().findClass()
|
||||
}
|
||||
|
||||
}
|
||||
+26
@@ -0,0 +1,26 @@
|
||||
import java.jang.String;
|
||||
|
||||
class JavaPsiFacade {
|
||||
static JavaPsiFacade getInstance() {
|
||||
return null;
|
||||
}
|
||||
|
||||
PsiClass findClass() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
interface PsiElement {
|
||||
PsiClass getContainingClass();
|
||||
}
|
||||
|
||||
interface PsiClass extends PsiElement {
|
||||
}
|
||||
|
||||
public class TestCompletion {
|
||||
|
||||
public void method(PsiElement e) {
|
||||
PsiClass c = <caret>
|
||||
}
|
||||
|
||||
}
|
||||
+47
@@ -0,0 +1,47 @@
|
||||
/*
|
||||
* Copyright 2000-2013 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @author Dmitry Batkovich <dmitry.batkovich@jetbrains.com>
|
||||
*/
|
||||
public class TestIndex {
|
||||
|
||||
void m() {
|
||||
JavaPsiFacade.getInstance().findClass();
|
||||
JavaPsiFacade.getInstance().findClass();
|
||||
JavaPsiFacade.getInstance().findClass();
|
||||
JavaPsiFacade.getInstance().findClass();
|
||||
JavaPsiFacade.getInstance().findClass();
|
||||
JavaPsiFacade.getInstance().findClass();
|
||||
}
|
||||
}
|
||||
|
||||
class JavaPsiFacade {
|
||||
static JavaPsiFacade getInstance() {
|
||||
return null;
|
||||
}
|
||||
|
||||
PsiClass findClass() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
interface PsiElement {
|
||||
PsiClass getContainingClass();
|
||||
}
|
||||
|
||||
interface PsiClass extends PsiElement {
|
||||
}
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
import java.jang.String;
|
||||
import java.lang.String;
|
||||
|
||||
interface PsiManager {
|
||||
Project getProject(String asd, String zxc);
|
||||
}
|
||||
|
||||
interface Project {}
|
||||
|
||||
public class TestCompletion {
|
||||
void m() {
|
||||
String asd = "123";
|
||||
PsiManager psiManager = null;
|
||||
Project p = psiManager.getProject(asd, zxc)
|
||||
}
|
||||
}
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
import java.jang.String;
|
||||
import java.lang.String;
|
||||
|
||||
interface PsiManager {
|
||||
Project getProject(String asd, String zxc);
|
||||
}
|
||||
|
||||
interface Project {}
|
||||
|
||||
public class TestCompletion {
|
||||
void m() {
|
||||
String asd = "123";
|
||||
Project p = <caret>
|
||||
}
|
||||
}
|
||||
+22
@@ -0,0 +1,22 @@
|
||||
import java.lang.String;
|
||||
|
||||
public class TestIndex {
|
||||
|
||||
PsiManager m;
|
||||
|
||||
void m() {
|
||||
m.getProject(null, null);
|
||||
m.getProject(null, null);
|
||||
m.getProject(null, null);
|
||||
m.getProject(null, null);
|
||||
m.getProject(null, null);
|
||||
m.getProject(null, null);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
interface PsiManager {
|
||||
Project getProject(String asd, String zxc);
|
||||
}
|
||||
|
||||
interface Project {}
|
||||
+26
@@ -0,0 +1,26 @@
|
||||
import java.jang.String;
|
||||
|
||||
class JavaPsiFacade {
|
||||
static JavaPsiFacade getInstance() {
|
||||
return null;
|
||||
}
|
||||
|
||||
PsiClass findClass() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
interface PsiElement {
|
||||
PsiClass getContainingClass();
|
||||
}
|
||||
|
||||
interface PsiClass extends PsiElement {
|
||||
}
|
||||
|
||||
public class TestCompletion {
|
||||
|
||||
public void method(PsiElement e) {
|
||||
PsiClass c = <caret>
|
||||
}
|
||||
|
||||
}
|
||||
+37
@@ -0,0 +1,37 @@
|
||||
/**
|
||||
* @author Dmitry Batkovich <dmitry.batkovich@jetbrains.com>
|
||||
*/
|
||||
public class TestIndex {
|
||||
|
||||
PsiElement e;
|
||||
|
||||
void m() {
|
||||
e.getContainingClass();
|
||||
e.getContainingClass();
|
||||
e.getContainingClass();
|
||||
e.getContainingClass();
|
||||
JavaPsiFacade.getInstance().findClass();
|
||||
JavaPsiFacade.getInstance().findClass();
|
||||
JavaPsiFacade.getInstance().findClass();
|
||||
JavaPsiFacade.getInstance().findClass();
|
||||
JavaPsiFacade.getInstance().findClass();
|
||||
JavaPsiFacade.getInstance().findClass();
|
||||
}
|
||||
}
|
||||
|
||||
class JavaPsiFacade {
|
||||
static JavaPsiFacade getInstance() {
|
||||
return null;
|
||||
}
|
||||
|
||||
PsiClass findClass() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
interface PsiElement {
|
||||
PsiClass getContainingClass();
|
||||
}
|
||||
|
||||
interface PsiClass extends PsiElement {
|
||||
}
|
||||
+20
@@ -0,0 +1,20 @@
|
||||
import java.jang.String;
|
||||
|
||||
class TestCompletuin{
|
||||
}
|
||||
|
||||
interface PsiManager {
|
||||
Project getProject();
|
||||
}
|
||||
|
||||
interface PsiElement {
|
||||
Project getProject1();
|
||||
}
|
||||
|
||||
interface Project {}
|
||||
|
||||
public class TestCompletion {
|
||||
void m(PsiElement e) {
|
||||
Project p = <caret>
|
||||
}
|
||||
}
|
||||
+35
@@ -0,0 +1,35 @@
|
||||
/**
|
||||
* @author Dmitry Batkovich <dmitry.batkovich@jetbrains.com>
|
||||
*/
|
||||
import java.lang.String;
|
||||
|
||||
public class TestIndex {
|
||||
|
||||
PsiElement e;
|
||||
|
||||
PsiManager m;
|
||||
|
||||
void m() {
|
||||
m.getProject();
|
||||
m.getProject();
|
||||
m.getProject();
|
||||
m.getProject();
|
||||
m.getProject();
|
||||
m.getProject();
|
||||
e.getProject1();
|
||||
e.getProject1();
|
||||
e.getProject1();
|
||||
e.getProject1();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
interface PsiManager {
|
||||
Project getProject();
|
||||
}
|
||||
|
||||
interface PsiElement {
|
||||
Project getProject1();
|
||||
}
|
||||
|
||||
interface Project {}
|
||||
+24
@@ -0,0 +1,24 @@
|
||||
import java.jang.String;
|
||||
|
||||
/**
|
||||
* @author Dmitry Batkovich <dmitry.batkovich@jetbrains.com>
|
||||
*/
|
||||
|
||||
class PsiElement {
|
||||
}
|
||||
|
||||
class PsiClass extends PsiElement {
|
||||
}
|
||||
|
||||
class PsiElementFactory {
|
||||
public PsiClass createClass() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public class TestCompletion {
|
||||
|
||||
public void method(PsiElementFactory f) {
|
||||
PsiElement e = <caret>
|
||||
}
|
||||
}
|
||||
+26
@@ -0,0 +1,26 @@
|
||||
/**
|
||||
* @author Dmitry Batkovich <dmitry.batkovich@jetbrains.com>
|
||||
*/
|
||||
public class TestIndex {
|
||||
|
||||
public void statMethod(PsiElementFactory f) {
|
||||
f.createClass();
|
||||
f.createClass();
|
||||
f.createClass();
|
||||
f.createClass();
|
||||
f.createClass();
|
||||
f.createClass();
|
||||
}
|
||||
}
|
||||
|
||||
class PsiElement {
|
||||
}
|
||||
|
||||
class PsiClass extends PsiElement {
|
||||
}
|
||||
|
||||
class PsiElementFactory {
|
||||
public PsiClass createClass() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
+24
@@ -0,0 +1,24 @@
|
||||
import java.jang.String;
|
||||
|
||||
/**
|
||||
* @author Dmitry Batkovich <dmitry.batkovich@jetbrains.com>
|
||||
*/
|
||||
|
||||
|
||||
class FileIndex {
|
||||
}
|
||||
|
||||
class ProjectFileIndex extends FileIndex {
|
||||
public static ProjectFileIndex getInstance(Project p) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
interface Project {}
|
||||
|
||||
public class TestCompletion {
|
||||
|
||||
public void method() {
|
||||
FileIndex fi = <caret>
|
||||
}
|
||||
}
|
||||
+28
@@ -0,0 +1,28 @@
|
||||
/**
|
||||
* @author Dmitry Batkovich <dmitry.batkovich@jetbrains.com>
|
||||
*/
|
||||
public class TestIndex {
|
||||
|
||||
public void statMethod() {
|
||||
ProjectFileIndex.getInstance(null);
|
||||
ProjectFileIndex.getInstance(null);
|
||||
ProjectFileIndex.getInstance(null);
|
||||
ProjectFileIndex.getInstance(null);
|
||||
ProjectFileIndex.getInstance(null);
|
||||
ProjectFileIndex.getInstance(null);
|
||||
ProjectFileIndex.getInstance(null);
|
||||
ProjectFileIndex.getInstance(null);
|
||||
}
|
||||
}
|
||||
|
||||
class FileIndex {
|
||||
}
|
||||
|
||||
class ProjectFileIndex extends FileIndex {
|
||||
public static ProjectFileIndex getInstance(Project p) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
interface Project {}
|
||||
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
/**
|
||||
* @author Dmitry Batkovich <dmitry.batkovich@jetbrains.com>
|
||||
*/
|
||||
|
||||
class LocalFileSystem {
|
||||
public LocalFileSystem returnSelf() {
|
||||
return this;
|
||||
}
|
||||
|
||||
public static LocalFileSystem getInstance() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public class TestCompletion {
|
||||
public void method(LocalFileSystem lfs) {
|
||||
LocalFileSystem anotherLfs = <caret>
|
||||
}
|
||||
}
|
||||
+26
@@ -0,0 +1,26 @@
|
||||
/**
|
||||
* @author Dmitry Batkovich <dmitry.batkovich@jetbrains.com>
|
||||
*/
|
||||
public class TestIndex {
|
||||
|
||||
public void statMethod(LocalFileSystemAware lfsa) {
|
||||
lfsa.returnLFS();
|
||||
lfsa.returnLFS();
|
||||
lfsa.returnLFS();
|
||||
lfsa.returnLFS();
|
||||
LocalFileSystem.getInstance();
|
||||
LocalFileSystem.getInstance();
|
||||
}
|
||||
}
|
||||
|
||||
class LocalFileSystem {
|
||||
public static LocalFileSystem getInstance() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
class LocalFileSystemAware {
|
||||
public LocalFileSystem returnLFS() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
+25
@@ -0,0 +1,25 @@
|
||||
/**
|
||||
* @author Dmitry Batkovich <dmitry.batkovich@jetbrains.com>
|
||||
*/
|
||||
|
||||
class JavaPsiFacade {
|
||||
public static PsiClass findClass(String qName) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
class PsiClass {
|
||||
|
||||
}
|
||||
|
||||
class PsiMethod {
|
||||
public PsiClass getContainingClass() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public class TestCompletion {
|
||||
public void method(PsiMethod m) {
|
||||
PsiClass someClass = <caret>
|
||||
}
|
||||
}
|
||||
+35
@@ -0,0 +1,35 @@
|
||||
/**
|
||||
* @author Dmitry Batkovich <dmitry.batkovich@jetbrains.com>
|
||||
*/
|
||||
public class TestIndex {
|
||||
|
||||
public void statMethod() {
|
||||
JavaPsiFacade.findClass("asd");
|
||||
JavaPsiFacade.findClass("asd");
|
||||
JavaPsiFacade.findClass("asd");
|
||||
}
|
||||
|
||||
public void statMethod(PsiMethod m) {
|
||||
m.getContainingClass();
|
||||
m.getContainingClass();
|
||||
m.getContainingClass();
|
||||
m.getContainingClass();
|
||||
m.getContainingClass();
|
||||
}
|
||||
}
|
||||
|
||||
class JavaPsiFacade {
|
||||
public static PsiClass findClass(String qName) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
class PsiClass {
|
||||
|
||||
}
|
||||
|
||||
class PsiMethod {
|
||||
public PsiClass getContainingClass() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
+23
@@ -0,0 +1,23 @@
|
||||
/**
|
||||
* @author Dmitry Batkovich <dmitry.batkovich@jetbrains.com>
|
||||
*/
|
||||
|
||||
|
||||
class Project {
|
||||
}
|
||||
|
||||
interface PsiElement {
|
||||
Project getProject();
|
||||
}
|
||||
|
||||
class PsiMethod implements PsiElement {
|
||||
public Project getProject() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public class TestCompletion {
|
||||
public void method(PsiMethod m) {
|
||||
Project project = <caret>
|
||||
}
|
||||
}
|
||||
+30
@@ -0,0 +1,30 @@
|
||||
/**
|
||||
* @author Dmitry Batkovich <dmitry.batkovich@jetbrains.com>
|
||||
*/
|
||||
public class TestIndex {
|
||||
|
||||
public void statMethod(PsiElement a, PsiElement b) {
|
||||
a.getProject();
|
||||
a.getProject();
|
||||
a.getProject();
|
||||
a.getProject();
|
||||
b.getProject();
|
||||
b.getProject();
|
||||
b.getProject();
|
||||
b.getProject();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
class Project {
|
||||
}
|
||||
|
||||
interface PsiElement {
|
||||
Project getProject();
|
||||
}
|
||||
|
||||
class PsiMethod implements PsiElement {
|
||||
public Project getProject() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
+31
@@ -0,0 +1,31 @@
|
||||
/**
|
||||
* @author Dmitry Batkovich <dmitry.batkovich@jetbrains.com>
|
||||
*/
|
||||
|
||||
class Project {
|
||||
}
|
||||
|
||||
interface PsiElement {
|
||||
Project getProject();
|
||||
}
|
||||
|
||||
class PsiClass implements PsiElement {
|
||||
public Project getProject() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
class PsiMethod implements PsiElement {
|
||||
public Project getProject() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public class TestCompletion {
|
||||
PsiClass c = new PsiClass();
|
||||
|
||||
public void method(PsiMethod m) {
|
||||
Project p = <caret>
|
||||
}
|
||||
}
|
||||
+36
@@ -0,0 +1,36 @@
|
||||
/**
|
||||
* @author Dmitry Batkovich <dmitry.batkovich@jetbrains.com>
|
||||
*/
|
||||
public class TestIndex {
|
||||
|
||||
public void statMethod(PsiClass c, PsiMethod m) {
|
||||
c.getProject();
|
||||
c.getProject();
|
||||
c.getProject();
|
||||
c.getProject();
|
||||
m.getProject();
|
||||
m.getProject();
|
||||
m.getProject();
|
||||
m.getProject();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
class Project {
|
||||
}
|
||||
|
||||
interface PsiElement {
|
||||
Project getProject();
|
||||
}
|
||||
|
||||
class PsiClass implements PsiElement {
|
||||
public Project getProject() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
class PsiMethod implements PsiElement {
|
||||
public Project getProject() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
+30
@@ -0,0 +1,30 @@
|
||||
package com.intellij.codeInsight.completion;
|
||||
|
||||
import com.intellij.openapi.util.io.FileUtil;
|
||||
import com.intellij.psi.PsiType;
|
||||
import com.intellij.testFramework.fixtures.JavaCodeInsightFixtureTestCase;
|
||||
import com.sun.tools.javac.Main;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* @author Dmitry Batkovich
|
||||
*/
|
||||
public abstract class AbstractCompilerAwareTest extends JavaCodeInsightFixtureTestCase {
|
||||
protected final File compileData(final String testCaseName, final String fileToCompile) {
|
||||
final File compilerOutput = getCompilerOutputPath(testCaseName);
|
||||
assertEquals(Main.compile(
|
||||
new String[]{"-g:vars", "-d", compilerOutput.getAbsolutePath(), String.format("%s/%s/%s", getTestDataPath(), testCaseName, fileToCompile)}), 0);
|
||||
return compilerOutput;
|
||||
}
|
||||
|
||||
private static File getCompilerOutputPath(final String testCaseName) {
|
||||
try {
|
||||
return FileUtil.createTempDirectory(testCaseName, "_compiled");
|
||||
}
|
||||
catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
+231
@@ -0,0 +1,231 @@
|
||||
package com.intellij.codeInsight.completion;
|
||||
|
||||
import com.intellij.JavaTestUtil;
|
||||
import com.intellij.codeInsight.completion.methodChains.completion.MethodsChainsCompletionContributor;
|
||||
import com.intellij.codeInsight.completion.methodChains.completion.lookup.ChainCompletionMethodCallLookupElement;
|
||||
import com.intellij.codeInsight.completion.methodChains.completion.lookup.WeightableChainLookupElement;
|
||||
import com.intellij.codeInsight.completion.methodChains.search.ChainRelevance;
|
||||
import com.intellij.codeInsight.lookup.LookupElement;
|
||||
import com.intellij.compilerOutputIndex.api.fs.FileVisitorService;
|
||||
import com.intellij.compilerOutputIndex.api.indexer.CompilerOutputIndexer;
|
||||
import com.intellij.ide.util.PropertiesComponent;
|
||||
import com.intellij.mock.MockProgressIndicator;
|
||||
import com.intellij.util.SmartList;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author Dmitry Batkovich
|
||||
*/
|
||||
public class MethodChainsCompletionTest extends AbstractCompilerAwareTest {
|
||||
private final static String TEST_INDEX_FILE_NAME = "TestIndex.java";
|
||||
private final static String TEST_COMPLETION_FILE_NAME = "TestCompletion.java";
|
||||
|
||||
private final static String BEFORE_COMPLETION_FILE = "BeforeCompletion.java";
|
||||
private final static String AFTER_COMPLETION_FILE = "AfterCompletion.java";
|
||||
|
||||
@Override
|
||||
protected void setUp() throws Exception {
|
||||
super.setUp();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void tearDown() throws Exception {
|
||||
super.tearDown();
|
||||
}
|
||||
|
||||
protected String getTestDataPath() {
|
||||
return JavaTestUtil.getJavaTestDataPath() + "/codeInsight/completion/methodChains/";
|
||||
}
|
||||
|
||||
public void testOneRelevantMethod() {
|
||||
assertAdvisorLookupElementEquals("e.getProject", 0, 8, 1, 0, assertOneElement(doCompletion()));
|
||||
}
|
||||
|
||||
public void testCyclingMethodsNotShowed() {
|
||||
assertEmpty(doCompletion());
|
||||
}
|
||||
|
||||
public void testStaticMethod() {
|
||||
final List<WeightableChainLookupElement> elements = doCompletion();
|
||||
assertAdvisorLookupElementEquals("getInstance", 0, 2, 1, 0, assertOneElement(elements));
|
||||
}
|
||||
|
||||
public void testStaticMethodAndMethod() {
|
||||
final List<WeightableChainLookupElement> elements = doCompletion();
|
||||
assertEquals(elements.size(), 2);
|
||||
assertAdvisorLookupElementEquals("findClass", 0, 3, 1, 1, elements.get(1));
|
||||
assertAdvisorLookupElementEquals("m.getContainingClass", 0, 5, 1, 0, elements.get(0));
|
||||
}
|
||||
|
||||
public void testOneChainContainsOther() {
|
||||
assertAdvisorLookupElementEquals("p.getBaseDir", 0, 8, 1, 0, assertOneElement(doCompletion()));
|
||||
}
|
||||
|
||||
public void testTwoVariablesWithOneTypeOrSuperType() {
|
||||
assertAdvisorLookupElementEquals("c.getProject", 0, 4, 1, 0, assertOneElement(doCompletion()));
|
||||
}
|
||||
|
||||
public void testSuperClassMethodsCallings() {
|
||||
assertAdvisorLookupElementEquals("m.getProject", 0, 8, 1, 0, assertOneElement(doCompletion()));
|
||||
}
|
||||
|
||||
public void testMethodReturnsSubclassOfTargetClassNotShowed2() {
|
||||
assertEmpty(doCompletion());
|
||||
}
|
||||
|
||||
public void testResultsForSuperClassesNotShowed() {
|
||||
assertEmpty(doCompletion());
|
||||
}
|
||||
|
||||
public void testInnerClasses() {
|
||||
assertAdvisorLookupElementEquals("j.getEntry", 0, 8, 1, 0, assertOneElement(doCompletion()));
|
||||
}
|
||||
|
||||
public void testMethodsWithSameName() {
|
||||
assertAdvisorLookupElementEquals("f.createType", 1, 8, 1, 0, assertOneElement(doCompletion()));
|
||||
}
|
||||
|
||||
public void testBigrams2() {
|
||||
final List<WeightableChainLookupElement> collection = doCompletion();
|
||||
assertAdvisorLookupElementEquals("e.getContainingFile().getVirtualFile", 0, 8, 1, 0, assertOneElement(collection));
|
||||
}
|
||||
|
||||
public void testBigrams3() {
|
||||
final List<WeightableChainLookupElement> collection = doCompletion();
|
||||
assertAdvisorLookupElementEquals("getInstance().findFile().findElementAt", 2, 8, 3, 0, assertOneElement(collection));
|
||||
}
|
||||
|
||||
public void _testReduceChain4() {
|
||||
final List<WeightableChainLookupElement> collection = doCompletion();
|
||||
assertAdvisorLookupElementEquals("b.getC", 0, 33, 1, 0, assertOneElement(collection));
|
||||
}
|
||||
|
||||
public void testGetterInContext() {
|
||||
assertAdvisorLookupElementEquals("getMyElement().getProject", 0, 8, 1, 0, assertOneElement(doCompletion()));
|
||||
}
|
||||
|
||||
public void testMethodParameterCompletion() {
|
||||
assertOneElement(doCompletion());
|
||||
}
|
||||
|
||||
public void testNoWayToObtainVariableExplicitly() {
|
||||
assertOneElement(doCompletion());
|
||||
}
|
||||
|
||||
public void testCyclingInstancesObtaining() {
|
||||
assertEmpty(doCompletion());
|
||||
}
|
||||
|
||||
public void testCyclingInstancesObtaining2() {
|
||||
assertOneElement(doCompletion());
|
||||
}
|
||||
|
||||
public void testResultRelevance() {
|
||||
final List<WeightableChainLookupElement> advisorWeightableChainLookupElements = doCompletion();
|
||||
assertEquals("e.getContainingClass", advisorWeightableChainLookupElements.get(0).getLookupString());
|
||||
assertEquals("getInstance().findClass", advisorWeightableChainLookupElements.get(1).getLookupString());
|
||||
}
|
||||
|
||||
public void testResultRelevance3() {
|
||||
final List<WeightableChainLookupElement> advisorWeightableChainLookupElements = doCompletion();
|
||||
assertSize(2, advisorWeightableChainLookupElements);
|
||||
assertEquals("e.getProject1", advisorWeightableChainLookupElements.get(0).getLookupString());
|
||||
assertEquals("psiManager.getProject", advisorWeightableChainLookupElements.get(1).getLookupString());
|
||||
}
|
||||
|
||||
public void testRenderingVariableInContextAndNotInContext() {
|
||||
doTestRendering();
|
||||
}
|
||||
|
||||
public void testRenderingStaticMethods() {
|
||||
doTestRendering();
|
||||
}
|
||||
|
||||
public void testRenderingIntroduceVariable() {
|
||||
doTestRendering();
|
||||
}
|
||||
|
||||
public void assertAdvisorLookupElementEquals(final String lookupText,
|
||||
final int unreachableParametersCount,
|
||||
final int lastMethodWeight,
|
||||
final int chainSize,
|
||||
final int notMatchedStringVars,
|
||||
final WeightableChainLookupElement actualLookupElement) {
|
||||
assertLookupElementStringEquals(actualLookupElement, lookupText);
|
||||
assertChainRelevanceEquals(actualLookupElement.getChainRelevance(), lastMethodWeight, chainSize, notMatchedStringVars,
|
||||
unreachableParametersCount);
|
||||
}
|
||||
|
||||
private static void assertLookupElementStringEquals(final LookupElement lookupElement, final String lookupText) {
|
||||
assertEquals(lookupText, lookupElement.getLookupString());
|
||||
}
|
||||
|
||||
private static void assertChainRelevanceEquals(final ChainRelevance chainRelevance,
|
||||
final int lastMethodWeight,
|
||||
final int chainSize,
|
||||
final int notMatchedStringVars,
|
||||
final int unreachableParametersCount) {
|
||||
assertEquals(notMatchedStringVars, chainRelevance.getNotMatchedStringVars());
|
||||
assertEquals(chainSize, chainRelevance.getChainSize());
|
||||
assertEquals(unreachableParametersCount, chainRelevance.getUnreachableParametersCount());
|
||||
assertEquals(lastMethodWeight, chainRelevance.getLastMethodOccurrences());
|
||||
}
|
||||
|
||||
private void doTestRendering() {
|
||||
PropertiesComponent.getInstance(getProject()).setValue(ChainCompletionMethodCallLookupElement.PROP_METHODS_CHAIN_COMPLETION_AUTO_COMPLETION, String.valueOf(true));
|
||||
indexCompiledData(compileData(getName(), TEST_INDEX_FILE_NAME));
|
||||
myFixture.configureByFiles(getBeforeCompletionFilePath());
|
||||
myFixture.complete(CompletionType.BASIC, MethodsChainsCompletionContributor.INVOCATIONS_THRESHOLD);
|
||||
PropertiesComponent.getInstance(getProject()).setValue(ChainCompletionMethodCallLookupElement.PROP_METHODS_CHAIN_COMPLETION_AUTO_COMPLETION, String.valueOf(false));
|
||||
myFixture.checkResultByFile(getAfterCompletionFilePath());
|
||||
}
|
||||
|
||||
private List<WeightableChainLookupElement> doCompletion() {
|
||||
try {
|
||||
indexCompiledData(compileData(getName(), TEST_INDEX_FILE_NAME));
|
||||
|
||||
final LookupElement[] allLookupElements = runCompletion();
|
||||
final List<WeightableChainLookupElement> targetLookupElements = new SmartList<WeightableChainLookupElement>();
|
||||
for (final LookupElement lookupElement : allLookupElements) {
|
||||
if (lookupElement instanceof WeightableChainLookupElement) {
|
||||
targetLookupElements.add((WeightableChainLookupElement)lookupElement);
|
||||
}
|
||||
}
|
||||
|
||||
return targetLookupElements;
|
||||
}
|
||||
finally {
|
||||
final CompilerOutputIndexer indexer = CompilerOutputIndexer.getInstance(getProject());
|
||||
indexer.projectClosed();
|
||||
indexer.removeIndexes();
|
||||
}
|
||||
}
|
||||
|
||||
private LookupElement[] runCompletion() {
|
||||
myFixture.configureByFiles(getTestCompletionFilePath());
|
||||
final LookupElement[] lookupElements = myFixture.complete(CompletionType.BASIC, MethodsChainsCompletionContributor.INVOCATIONS_THRESHOLD);
|
||||
return lookupElements == null ? LookupElement.EMPTY_ARRAY : lookupElements;
|
||||
}
|
||||
|
||||
private void indexCompiledData(final File compilerOutput) {
|
||||
final FileVisitorService.DirectoryClassFiles visitorService = new FileVisitorService.DirectoryClassFiles(compilerOutput);
|
||||
final CompilerOutputIndexer indexer = CompilerOutputIndexer.getInstance(getProject());
|
||||
indexer.projectOpened();
|
||||
indexer.clear();
|
||||
indexer.reindex(visitorService, new MockProgressIndicator());
|
||||
}
|
||||
|
||||
private String getTestCompletionFilePath() {
|
||||
return getTestDataPath() + getName() + "/" + TEST_COMPLETION_FILE_NAME;
|
||||
}
|
||||
|
||||
private String getBeforeCompletionFilePath() {
|
||||
return getName() + "/" + BEFORE_COMPLETION_FILE;
|
||||
}
|
||||
|
||||
private String getAfterCompletionFilePath() {
|
||||
return getName() + "/" + AFTER_COMPLETION_FILE;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user