Commit 5fe52cc4 authored by Roman.Ivanov's avatar Roman.Ivanov
Browse files

Java formatter: skip also spaces before enum for dependant spacing: IDEA-203464, IDEA-204458

parent ba93dfae
Showing with 74 additions and 1 deletion
+74 -1
...@@ -277,7 +277,7 @@ public class JavaSpacePropertyProcessor extends JavaElementVisitor { ...@@ -277,7 +277,7 @@ public class JavaSpacePropertyProcessor extends JavaElementVisitor {
private void createSpacingForEnumBraces() { private void createSpacingForEnumBraces() {
// Ignore comments in front of enum for dependent spacing // Ignore comments in front of enum for dependent spacing
PsiElement first = myParent.getFirstChild(); PsiElement first = myParent.getFirstChild();
while (first instanceof PsiDocComment) { while (first instanceof PsiDocComment || first instanceof PsiWhiteSpace) {
first = first.getNextSibling(); first = first.getNextSibling();
} }
int spaces = myJavaSettings.SPACE_INSIDE_ONE_LINE_ENUM_BRACES ? 1 : 0; int spaces = myJavaSettings.SPACE_INSIDE_ONE_LINE_ENUM_BRACES ? 1 : 0;
......
...@@ -13,6 +13,7 @@ import com.intellij.psi.JavaCodeFragmentFactory ...@@ -13,6 +13,7 @@ import com.intellij.psi.JavaCodeFragmentFactory
import com.intellij.psi.PsiElement import com.intellij.psi.PsiElement
import com.intellij.psi.codeStyle.CodeStyleManager import com.intellij.psi.codeStyle.CodeStyleManager
import com.intellij.psi.codeStyle.CommonCodeStyleSettings import com.intellij.psi.codeStyle.CommonCodeStyleSettings
import com.intellij.psi.codeStyle.CommonCodeStyleSettings.WRAP_ALWAYS
import com.intellij.testFramework.LightIdeaTestCase import com.intellij.testFramework.LightIdeaTestCase
import com.intellij.testFramework.LightPlatformTestCase import com.intellij.testFramework.LightPlatformTestCase
import com.intellij.util.IncorrectOperationException import com.intellij.util.IncorrectOperationException
...@@ -3684,4 +3685,76 @@ public class Test { ...@@ -3684,4 +3685,76 @@ public class Test {
) )
} }
fun testIdeaIDEA203464() {
getSettings().apply{
ENUM_CONSTANTS_WRAP = WRAP_ALWAYS
KEEP_LINE_BREAKS = false
}
doTextTest(
"""
/**
* javadoc
*/
public enum EnumApplyChannel {
C;
public String method() {
return null;
}
}""".trimIndent(),
"""
/**
* javadoc
*/
public enum EnumApplyChannel {
C;
public String method() {
return null;
}
}""".trimIndent()
)
}
fun testIdeaIDEA198408() {
getSettings().apply{
ENUM_CONSTANTS_WRAP = WRAP_ALWAYS
}
doTextTest(
"""
/** JavaDoc */
public enum LevelCode {HIGH(3),
MEDIUM(2),
LOW(1);
private final int levelCode;
LevelCode(int levelCode) {
this.levelCode = levelCode;
}
}""".trimIndent(),
"""
/**
* JavaDoc
*/
public enum LevelCode {
HIGH(3),
MEDIUM(2),
LOW(1);
private final int levelCode;
LevelCode(int levelCode) {
this.levelCode = levelCode;
}
}""".trimIndent()
)
}
} }
\ No newline at end of file
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment