WEB-5568 Expand CoffeeScript Formatter Options to Match Other Languages

Respect 'relative to parent' indent flag during child code style attributes processing
This commit is contained in:
Denis.Zhdanov
2013-01-23 11:41:41 +04:00
parent ad7cf6afd0
commit 94b4fad389
2 changed files with 13 additions and 0 deletions
@@ -341,6 +341,10 @@ public abstract class AbstractBlockWrapper {
if (childIndent == null) childIndent = (IndentImpl)Indent.getContinuationWithoutFirstIndent(indentOption.USE_RELATIVE_INDENTS);
IndentData indent = getIndent(indentOption, index, childIndent);
if (childIndent.isRelativeToDirectParent() && myParent != null) {
return new IndentData(indent.getIndentSpaces() + CoreFormatterUtil.getOffsetBefore(CoreFormatterUtil.getFirstLeaf(myParent)),
indent.getSpaces());
}
if (myParent == null || (myFlags & CAN_USE_FIRST_CHILD_INDENT_AS_BLOCK_INDENT) != 0 && getWhiteSpace().containsLineFeeds()) {
return indent.add(getWhiteSpace());
}
@@ -250,6 +250,15 @@ public class CoreFormatterUtil {
if (indent.getType() == Indent.Type.NONE) return new IndentData(0);
if (indent.getType() == Indent.Type.SPACES) return new IndentData(0, indent.getSpaces());
return new IndentData(options.INDENT_SIZE);
}
@NotNull
public static LeafBlockWrapper getFirstLeaf(@NotNull AbstractBlockWrapper block) {
if (block instanceof LeafBlockWrapper) {
return (LeafBlockWrapper)block;
}
else {
return getFirstLeaf(((CompositeBlockWrapper)block).getChildren().get(0));
}
}
}