3
3
import com .intellij .openapi .command .WriteCommandAction ;
4
4
import com .intellij .psi .PsiFile ;
5
5
import com .intellij .psi .codeStyle .CodeStyleManager ;
6
+ import com .intellij .psi .codeStyle .CodeStyleSettings ;
6
7
import com .intellij .psi .codeStyle .CodeStyleSettingsManager ;
7
8
import com .intellij .psi .codeStyle .CommonCodeStyleSettings ;
9
+ import com .neueda .jetbrains .plugin .graphdb .jetbrains .formatter .CypherCodeStyleSettings ;
8
10
import com .neueda .jetbrains .plugin .graphdb .language .cypher .CypherLanguage ;
9
11
import com .neueda .jetbrains .plugin .graphdb .test .integration .neo4j .util .base .BaseIntegrationTest ;
10
12
13
15
public class CypherFormattingTest extends BaseIntegrationTest {
14
16
15
17
public void testFormatter () {
16
- PsiFile file = myFixture .addFileToProject ("test.cypher" , "match (a:Person)-[]-(b) return a,b;" );
18
+ PsiFile file = myFixture .addFileToProject ("test.cypher" ,
19
+ "match (a:Person{name:'Dmitry'})-[]-(b) where b.title='Neueda' return a,b;" );
17
20
myFixture .configureFromExistingVirtualFile (file .getVirtualFile ());
18
21
19
- CommonCodeStyleSettings settings = CodeStyleSettingsManager .getSettings (getProject ())
20
- .getCommonSettings (CypherLanguage .INSTANCE );
21
- settings .SPACE_AFTER_COLON = true ;
22
- settings .SPACE_WITHIN_BRACKETS = true ;
23
- settings .SPACE_AFTER_COMMA = true ;
22
+ CodeStyleSettings settings = CodeStyleSettingsManager .getSettings (getProject ());
23
+ CommonCodeStyleSettings commonSettings = settings .getCommonSettings (CypherLanguage .INSTANCE );
24
+ CypherCodeStyleSettings customSettings = settings .getCustomSettings (CypherCodeStyleSettings .class );
25
+
26
+ customSettings .SPACE_AFTER_COLON = true ;
27
+ commonSettings .SPACE_WITHIN_BRACKETS = true ;
28
+ commonSettings .SPACE_AFTER_COMMA = true ;
24
29
25
30
new WriteCommandAction .Simple (getProject ()) {
26
31
@ Override
@@ -31,6 +36,8 @@ protected void run() throws Throwable {
31
36
}
32
37
}.execute ();
33
38
34
- myFixture .checkResult ("match ( a: Person )-[]-( b ) return a, b;" );
39
+ myFixture .checkResult ("match ( a: Person {name: 'Dmitry'} )-[]-( b )\n " +
40
+ "where b.title = 'Neueda'\n " +
41
+ "return a, b;" );
35
42
}
36
43
}
0 commit comments