Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remaining changes from Nickel idempotency issue #555

Merged
merged 3 commits into from
Jul 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
14 changes: 11 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -886,13 +886,20 @@ This Tree-sitter query:

...while the single-lined `(1, 2, 3)` is kept as is.

If we used `@append_spaced_softline` rather than
`@append_spaced_scoped_softline`, the `1,` would be followed by a space rather
than a newline, because it's inside a single-line `product_expression`.

### Testing context with predicates

Sometimes, similarly to what happens with softlines, we want a query to match only if the context is single-line, or multi-line. Topiary has several predicates that achieve this result.
Sometimes, similarly to what happens with softlines, we want a query to match
only if the context is single-line, or multi-line. Topiary has several
predicates that achieve this result.

### `#single_line_only!` / `#multi_line_only!`

These predicates allow the query to trigger only if the matched nodes are in a single-line (resp. multi-line) context.
These predicates allow the query to trigger only if the matched nodes are in a
single-line (resp. multi-line) context.

#### Example

Expand Down Expand Up @@ -921,7 +928,8 @@ These predicates allow the query to trigger only if the matched nodes are in a s

### `#single_line_scope_only!` / `#multi_line_scope_only!`

These predicates allow the query to trigger only if the associated custom scope containing the matched nodes are is single-line (resp. multi-line).
These predicates allow the query to trigger only if the associated custom scope
containing the matched nodes are is single-line (resp. multi-line).

#### Example

Expand Down
16 changes: 12 additions & 4 deletions topiary/tests/samples/expected/nickel.ncl
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
{
regression_tests = [
{
a = [
b
&& (c & d | e)
]
},
{
id
| a -> a
},

# Interpolated record operation chains (in
# a multi-line comment)
{
Expand Down Expand Up @@ -2435,8 +2446,5 @@
```
"%
= fun s => %enum_from_str% s,
},

id
| a -> a,
}
}
16 changes: 12 additions & 4 deletions topiary/tests/samples/input/nickel.ncl
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
{
regression_tests = [
{
a = [
b
&& (c & d | e)
]
},
{
id |
a -> a
},

# Interpolated record operation chains (in
# a multi-line comment)
{
Expand Down Expand Up @@ -2425,8 +2436,5 @@
```
"%
= fun s => %enum_from_str% s,
},

id |
a -> a,
}
}