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 @@ -23,6 +23,54 @@
}
]
},
{
"name": "scopes/markdown/collectionItem.unenclosed.iteration2",
"languageId": "markdown",
"facet": "collectionItem.unenclosed.iteration",
"code": "- First item\n Paragraph\n- Second item",
"scopes": [
{
"targets": [
{
"content": "0:0-2:13"
}
],
"domain": "0:0-2:13"
}
]
},
{
"name": "scopes/markdown/collectionItem.unenclosed.iteration3",
"languageId": "markdown",
"facet": "collectionItem.unenclosed.iteration",
"code": "- [ ] First item\n- [ ] Second item",
"scopes": [
{
"targets": [
{
"content": "0:0-1:17"
}
],
"domain": "0:0-1:17"
},
{
"targets": [
{
"content": "0:3-0:4"
}
],
"domain": "0:3-0:4"
},
{
"targets": [
{
"content": "1:3-1:4"
}
],
"domain": "1:3-1:4"
}
]
},
{
"name": "scopes/markdown/collectionItem.unenclosed.multiLine",
"languageId": "markdown",
Expand Down Expand Up @@ -51,13 +99,83 @@
"targets": [
{
"content": "2:2-2:42",
"removal": "2:0-2:42"
"removal": "1:39-2:42"
}
],
"domain": "2:0-2:42"
}
]
},
{
"name": "scopes/markdown/collectionItem.unenclosed.multiLine2",
"languageId": "markdown",
"facet": "collectionItem.unenclosed.multiLine",
"code": "- First item\n Paragraph\n- Second item",
"scopes": [
{
"targets": [
{
"content": "0:2-1:11",
"removal": "0:0-2:0"
}
],
"domain": "0:0-1:11"
},
{
"targets": [
{
"content": "2:2-2:13",
"removal": "1:11-2:13"
}
],
"domain": "2:0-2:13"
}
]
},
{
"name": "scopes/markdown/collectionItem.unenclosed.multiLine3",
"languageId": "markdown",
"facet": "collectionItem.unenclosed.multiLine",
"code": "- [ ] First item\n- [ ] Second item",
"scopes": [
{
"targets": [
{
"content": "0:2-0:16",
"removal": "0:0-1:0"
}
],
"domain": "0:0-0:16"
},
{
"targets": [
{
"content": "0:3-0:4",
"removal": "0:3-0:4"
}
],
"domain": "0:3-0:4"
},
{
"targets": [
{
"content": "1:2-1:17",
"removal": "0:16-1:17"
}
],
"domain": "1:0-1:17"
},
{
"targets": [
{
"content": "1:3-1:4",
"removal": "1:3-1:4"
}
],
"domain": "1:3-1:4"
}
]
},
{
"name": "scopes/markdown/comment.block",
"languageId": "markdown",
Expand Down
8 changes: 8 additions & 0 deletions packages/app-web-docs/src/docs/user/languages/markdown.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,20 @@ Below are visualizations of all our scope tests for this language. These were cr

<ScopeVisualizer fixtureName="scopes/markdown/collectionItem.unenclosed.multiLine" languageId="markdown" />

<ScopeVisualizer fixtureName="scopes/markdown/collectionItem.unenclosed.multiLine2" languageId="markdown" />

<ScopeVisualizer fixtureName="scopes/markdown/collectionItem.unenclosed.multiLine3" languageId="markdown" />

#### 2. Collection item: Unenclosed (iteration)

<i>Iteration scope for items in a comma-separated list without enclosing delimiters</i>

<ScopeVisualizer fixtureName="scopes/markdown/collectionItem.unenclosed.iteration" languageId="markdown" />

<ScopeVisualizer fixtureName="scopes/markdown/collectionItem.unenclosed.iteration2" languageId="markdown" />

<ScopeVisualizer fixtureName="scopes/markdown/collectionItem.unenclosed.iteration3" languageId="markdown" />

### Comment

#### 1. Comment: Block
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,10 @@ Default: `item`

<ScopeVisualizer fixtureName="scopes/markdown/collectionItem.unenclosed.multiLine" />

<ScopeVisualizer fixtureName="scopes/markdown/collectionItem.unenclosed.multiLine2" />

<ScopeVisualizer fixtureName="scopes/markdown/collectionItem.unenclosed.multiLine3" />

##### Scala

<ScopeVisualizer fixtureName="scopes/scala/collectionItem/collectionItem.unenclosed.multiLine" />
Expand Down Expand Up @@ -255,6 +259,10 @@ Default: `item`

<ScopeVisualizer fixtureName="scopes/markdown/collectionItem.unenclosed.iteration" />

<ScopeVisualizer fixtureName="scopes/markdown/collectionItem.unenclosed.iteration2" />

<ScopeVisualizer fixtureName="scopes/markdown/collectionItem.unenclosed.iteration3" />

##### Python

<ScopeVisualizer fixtureName="scopes/python/collectionItem/collectionItem.unenclosed.iteration" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1499,6 +1499,54 @@
}
]
},
{
"name": "scopes/markdown/collectionItem.unenclosed.iteration2",
"languageId": "markdown",
"facet": "collectionItem.unenclosed.iteration",
"code": "- First item\n Paragraph\n- Second item",
"scopes": [
{
"targets": [
{
"content": "0:0-2:13"
}
],
"domain": "0:0-2:13"
}
]
},
{
"name": "scopes/markdown/collectionItem.unenclosed.iteration3",
"languageId": "markdown",
"facet": "collectionItem.unenclosed.iteration",
"code": "- [ ] First item\n- [ ] Second item",
"scopes": [
{
"targets": [
{
"content": "0:0-1:17"
}
],
"domain": "0:0-1:17"
},
{
"targets": [
{
"content": "0:3-0:4"
}
],
"domain": "0:3-0:4"
},
{
"targets": [
{
"content": "1:3-1:4"
}
],
"domain": "1:3-1:4"
}
]
},
{
"name": "scopes/markdown/collectionItem.unenclosed.multiLine",
"languageId": "markdown",
Expand Down Expand Up @@ -1527,13 +1575,83 @@
"targets": [
{
"content": "2:2-2:42",
"removal": "2:0-2:42"
"removal": "1:39-2:42"
}
],
"domain": "2:0-2:42"
}
]
},
{
"name": "scopes/markdown/collectionItem.unenclosed.multiLine2",
"languageId": "markdown",
"facet": "collectionItem.unenclosed.multiLine",
"code": "- First item\n Paragraph\n- Second item",
"scopes": [
{
"targets": [
{
"content": "0:2-1:11",
"removal": "0:0-2:0"
}
],
"domain": "0:0-1:11"
},
{
"targets": [
{
"content": "2:2-2:13",
"removal": "1:11-2:13"
}
],
"domain": "2:0-2:13"
}
]
},
{
"name": "scopes/markdown/collectionItem.unenclosed.multiLine3",
"languageId": "markdown",
"facet": "collectionItem.unenclosed.multiLine",
"code": "- [ ] First item\n- [ ] Second item",
"scopes": [
{
"targets": [
{
"content": "0:2-0:16",
"removal": "0:0-1:0"
}
],
"domain": "0:0-0:16"
},
{
"targets": [
{
"content": "0:3-0:4",
"removal": "0:3-0:4"
}
],
"domain": "0:3-0:4"
},
{
"targets": [
{
"content": "1:2-1:17",
"removal": "0:16-1:17"
}
],
"domain": "1:0-1:17"
},
{
"targets": [
{
"content": "1:3-1:4",
"removal": "1:3-1:4"
}
],
"domain": "1:3-1:4"
}
]
},
{
"name": "scopes/plaintext/collectionItem/collectionItem.textual.iteration",
"languageId": "plaintext",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,16 @@ export abstract class QueryPredicateOperator<T extends HasSchema> {
*/
abstract readonly schema: InferSchemaType<T>;

/**
* Whether it is ok for a node argument to be missing. If true, then the
* operator will just accept the pattern if the given node is missing. If
* false, then the operator will throw an error if the node is missing.
*
* This is useful if we want to set some flag on a node, but only if it's
* present.
*/
protected allowMissingNode: boolean = false;

/**
* Given a list of operands, return whether the operator accepts the given
* operands. This is where the actual logic of the operator is implemented.
Expand All @@ -47,21 +57,6 @@ export abstract class QueryPredicateOperator<T extends HasSchema> {
...args: AcceptFunctionArgs<z.infer<InferSchemaType<T>>>
): boolean;

/**
* Whether it is ok for a node argument to be missing. If true, then the
* operator will just accept the pattern if the given node is missing. If
* false, then the operator will throw an error if the node is missing.
*
* This is useful if we want to set some flag on a node, but only if it's
* present.
*
* @returns A boolean indicating whether it is ok for a node argument to be
* missing.
*/
protected allowMissingNode(): boolean {
return false;
}

/**
* Given a list of operands, return a predicate function that can be used to
* test whether a given match satisfies the predicate.
Expand All @@ -84,7 +79,7 @@ export abstract class QueryPredicateOperator<T extends HasSchema> {
} catch (error) {
if (
error instanceof CaptureNotFoundError &&
this.allowMissingNode()
this.allowMissingNode
) {
return true;
}
Expand Down
Loading
Loading