Skip to content

Commit 15bfde5

Browse files
Added more scope support facets (#2102)
This pull request has these goals: 1. To flesh out the available facets and their definitions 2. To provide one example scope fixture of each facet 3. Update the domain of for each loops name/value/type 4. Update domain of iteration scope for formal arguments Once the above is done I'm going to do the bulk fixture recorder we talked about to fill in the other languages. ## 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 --------- Co-authored-by: Pokey Rule <[email protected]>
1 parent 730349d commit 15bfde5

File tree

95 files changed

+2571
-94
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

95 files changed

+2571
-94
lines changed
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,27 @@
11
import { htmlScopeSupport } from "./html";
2+
import { javaScopeSupport } from "./java";
23
import { javascriptScopeSupport } from "./javascript";
4+
import { pythonScopeSupport } from "./python";
35
import { LanguageScopeSupportFacetMap } from "./scopeSupportFacets.types";
6+
import { talonScopeSupport } from "./talon";
7+
import { typescriptScopeSupport } from "./typescript";
48

59
export function getLanguageScopeSupport(
610
languageId: string,
711
): LanguageScopeSupportFacetMap {
812
switch (languageId) {
913
case "javascript":
1014
return javascriptScopeSupport;
15+
case "typescript":
16+
return typescriptScopeSupport;
17+
case "java":
18+
return javaScopeSupport;
19+
case "python":
20+
return pythonScopeSupport;
1121
case "html":
1222
return htmlScopeSupport;
23+
case "talon":
24+
return talonScopeSupport;
1325
}
1426
throw Error(`Unsupported language: '${languageId}'`);
1527
}
Lines changed: 63 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
/* eslint-disable @typescript-eslint/naming-convention */
2+
13
import {
24
LanguageScopeSupportFacetMap,
35
ScopeSupportFacetLevel,
@@ -6,14 +8,67 @@ import {
68
const { supported, notApplicable } = ScopeSupportFacetLevel;
79

810
export const htmlScopeSupport: LanguageScopeSupportFacetMap = {
9-
["key.attribute"]: supported,
10-
["tags"]: supported,
11+
element: supported,
12+
tags: supported,
13+
startTag: supported,
14+
endTag: supported,
15+
attribute: supported,
16+
"key.attribute": supported,
17+
"value.attribute": supported,
18+
"comment.block": supported,
1119

20+
"argument.actual": notApplicable,
21+
"argument.actual.iteration": notApplicable,
22+
"argument.formal": notApplicable,
23+
"argument.formal.iteration": notApplicable,
24+
"branch.if": notApplicable,
25+
"branch.switchCase": notApplicable,
26+
"branch.try": notApplicable,
27+
"comment.line": notApplicable,
28+
"condition.doWhile": notApplicable,
29+
"condition.for": notApplicable,
30+
"condition.if": notApplicable,
31+
"condition.switchCase": notApplicable,
32+
"condition.ternary": notApplicable,
33+
"condition.while": notApplicable,
34+
"functionCall.constructor": notApplicable,
35+
"functionCallee.constructor": notApplicable,
36+
"key.mapPair.iteration": notApplicable,
37+
"key.mapPair": notApplicable,
38+
"name.assignment": notApplicable,
39+
"name.class": notApplicable,
40+
"name.field": notApplicable,
41+
"name.foreach": notApplicable,
42+
"name.function": notApplicable,
43+
"namedFunction.method": notApplicable,
44+
"string.multiLine": notApplicable,
45+
"string.singleLine": notApplicable,
46+
"type.assignment": notApplicable,
47+
"type.field": notApplicable,
48+
"type.foreach": notApplicable,
49+
"type.formalParameter": notApplicable,
50+
"type.interface": notApplicable,
51+
"type.return": notApplicable,
52+
"value.assignment": notApplicable,
53+
"value.field": notApplicable,
54+
"value.foreach": notApplicable,
55+
"value.mapPair.iteration": notApplicable,
56+
"value.mapPair": notApplicable,
57+
"value.return.lambda": notApplicable,
58+
"value.return": notApplicable,
59+
anonymousFunction: notApplicable,
60+
class: notApplicable,
61+
className: notApplicable,
62+
command: notApplicable,
63+
fieldAccess: notApplicable,
64+
functionCall: notApplicable,
65+
functionCallee: notApplicable,
66+
functionName: notApplicable,
67+
ifStatement: notApplicable,
68+
list: notApplicable,
69+
map: notApplicable,
1270
namedFunction: notApplicable,
13-
["name.assignment"]: notApplicable,
14-
["key.mapPair"]: notApplicable,
15-
["key.mapPair.iteration"]: notApplicable,
16-
["value.mapPair"]: notApplicable,
17-
["value.mapPair.iteration"]: notApplicable,
18-
["value.assignment"]: notApplicable,
71+
regularExpression: notApplicable,
72+
statement: notApplicable,
73+
switchStatementSubject: notApplicable,
1974
};
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
/* eslint-disable @typescript-eslint/naming-convention */
2+
3+
import {
4+
LanguageScopeSupportFacetMap,
5+
ScopeSupportFacetLevel,
6+
} from "./scopeSupportFacets.types";
7+
8+
const { supported, notApplicable } = ScopeSupportFacetLevel;
9+
10+
export const javaScopeSupport: LanguageScopeSupportFacetMap = {
11+
"name.foreach": supported,
12+
"value.foreach": supported,
13+
"type.foreach": supported,
14+
15+
element: notApplicable,
16+
tags: notApplicable,
17+
attribute: notApplicable,
18+
"key.attribute": notApplicable,
19+
"value.attribute": notApplicable,
20+
};
Lines changed: 80 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
/* eslint-disable @typescript-eslint/naming-convention */
2+
13
import {
24
LanguageScopeSupportFacetMap,
35
ScopeSupportFacetLevel,
@@ -6,14 +8,83 @@ import {
68
const { supported, notApplicable } = ScopeSupportFacetLevel;
79

810
export const javascriptScopeSupport: LanguageScopeSupportFacetMap = {
11+
list: supported,
12+
map: supported,
13+
statement: supported,
14+
ifStatement: supported,
15+
regularExpression: supported,
16+
switchStatementSubject: supported,
17+
fieldAccess: supported,
18+
19+
class: supported,
20+
className: supported,
21+
922
namedFunction: supported,
10-
["name.assignment"]: supported,
11-
["key.mapPair"]: supported,
12-
["key.mapPair.iteration"]: supported,
13-
["value.mapPair"]: supported,
14-
["value.mapPair.iteration"]: supported,
15-
["value.assignment"]: supported,
16-
17-
["key.attribute"]: notApplicable,
18-
["tags"]: notApplicable,
23+
"namedFunction.method": supported,
24+
anonymousFunction: supported,
25+
functionName: supported,
26+
27+
functionCall: supported,
28+
"functionCall.constructor": supported,
29+
functionCallee: supported,
30+
"functionCallee.constructor": supported,
31+
32+
"argument.actual": supported,
33+
"argument.actual.iteration": supported,
34+
"argument.formal": supported,
35+
"argument.formal.iteration": supported,
36+
37+
"comment.line": supported,
38+
"comment.block": supported,
39+
40+
"string.singleLine": supported,
41+
"string.multiLine": supported,
42+
43+
"branch.if": supported,
44+
"branch.if.iteration": supported,
45+
"branch.try": supported,
46+
"branch.switchCase": supported,
47+
"branch.switchCase.iteration": supported,
48+
"branch.ternary": supported,
49+
50+
"condition.if": supported,
51+
"condition.while": supported,
52+
"condition.doWhile": supported,
53+
"condition.for": supported,
54+
"condition.ternary": supported,
55+
"condition.switchCase": supported,
56+
57+
"name.foreach": supported,
58+
"name.assignment": supported,
59+
"name.assignment.pattern": supported,
60+
"name.function": supported,
61+
"name.class": supported,
62+
"name.field": supported,
63+
64+
"key.mapPair": supported,
65+
"key.mapPair.iteration": supported,
66+
67+
"value.mapPair": supported,
68+
"value.mapPair.iteration": supported,
69+
"value.assignment": supported,
70+
"value.foreach": supported,
71+
"value.return": supported,
72+
"value.return.lambda": supported,
73+
"value.field": supported,
74+
75+
element: supported,
76+
tags: supported,
77+
startTag: supported,
78+
endTag: supported,
79+
attribute: supported,
80+
"key.attribute": supported,
81+
"value.attribute": supported,
82+
83+
"type.assignment": notApplicable,
84+
"type.formalParameter": notApplicable,
85+
"type.return": notApplicable,
86+
"type.field": notApplicable,
87+
"type.foreach": notApplicable,
88+
"type.interface": notApplicable,
89+
command: notApplicable,
1990
};
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
/* eslint-disable @typescript-eslint/naming-convention */
2+
3+
import {
4+
LanguageScopeSupportFacetMap,
5+
ScopeSupportFacetLevel,
6+
} from "./scopeSupportFacets.types";
7+
8+
const { supported, supportedLegacy, notApplicable } = ScopeSupportFacetLevel;
9+
10+
export const pythonScopeSupport: LanguageScopeSupportFacetMap = {
11+
"name.foreach": supported,
12+
"value.foreach": supported,
13+
14+
"argument.actual": supportedLegacy,
15+
"argument.actual.iteration": supportedLegacy,
16+
"argument.formal": supportedLegacy,
17+
"argument.formal.iteration": supportedLegacy,
18+
19+
element: notApplicable,
20+
tags: notApplicable,
21+
attribute: notApplicable,
22+
"key.attribute": notApplicable,
23+
"value.attribute": notApplicable,
24+
};

0 commit comments

Comments
 (0)