[groovy] fix spockTableWithComments (IDEA-137145)

This commit is contained in:
Pap Lőrinc
2015-09-01 21:40:13 +03:00
committed by Max Medvedev
7 changed files with 54 additions and 67 deletions
@@ -18,6 +18,7 @@ package com.intellij.testFramework.fixtures;
import com.intellij.psi.PsiClass;
import com.intellij.psi.PsiPackage;
import com.intellij.psi.impl.JavaPsiFacadeEx;
import org.intellij.lang.annotations.Language;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
@@ -27,7 +28,7 @@ import org.jetbrains.annotations.NotNull;
public interface JavaCodeInsightTestFixture extends CodeInsightTestFixture {
JavaPsiFacadeEx getJavaFacade();
PsiClass addClass(@NotNull @NonNls final String classText);
PsiClass addClass(@NotNull @NonNls @Language("JAVA") final String classText);
@NotNull
PsiClass findClass(@NotNull @NonNls String name);
@@ -438,8 +438,7 @@ public class GroovyBlockGenerator {
private boolean shouldSkip(boolean classLevel, PsiElement psi) {
if (psi instanceof PsiComment) {
PsiElement prev = psi.getPrevSibling();
if (prev != null && prev.getNode().getElementType() != GroovyTokenTypes.mNLS || classLevel && !fieldGroupEnded(psi)) {
if ((psi.getPrevSibling() != null) || (classLevel && !fieldGroupEnded(psi))) {
return true;
}
}
@@ -115,9 +115,8 @@ public class FormatterTest extends GroovyFormatterTestCase {
public void testAnnotationOnSeparateLine() throws Throwable { doTest(); }
public void testAlignMultipleVariables() throws Throwable { doTest(); }
//public void testSpockTable() throws Throwable {myFixture.addClass('package spock.lang; public class Specification{}'); doTest(); }
//public void testSpockTableComments() throws Throwable {myFixture.addClass('package spock.lang; public class Specification{}'); doTest(); }
//public void testSpockTableWithStringComment() throws Throwable {myFixture.addClass('package spock.lang; public class Specification{}'); doTest(); }
//public void testSpockTableWithStringComment() throws Throwable { doTest() }
public void testSpockTableWithComments() throws Throwable { doTest() }
public void testElseIfs() throws Throwable {
groovySettings.SPECIAL_ELSE_IF_TREATMENT = false;
@@ -223,7 +222,7 @@ public class FormatterTest extends GroovyFormatterTestCase {
doTest();
}
public void testGeese1() {doGeeseTest();}
public void testGeese2() {doGeeseTest();}
public void testGeese3() {doGeeseTest();}
@@ -1,31 +0,0 @@
class HelloSpock extends spock.lang.Specification {
def "length of Spock's and his friends' names"() {
expect:
name.size() == length
where:
name | length | foo
"Spock" | 5
"Kirk" | 4 | xxx | yyy
"Scotty" | 6 |dddddddddd | fff
//aaa
a | b | c
}
}
-----
class HelloSpock extends spock.lang.Specification {
def "length of Spock's and his friends' names"() {
expect:
name.size() == length
where:
name | length | foo
"Spock" | 5
"Kirk" | 4 | xxx | yyy
"Scotty" | 6 | dddddddddd | fff
//aaa
a | b | c
}
}
@@ -1,23 +0,0 @@
class HelloSpock extends spock.lang.Specification {
def "length of Spock's and his friends' names"() {
expect:
name.size() == length
where:
name | length
"Kirk" | 4 // a great guy
"Scotty" | 6
}
}
-----
class HelloSpock extends spock.lang.Specification {
def "length of Spock's and his friends' names"() {
expect:
name.size() == length
where:
name | length
"Kirk" | 4 // a great guy
"Scotty" | 6
}
}
@@ -0,0 +1,43 @@
class HelloSpock extends spock.lang.Specification {
def 'different length tables with comments are aligned properly'() {
expect:
ordinal.size() > 0
where:
ordinal | value1 | value2 || value3
'first' | 111111111 | 1 || 1
'second' | 2 | 2 || 2 // comment after lines
'third' | 3 | 3 || 3
'fourth' | 4 | 4 || 4444444444
// comment between lines
'fifth' | 5 | 555555555 || 5
/* block comment and empty line between lines */
'sixth' | 6 | 6 || 6
unalignedVariableAfterTable=value1+value2
}
}
-----
class HelloSpock extends spock.lang.Specification {
def 'different length tables with comments are aligned properly'() {
expect:
ordinal.size() > 0
where:
ordinal | value1 | value2 || value3
'first' | 111111111 | 1 || 1
'second' | 2 | 2 || 2 // comment after lines
'third' | 3 | 3 || 3
'fourth' | 4 | 4 || 4444444444
// comment between lines
'fifth' | 5 | 555555555 || 5
/* block comment and empty line between lines */
'sixth' | 6 | 6 || 6
unalignedVariableAfterTable = value1 + value2
}
}
@@ -13,12 +13,11 @@ class HelloSpock extends spock.lang.Specification {
class HelloSpock extends spock.lang.Specification {
def "length of Spock's and his friends' names"() {
expect:
name.size() == length
name.size() == length
where:
"something"
name || length
"Kirk" || 4
"Scotty" || 6
where: "something"
name || length
"Kirk" || 4
"Scotty" || 6
}
}