diff options
Diffstat (limited to 'src/server/action_invert_if_statements.odin')
| -rw-r--r-- | src/server/action_invert_if_statements.odin | 19 |
1 files changed, 8 insertions, 11 deletions
diff --git a/src/server/action_invert_if_statements.odin b/src/server/action_invert_if_statements.odin index 8e904e5..a41127a 100644 --- a/src/server/action_invert_if_statements.odin +++ b/src/server/action_invert_if_statements.odin @@ -19,7 +19,7 @@ import "src:common" * So for now, we only support only one level of if statements without else-if chains. */ -@(private="package") +@(private = "package") add_invert_if_action :: proc( document: ^Document, position: common.AbsolutePosition, @@ -45,15 +45,7 @@ add_invert_if_action :: proc( workspaceEdit.changes = make(map[string][]TextEdit, 0, context.temp_allocator) workspaceEdit.changes[uri] = textEdits[:] - append( - actions, - CodeAction { - kind = "refactor.more", - isPreferred = false, - title = "Invert if", - edit = workspaceEdit, - }, - ) + append(actions, CodeAction{kind = "refactor.more", isPreferred = false, title = "Invert if", edit = workspaceEdit}) } // Find the innermost if statement that contains the given position @@ -71,7 +63,11 @@ find_if_stmt_at_position :: proc(stmts: []^ast.Stmt, position: common.AbsolutePo return nil } -find_if_stmt_in_node :: proc(node: ^ast.Node, position: common.AbsolutePosition, in_else_clause: bool) -> ^ast.If_Stmt { +find_if_stmt_in_node :: proc( + node: ^ast.Node, + position: common.AbsolutePosition, + in_else_clause: bool, +) -> ^ast.If_Stmt { if node == nil { return nil } @@ -238,6 +234,7 @@ generate_inverted_if :: proc(document: ^Document, if_stmt: ^ast.If_Stmt) -> (str } // Get the indentation (leading whitespace) of the line containing the given offset +@(private = "package") get_line_indentation :: proc(src: string, offset: int) -> string { line_start := offset for line_start > 0 && src[line_start - 1] != '\n' { |