-
-
Notifications
You must be signed in to change notification settings - Fork 85
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
Scope tests #2053
Conversation
ests' of github.com:
As discussed in original issue, we'd like to remove the brackets when it's a single-line range. Why not just use the originally suggested format, modulo the notion that we do one range type per section?
I think that makes sense if there are only two lines, but what happens if there are more lines? Do the middle ones go above or below? I think I'd lean toward consistency |
It's just a question about how we would represent an empty range?
the lines outside of the range would not be affected by this.
vs
|
By "original format" I mean that specified in the Examples section of the description of #1524, just modified so that
no I don't mean lines outside range, I mean lines inside range. But I guess we can just leave out the annotations there because we know the range is contiguous? eg
I think it's an interesting idea, tho I wonder if we drop a bunch of the I also wonder if there's some ambiguity here as there's no marker distinguishing annotation lines from code lines, and we're no longer following alternation convention |
That was what I was thinking. As you said it's a contiguous range. We can of course extend the top line all the way to the right if we think that is a better indicator? edit: This format also works out quite nicely when we have leading and trailing delimiters with empty lines
|
@pokey I have updated the fixture files. |
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.
Just had a quick look through a few of the fixture files, and left a few comments. Lmk if you want me to review the rest
packages/cursorless-vscode-e2e/src/suite/fixtures/scopes/javascript/assignment.name.scope
Outdated
Show resolved
Hide resolved
packages/cursorless-vscode-e2e/src/suite/fixtures/scopes/javascript/assignment.name.scope
Outdated
Show resolved
Hide resolved
packages/cursorless-vscode-e2e/src/suite/fixtures/scopes/javascript/assignment.value.scope
Outdated
Show resolved
Hide resolved
packages/cursorless-vscode-e2e/src/suite/fixtures/scopes/javascript/function.scope
Outdated
Show resolved
Hide resolved
packages/cursorless-vscode-e2e/src/suite/fixtures/scopes/javascript/function.scope
Outdated
Show resolved
Hide resolved
packages/cursorless-vscode-e2e/src/suite/fixtures/scopes/javascript/line.scope
Outdated
Show resolved
Hide resolved
packages/cursorless-vscode-e2e/src/suite/fixtures/scopes/javascript/line.scope
Outdated
Show resolved
Hide resolved
packages/cursorless-vscode-e2e/src/suite/fixtures/scopes/javascript/line.scope
Outdated
Show resolved
Hide resolved
packages/cursorless-vscode-e2e/src/suite/fixtures/scopes/javascript/line.scope
Outdated
Show resolved
Hide resolved
Do we want iteration scope in these fixtures? Or maybe that should be a separate fixture? |
Hmm. Not sure. Maybe separate fixture? I wonder if iteration scope for each scope should be its own facet. Not a bad idea, to make people think about iteration scope for scopes for which it matters |
Yes I was thinking of separate facets. Probably a good idea? |
Yeah let's go with separate facets 👍 |
@pokey Iterations scope facet and fixtures added |
|
||
export const htmlSupport: LanguageScopeSupportFacetMap = { | ||
["key.attribute"]: supported, | ||
["tags.element"]: supported, |
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.
Why the .element
here?
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.
We might have tags in another context in the future. I'm just trying to be thorough.
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. I guess it's a bit more future proof, tho feels like following this convention to the letter might result in some awkward names. Idk cc/ @josharian
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.
idk either
how immutable do we need these facets to be? can we lower the cost of mistakes sufficiently that it doesn't matter much?
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.
Were gonna have a lot of files with these facets as their name so it's not gonna be that easy to change them, but also definitely not impossible.
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 guess a simple rename should handle all the typescript refs, and then we could easily write a script that moves the test fixtures
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.
A bit annoying having to do a script, but definitely doable
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.
Update from meet-up: let's go with just tags
. It's ok to have the general thing and then sub-facets as well
packages/cursorless-vscode-e2e/src/suite/fixtures/scopes/html/tags.element.scope
Outdated
Show resolved
Hide resolved
[#1 Range] = | ||
[#1 Domain] = 0:0-0:14 | ||
0| { value: 123 } | ||
>--------------< |
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.
Huh. Technically this iteration scope is not for this facet. Not sure there's much we can do about that tho 🤷♂️
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 don't think so. This would be a reason to have more fine grained scopes as well.
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.
Yeah fair point. I wonder how many of our facets should really be their own scopes 🤔. I guess nice thing bout facets is it makes it easier for us to switch them to their own scopes later because they're explicitly tagged
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.
Probably quite a few.
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 think one indicator that a scope maybe should split is that we have multiple iteration scopes as in the above example. For example all the different types of ways you can do functions in javascript is still the same function scope, but a value in a map pair is not really the same thing as a return statement value and they do have different iteration scopes. This is definitely going to be on a case by case basis, but I think that having multiple iteration scopes for the same scope is a bit of a warning sign.
packages/common/src/scopeSupportFacets/getLanguageScopeSupport.ts
Outdated
Show resolved
Hide resolved
@pokey Updated after today's meeting discussion |
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.
Couple more minor comments
Co-authored-by: Pokey Rule <[email protected]>
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 find I'm not in love with label and examples fields of facet info. Shall we make them optional and delete them where they're unhelpful? I'm happy to do that as I have opinions about where they're unhelpful 😅
["value.assignment"]: supported, | ||
|
||
["key.attribute"]: notApplicable, | ||
["tags"]: notApplicable, |
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
label: "Word", | ||
description: "A single word in a token", | ||
scopeType: "word", | ||
examples: ["foo_bar", "fooBar"], |
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.
These examples are pretty misleading. If we're going to take the example thing seriously, we need to figure out a way to demarcate substrings. I do question how useful / ergonomic it is to just drop these examples into strings. The examples from test casees are already there and likely to be far more useful
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 examples as a very general guide. If you want details you she'd look at the actual fixtures
label: "Line", | ||
description: "A single line in the document", | ||
scopeType: "line", | ||
examples: ["foo"], |
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 is unhelpful in the other direction. Really questioning the utility of these examples 🤔
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.
If you don't like them we can't ditch them
export interface ScopeSupportFacetInfo { | ||
readonly label: string; | ||
readonly description: string; | ||
readonly scopeType: SimpleScopeTypeType; |
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.
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 comment
The 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 comment
The 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.
label: "Attributes key", | ||
description: "Key(LHS) of an attribute", | ||
scopeType: "collectionKey", | ||
examples: ['id="root"'], |
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.
As in other examples, this would be more helpful if there were a way to put it in context, but a flat string is not a particularly comfortable way to do that
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.
Absolutely.
description: "Iteration of map pair keys", | ||
scopeType: "collectionKey", | ||
isIteration: true, | ||
examples: ["{ value: 0 }"], |
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 shouldn't include the curly brackets, but then it becomes pretty unclear what's going on here. I guess we could use multiple?
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.
The examples are not the content range. It's just example of the type of code that would have this facet
examples: ['id="root"'], | ||
}, | ||
["key.mapPair"]: { | ||
label: "Map key", |
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.
These labels feel kinda useless / arbitrary and a bit redundant with the description. I wonder if we just autogenerate these from the id like we do for human-readable scope types. Ie key.mapPair
=> "key (map pair)"
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.
Sounds good to me
@@ -0,0 +1,82 @@ | |||
import { SimpleScopeTypeType } from "../types/command/PartialTargetDescriptor.types"; | |||
|
|||
const scopeSupportFacets = [ |
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 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 comment
The 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 comment
The reason will be displayed to describe this comment to others. Learn more.
Eg key.mapPair
, key.attribute
, etc could all be their own scopes. I think every facet here should probably just be a new fine-grained scope. Not something to change for this PR just an observation. Makes me question the notion of facets entirely, but they're undoubtedly a step forward so nothing to get in the way of this PR
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.
Totally agree
I would be happy to remove label and examples, but I don't think we should make them optional. |
Started implementing a new scope handler test representation
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[]
.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.
Relevant issues
#1524
#2010
Checklist