fixed EA-83621

This commit is contained in:
Yaroslav Lepenkin
2017-09-20 14:18:07 +02:00
parent 2ab0b7adda
commit 14d28e2ff2
2 changed files with 12 additions and 14 deletions
@@ -85,6 +85,7 @@ public abstract class AbstractBlockWrapper {
*
* @return the whitespace preceding the block
*/
@Nullable
public WhiteSpace getWhiteSpace() {
return myWhiteSpaceBefore;
}
@@ -88,22 +88,19 @@ public class CoreFormatterUtil {
* @return non-line feed symbols to the left of the given wrapped block
*/
public static int getStartColumn(@Nullable LeafBlockWrapper block) {
if (block != null) {
int result = 0;
while (true) {
final WhiteSpace whiteSpace = block.getWhiteSpace();
if (block == null) return -1;
int result = 0;
while (true) {
final WhiteSpace whiteSpace = block.getWhiteSpace();
if (whiteSpace != null) {
result += whiteSpace.getTotalSpaces();
if (whiteSpace.containsLineFeeds()) {
return result;
}
block = block.getPreviousBlock();
if (result > CodeStyleSettings.MAX_RIGHT_MARGIN || block == null) return result;
result += block.getSymbolsAtTheLastLine();
if (block.containsLineFeeds()) return result;
if (whiteSpace.containsLineFeeds()) return result;
}
}
else {
return -1;
block = block.getPreviousBlock();
if (result > CodeStyleSettings.MAX_RIGHT_MARGIN || block == null) return result;
result += block.getSymbolsAtTheLastLine();
if (block.containsLineFeeds()) return result;
}
}