1
1
package fr .adrienbrault .idea .symfony2plugin .tests ;
2
2
3
3
import com .intellij .openapi .application .ApplicationManager ;
4
- import com .intellij .openapi .project . Project ;
4
+ import com .intellij .openapi .util . Computable ;
5
5
import com .intellij .openapi .vfs .VfsUtil ;
6
6
import com .intellij .openapi .vfs .VirtualFile ;
7
- import com .intellij .testFramework .UsefulTestCase ;
8
7
import com .intellij .testFramework .fixtures .IdeaProjectTestFixture ;
9
8
import com .intellij .testFramework .fixtures .IdeaTestFixtureFactory ;
9
+ import com .intellij .testFramework .fixtures .JavaTestFixtureFactory ;
10
+ import com .intellij .testFramework .fixtures .impl .LightTempDirTestFixtureImpl ;
10
11
import fr .adrienbrault .idea .symfony2plugin .Settings ;
11
12
import org .apache .commons .lang .RandomStringUtils ;
12
13
import org .apache .commons .lang .StringUtils ;
21
22
/**
22
23
* @author Daniel Espendiller <[email protected] >
23
24
*/
24
- abstract public class SymfonyTempCodeInsightFixtureTestCase extends UsefulTestCase {
25
- private Project project ;
26
-
27
- private IdeaProjectTestFixture myFixture ;
28
-
25
+ abstract public class SymfonyTempCodeInsightFixtureTestCase extends SymfonyLightCodeInsightFixtureTestCase {
29
26
@ Override
30
27
public void setUp () throws Exception {
31
28
super .setUp ();
32
29
33
- myFixture = IdeaTestFixtureFactory .getFixtureFactory ()
30
+ // clear super fixtures instances
31
+ this .myFixture .tearDown ();
32
+
33
+ // heavy project
34
+ // @TODO: still no index process
35
+ IdeaProjectTestFixture fixtures = IdeaTestFixtureFactory .getFixtureFactory ()
34
36
.createFixtureBuilder (RandomStringUtils .randomAlphanumeric (20 ))
35
37
.getFixture ();
36
38
37
- myFixture .setUp ();
38
-
39
- project = myFixture .getProject ();
40
- Settings .getInstance (project ).pluginEnabled = true ;
41
- }
42
-
43
- protected void tearDown () throws Exception {
44
- this .project = null ;
39
+ this .myFixture = JavaTestFixtureFactory .getFixtureFactory ()
40
+ .createCodeInsightFixture (fixtures , new LightTempDirTestFixtureImpl (true ));
45
41
46
- try {
47
- this .myFixture .tearDown ();
48
- } finally {
49
- this .myFixture = null ;
50
- super .tearDown ();
51
- }
52
- }
42
+ this .myFixture .setUp ();
43
+ this .myModule = this .myFixture .getModule ();
53
44
54
- @ NotNull
55
- protected Project getProject () {
56
- return project ;
45
+ Settings .getInstance (getProject ()).pluginEnabled = true ;
57
46
}
58
47
59
48
@ NotNull
@@ -73,31 +62,30 @@ protected VirtualFile[] createFiles(@NotNull String... files) {
73
62
}
74
63
75
64
protected VirtualFile createFile (@ NotNull String file , @ Nullable String content ) {
76
- final VirtualFile [] childData = new VirtualFile [1 ];
77
-
78
- ApplicationManager .getApplication ().runWriteAction (new Runnable () {
65
+ return ApplicationManager .getApplication ().runWriteAction (new Computable <VirtualFile >() {
79
66
@ Override
80
- public void run () {
67
+ public VirtualFile compute () {
68
+ VirtualFile virtualFile = null ;
81
69
try {
82
70
String [] paths = file .split ("/" );
83
71
84
- if (paths .length == 0 ) {
85
- childData [ 0 ] = getProject ().getBaseDir ().createChildData (this , file );
72
+ if (paths .length == 0 ) {
73
+ virtualFile = getProject ().getBaseDir ().createChildData (this , file );
86
74
} else {
87
- childData [ 0 ] = VfsUtil .createDirectoryIfMissing (
75
+ virtualFile = VfsUtil .createDirectoryIfMissing (
88
76
getProject ().getBaseDir (),
89
77
StringUtils .join (Arrays .copyOf (paths , paths .length - 1 ), "/" )
90
78
).createChildData (this , paths [paths .length - 1 ]);
91
79
}
92
80
93
- if (content != null ) {
94
- childData [ 0 ] .setBinaryContent (content .getBytes ());
81
+ if (content != null ) {
82
+ virtualFile .setBinaryContent (content .getBytes ());
95
83
}
96
84
} catch (IOException ignored ) {
97
85
}
86
+
87
+ return virtualFile ;
98
88
}
99
89
});
100
-
101
- return childData [0 ];
102
90
}
103
91
}
0 commit comments