Skip to content
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,24 @@ In addition to the above aspects, you can also use the following inline operator
- `@foo.start` and `@foo.end` to construct the scope using a range between two nodes (inclusive).
- `@foo.startOf` and `@foo.endOf` to refer to the start and end positions of a node. For example, you could use `@foo.start.endOf` to indicate that the scope should start at the end of the node.

## Iteration capture aliases

Use these aliases when several scopes share an iteration range:

- `@statementNameValue.iteration` expands to `@statement.iteration`,
`@name.iteration`, and `@value.iteration`.
- `@statementNameValueType.iteration` expands to the same captures plus
`@type.iteration`, for languages and contexts that need type iteration.

Both aliases support `.domain`, `.start.endOf`, `.end.startOf`, and `.end.endOf`. For example, a Java block can share iteration boundaries without repeating the pattern for each scope:

```scm
(_
"{" @statementNameValueType.iteration.start.endOf
"}" @statementNameValueType.iteration.end.startOf
)
```

## Query predicate operators

We also support a number of query predicate operators for modifying the scope. See [`queryPredicateOperators.ts`](../../../../../packages/lib-engine/src/languages/TreeSitterQuery/queryPredicateOperators.ts) for a list of available operators.
Original file line number Diff line number Diff line change
Expand Up @@ -915,6 +915,46 @@
}
]
},
{
"name": "scopes/shellscript/name/name.iteration.block2",
"languageId": "shellscript",
"facet": "name.iteration.block",
"code": "if true; then\n :\nelif false; then\n :\nelse\n :\nfi",
"scopes": [
{
"targets": [
{
"content": "0:0-6:2"
}
],
"domain": "0:0-6:2"
},
{
"targets": [
{
"content": "0:13-2:0"
}
],
"domain": "0:13-2:0"
},
{
"targets": [
{
"content": "2:16-4:0"
}
],
"domain": "2:16-4:0"
},
{
"targets": [
{
"content": "4:4-6:0"
}
],
"domain": "4:4-6:0"
}
]
},
{
"name": "scopes/shellscript/name/name.iteration.block3",
"languageId": "shellscript",
Expand All @@ -939,6 +979,30 @@
}
]
},
{
"name": "scopes/shellscript/name/name.iteration.block4",
"languageId": "shellscript",
"facet": "name.iteration.block",
"code": "case $foo in\n 0) bar=0 ;;\nesac",
"scopes": [
{
"targets": [
{
"content": "0:0-2:4"
}
],
"domain": "0:0-2:4"
},
{
"targets": [
{
"content": "1:6-1:13"
}
],
"domain": "1:6-1:13"
}
]
},
{
"name": "scopes/shellscript/name/name.iteration.document",
"languageId": "shellscript",
Expand Down Expand Up @@ -1441,6 +1505,46 @@
}
]
},
{
"name": "scopes/shellscript/statement/statement.iteration.block2",
"languageId": "shellscript",
"facet": "statement.iteration.block",
"code": "if true; then\n :\nelif false; then\n :\nelse\n :\nfi",
"scopes": [
{
"targets": [
{
"content": "0:0-6:2"
}
],
"domain": "0:0-6:2"
},
{
"targets": [
{
"content": "0:13-2:0"
}
],
"domain": "0:13-2:0"
},
{
"targets": [
{
"content": "2:16-4:0"
}
],
"domain": "2:16-4:0"
},
{
"targets": [
{
"content": "4:4-6:0"
}
],
"domain": "4:4-6:0"
}
]
},
{
"name": "scopes/shellscript/statement/statement.iteration.block3",
"languageId": "shellscript",
Expand All @@ -1465,6 +1569,30 @@
}
]
},
{
"name": "scopes/shellscript/statement/statement.iteration.block4",
"languageId": "shellscript",
"facet": "statement.iteration.block",
"code": "case $foo in\n 0) bar=0 ;;\nesac",
"scopes": [
{
"targets": [
{
"content": "0:0-2:4"
}
],
"domain": "0:0-2:4"
},
{
"targets": [
{
"content": "1:6-1:13"
}
],
"domain": "1:6-1:13"
}
]
},
{
"name": "scopes/shellscript/statement/statement.iteration.document",
"languageId": "shellscript",
Expand Down Expand Up @@ -1864,6 +1992,46 @@
}
]
},
{
"name": "scopes/shellscript/value/value.iteration.block2",
"languageId": "shellscript",
"facet": "value.iteration.block",
"code": "if true; then\n :\nelif false; then\n :\nelse\n :\nfi",
"scopes": [
{
"targets": [
{
"content": "0:0-6:2"
}
],
"domain": "0:0-6:2"
},
{
"targets": [
{
"content": "0:13-2:0"
}
],
"domain": "0:13-2:0"
},
{
"targets": [
{
"content": "2:16-4:0"
}
],
"domain": "2:16-4:0"
},
{
"targets": [
{
"content": "4:4-6:0"
}
],
"domain": "4:4-6:0"
}
]
},
{
"name": "scopes/shellscript/value/value.iteration.block3",
"languageId": "shellscript",
Expand All @@ -1888,6 +2056,30 @@
}
]
},
{
"name": "scopes/shellscript/value/value.iteration.block4",
"languageId": "shellscript",
"facet": "value.iteration.block",
"code": "case $foo in\n 0) bar=0 ;;\nesac",
"scopes": [
{
"targets": [
{
"content": "0:0-2:4"
}
],
"domain": "0:0-2:4"
},
{
"targets": [
{
"content": "1:6-1:13"
}
],
"domain": "1:6-1:13"
}
]
},
{
"name": "scopes/shellscript/value/value.iteration.document",
"languageId": "shellscript",
Expand Down
12 changes: 12 additions & 0 deletions packages/app-web-docs/src/docs/user/languages/shellscript.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -313,8 +313,12 @@ Below are visualizations of all our scope tests for this language. These were cr

<ScopeVisualizer fixtureName="scopes/shellscript/name/name.iteration.block" languageId="shellscript" />

<ScopeVisualizer fixtureName="scopes/shellscript/name/name.iteration.block2" languageId="shellscript" />

<ScopeVisualizer fixtureName="scopes/shellscript/name/name.iteration.block3" languageId="shellscript" />

<ScopeVisualizer fixtureName="scopes/shellscript/name/name.iteration.block4" languageId="shellscript" />

#### 9. Name (iteration document)

<i>Iteration scope for names: the entire document including leading and trailing empty lines.</i>
Expand Down Expand Up @@ -469,8 +473,12 @@ Below are visualizations of all our scope tests for this language. These were cr

<ScopeVisualizer fixtureName="scopes/shellscript/statement/statement.iteration.block" languageId="shellscript" />

<ScopeVisualizer fixtureName="scopes/shellscript/statement/statement.iteration.block2" languageId="shellscript" />

<ScopeVisualizer fixtureName="scopes/shellscript/statement/statement.iteration.block3" languageId="shellscript" />

<ScopeVisualizer fixtureName="scopes/shellscript/statement/statement.iteration.block4" languageId="shellscript" />

#### 19. Statement (iteration document)

<i>Iteration scope for statements: the entire document including leading and trailing empty lines.</i>
Expand Down Expand Up @@ -537,8 +545,12 @@ Below are visualizations of all our scope tests for this language. These were cr

<ScopeVisualizer fixtureName="scopes/shellscript/value/value.iteration.block" languageId="shellscript" />

<ScopeVisualizer fixtureName="scopes/shellscript/value/value.iteration.block2" languageId="shellscript" />

<ScopeVisualizer fixtureName="scopes/shellscript/value/value.iteration.block3" languageId="shellscript" />

<ScopeVisualizer fixtureName="scopes/shellscript/value/value.iteration.block4" languageId="shellscript" />

#### 10. Value (iteration document)

<i>Iteration scope for values: the entire document including leading and trailing empty lines.</i>
Expand Down
64 changes: 64 additions & 0 deletions packages/app-web-docs/src/docs/user/scopes/fixtures/name.json
Original file line number Diff line number Diff line change
Expand Up @@ -12083,6 +12083,46 @@
}
]
},
{
"name": "scopes/shellscript/name/name.iteration.block2",
"languageId": "shellscript",
"facet": "name.iteration.block",
"code": "if true; then\n :\nelif false; then\n :\nelse\n :\nfi",
"scopes": [
{
"targets": [
{
"content": "0:0-6:2"
}
],
"domain": "0:0-6:2"
},
{
"targets": [
{
"content": "0:13-2:0"
}
],
"domain": "0:13-2:0"
},
{
"targets": [
{
"content": "2:16-4:0"
}
],
"domain": "2:16-4:0"
},
{
"targets": [
{
"content": "4:4-6:0"
}
],
"domain": "4:4-6:0"
}
]
},
{
"name": "scopes/shellscript/name/name.iteration.block3",
"languageId": "shellscript",
Expand All @@ -12107,6 +12147,30 @@
}
]
},
{
"name": "scopes/shellscript/name/name.iteration.block4",
"languageId": "shellscript",
"facet": "name.iteration.block",
"code": "case $foo in\n 0) bar=0 ;;\nesac",
"scopes": [
{
"targets": [
{
"content": "0:0-2:4"
}
],
"domain": "0:0-2:4"
},
{
"targets": [
{
"content": "1:6-1:13"
}
],
"domain": "1:6-1:13"
}
]
},
{
"name": "scopes/shellscript/name/name.iteration.document",
"languageId": "shellscript",
Expand Down
Loading
Loading