2024-01-17 14:30:11 +01:00
|
|
|
import refactor
|
|
|
|
|
import liblkqllang as lkql
|
|
|
|
|
from refactor import Action, ActionKind
|
|
|
|
|
|
2025-11-26 10:37:29 +01:00
|
|
|
|
2024-01-17 14:30:11 +01:00
|
|
|
class App(refactor.Refactor):
|
|
|
|
|
|
|
|
|
|
def preprocess(self, unit):
|
|
|
|
|
for binding_pat in unit.root.findall(lkql.BindingPattern):
|
2025-11-26 12:21:41 +01:00
|
|
|
# Remove every token from the @ token to the last whitespace after the '*'
|
|
|
|
|
# token.
|
2025-11-26 10:37:29 +01:00
|
|
|
|
|
|
|
|
if binding_pat.f_value_pattern and binding_pat.f_value_pattern.is_a(
|
|
|
|
|
lkql.UniversalPattern
|
|
|
|
|
):
|
|
|
|
|
cur_tok = refactor.first_with_pred(
|
|
|
|
|
binding_pat.token_start, lambda t: t.kind == "At"
|
|
|
|
|
)
|
|
|
|
|
if cur_tok.previous.kind == "Whitespace":
|
2024-01-17 14:30:11 +01:00
|
|
|
cur_tok = cur_tok.previous
|
|
|
|
|
end_tok = binding_pat.token_end.next
|
|
|
|
|
|
|
|
|
|
while cur_tok != end_tok:
|
|
|
|
|
self.add_action(cur_tok, Action(ActionKind.replace, ""))
|
|
|
|
|
cur_tok = cur_tok.next
|
|
|
|
|
|
|
|
|
|
|
2025-11-26 10:37:29 +01:00
|
|
|
if __name__ == "__main__":
|
2024-01-17 14:30:11 +01:00
|
|
|
App.run()
|