erg/crates/els/doc/code_action.md
2023-05-28 22:40:22 +09:00

926 B

Available Code Actions

eliminate_unused_vars

This code action will eliminate unused variables in code.

foo = 1
for! 0..3, i =>
    print! 1

for! 0..3, _ =>
    print! 1

change_case

This code action will change non-snake case variables to snake case.

fooBar = 1

foo_bar = 1

inline_variables

This code action will inline variables.

two = 1 + 1
print! two
print! two * 1

print! 1 + 1
print!((1 + 1) * 1)

extract_variables

This code action will extract variables.

print! |1 + 1| # |...| is selected

new_var = 1 + 1
print! new_var

extract_functions

This code action will extract functions.

if foo, do:
    # |...| is selected
    |for arr, i =>
        ...
    bar()|

new_func() =
    for arr, i =>
        ...
    bar()

if foo, do:
    new_func()