-
-
Notifications
You must be signed in to change notification settings - Fork 84
Scope tests #2053
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Scope tests #2053
Changes from all commits
6ac7ea6
9bc6d8a
8326276
5feb0cf
6cd7cc0
eac4b30
fcef5ec
0348ae4
dde8a77
9f79367
33263bb
91a5fc2
9123d4b
ec2004c
a1e62ea
fcefb46
191454f
5814cd5
e3753b3
7dcde95
c5d8fdb
071e815
c6b8aaf
b756723
9965927
5e76ff0
1995cde
b93893e
f45a753
d5d4c28
473a084
ee9fa80
2f8dfa2
bf70406
bf5e187
f2b63d8
9f9de74
fc63d43
cbd156f
653354e
fee4588
1a96826
0e70883
ed21c4d
f783cb1
4c39f55
963675e
c5da832
ef8d452
66669f2
6c38cc3
eb348ba
2f51f65
459761c
c096e8a
ac90914
da04e03
637d8ea
aa05a65
4f703a4
35718a3
12e7588
b0f4fef
cca1d21
06d00b4
b8c2ade
5f1d178
93d36d0
b8a80a8
7adcef6
cfebfd9
72ef3f5
d427431
616988e
2d8c499
008f4ce
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
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}'`); | ||
} |
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, | ||
}; |
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, | ||
}; |
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", | ||
}, | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
import { SimpleScopeTypeType } from "../types/command/PartialTargetDescriptor.types"; | ||
|
||
const scopeSupportFacets = [ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I do feel like all of these could be their own fine-grained scope. I wonder if we think about moving in that direction sooner rather than later There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't quite follow what you're suggesting? What exactly do you want to make more fine grained? I definitely prefer them fine grained There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Eg There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Totally agree |
||
// "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; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What's going to happen when we want to test "round"? That's not a simple scope type There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I just copied the interface from your issue. We can make it a scope type instead? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe ok for the time being. I wonder if we create a utility function to make it more ergonomic once we need to support complex scopes. |
||
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> | ||
>; |
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", | ||
}, | ||
}; |
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] = " " |
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> | ||
>----------------< |
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 } | ||
>------------< |
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] = " " |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this isn't true. JSX is valid in JS. Shall we just mark it unsupported / leave it undefined for now?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was thinking that we should test all jsx under javascriptreact and not javascript. I would leave it undefined if anything. Saying that it's unsupported is not true either.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm. Probably fine for now. At some point we should prob figure out how to automatically run tests for all langs where they're applicable, eg run our js tests in ts, etc. We could maybe make subsets of languages and then define a way to import tests from one language to another. But we can do that in a follow-up