From c6f6dfaf15e756d82f4ee8786fc35a62337d8d2c Mon Sep 17 00:00:00 2001 From: Yaroslav Lepenkin Date: Wed, 17 Jun 2015 14:04:22 +0300 Subject: [PATCH] added abstract getType method to Indent class --- platform/lang-api/src/com/intellij/formatting/Indent.java | 2 ++ platform/lang-impl/src/com/intellij/formatting/IndentImpl.java | 3 ++- .../autodetect/FormatterBasedLineIndentInfoBuilder.java | 3 ++- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/platform/lang-api/src/com/intellij/formatting/Indent.java b/platform/lang-api/src/com/intellij/formatting/Indent.java index 6840af811c61..b8cc9fd45ed7 100644 --- a/platform/lang-api/src/com/intellij/formatting/Indent.java +++ b/platform/lang-api/src/com/intellij/formatting/Indent.java @@ -83,6 +83,8 @@ import org.jetbrains.annotations.NotNull; public abstract class Indent { private static IndentFactory myFactory; + public abstract Type getType(); + static void setFactory(IndentFactory factory) { myFactory = factory; } diff --git a/platform/lang-impl/src/com/intellij/formatting/IndentImpl.java b/platform/lang-impl/src/com/intellij/formatting/IndentImpl.java index 7e35e84e4dbf..314531d5714b 100644 --- a/platform/lang-impl/src/com/intellij/formatting/IndentImpl.java +++ b/platform/lang-impl/src/com/intellij/formatting/IndentImpl.java @@ -18,7 +18,7 @@ package com.intellij.formatting; import org.jetbrains.annotations.NonNls; -public class IndentImpl extends Indent { +class IndentImpl extends Indent { private final boolean myIsAbsolute; private final boolean myRelativeToDirectParent; @@ -38,6 +38,7 @@ public class IndentImpl extends Indent { myEnforceIndentToChildren = enforceIndentToChildren; } + @Override public Type getType() { return myType; } diff --git a/platform/lang-impl/src/com/intellij/psi/codeStyle/autodetect/FormatterBasedLineIndentInfoBuilder.java b/platform/lang-impl/src/com/intellij/psi/codeStyle/autodetect/FormatterBasedLineIndentInfoBuilder.java index 86ce3c6ab763..164956c51e4a 100644 --- a/platform/lang-impl/src/com/intellij/psi/codeStyle/autodetect/FormatterBasedLineIndentInfoBuilder.java +++ b/platform/lang-impl/src/com/intellij/psi/codeStyle/autodetect/FormatterBasedLineIndentInfoBuilder.java @@ -59,7 +59,8 @@ public class FormatterBasedLineIndentInfoBuilder { List normallyIndentedBlocks = ContainerUtil.filter(getBlocksStartingNewLine(), new Condition() { @Override public boolean value(Block block) { - Indent.Type type = block.getIndent() instanceof IndentImpl ? ((IndentImpl)block.getIndent()).getType() : null; + Indent indent = block.getIndent(); + Indent.Type type = indent != null ? indent.getType() : null; return type == Indent.Type.NONE || type == Indent.Type.NORMAL; } });