Skip to content

Commit b6ac60f

Browse files
Added comment facets
1 parent 58bfb9a commit b6ac60f

File tree

14 files changed

+136
-12
lines changed

14 files changed

+136
-12
lines changed

Diff for: packages/common/src/scopeSupportFacets/java.ts

+3
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ export const javaScopeSupport: LanguageScopeSupportFacetMap = {
1212
"value.foreach": supported,
1313
"type.foreach": supported,
1414

15+
"comment.line": supported,
16+
"comment.block": supported,
17+
1518
element: notApplicable,
1619
tags: notApplicable,
1720
attribute: notApplicable,

Diff for: packages/common/src/scopeSupportFacets/python.ts

+3
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@ export const pythonScopeSupport: LanguageScopeSupportFacetMap = {
1616
"argument.formal": supportedLegacy,
1717
"argument.formal.iteration": supportedLegacy,
1818

19+
"comment.line": supported,
20+
"comment.block": supported,
21+
1922
element: notApplicable,
2023
tags: notApplicable,
2124
attribute: notApplicable,

Diff for: packages/common/src/scopeSupportFacets/talon.ts

+3
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,7 @@ const { supported } = ScopeSupportFacetLevel;
99

1010
export const talonScopeSupport: LanguageScopeSupportFacetMap = {
1111
command: supported,
12+
13+
"comment.line": supported,
14+
"comment.block": supported,
1215
};
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
/*
2+
Hello world
3+
*/
4+
---
5+
6+
[Content] =
7+
[Removal] =
8+
[Domain] = 0:0-2:2
9+
0| /*
10+
>--
11+
1| Hello world
12+
-------------
13+
2| */
14+
--<
15+
16+
[Insertion delimiter] = "\n"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
/**
2+
* Hello world
3+
*/
4+
---
5+
6+
[Content] =
7+
[Removal] =
8+
[Domain] = 0:0-2:2
9+
0| /**
10+
>---
11+
1| * Hello world
12+
-------------
13+
2| */
14+
--<
15+
16+
[Insertion delimiter] = "\n"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// Hello
2+
// World
3+
---
4+
5+
[Content] =
6+
[Removal] =
7+
[Domain] = 0:0-1:8
8+
0| // Hello
9+
>--------
10+
1| // World
11+
--------<
12+
13+
[Insertion delimiter] = "\n"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
// Hello world
2+
---
3+
4+
[Content] =
5+
[Removal] =
6+
[Domain] = 0:0-0:14
7+
0| // Hello world
8+
>--------------<
9+
10+
[Insertion delimiter] = "\n"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// Hello
2+
// World
3+
---
4+
5+
[Content] =
6+
[Removal] =
7+
[Domain] = 0:0-1:8
8+
0| // Hello
9+
>--------
10+
1| // World
11+
--------<
12+
13+
[Insertion delimiter] = "\n"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Hello
2+
# World
3+
---
4+
5+
[Content] =
6+
[Removal] =
7+
[Domain] = 0:0-1:7
8+
0| # Hello
9+
>-------
10+
1| # World
11+
-------<
12+
13+
[Insertion delimiter] = "\n"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# Hello world
2+
---
3+
4+
[Content] =
5+
[Removal] =
6+
[Domain] = 0:0-0:13
7+
0| # Hello world
8+
>-------------<
9+
10+
[Insertion delimiter] = "\n"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Hello
2+
# World
3+
---
4+
5+
[Content] =
6+
[Removal] =
7+
[Domain] = 0:0-1:7
8+
0| # Hello
9+
>-------
10+
1| # World
11+
-------<
12+
13+
[Insertion delimiter] = "\n"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# Hello world
2+
---
3+
4+
[Content] =
5+
[Removal] =
6+
[Domain] = 0:0-0:13
7+
0| # Hello world
8+
>-------------<
9+
10+
[Insertion delimiter] = "\n"

Diff for: packages/cursorless-vscode-e2e/src/suite/scopes.vscode.test.ts

+9-11
Original file line numberDiff line numberDiff line change
@@ -145,19 +145,17 @@ function getScopeType(
145145
scopeType: ScopeType;
146146
isIteration: boolean;
147147
} {
148-
if (languageId === "textual") {
149-
const { scopeType, isIteration } =
150-
textualScopeSupportFacetInfos[facetId as TextualScopeSupportFacet];
151-
return {
152-
scopeType: { type: scopeType },
153-
isIteration: isIteration ?? false,
154-
};
148+
const facetInfo =
149+
languageId === "textual"
150+
? textualScopeSupportFacetInfos[facetId as TextualScopeSupportFacet]
151+
: scopeSupportFacetInfos[facetId as ScopeSupportFacet];
152+
153+
if (facetInfo == null) {
154+
throw Error(`Unknown facet '${facetId}'`);
155155
}
156156

157-
const { scopeType, isIteration } =
158-
scopeSupportFacetInfos[facetId as ScopeSupportFacet];
159157
return {
160-
scopeType: { type: scopeType },
161-
isIteration: isIteration ?? false,
158+
scopeType: { type: facetInfo.scopeType },
159+
isIteration: facetInfo.isIteration ?? false,
162160
};
163161
}

Diff for: queries/talon.scm

+4-1
Original file line numberDiff line numberDiff line change
@@ -174,4 +174,7 @@ arguments: (_) @argumentOrParameter.iteration
174174

175175
;;!! # foo
176176
;;! ^^^^^
177-
(comment) @comment
177+
(
178+
(comment) @comment
179+
(#contiguous! @comment)
180+
)

0 commit comments

Comments
 (0)