IDEA-83061 Formatteroption for spaces within list literal and spaces within map literal

This commit is contained in:
Maxim.Medvedev
2012-03-27 17:58:25 +04:00
parent 7e16ccb578
commit 036e48efca
4 changed files with 17 additions and 7 deletions
@@ -43,6 +43,7 @@ import org.jetbrains.plugins.groovy.lang.parser.GroovyElementTypes;
import org.jetbrains.plugins.groovy.lang.psi.GrQualifiedReference;
import org.jetbrains.plugins.groovy.lang.psi.GroovyFile;
import org.jetbrains.plugins.groovy.lang.psi.GroovyFileBase;
import org.jetbrains.plugins.groovy.lang.psi.api.auxiliary.GrListOrMap;
import org.jetbrains.plugins.groovy.lang.psi.api.auxiliary.GrThrowsClause;
import org.jetbrains.plugins.groovy.lang.psi.api.statements.GrLabeledStatement;
import org.jetbrains.plugins.groovy.lang.psi.api.statements.GrStatement;
@@ -312,9 +313,10 @@ public class GroovyBlockGenerator implements GroovyElementTypes {
}
return blockPsi instanceof GrParameterList && mySettings.ALIGN_MULTILINE_PARAMETERS ||
blockPsi instanceof GrExtendsClause && mySettings.ALIGN_MULTILINE_EXTENDS_LIST ||
blockPsi instanceof GrThrowsClause && mySettings.ALIGN_MULTILINE_THROWS_LIST ||
blockPsi instanceof GrConditionalExpression && mySettings.ALIGN_MULTILINE_TERNARY_OPERATION;
blockPsi instanceof GrExtendsClause && mySettings.ALIGN_MULTILINE_EXTENDS_LIST ||
blockPsi instanceof GrThrowsClause && mySettings.ALIGN_MULTILINE_THROWS_LIST ||
blockPsi instanceof GrConditionalExpression && mySettings.ALIGN_MULTILINE_TERNARY_OPERATION ||
blockPsi instanceof GrListOrMap && myGroovySettings.ALIGN_MULTILINE_LIST_OR_MAP;
}
private static boolean isListLikeClause(PsiElement blockPsi) {
@@ -323,7 +325,8 @@ public class GroovyBlockGenerator implements GroovyElementTypes {
blockPsi instanceof GrAssignmentExpression ||
blockPsi instanceof GrConditionalExpression ||
blockPsi instanceof GrExtendsClause ||
blockPsi instanceof GrThrowsClause;
blockPsi instanceof GrThrowsClause ||
blockPsi instanceof GrListOrMap;
}
private static boolean isKeyword(ASTNode node) {
@@ -42,6 +42,7 @@ public class GroovyCodeStyleSettings extends CustomCodeStyleSettings {
public boolean USE_FLYING_GEESE_BRACES = false;
public boolean SPACE_IN_NAMED_ARGUMENT = true;
public boolean ALIGN_MULTILINE_LIST_OR_MAP = false;
public GroovyCodeStyleSettings(CodeStyleSettings container) {
super("GroovyCodeStyleSettings", container);
@@ -44,6 +44,7 @@ public class GroovyLanguageCodeStyleSettingsProvider extends LanguageCodeStyleSe
if (settingsType == SettingsType.WRAPPING_AND_BRACES_SETTINGS) {
consumer.showAllStandardOptions();
consumer.showCustomOption(GroovyCodeStyleSettings.class, "USE_FLYING_GEESE_BRACES", "Use flying geese braces", CodeStyleSettingsCustomizable.WRAPPING_BRACES);
consumer.showCustomOption(GroovyCodeStyleSettings.class, "ALIGN_MULTILINE_LIST_OR_MAP", "Align when multiple", "List and map literals");
return;
}
if (settingsType == SettingsType.SPACING_SETTINGS) {
@@ -133,9 +133,14 @@ public abstract class GroovyIndentProcessor implements GroovyElementTypes {
// For arguments
if (psiParent instanceof GrArgumentList) {
if (child.getElementType() != mLPAREN &&
child.getElementType() != mRPAREN) {
return Indent.getContinuationIndent();
if (child.getElementType() != mLPAREN && child.getElementType() != mRPAREN /*&& child.getElementType() != mCOMMA*/) {
return Indent.getContinuationWithoutFirstIndent();
}
}
if (psiParent instanceof GrListOrMap) {
if (child.getElementType() != mLBRACK && child.getElementType() != mRBRACK /*&& child.getElementType() != mCOMMA*/) {
return Indent.getContinuationWithoutFirstIndent();
}
}