From 4c03bfdf16540d04bd9a240390846db52b33dc8e Mon Sep 17 00:00:00 2001 From: Bruno BELANYI Date: Tue, 23 Apr 2024 16:36:11 +0000 Subject: [PATCH] WIP: Add indentation queries for multi-value 'select' FIXME: add insertion tests for both cases... --- queries/indents.scm | 9 +++++++++ test/indent/select.bp | 32 ++++++++++++++++++++++++++++++++ test/indent_spec.lua | 6 ++++++ 3 files changed, 47 insertions(+) diff --git a/queries/indents.scm b/queries/indents.scm index 9e63d1e..cd5b726 100644 --- a/queries/indents.scm +++ b/queries/indents.scm @@ -11,6 +11,15 @@ (select_expression ")" @indent.branch) +(select_value) @indent.begin +(select_value + ")" @indent.branch) + +; (select_pattern +; "(" @indent.begin) +; (select_pattern +; ")" @indent.branch) + (select_cases) @indent.begin (select_cases "}" @indent.branch) diff --git a/test/indent/select.bp b/test/indent/select.bp index 6d95b2c..6c432b2 100644 --- a/test/indent/select.bp +++ b/test/indent/select.bp @@ -26,3 +26,35 @@ foo = select( default: 0, } ) + +foo = select(( + arch(), + os(), +), { + (default, default): [], +}) + +foo = select( + (arch(), os()), + { + (default, default): [], + } +) + +// We're really getting into more and more unlikely choices here... +foo = select( + ( + arch(), + os(), + ), + { + (default, default): [], + } +) + +foo = select((arch(), os()), { + ( + default, + default, + ): [], +}) diff --git a/test/indent_spec.lua b/test/indent_spec.lua index 26b9d3b..22db06c 100644 --- a/test/indent_spec.lua +++ b/test/indent_spec.lua @@ -47,5 +47,11 @@ describe("indent Blueprint:", function() runner:new_line("test/indent/select.bp", { on_line = 26, text = 'default: "value"', indent = 8 }, "default case, trailing, alternate formatting") runner:new_line("test/indent/select.bp", { on_line = 26, text = '}', indent = 4 }, "select cases closing delimiter, alternate formatting") runner:new_line("test/indent/select.bp", { on_line = 27, text = ')', indent = 0 }, "select expression closing delimiter, alternate formatting") + runner:new_line("test/indent/select.bp", { on_line = 46, text = 'device()', indent = 8 }, "multi-valued select condition, begin") + runner:new_line("test/indent/select.bp", { on_line = 47, text = 'device()', indent = 8 }, "multi-valued select condition, middle") + runner:new_line("test/indent/select.bp", { on_line = 48, text = 'device()', indent = 8 }, "multi-valued select condition, end") + runner:new_line("test/indent/select.bp", { on_line = 56, text = 'default,', indent = 8 }, "multi-valued select case, begin") + runner:new_line("test/indent/select.bp", { on_line = 57, text = 'default,', indent = 8 }, "multi-valued select case, middle") + runner:new_line("test/indent/select.bp", { on_line = 58, text = 'default,', indent = 8 }, "multi-valued select case, end") end) end)