Skip to content

Commit

Permalink
Added comment facets
Browse files Browse the repository at this point in the history
  • Loading branch information
AndreasArvidsson committed Dec 15, 2023
1 parent 58bfb9a commit b6ac60f
Show file tree
Hide file tree
Showing 14 changed files with 136 additions and 12 deletions.
3 changes: 3 additions & 0 deletions packages/common/src/scopeSupportFacets/java.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ export const javaScopeSupport: LanguageScopeSupportFacetMap = {
"value.foreach": supported,
"type.foreach": supported,

"comment.line": supported,
"comment.block": supported,

element: notApplicable,
tags: notApplicable,
attribute: notApplicable,
Expand Down
3 changes: 3 additions & 0 deletions packages/common/src/scopeSupportFacets/python.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ export const pythonScopeSupport: LanguageScopeSupportFacetMap = {
"argument.formal": supportedLegacy,
"argument.formal.iteration": supportedLegacy,

"comment.line": supported,
"comment.block": supported,

element: notApplicable,
tags: notApplicable,
attribute: notApplicable,
Expand Down
3 changes: 3 additions & 0 deletions packages/common/src/scopeSupportFacets/talon.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,7 @@ const { supported } = ScopeSupportFacetLevel;

export const talonScopeSupport: LanguageScopeSupportFacetMap = {
command: supported,

"comment.line": supported,
"comment.block": supported,
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/*
Hello world
*/
---

[Content] =
[Removal] =
[Domain] = 0:0-2:2
0| /*
>--
1| Hello world
-------------
2| */
--<

[Insertion delimiter] = "\n"
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/**
* Hello world
*/
---

[Content] =
[Removal] =
[Domain] = 0:0-2:2
0| /**
>---
1| * Hello world
-------------
2| */
--<

[Insertion delimiter] = "\n"
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// Hello
// World
---

[Content] =
[Removal] =
[Domain] = 0:0-1:8
0| // Hello
>--------
1| // World
--------<

[Insertion delimiter] = "\n"
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// Hello world
---

[Content] =
[Removal] =
[Domain] = 0:0-0:14
0| // Hello world
>--------------<

[Insertion delimiter] = "\n"
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// Hello
// World
---

[Content] =
[Removal] =
[Domain] = 0:0-1:8
0| // Hello
>--------
1| // World
--------<

[Insertion delimiter] = "\n"
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Hello
# World
---

[Content] =
[Removal] =
[Domain] = 0:0-1:7
0| # Hello
>-------
1| # World
-------<

[Insertion delimiter] = "\n"
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Hello world
---

[Content] =
[Removal] =
[Domain] = 0:0-0:13
0| # Hello world
>-------------<

[Insertion delimiter] = "\n"
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Hello
# World
---

[Content] =
[Removal] =
[Domain] = 0:0-1:7
0| # Hello
>-------
1| # World
-------<

[Insertion delimiter] = "\n"
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Hello world
---

[Content] =
[Removal] =
[Domain] = 0:0-0:13
0| # Hello world
>-------------<

[Insertion delimiter] = "\n"
20 changes: 9 additions & 11 deletions packages/cursorless-vscode-e2e/src/suite/scopes.vscode.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -145,19 +145,17 @@ function getScopeType(
scopeType: ScopeType;
isIteration: boolean;
} {
if (languageId === "textual") {
const { scopeType, isIteration } =
textualScopeSupportFacetInfos[facetId as TextualScopeSupportFacet];
return {
scopeType: { type: scopeType },
isIteration: isIteration ?? false,
};
const facetInfo =
languageId === "textual"
? textualScopeSupportFacetInfos[facetId as TextualScopeSupportFacet]
: scopeSupportFacetInfos[facetId as ScopeSupportFacet];

if (facetInfo == null) {
throw Error(`Unknown facet '${facetId}'`);
}

const { scopeType, isIteration } =
scopeSupportFacetInfos[facetId as ScopeSupportFacet];
return {
scopeType: { type: scopeType },
isIteration: isIteration ?? false,
scopeType: { type: facetInfo.scopeType },
isIteration: facetInfo.isIteration ?? false,
};
}
5 changes: 4 additions & 1 deletion queries/talon.scm
Original file line number Diff line number Diff line change
Expand Up @@ -174,4 +174,7 @@ arguments: (_) @argumentOrParameter.iteration

;;!! # foo
;;! ^^^^^
(comment) @comment
(
(comment) @comment
(#contiguous! @comment)
)

0 comments on commit b6ac60f

Please sign in to comment.