(ctx context.Context, sourceFile *ast.SourceFile, position int)
| 117 | } |
| 118 | |
| 119 | func FormatOnOpeningCurly(ctx context.Context, sourceFile *ast.SourceFile, position int) []core.TextChange { |
| 120 | openingCurly := findImmediatelyPrecedingTokenOfKind(position, ast.KindOpenBraceToken, sourceFile) |
| 121 | if openingCurly == nil { |
| 122 | return nil |
| 123 | } |
| 124 | curlyBraceRange := openingCurly.Parent |
| 125 | outermostNode := findOutermostNodeWithinListLevel(curlyBraceRange) |
| 126 | /** |
| 127 | * We limit the span to end at the opening curly to handle the case where |
| 128 | * the brace matched to that just typed will be incorrect after further edits. |
| 129 | * For example, we could type the opening curly for the following method |
| 130 | * body without brace-matching activated: |
| 131 | * ``` |
| 132 | * class C { |
| 133 | * foo() |
| 134 | * } |
| 135 | * ``` |
| 136 | * and we wouldn't want to move the closing brace. |
| 137 | */ |
| 138 | textRange := core.NewTextRange(GetLineStartPositionForPosition(scanner.GetTokenPosOfNode(outermostNode, sourceFile, false), sourceFile), position) |
| 139 | return FormatSpan(ctx, textRange, sourceFile, FormatRequestKindFormatOnOpeningCurlyBrace) |
| 140 | } |
| 141 | |
| 142 | func FormatOnClosingCurly(ctx context.Context, sourceFile *ast.SourceFile, position int) []core.TextChange { |
| 143 | precedingToken := findImmediatelyPrecedingTokenOfKind(position, ast.KindCloseBraceToken, sourceFile) |
no test coverage detected