-
-
Notifications
You must be signed in to change notification settings - Fork 82
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Started implementing a new scope handler test representation ``` [Content] const name = "Hello world"; ^^^^^^^^^^^^^ ``` Originally I was thinking of doing `^` for each character. That worked fine until @pokey asked the question about empty ranges which we actually has in a few places. So I switch to a multiline representation of `[---]` where the empty range would be `[]`. ``` [Content] function myFunk() { [------------------- } -] ``` I do wonder if we want to start multiline ranges above the source code and end it below. Makes it so the code is actually inside the range endings. ``` [Content] [------------------- function myFunk() { } -] ``` Relevant issues #1524 #2010 ## 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: pre-commit-ci-lite[bot] <117423508+pre-commit-ci-lite[bot]@users.noreply.github.com> Co-authored-by: Pokey Rule <755842+pokey@users.noreply.github.com>
- Loading branch information
1 parent
740e3ef
commit 43cf0da
Showing
32 changed files
with
1,344 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 15 additions & 0 deletions
15
packages/common/src/scopeSupportFacets/getLanguageScopeSupport.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import { htmlScopeSupport } from "./html"; | ||
import { javascriptScopeSupport } from "./javascript"; | ||
import { LanguageScopeSupportFacetMap } from "./scopeSupportFacets.types"; | ||
|
||
export function getLanguageScopeSupport( | ||
languageId: string, | ||
): LanguageScopeSupportFacetMap { | ||
switch (languageId) { | ||
case "javascript": | ||
return javascriptScopeSupport; | ||
case "html": | ||
return htmlScopeSupport; | ||
} | ||
throw Error(`Unsupported language: '${languageId}'`); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import { | ||
LanguageScopeSupportFacetMap, | ||
ScopeSupportFacetLevel, | ||
} from "./scopeSupportFacets.types"; | ||
|
||
const { supported, notApplicable } = ScopeSupportFacetLevel; | ||
|
||
export const htmlScopeSupport: LanguageScopeSupportFacetMap = { | ||
["key.attribute"]: supported, | ||
["tags"]: supported, | ||
|
||
namedFunction: notApplicable, | ||
["name.assignment"]: notApplicable, | ||
["key.mapPair"]: notApplicable, | ||
["key.mapPair.iteration"]: notApplicable, | ||
["value.mapPair"]: notApplicable, | ||
["value.mapPair.iteration"]: notApplicable, | ||
["value.assignment"]: notApplicable, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import { | ||
LanguageScopeSupportFacetMap, | ||
ScopeSupportFacetLevel, | ||
} from "./scopeSupportFacets.types"; | ||
|
||
const { supported, notApplicable } = ScopeSupportFacetLevel; | ||
|
||
export const javascriptScopeSupport: LanguageScopeSupportFacetMap = { | ||
namedFunction: supported, | ||
["name.assignment"]: supported, | ||
["key.mapPair"]: supported, | ||
["key.mapPair.iteration"]: supported, | ||
["value.mapPair"]: supported, | ||
["value.mapPair.iteration"]: supported, | ||
["value.assignment"]: supported, | ||
|
||
["key.attribute"]: notApplicable, | ||
["tags"]: notApplicable, | ||
}; |
48 changes: 48 additions & 0 deletions
48
packages/common/src/scopeSupportFacets/scopeSupportFacetInfos.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import { | ||
ScopeSupportFacet, | ||
ScopeSupportFacetInfo, | ||
} from "./scopeSupportFacets.types"; | ||
|
||
export const scopeSupportFacetInfos: Record< | ||
ScopeSupportFacet, | ||
ScopeSupportFacetInfo | ||
> = { | ||
namedFunction: { | ||
description: "A named function", | ||
scopeType: "namedFunction", | ||
}, | ||
["name.assignment"]: { | ||
description: "Name(LHS) of an assignment", | ||
scopeType: "name", | ||
}, | ||
["key.attribute"]: { | ||
description: "Key(LHS) of an attribute", | ||
scopeType: "collectionKey", | ||
}, | ||
["key.mapPair"]: { | ||
description: "Key(LHS) of a map pair", | ||
scopeType: "collectionKey", | ||
}, | ||
["key.mapPair.iteration"]: { | ||
description: "Iteration of map pair keys", | ||
scopeType: "collectionKey", | ||
isIteration: true, | ||
}, | ||
["value.assignment"]: { | ||
description: "Value(RHS) of an assignment", | ||
scopeType: "value", | ||
}, | ||
["value.mapPair"]: { | ||
description: "Key(RHS) of a map pair", | ||
scopeType: "value", | ||
}, | ||
["value.mapPair.iteration"]: { | ||
description: "Iteration of map pair values", | ||
scopeType: "value", | ||
isIteration: true, | ||
}, | ||
["tags"]: { | ||
description: "Both tags in an xml element", | ||
scopeType: "xmlBothTags", | ||
}, | ||
}; |
80 changes: 80 additions & 0 deletions
80
packages/common/src/scopeSupportFacets/scopeSupportFacets.types.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
import { SimpleScopeTypeType } from "../types/command/PartialTargetDescriptor.types"; | ||
|
||
const scopeSupportFacets = [ | ||
// "list", | ||
// "list.interior", | ||
// "map", | ||
// "map.interior", | ||
// "collectionKey", | ||
"namedFunction", | ||
// "namedFunction.interior", | ||
// "functionName", | ||
// "anonymousFunction", | ||
// "anonymousFunction.interior", | ||
"name.assignment", | ||
"key.attribute", | ||
"key.mapPair", | ||
"key.mapPair.iteration", | ||
"value.assignment", | ||
"value.mapPair", | ||
"value.mapPair.iteration", | ||
// "value.assignment.removal", | ||
// "value.return", | ||
// "value.return.removal", | ||
// "value.collectionItem", | ||
// "value.collectionItem.removal", | ||
// "statement", | ||
// "ifStatement", | ||
// "condition.if", | ||
// "condition.while", | ||
// "condition.doWhile", | ||
// "condition.for", | ||
// "condition.ternary", | ||
// "branch", | ||
// "comment.line", | ||
// "comment.block", | ||
// "string.singleLine", | ||
// "string.multiLine", | ||
// "textFragment", | ||
// "functionCall", | ||
// "functionCallee", | ||
// "argumentOrParameter.argument", | ||
// "argumentOrParameter.argument.removal", | ||
// "argumentOrParameter.parameter", | ||
// "argumentOrParameter.parameter.removal", | ||
// "class", | ||
// "class.interior", | ||
// "className", | ||
// "type", | ||
"tags", | ||
] as const; | ||
|
||
const textualScopeSupportFacets = [ | ||
"character", | ||
"word", | ||
"token", | ||
"line", | ||
"paragraph", | ||
"document", | ||
] as const; | ||
|
||
export interface ScopeSupportFacetInfo { | ||
readonly description: string; | ||
readonly scopeType: SimpleScopeTypeType; | ||
readonly isIteration?: boolean; | ||
} | ||
|
||
export enum ScopeSupportFacetLevel { | ||
supported, | ||
unsupported, | ||
notApplicable, | ||
} | ||
|
||
export type ScopeSupportFacet = (typeof scopeSupportFacets)[number]; | ||
|
||
export type TextualScopeSupportFacet = | ||
(typeof textualScopeSupportFacets)[number]; | ||
|
||
export type LanguageScopeSupportFacetMap = Partial< | ||
Record<ScopeSupportFacet, ScopeSupportFacetLevel> | ||
>; |
35 changes: 35 additions & 0 deletions
35
packages/common/src/scopeSupportFacets/textualScopeSupportFacetInfos.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import { | ||
ScopeSupportFacetInfo, | ||
TextualScopeSupportFacet, | ||
} from "./scopeSupportFacets.types"; | ||
|
||
export const textualScopeSupportFacetInfos: Record< | ||
TextualScopeSupportFacet, | ||
ScopeSupportFacetInfo | ||
> = { | ||
character: { | ||
description: "A single character in the document", | ||
scopeType: "character", | ||
}, | ||
word: { | ||
description: "A single word in a token", | ||
scopeType: "word", | ||
}, | ||
token: { | ||
description: "A single token in the document", | ||
scopeType: "token", | ||
}, | ||
line: { | ||
description: "A single line in the document", | ||
scopeType: "line", | ||
}, | ||
paragraph: { | ||
description: | ||
"A single paragraph(contiguous block of lines) in the document", | ||
scopeType: "paragraph", | ||
}, | ||
document: { | ||
description: "The entire document", | ||
scopeType: "document", | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 20 additions & 0 deletions
20
packages/cursorless-vscode-e2e/src/suite/fixtures/scopes/html/key.attribute.scope
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<div id="root"></div> | ||
--- | ||
|
||
[Content] = 0:5-0:7 | ||
0| <div id="root"></div> | ||
>--< | ||
|
||
[Removal] = 0:5-0:8 | ||
0| <div id="root"></div> | ||
>---< | ||
|
||
[Trailing delimiter] = 0:7-0:8 | ||
0| <div id="root"></div> | ||
>-< | ||
|
||
[Domain] = 0:5-0:14 | ||
0| <div id="root"></div> | ||
>---------< | ||
|
||
[Insertion delimiter] = " " |
20 changes: 20 additions & 0 deletions
20
packages/cursorless-vscode-e2e/src/suite/fixtures/scopes/html/tags.scope
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<div>hello</div> | ||
--- | ||
|
||
[.1 Content] = | ||
[.1 Removal] = 0:0-0:5 | ||
0| <div>hello</div> | ||
>-----< | ||
|
||
[.1 Insertion delimiter] = " " | ||
|
||
[.2 Content] = | ||
[.2 Removal] = 0:10-0:16 | ||
0| <div>hello</div> | ||
>------< | ||
|
||
[.2 Insertion delimiter] = " " | ||
|
||
[Domain] = 0:0-0:16 | ||
0| <div>hello</div> | ||
>----------------< |
7 changes: 7 additions & 0 deletions
7
...es/cursorless-vscode-e2e/src/suite/fixtures/scopes/javascript/key.mapPair.iteration.scope
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ value: 123 } | ||
--- | ||
|
||
[Range] = | ||
[Domain] = 0:1-0:13 | ||
0| { value: 123 } | ||
>------------< |
20 changes: 20 additions & 0 deletions
20
packages/cursorless-vscode-e2e/src/suite/fixtures/scopes/javascript/key.mapPair.scope
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
{ value: 123 } | ||
--- | ||
|
||
[Content] = 0:2-0:7 | ||
0| { value: 123 } | ||
>-----< | ||
|
||
[Removal] = 0:2-0:9 | ||
0| { value: 123 } | ||
>-------< | ||
|
||
[Trailing delimiter] = 0:7-0:9 | ||
0| { value: 123 } | ||
>--< | ||
|
||
[Domain] = 0:2-0:12 | ||
0| { value: 123 } | ||
>----------< | ||
|
||
[Insertion delimiter] = " " |
Oops, something went wrong.