Skip to content

Commit

Permalink
Inline GetDefaultIndentationFromTokenLine
Browse files Browse the repository at this point in the history
  • Loading branch information
jnm2 committed Dec 29, 2024
1 parent 3bf6824 commit 9184234
Showing 1 changed file with 6 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -318,13 +318,17 @@ private static IndentationResult GetIndentationBasedOnToken(Indenter indenter, S
}
}

var result = TryGetIndentationForQueryExpression(indenter, token);
var result = TryGetIndentationForQueryExpression(indenter, token)
?? TryGetIndentationFromMultilineStatement(indenter, token);

if (result is not null)
{
return result.Value;
}

return GetDefaultIndentationFromTokenLine(indenter, token);
var spaceToAdd = indenter.Options.FormattingOptions.IndentationSize;

return indenter.IndentFromStartOfLine(indenter.Finder.GetIndentationOfCurrentPosition(indenter.Tree, token, position, spaceToAdd, indenter.CancellationToken));
}

private static IndentationResult? TryGetIndentationFromCommaSeparatedList(Indenter indenter, SyntaxToken token)
Expand Down Expand Up @@ -485,18 +489,4 @@ private static bool IsPartOfQueryExpression(SyntaxToken token)

return null;
}

private static IndentationResult GetDefaultIndentationFromTokenLine(Indenter indenter, SyntaxToken token)
{
if (TryGetIndentationFromMultilineStatement(indenter, token) is { } result)
{
return result;
}

var position = indenter.GetCurrentPositionNotBelongToEndOfFileToken(indenter.LineToBeIndented.Start);

var spaceToAdd = indenter.Options.FormattingOptions.IndentationSize;

return indenter.IndentFromStartOfLine(indenter.Finder.GetIndentationOfCurrentPosition(indenter.Tree, token, position, spaceToAdd, indenter.CancellationToken));
}
}

0 comments on commit 9184234

Please sign in to comment.