mirror of
https://github.com/cursorless-dev/cursorless.git
synced 2024-10-04 12:57:58 +03:00
Add scope test machinery for remaining languages (#2326)
## Checklist - [x] I have added [tests](https://www.cursorless.org/docs/contributing/test-case-recorder/) - [/] I have updated the [docs](https://github.com/cursorless-dev/cursorless/tree/main/docs) and [cheatsheet](https://github.com/cursorless-dev/cursorless/tree/main/cursorless-talon/src/cheatsheet) - [/] I have not broken the cheatsheet
This commit is contained in:
parent
f143950519
commit
dbb5fb8505
@ -1,19 +0,0 @@
|
||||
languageId: cpp
|
||||
command:
|
||||
version: 1
|
||||
spokenForm: take comment
|
||||
action: setSelection
|
||||
targets:
|
||||
- type: primitive
|
||||
modifier: {type: containingScope, scopeType: comment}
|
||||
initialState:
|
||||
documentContents: int a; // the comment
|
||||
selections:
|
||||
- anchor: {line: 0, character: 20}
|
||||
active: {line: 0, character: 20}
|
||||
marks: {}
|
||||
finalState:
|
||||
documentContents: int a; // the comment
|
||||
selections:
|
||||
- anchor: {line: 0, character: 7}
|
||||
active: {line: 0, character: 21}
|
@ -1,29 +0,0 @@
|
||||
languageId: cpp
|
||||
command:
|
||||
version: 1
|
||||
spokenForm: take if state
|
||||
action: setSelection
|
||||
targets:
|
||||
- type: primitive
|
||||
modifier: {type: containingScope, scopeType: ifStatement}
|
||||
initialState:
|
||||
documentContents: |-
|
||||
void f() {
|
||||
if (true) {
|
||||
|
||||
}
|
||||
}
|
||||
selections:
|
||||
- anchor: {line: 2, character: 8}
|
||||
active: {line: 2, character: 8}
|
||||
marks: {}
|
||||
finalState:
|
||||
documentContents: |-
|
||||
void f() {
|
||||
if (true) {
|
||||
|
||||
}
|
||||
}
|
||||
selections:
|
||||
- anchor: {line: 1, character: 4}
|
||||
active: {line: 3, character: 5}
|
@ -1,29 +0,0 @@
|
||||
languageId: cpp
|
||||
command:
|
||||
version: 1
|
||||
spokenForm: take if state
|
||||
action: setSelection
|
||||
targets:
|
||||
- type: primitive
|
||||
modifier: {type: containingScope, scopeType: ifStatement}
|
||||
initialState:
|
||||
documentContents: |-
|
||||
void f() {
|
||||
if constexpr (true) {
|
||||
|
||||
}
|
||||
}
|
||||
selections:
|
||||
- anchor: {line: 2, character: 8}
|
||||
active: {line: 2, character: 8}
|
||||
marks: {}
|
||||
finalState:
|
||||
documentContents: |-
|
||||
void f() {
|
||||
if constexpr (true) {
|
||||
|
||||
}
|
||||
}
|
||||
selections:
|
||||
- anchor: {line: 1, character: 4}
|
||||
active: {line: 3, character: 5}
|
@ -1,24 +0,0 @@
|
||||
languageId: cpp
|
||||
command:
|
||||
version: 1
|
||||
spokenForm: take parse tree string
|
||||
action: setSelection
|
||||
targets:
|
||||
- type: primitive
|
||||
modifier: {type: containingScope, scopeType: string}
|
||||
spokenFormError: >-
|
||||
simple scope type type with id string; this is a private spoken form currently
|
||||
only for internal experimentation
|
||||
initialState:
|
||||
documentContents: |
|
||||
char* a = "hello world";
|
||||
selections:
|
||||
- anchor: {line: 0, character: 21}
|
||||
active: {line: 0, character: 21}
|
||||
marks: {}
|
||||
finalState:
|
||||
documentContents: |
|
||||
char* a = "hello world";
|
||||
selections:
|
||||
- anchor: {line: 0, character: 10}
|
||||
active: {line: 0, character: 23}
|
@ -1,23 +0,0 @@
|
||||
languageId: latex
|
||||
command:
|
||||
version: 1
|
||||
spokenForm: change comment
|
||||
action: clearAndSetSelection
|
||||
targets:
|
||||
- type: primitive
|
||||
modifier: {type: containingScope, scopeType: comment, includeSiblings: false}
|
||||
initialState:
|
||||
documentContents: |
|
||||
\iffalse
|
||||
some comment
|
||||
\fi
|
||||
selections:
|
||||
- anchor: {line: 0, character: 0}
|
||||
active: {line: 0, character: 0}
|
||||
marks: {}
|
||||
finalState:
|
||||
documentContents: |+
|
||||
|
||||
selections:
|
||||
- anchor: {line: 0, character: 0}
|
||||
active: {line: 0, character: 0}
|
@ -1,21 +0,0 @@
|
||||
languageId: latex
|
||||
command:
|
||||
version: 1
|
||||
spokenForm: change comment
|
||||
action: clearAndSetSelection
|
||||
targets:
|
||||
- type: primitive
|
||||
modifier: {type: containingScope, scopeType: comment, includeSiblings: false}
|
||||
initialState:
|
||||
documentContents: |
|
||||
\LaTeX % some comment
|
||||
selections:
|
||||
- anchor: {line: 0, character: 8}
|
||||
active: {line: 0, character: 8}
|
||||
marks: {}
|
||||
finalState:
|
||||
documentContents: |
|
||||
\LaTeX
|
||||
selections:
|
||||
- anchor: {line: 0, character: 7}
|
||||
active: {line: 0, character: 7}
|
@ -1,19 +0,0 @@
|
||||
languageId: markdown
|
||||
command:
|
||||
version: 1
|
||||
spokenForm: change comment
|
||||
action: clearAndSetSelection
|
||||
targets:
|
||||
- type: primitive
|
||||
modifier: {type: containingScope, scopeType: comment, includeSiblings: false}
|
||||
initialState:
|
||||
documentContents: <!-- hello world -->
|
||||
selections:
|
||||
- anchor: {line: 0, character: 16}
|
||||
active: {line: 0, character: 16}
|
||||
marks: {}
|
||||
finalState:
|
||||
documentContents: ""
|
||||
selections:
|
||||
- anchor: {line: 0, character: 0}
|
||||
active: {line: 0, character: 0}
|
@ -1,19 +0,0 @@
|
||||
languageId: ruby
|
||||
command:
|
||||
version: 1
|
||||
spokenForm: change comment
|
||||
action: clearAndSetSelection
|
||||
targets:
|
||||
- type: primitive
|
||||
modifier: {type: containingScope, scopeType: comment, includeSiblings: false}
|
||||
initialState:
|
||||
documentContents: "# Hello World"
|
||||
selections:
|
||||
- anchor: {line: 0, character: 9}
|
||||
active: {line: 0, character: 9}
|
||||
marks: {}
|
||||
finalState:
|
||||
documentContents: ""
|
||||
selections:
|
||||
- anchor: {line: 0, character: 0}
|
||||
active: {line: 0, character: 0}
|
@ -1,19 +0,0 @@
|
||||
languageId: ruby
|
||||
command:
|
||||
version: 1
|
||||
spokenForm: change comment
|
||||
action: clearAndSetSelection
|
||||
targets:
|
||||
- type: primitive
|
||||
modifier: {type: containingScope, scopeType: comment, includeSiblings: false}
|
||||
initialState:
|
||||
documentContents: "a = 0 # Hello World"
|
||||
selections:
|
||||
- anchor: {line: 0, character: 8}
|
||||
active: {line: 0, character: 8}
|
||||
marks: {}
|
||||
finalState:
|
||||
documentContents: "a = 0 "
|
||||
selections:
|
||||
- anchor: {line: 0, character: 6}
|
||||
active: {line: 0, character: 6}
|
@ -1,22 +0,0 @@
|
||||
languageId: ruby
|
||||
command:
|
||||
version: 1
|
||||
spokenForm: change comment
|
||||
action: clearAndSetSelection
|
||||
targets:
|
||||
- type: primitive
|
||||
modifier: {type: containingScope, scopeType: comment, includeSiblings: false}
|
||||
initialState:
|
||||
documentContents: |-
|
||||
=begin
|
||||
Hi
|
||||
=end
|
||||
selections:
|
||||
- anchor: {line: 1, character: 3}
|
||||
active: {line: 1, character: 3}
|
||||
marks: {}
|
||||
finalState:
|
||||
documentContents: ""
|
||||
selections:
|
||||
- anchor: {line: 0, character: 0}
|
||||
active: {line: 0, character: 0}
|
@ -1,19 +0,0 @@
|
||||
languageId: scala
|
||||
command:
|
||||
version: 0
|
||||
spokenForm: change if state
|
||||
action: clearAndSetSelection
|
||||
targets:
|
||||
- type: primitive
|
||||
modifier: {type: containingScope, scopeType: ifStatement, includeSiblings: false}
|
||||
initialState:
|
||||
documentContents: val test = if (true) true else false
|
||||
selections:
|
||||
- anchor: {line: 0, character: 12}
|
||||
active: {line: 0, character: 12}
|
||||
marks: {}
|
||||
finalState:
|
||||
documentContents: "val test = "
|
||||
selections:
|
||||
- anchor: {line: 0, character: 11}
|
||||
active: {line: 0, character: 11}
|
@ -1,24 +0,0 @@
|
||||
languageId: scala
|
||||
command:
|
||||
version: 0
|
||||
spokenForm: change if state
|
||||
action: clearAndSetSelection
|
||||
targets:
|
||||
- type: primitive
|
||||
modifier: {type: containingScope, scopeType: ifStatement, includeSiblings: false}
|
||||
initialState:
|
||||
documentContents: |-
|
||||
val test = if (true) {
|
||||
true
|
||||
} else {
|
||||
false
|
||||
}
|
||||
selections:
|
||||
- anchor: {line: 0, character: 12}
|
||||
active: {line: 0, character: 12}
|
||||
marks: {}
|
||||
finalState:
|
||||
documentContents: "val test = "
|
||||
selections:
|
||||
- anchor: {line: 0, character: 11}
|
||||
active: {line: 0, character: 11}
|
17
data/fixtures/scopes/c/comment.line.scope
Normal file
17
data/fixtures/scopes/c/comment.line.scope
Normal file
@ -0,0 +1,17 @@
|
||||
int a; // the comment
|
||||
---
|
||||
|
||||
[Content] =
|
||||
[Domain] = 0:7-0:21
|
||||
>--------------<
|
||||
0| int a; // the comment
|
||||
|
||||
[Removal] = 0:6-0:21
|
||||
>---------------<
|
||||
0| int a; // the comment
|
||||
|
||||
[Leading delimiter] = 0:6-0:7
|
||||
>-<
|
||||
0| int a; // the comment
|
||||
|
||||
[Insertion delimiter] = "\n"
|
19
data/fixtures/scopes/c/ifStatement.scope
Normal file
19
data/fixtures/scopes/c/ifStatement.scope
Normal file
@ -0,0 +1,19 @@
|
||||
void func() {
|
||||
if (true) { }
|
||||
}
|
||||
---
|
||||
|
||||
[Content] =
|
||||
[Domain] = 1:4-1:17
|
||||
>-------------<
|
||||
1| if (true) { }
|
||||
|
||||
[Removal] = 1:0-1:17
|
||||
>-----------------<
|
||||
1| if (true) { }
|
||||
|
||||
[Leading delimiter] = 1:0-1:4
|
||||
>----<
|
||||
1| if (true) { }
|
||||
|
||||
[Insertion delimiter] = "\n"
|
17
data/fixtures/scopes/c/string.singleLine.scope
Normal file
17
data/fixtures/scopes/c/string.singleLine.scope
Normal file
@ -0,0 +1,17 @@
|
||||
char* a = "hello world";
|
||||
---
|
||||
|
||||
[Content] =
|
||||
[Domain] = 0:10-0:23
|
||||
>-------------<
|
||||
0| char* a = "hello world";
|
||||
|
||||
[Removal] = 0:9-0:23
|
||||
>--------------<
|
||||
0| char* a = "hello world";
|
||||
|
||||
[Leading delimiter] = 0:9-0:10
|
||||
>-<
|
||||
0| char* a = "hello world";
|
||||
|
||||
[Insertion delimiter] = " "
|
10
data/fixtures/scopes/clojure/comment.line.scope
Normal file
10
data/fixtures/scopes/clojure/comment.line.scope
Normal file
@ -0,0 +1,10 @@
|
||||
;; foo
|
||||
---
|
||||
|
||||
[Content] =
|
||||
[Removal] =
|
||||
[Domain] = 0:0-0:6
|
||||
>------<
|
||||
0| ;; foo
|
||||
|
||||
[Insertion delimiter] = "\n"
|
19
data/fixtures/scopes/cpp/ifStatement.scope
Normal file
19
data/fixtures/scopes/cpp/ifStatement.scope
Normal file
@ -0,0 +1,19 @@
|
||||
void funk() {
|
||||
if constexpr (true) {}
|
||||
}
|
||||
---
|
||||
|
||||
[Content] =
|
||||
[Domain] = 1:4-1:26
|
||||
>----------------------<
|
||||
1| if constexpr (true) {}
|
||||
|
||||
[Removal] = 1:0-1:26
|
||||
>--------------------------<
|
||||
1| if constexpr (true) {}
|
||||
|
||||
[Leading delimiter] = 1:0-1:4
|
||||
>----<
|
||||
1| if constexpr (true) {}
|
||||
|
||||
[Insertion delimiter] = "\n"
|
17
data/fixtures/scopes/css/comment.block.scope
Normal file
17
data/fixtures/scopes/css/comment.block.scope
Normal file
@ -0,0 +1,17 @@
|
||||
/*
|
||||
foo
|
||||
bar
|
||||
*/
|
||||
---
|
||||
|
||||
[Content] =
|
||||
[Removal] =
|
||||
[Domain] = 0:0-3:2
|
||||
>--
|
||||
0| /*
|
||||
1| foo
|
||||
2| bar
|
||||
3| */
|
||||
--<
|
||||
|
||||
[Insertion delimiter] = "\n"
|
10
data/fixtures/scopes/css/comment.line.scope
Normal file
10
data/fixtures/scopes/css/comment.line.scope
Normal file
@ -0,0 +1,10 @@
|
||||
/* foo */
|
||||
---
|
||||
|
||||
[Content] =
|
||||
[Removal] =
|
||||
[Domain] = 0:0-0:9
|
||||
>---------<
|
||||
0| /* foo */
|
||||
|
||||
[Insertion delimiter] = "\n"
|
19
data/fixtures/scopes/css/string.singleLine.scope
Normal file
19
data/fixtures/scopes/css/string.singleLine.scope
Normal file
@ -0,0 +1,19 @@
|
||||
* {
|
||||
color: "foo"
|
||||
}
|
||||
---
|
||||
|
||||
[Content] =
|
||||
[Domain] = 1:11-1:16
|
||||
>-----<
|
||||
1| color: "foo"
|
||||
|
||||
[Removal] = 1:10-1:16
|
||||
>------<
|
||||
1| color: "foo"
|
||||
|
||||
[Leading delimiter] = 1:10-1:11
|
||||
>-<
|
||||
1| color: "foo"
|
||||
|
||||
[Insertion delimiter] = " "
|
10
data/fixtures/scopes/go/comment.line.scope
Normal file
10
data/fixtures/scopes/go/comment.line.scope
Normal file
@ -0,0 +1,10 @@
|
||||
// foo
|
||||
---
|
||||
|
||||
[Content] =
|
||||
[Removal] =
|
||||
[Domain] = 0:0-0:6
|
||||
>------<
|
||||
0| // foo
|
||||
|
||||
[Insertion delimiter] = "\n"
|
15
data/fixtures/scopes/latex/comment.block.scope
Normal file
15
data/fixtures/scopes/latex/comment.block.scope
Normal file
@ -0,0 +1,15 @@
|
||||
\iffalse
|
||||
some comment
|
||||
\fi
|
||||
---
|
||||
|
||||
[Content] =
|
||||
[Removal] =
|
||||
[Domain] = 0:0-2:3
|
||||
>--------
|
||||
0| \iffalse
|
||||
1| some comment
|
||||
2| \fi
|
||||
---<
|
||||
|
||||
[Insertion delimiter] = "\n"
|
17
data/fixtures/scopes/latex/comment.line.scope
Normal file
17
data/fixtures/scopes/latex/comment.line.scope
Normal file
@ -0,0 +1,17 @@
|
||||
\LaTeX % some comment
|
||||
---
|
||||
|
||||
[Content] =
|
||||
[Domain] = 0:7-0:21
|
||||
>--------------<
|
||||
0| \LaTeX % some comment
|
||||
|
||||
[Removal] = 0:6-0:21
|
||||
>---------------<
|
||||
0| \LaTeX % some comment
|
||||
|
||||
[Leading delimiter] = 0:6-0:7
|
||||
>-<
|
||||
0| \LaTeX % some comment
|
||||
|
||||
[Insertion delimiter] = "\n"
|
17
data/fixtures/scopes/markdown/comment.block.scope
Normal file
17
data/fixtures/scopes/markdown/comment.block.scope
Normal file
@ -0,0 +1,17 @@
|
||||
<!--
|
||||
Hello
|
||||
World
|
||||
-->
|
||||
---
|
||||
|
||||
[Content] =
|
||||
[Removal] =
|
||||
[Domain] = 0:0-3:3
|
||||
>----
|
||||
0| <!--
|
||||
1| Hello
|
||||
2| World
|
||||
3| -->
|
||||
---<
|
||||
|
||||
[Insertion delimiter] = "\n"
|
10
data/fixtures/scopes/markdown/comment.line.scope
Normal file
10
data/fixtures/scopes/markdown/comment.line.scope
Normal file
@ -0,0 +1,10 @@
|
||||
<!-- Hello World -->
|
||||
---
|
||||
|
||||
[Content] =
|
||||
[Removal] =
|
||||
[Domain] = 0:0-0:21
|
||||
>---------------------<
|
||||
0| <!-- Hello World -->
|
||||
|
||||
[Insertion delimiter] = "\n"
|
15
data/fixtures/scopes/ruby/comment.block.scope
Normal file
15
data/fixtures/scopes/ruby/comment.block.scope
Normal file
@ -0,0 +1,15 @@
|
||||
=begin
|
||||
Hi
|
||||
=end
|
||||
---
|
||||
|
||||
[Content] =
|
||||
[Removal] =
|
||||
[Domain] = 0:0-2:4
|
||||
>------
|
||||
0| =begin
|
||||
1| Hi
|
||||
2| =end
|
||||
----<
|
||||
|
||||
[Insertion delimiter] = "\n"
|
10
data/fixtures/scopes/ruby/comment.line.scope
Normal file
10
data/fixtures/scopes/ruby/comment.line.scope
Normal file
@ -0,0 +1,10 @@
|
||||
# Hello World
|
||||
---
|
||||
|
||||
[Content] =
|
||||
[Removal] =
|
||||
[Domain] = 0:0-0:13
|
||||
>-------------<
|
||||
0| # Hello World
|
||||
|
||||
[Insertion delimiter] = "\n"
|
17
data/fixtures/scopes/ruby/comment.line2.scope
Normal file
17
data/fixtures/scopes/ruby/comment.line2.scope
Normal file
@ -0,0 +1,17 @@
|
||||
a = 0 # Hello World
|
||||
---
|
||||
|
||||
[Content] =
|
||||
[Domain] = 0:6-0:19
|
||||
>-------------<
|
||||
0| a = 0 # Hello World
|
||||
|
||||
[Removal] = 0:5-0:19
|
||||
>--------------<
|
||||
0| a = 0 # Hello World
|
||||
|
||||
[Leading delimiter] = 0:5-0:6
|
||||
>-<
|
||||
0| a = 0 # Hello World
|
||||
|
||||
[Insertion delimiter] = "\n"
|
13
data/fixtures/scopes/rust/ifStatement.scope
Normal file
13
data/fixtures/scopes/rust/ifStatement.scope
Normal file
@ -0,0 +1,13 @@
|
||||
if true {}
|
||||
else {};
|
||||
---
|
||||
|
||||
[Content] =
|
||||
[Removal] =
|
||||
[Domain] = 0:0-1:7
|
||||
>-----------
|
||||
0| if true {}
|
||||
1| else {};
|
||||
-------<
|
||||
|
||||
[Insertion delimiter] = "\n"
|
17
data/fixtures/scopes/scala/ifStatement.scope
Normal file
17
data/fixtures/scopes/scala/ifStatement.scope
Normal file
@ -0,0 +1,17 @@
|
||||
val test = if (true) true else false
|
||||
---
|
||||
|
||||
[Content] =
|
||||
[Domain] = 0:11-0:36
|
||||
>-------------------------<
|
||||
0| val test = if (true) true else false
|
||||
|
||||
[Removal] = 0:10-0:36
|
||||
>--------------------------<
|
||||
0| val test = if (true) true else false
|
||||
|
||||
[Leading delimiter] = 0:10-0:11
|
||||
>-<
|
||||
0| val test = if (true) true else false
|
||||
|
||||
[Insertion delimiter] = "\n"
|
31
data/fixtures/scopes/scala/ifStatement2.scope
Normal file
31
data/fixtures/scopes/scala/ifStatement2.scope
Normal file
@ -0,0 +1,31 @@
|
||||
val test = if (true) {
|
||||
true
|
||||
} else {
|
||||
false
|
||||
}
|
||||
---
|
||||
|
||||
[Content] =
|
||||
[Domain] = 0:11-4:1
|
||||
>-----------
|
||||
0| val test = if (true) {
|
||||
1| true
|
||||
2| } else {
|
||||
3| false
|
||||
4| }
|
||||
-<
|
||||
|
||||
[Removal] = 0:10-4:1
|
||||
>------------
|
||||
0| val test = if (true) {
|
||||
1| true
|
||||
2| } else {
|
||||
3| false
|
||||
4| }
|
||||
-<
|
||||
|
||||
[Leading delimiter] = 0:10-0:11
|
||||
>-<
|
||||
0| val test = if (true) {
|
||||
|
||||
[Insertion delimiter] = "\n"
|
15
packages/common/src/scopeSupportFacets/c.ts
Normal file
15
packages/common/src/scopeSupportFacets/c.ts
Normal file
@ -0,0 +1,15 @@
|
||||
/* eslint-disable @typescript-eslint/naming-convention */
|
||||
|
||||
import {
|
||||
LanguageScopeSupportFacetMap,
|
||||
ScopeSupportFacetLevel,
|
||||
} from "./scopeSupportFacets.types";
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
const { supported, unsupported, notApplicable } = ScopeSupportFacetLevel;
|
||||
|
||||
export const cScopeSupport: LanguageScopeSupportFacetMap = {
|
||||
ifStatement: supported,
|
||||
"comment.line": supported,
|
||||
"string.singleLine": supported,
|
||||
};
|
13
packages/common/src/scopeSupportFacets/clojure.ts
Normal file
13
packages/common/src/scopeSupportFacets/clojure.ts
Normal file
@ -0,0 +1,13 @@
|
||||
/* eslint-disable @typescript-eslint/naming-convention */
|
||||
|
||||
import {
|
||||
LanguageScopeSupportFacetMap,
|
||||
ScopeSupportFacetLevel,
|
||||
} from "./scopeSupportFacets.types";
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
const { supported, unsupported, notApplicable } = ScopeSupportFacetLevel;
|
||||
|
||||
export const clojureScopeSupport: LanguageScopeSupportFacetMap = {
|
||||
"comment.line": supported,
|
||||
};
|
15
packages/common/src/scopeSupportFacets/cpp.ts
Normal file
15
packages/common/src/scopeSupportFacets/cpp.ts
Normal file
@ -0,0 +1,15 @@
|
||||
/* eslint-disable @typescript-eslint/naming-convention */
|
||||
|
||||
// import { cScopeSupport } from "./c";
|
||||
import {
|
||||
LanguageScopeSupportFacetMap,
|
||||
ScopeSupportFacetLevel,
|
||||
} from "./scopeSupportFacets.types";
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
const { supported, unsupported, notApplicable } = ScopeSupportFacetLevel;
|
||||
|
||||
export const cppScopeSupport: LanguageScopeSupportFacetMap = {
|
||||
// ...cScopeSupport,
|
||||
ifStatement: supported,
|
||||
};
|
15
packages/common/src/scopeSupportFacets/css.ts
Normal file
15
packages/common/src/scopeSupportFacets/css.ts
Normal file
@ -0,0 +1,15 @@
|
||||
/* eslint-disable @typescript-eslint/naming-convention */
|
||||
|
||||
import {
|
||||
LanguageScopeSupportFacetMap,
|
||||
ScopeSupportFacetLevel,
|
||||
} from "./scopeSupportFacets.types";
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
const { supported, unsupported, notApplicable } = ScopeSupportFacetLevel;
|
||||
|
||||
export const cssScopeSupport: LanguageScopeSupportFacetMap = {
|
||||
"comment.line": supported,
|
||||
"comment.block": supported,
|
||||
"string.singleLine": supported,
|
||||
};
|
@ -1,36 +1,77 @@
|
||||
import { cScopeSupport } from "./c";
|
||||
import { clojureScopeSupport } from "./clojure";
|
||||
import { cppScopeSupport } from "./cpp";
|
||||
import { csharpScopeSupport } from "./csharp";
|
||||
import { cssScopeSupport } from "./css";
|
||||
import { goScopeSupport } from "./go";
|
||||
import { htmlScopeSupport } from "./html";
|
||||
import { javaScopeSupport } from "./java";
|
||||
import { javascriptScopeSupport } from "./javascript";
|
||||
import { jsonScopeSupport } from "./json";
|
||||
import { pythonScopeSupport } from "./python";
|
||||
import { csharpScopeSupport } from "./csharp";
|
||||
import { jsoncScopeSupport } from "./jsonc";
|
||||
import { latexScopeSupport } from "./latex";
|
||||
import { luaScopeSupport } from "./lua";
|
||||
import { markdownScopeSupport } from "./markdown";
|
||||
import { pythonScopeSupport } from "./python";
|
||||
import { rubyScopeSupport } from "./ruby";
|
||||
import { rustScopeSupport } from "./rust";
|
||||
import { scalaScopeSupport } from "./scala";
|
||||
import { LanguageScopeSupportFacetMap } from "./scopeSupportFacets.types";
|
||||
import { scssScopeSupport } from "./scss";
|
||||
import { talonScopeSupport } from "./talon";
|
||||
import { typescriptScopeSupport } from "./typescript";
|
||||
import { typescriptreactScopeSupport } from "./typescriptreact";
|
||||
|
||||
export function getLanguageScopeSupport(
|
||||
languageId: string,
|
||||
): LanguageScopeSupportFacetMap {
|
||||
switch (languageId) {
|
||||
case "c":
|
||||
return cScopeSupport;
|
||||
case "clojure":
|
||||
return clojureScopeSupport;
|
||||
case "cpp":
|
||||
return cppScopeSupport;
|
||||
case "csharp":
|
||||
return csharpScopeSupport;
|
||||
case "css":
|
||||
return cssScopeSupport;
|
||||
case "go":
|
||||
return goScopeSupport;
|
||||
case "html":
|
||||
return htmlScopeSupport;
|
||||
case "java":
|
||||
return javaScopeSupport;
|
||||
case "latex":
|
||||
return latexScopeSupport;
|
||||
case "markdown":
|
||||
return markdownScopeSupport;
|
||||
case "javascript":
|
||||
return javascriptScopeSupport;
|
||||
case "javascriptreact":
|
||||
return javascriptScopeSupport;
|
||||
case "json":
|
||||
return jsonScopeSupport;
|
||||
case "python":
|
||||
return pythonScopeSupport;
|
||||
case "talon":
|
||||
return talonScopeSupport;
|
||||
case "typescript":
|
||||
return typescriptScopeSupport;
|
||||
case "jsonc":
|
||||
return jsoncScopeSupport;
|
||||
case "lua":
|
||||
return luaScopeSupport;
|
||||
case "python":
|
||||
return pythonScopeSupport;
|
||||
case "ruby":
|
||||
return rubyScopeSupport;
|
||||
case "rust":
|
||||
return rustScopeSupport;
|
||||
case "scala":
|
||||
return scalaScopeSupport;
|
||||
case "talon":
|
||||
return talonScopeSupport;
|
||||
case "scss":
|
||||
return scssScopeSupport;
|
||||
case "typescript":
|
||||
return typescriptScopeSupport;
|
||||
case "typescriptreact":
|
||||
return typescriptreactScopeSupport;
|
||||
}
|
||||
throw Error(`Unsupported language: '${languageId}'`);
|
||||
}
|
||||
|
13
packages/common/src/scopeSupportFacets/go.ts
Normal file
13
packages/common/src/scopeSupportFacets/go.ts
Normal file
@ -0,0 +1,13 @@
|
||||
/* eslint-disable @typescript-eslint/naming-convention */
|
||||
|
||||
import {
|
||||
LanguageScopeSupportFacetMap,
|
||||
ScopeSupportFacetLevel,
|
||||
} from "./scopeSupportFacets.types";
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
const { supported, unsupported, notApplicable } = ScopeSupportFacetLevel;
|
||||
|
||||
export const goScopeSupport: LanguageScopeSupportFacetMap = {
|
||||
"comment.line": supported,
|
||||
};
|
@ -5,7 +5,8 @@ import {
|
||||
ScopeSupportFacetLevel,
|
||||
} from "./scopeSupportFacets.types";
|
||||
|
||||
const { supported, notApplicable } = ScopeSupportFacetLevel;
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
const { supported, unsupported, notApplicable } = ScopeSupportFacetLevel;
|
||||
|
||||
export const javascriptScopeSupport: LanguageScopeSupportFacetMap = {
|
||||
list: supported,
|
||||
|
14
packages/common/src/scopeSupportFacets/javascriptreact.ts
Normal file
14
packages/common/src/scopeSupportFacets/javascriptreact.ts
Normal file
@ -0,0 +1,14 @@
|
||||
/* eslint-disable @typescript-eslint/naming-convention */
|
||||
|
||||
import { javascriptScopeSupport } from "./javascript";
|
||||
import {
|
||||
LanguageScopeSupportFacetMap,
|
||||
ScopeSupportFacetLevel,
|
||||
} from "./scopeSupportFacets.types";
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
const { supported, unsupported, notApplicable } = ScopeSupportFacetLevel;
|
||||
|
||||
export const javascriptreactScopeSupport: LanguageScopeSupportFacetMap = {
|
||||
...javascriptScopeSupport,
|
||||
};
|
14
packages/common/src/scopeSupportFacets/jsonc.ts
Normal file
14
packages/common/src/scopeSupportFacets/jsonc.ts
Normal file
@ -0,0 +1,14 @@
|
||||
/* eslint-disable @typescript-eslint/naming-convention */
|
||||
|
||||
import { jsonScopeSupport } from "./json";
|
||||
import {
|
||||
LanguageScopeSupportFacetMap,
|
||||
ScopeSupportFacetLevel,
|
||||
} from "./scopeSupportFacets.types";
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
const { supported, unsupported, notApplicable } = ScopeSupportFacetLevel;
|
||||
|
||||
export const jsoncScopeSupport: LanguageScopeSupportFacetMap = {
|
||||
...jsonScopeSupport,
|
||||
};
|
14
packages/common/src/scopeSupportFacets/latex.ts
Normal file
14
packages/common/src/scopeSupportFacets/latex.ts
Normal file
@ -0,0 +1,14 @@
|
||||
/* eslint-disable @typescript-eslint/naming-convention */
|
||||
|
||||
import {
|
||||
LanguageScopeSupportFacetMap,
|
||||
ScopeSupportFacetLevel,
|
||||
} from "./scopeSupportFacets.types";
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
const { supported, unsupported, notApplicable } = ScopeSupportFacetLevel;
|
||||
|
||||
export const latexScopeSupport: LanguageScopeSupportFacetMap = {
|
||||
"comment.line": supported,
|
||||
"comment.block": supported,
|
||||
};
|
14
packages/common/src/scopeSupportFacets/markdown.ts
Normal file
14
packages/common/src/scopeSupportFacets/markdown.ts
Normal file
@ -0,0 +1,14 @@
|
||||
/* eslint-disable @typescript-eslint/naming-convention */
|
||||
|
||||
import {
|
||||
LanguageScopeSupportFacetMap,
|
||||
ScopeSupportFacetLevel,
|
||||
} from "./scopeSupportFacets.types";
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
const { supported, unsupported, notApplicable } = ScopeSupportFacetLevel;
|
||||
|
||||
export const markdownScopeSupport: LanguageScopeSupportFacetMap = {
|
||||
"comment.line": supported,
|
||||
"comment.block": supported,
|
||||
};
|
14
packages/common/src/scopeSupportFacets/ruby.ts
Normal file
14
packages/common/src/scopeSupportFacets/ruby.ts
Normal file
@ -0,0 +1,14 @@
|
||||
/* eslint-disable @typescript-eslint/naming-convention */
|
||||
|
||||
import {
|
||||
LanguageScopeSupportFacetMap,
|
||||
ScopeSupportFacetLevel,
|
||||
} from "./scopeSupportFacets.types";
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
const { supported, unsupported, notApplicable } = ScopeSupportFacetLevel;
|
||||
|
||||
export const rubyScopeSupport: LanguageScopeSupportFacetMap = {
|
||||
"comment.line": supported,
|
||||
"comment.block": supported,
|
||||
};
|
13
packages/common/src/scopeSupportFacets/rust.ts
Normal file
13
packages/common/src/scopeSupportFacets/rust.ts
Normal file
@ -0,0 +1,13 @@
|
||||
/* eslint-disable @typescript-eslint/naming-convention */
|
||||
|
||||
import {
|
||||
LanguageScopeSupportFacetMap,
|
||||
ScopeSupportFacetLevel,
|
||||
} from "./scopeSupportFacets.types";
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
const { supported, unsupported, notApplicable } = ScopeSupportFacetLevel;
|
||||
|
||||
export const rustScopeSupport: LanguageScopeSupportFacetMap = {
|
||||
ifStatement: supported,
|
||||
};
|
13
packages/common/src/scopeSupportFacets/scala.ts
Normal file
13
packages/common/src/scopeSupportFacets/scala.ts
Normal file
@ -0,0 +1,13 @@
|
||||
/* eslint-disable @typescript-eslint/naming-convention */
|
||||
|
||||
import {
|
||||
LanguageScopeSupportFacetMap,
|
||||
ScopeSupportFacetLevel,
|
||||
} from "./scopeSupportFacets.types";
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
const { supported, unsupported, notApplicable } = ScopeSupportFacetLevel;
|
||||
|
||||
export const scalaScopeSupport: LanguageScopeSupportFacetMap = {
|
||||
ifStatement: supported,
|
||||
};
|
14
packages/common/src/scopeSupportFacets/scss.ts
Normal file
14
packages/common/src/scopeSupportFacets/scss.ts
Normal file
@ -0,0 +1,14 @@
|
||||
/* eslint-disable @typescript-eslint/naming-convention */
|
||||
|
||||
import { cssScopeSupport } from "./css";
|
||||
import {
|
||||
LanguageScopeSupportFacetMap,
|
||||
ScopeSupportFacetLevel,
|
||||
} from "./scopeSupportFacets.types";
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
const { supported, unsupported, notApplicable } = ScopeSupportFacetLevel;
|
||||
|
||||
export const scssScopeSupport: LanguageScopeSupportFacetMap = {
|
||||
...cssScopeSupport,
|
||||
};
|
@ -1,5 +1,6 @@
|
||||
/* eslint-disable @typescript-eslint/naming-convention */
|
||||
|
||||
// import { javascriptScopeSupport } from "./javascript";
|
||||
import {
|
||||
LanguageScopeSupportFacetMap,
|
||||
ScopeSupportFacetLevel,
|
||||
@ -8,6 +9,7 @@ import {
|
||||
const { supported } = ScopeSupportFacetLevel;
|
||||
|
||||
export const typescriptScopeSupport: LanguageScopeSupportFacetMap = {
|
||||
// ...javascriptScopeSupport,
|
||||
"type.variable": supported,
|
||||
"type.formalParameter": supported,
|
||||
"type.return": supported,
|
||||
|
14
packages/common/src/scopeSupportFacets/typescriptreact.ts
Normal file
14
packages/common/src/scopeSupportFacets/typescriptreact.ts
Normal file
@ -0,0 +1,14 @@
|
||||
/* eslint-disable @typescript-eslint/naming-convention */
|
||||
|
||||
import {
|
||||
LanguageScopeSupportFacetMap,
|
||||
ScopeSupportFacetLevel,
|
||||
} from "./scopeSupportFacets.types";
|
||||
import { typescriptScopeSupport } from "./typescript";
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
const { supported, unsupported, notApplicable } = ScopeSupportFacetLevel;
|
||||
|
||||
export const typescriptreactScopeSupport: LanguageScopeSupportFacetMap = {
|
||||
...typescriptScopeSupport,
|
||||
};
|
@ -121,7 +121,7 @@ export class LanguageDefinitions {
|
||||
|
||||
if (definition == null) {
|
||||
throw new Error(
|
||||
"Expected language definition entry missing for languageId " +
|
||||
"Expected language definition entry is missing for languageId " +
|
||||
languageId,
|
||||
);
|
||||
}
|
||||
|
@ -6,8 +6,8 @@ export const legacyLanguageIds = [
|
||||
"c",
|
||||
"clojure",
|
||||
"cpp",
|
||||
"css",
|
||||
"csharp",
|
||||
"css",
|
||||
"go",
|
||||
"html",
|
||||
"java",
|
||||
@ -20,9 +20,9 @@ export const legacyLanguageIds = [
|
||||
"php",
|
||||
"python",
|
||||
"ruby",
|
||||
"rust",
|
||||
"scala",
|
||||
"scss",
|
||||
"rust",
|
||||
"typescript",
|
||||
"typescriptreact",
|
||||
"xml",
|
||||
|
@ -133,7 +133,6 @@ const ifStatementMatcher = matcher(ifStatementFinder);
|
||||
const nodeMatchers: Partial<
|
||||
Record<SimpleScopeTypeType, NodeMatcherAlternative>
|
||||
> = {
|
||||
comment: "comment",
|
||||
map: "map_lit",
|
||||
|
||||
collectionKey: matcher(mapParityNodeFinder(0)),
|
||||
@ -164,8 +163,6 @@ const nodeMatchers: Partial<
|
||||
// A list is either a vector literal or a quoted list literal
|
||||
list: ["vec_lit", "quoting_lit.list_lit"],
|
||||
|
||||
string: "str_lit",
|
||||
|
||||
functionCall: functionCallPattern,
|
||||
functionCallee: chainedMatcher([
|
||||
functionCallFinder,
|
||||
|
@ -79,10 +79,7 @@ const nodeMatchers: Partial<
|
||||
"union_specifier[name]",
|
||||
"function_definition[declarator][declarator][namespace]", // void ClassName::method() {}
|
||||
],
|
||||
ifStatement: "if_statement",
|
||||
["private.switchStatementSubject"]: "switch_statement[condition][value]",
|
||||
string: "string_literal",
|
||||
comment: "comment",
|
||||
anonymousFunction: "lambda_expression",
|
||||
list: "initializer_list",
|
||||
functionCall: ["call_expression", "declaration.init_declarator!"],
|
||||
|
@ -52,10 +52,10 @@ export const languageMatchers: Record<
|
||||
Partial<Record<SimpleScopeTypeType, NodeMatcher>>
|
||||
> = {
|
||||
c: cpp,
|
||||
cpp,
|
||||
css: scss,
|
||||
csharp,
|
||||
clojure,
|
||||
cpp,
|
||||
csharp,
|
||||
css: scss,
|
||||
go,
|
||||
java,
|
||||
latex,
|
||||
@ -63,9 +63,9 @@ export const languageMatchers: Record<
|
||||
php,
|
||||
python,
|
||||
ruby,
|
||||
rust,
|
||||
scala,
|
||||
scss,
|
||||
rust,
|
||||
};
|
||||
|
||||
function matcherIncludeSiblings(matcher: NodeMatcher): NodeMatcher {
|
||||
|
@ -6,7 +6,6 @@ import { getNodeInternalRange, getNodeRange } from "../util/nodeSelectors";
|
||||
import { LegacyLanguageId } from "./LegacyLanguageId";
|
||||
import { getNodeMatcher } from "./getNodeMatcher";
|
||||
import { stringTextFragmentExtractor as rubyStringTextFragmentExtractor } from "./ruby";
|
||||
import { stringTextFragmentExtractor as scssStringTextFragmentExtractor } from "./scss";
|
||||
|
||||
export type TextFragmentExtractor = (
|
||||
node: SyntaxNode,
|
||||
@ -104,28 +103,8 @@ export default function getTextFragmentExtractor(
|
||||
return textFragmentExtractors[languageId as LegacyLanguageId];
|
||||
}
|
||||
|
||||
// NB: For now when we want use the entire file as a text fragment we just
|
||||
// return null so that the extractor uses it. In the future we should probably
|
||||
// make a fragment extractor which just pulls out the whole document itself
|
||||
type FullDocumentTextFragmentExtractor = null;
|
||||
const fullDocumentTextFragmentExtractor = null;
|
||||
|
||||
const textFragmentExtractors: Record<
|
||||
LegacyLanguageId,
|
||||
TextFragmentExtractor | FullDocumentTextFragmentExtractor
|
||||
> = {
|
||||
c: constructDefaultTextFragmentExtractor("c"),
|
||||
clojure: constructDefaultTextFragmentExtractor(
|
||||
"clojure",
|
||||
constructHackedStringTextFragmentExtractor("clojure"),
|
||||
),
|
||||
cpp: constructDefaultTextFragmentExtractor("cpp"),
|
||||
csharp: constructDefaultTextFragmentExtractor("csharp"),
|
||||
css: constructDefaultTextFragmentExtractor(
|
||||
"css",
|
||||
scssStringTextFragmentExtractor,
|
||||
),
|
||||
latex: fullDocumentTextFragmentExtractor,
|
||||
const textFragmentExtractors: Record<LegacyLanguageId, TextFragmentExtractor> =
|
||||
{
|
||||
ruby: constructDefaultTextFragmentExtractor(
|
||||
"ruby",
|
||||
rubyStringTextFragmentExtractor,
|
||||
@ -134,9 +113,5 @@ const textFragmentExtractors: Record<
|
||||
"scala",
|
||||
constructHackedStringTextFragmentExtractor("scala"),
|
||||
),
|
||||
scss: constructDefaultTextFragmentExtractor(
|
||||
"scss",
|
||||
scssStringTextFragmentExtractor,
|
||||
),
|
||||
rust: constructDefaultTextFragmentExtractor("rust"),
|
||||
};
|
||||
|
@ -201,8 +201,6 @@ const nodeMatchers: Partial<
|
||||
|
||||
collectionItem: matcher(patternFinder("enum_item"), extractItemContent),
|
||||
|
||||
comment: ["block_comment", "line_comment"],
|
||||
|
||||
part: "part",
|
||||
chapter: "chapter",
|
||||
section: "section",
|
||||
|
@ -147,7 +147,6 @@ const nodeMatchers: Partial<
|
||||
1,
|
||||
),
|
||||
string: ["raw_string_literal", "string_literal"],
|
||||
ifStatement: ["if_expression", "if_let_expression"],
|
||||
condition: cascadingMatcher(
|
||||
patternMatcher("while_expression[condition]", "if_expression[condition]"),
|
||||
matcher(
|
||||
|
@ -21,8 +21,6 @@ const nodeMatchers: Partial<
|
||||
"trait_definition[name]",
|
||||
],
|
||||
|
||||
ifStatement: "if_expression",
|
||||
|
||||
string: ["interpolated_string_expression", "string"],
|
||||
comment: "comment",
|
||||
|
||||
|
@ -17,7 +17,6 @@ import {
|
||||
import {
|
||||
childRangeSelector,
|
||||
delimitedSelector,
|
||||
getNodeRange,
|
||||
simpleSelectionExtractor,
|
||||
} from "../util/nodeSelectors";
|
||||
|
||||
@ -118,12 +117,10 @@ const nodeMatchers: Partial<
|
||||
childRangeSelector([], ["attribute_name", "string_value"]),
|
||||
),
|
||||
),
|
||||
string: "string_value",
|
||||
functionCall: "call_expression",
|
||||
functionCallee: "call_expression.function_name!",
|
||||
namedFunction: ["mixin_statement", "function_statement"],
|
||||
functionName: ["mixin_statement.name!", "function_statement.name!"],
|
||||
comment: ["comment", "single_line_comment"],
|
||||
argumentOrParameter: cascadingMatcher(
|
||||
matcher(
|
||||
patternFinder("arguments.*!", "parameters.*!"),
|
||||
@ -167,14 +164,3 @@ const nodeMatchers: Partial<
|
||||
};
|
||||
|
||||
export const patternMatchers = createPatternMatchers(nodeMatchers);
|
||||
|
||||
export function stringTextFragmentExtractor(
|
||||
node: SyntaxNode,
|
||||
_selection: SelectionWithEditor,
|
||||
) {
|
||||
if (node.type === "string_value") {
|
||||
return getNodeRange(node);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
4
queries/c.scm
Normal file
4
queries/c.scm
Normal file
@ -0,0 +1,4 @@
|
||||
(if_statement) @ifStatement
|
||||
|
||||
(string_literal) @string @textFragment
|
||||
(comment) @comment @textFragment
|
3
queries/clojure.scm
Normal file
3
queries/clojure.scm
Normal file
@ -0,0 +1,3 @@
|
||||
(comment) @comment @textFragment
|
||||
|
||||
(str_lit) @string @textFragment
|
1
queries/cpp.scm
Normal file
1
queries/cpp.scm
Normal file
@ -0,0 +1 @@
|
||||
;; import c.scm
|
3
queries/css.scm
Normal file
3
queries/css.scm
Normal file
@ -0,0 +1,3 @@
|
||||
(string_value) @string @textFragment
|
||||
|
||||
(comment) @comment @textFragment
|
4
queries/latex.scm
Normal file
4
queries/latex.scm
Normal file
@ -0,0 +1,4 @@
|
||||
[
|
||||
(block_comment)
|
||||
(line_comment)
|
||||
] @comment
|
4
queries/rust.scm
Normal file
4
queries/rust.scm
Normal file
@ -0,0 +1,4 @@
|
||||
[
|
||||
(if_expression)
|
||||
(if_let_expression)
|
||||
] @ifStatement
|
1
queries/scala.scm
Normal file
1
queries/scala.scm
Normal file
@ -0,0 +1 @@
|
||||
(if_expression) @ifStatement
|
3
queries/scss.scm
Normal file
3
queries/scss.scm
Normal file
@ -0,0 +1,3 @@
|
||||
;; import css.scm
|
||||
|
||||
(single_line_comment) @comment @textFragment
|
Loading…
Reference in New Issue
Block a user