Skip to content
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

Add "access" scope type #1519

Merged
merged 6 commits into from
Oct 19, 2023
Merged

Add "access" scope type #1519

merged 6 commits into from
Oct 19, 2023

Conversation

pokey
Copy link
Member

@pokey pokey commented Jun 8, 2023

Questions

  • Unfortunately, both the queries and tests are almost identically duplicated between Typescript and Python 😕.
    • I wonder if we should support some kind of templating language, eg handlebars, along with a meta-updater-style approach where we keep the generated files in source control as well
    • For the test cases, we could maybe support a list of language ids in the recorded test yaml 🤷‍♂️
  • Also, should the . be considered part of the content range, or just the removal range?
  • Should a function call on its own be considered "access"? eg foo(). What about an identifier on its own, eg foo?

Checklist

  • Make it so eg bar or foo() on its own is an access? That might cover a lot of things 🤔. Eg what happens with something in parens? That could end up as part of access, eg (a + b).c
  • What does happen with (a + b).c?
  • I have added tests
  • I have updated the docs and cheatsheet
  • I have not broken the cheatsheet

(
(member_expression
object: (call_expression
function: (_) @dummy
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wasn't sure what to call nodes like this where we're just using them to allow us to write a predicate that rejects the pattern. We should probably standardize on something that allows multiple per pattern, because in the future I'd like to be strict about allowable capture names to detect typos in capture names, which today just result in scopes silently not working

@pokey pokey requested a review from AndreasArvidsson June 8, 2023 10:21
@pokey pokey marked this pull request as ready for review June 8, 2023 10:21
@pokey pokey force-pushed the pokey/add-access-scope-type branch 4 times, most recently from ab22d0d to fccb908 Compare June 8, 2023 12:23
@pokey pokey added the to discuss Plan to discuss at meet-up label Jun 13, 2023
@AndreasArvidsson
Copy link
Member

I don't think the dot should be part of the content range. I view this as a delimiter.

I definitely understand what you mean about the test cases. On fixture for multiple languages might be reasonable.

@pokey
Copy link
Member Author

pokey commented Jun 13, 2023

yeah I'm on the fence, because it is a bit like a delimiter, but not quite. Comparing it to "arg", in that case, an arg can exist without the ,, whereas something that is after the first element in the chain can't exist without the .. Ie you can't take it and make it a single-element access chain without a . the way you can with an arg. So the . really feels more like it is a part of the access. That being said, I do think you'd probably expect "change" to leave the . 🤔

To make it a delimiter, we'd need to:

  1. support insertion delimiters for our tree-sitter queries, and
  2. Ensure that a single function call / identifier / access is considered an "access"

Which are not unreasonable anyway imo

@pokey
Copy link
Member Author

pokey commented Jun 13, 2023

I guess one argument to treat it as a delimiter is that the decision to use ?. instead of . is determined by the preceding identifier rather than the following, so arguably it's not wholly owned by the trailing access

@pokey
Copy link
Member Author

pokey commented Jun 13, 2023

aligned on having it be delimiter, so need the extra things above

@pokey pokey marked this pull request as draft June 13, 2023 15:10
@pokey pokey removed the to discuss Plan to discuss at meet-up label Jun 13, 2023
@pokey
Copy link
Member Author

pokey commented Oct 3, 2023

Update from meet-up (see #1923 (comment) for more context):

  • Make it private by not having it appear in csvs, but don't throw error if we manually add it to the csv. Also call it private.access
  • Ship it as is where it includes the . in the content range. If it's annoying we'll revisit

@pokey pokey force-pushed the pokey/add-access-scope-type branch from fccb908 to 2862db6 Compare October 3, 2023 17:24
@pokey pokey marked this pull request as ready for review October 3, 2023 17:55
@pokey
Copy link
Member Author

pokey commented Oct 3, 2023

Ok it's now a private scope type. You'll need to add a line like the following to your modifier_scope_types.csv:

# WARNING: Please do not copy this into your own CSVs; it is for internal
# experimentation and may break at any time without warning.
# See https://github.com/cursorless-dev/cursorless/pull/1519#issuecomment-1745459484
access, private.fieldAccess

@AndreasArvidsson it's worth giving this a whirl to make sure that:

  1. You can't use it without adding the above line, and there's no error if you don't
  2. It works if you do add the above line

NOTE to anyone stumbling across this PR: if you do not heed the warning above, and do paste the above lines in your CSV, please at least subscribe to notifications for this PR; we'll leave a message here when we deactivate this feature in the future 😊

@pokey
Copy link
Member Author

pokey commented Oct 3, 2023

Keep in mind that someone could still copy one of our settings csvs and get it that way, but hopefully the comment helps 🤷

@pokey pokey marked this pull request as draft October 4, 2023 10:33
@pokey pokey marked this pull request as ready for review October 4, 2023 10:35
@AndreasArvidsson
Copy link
Member

AndreasArvidsson commented Oct 5, 2023

Tested and works as expected

This is also one of those scopes where I would like to have a text based fall back :D

@pokey
Copy link
Member Author

pokey commented Oct 5, 2023

Yeah that would be nice. Could prob build something using the pair scopes once those are migrated

@pokey pokey enabled auto-merge October 17, 2023 13:45
@pokey
Copy link
Member Author

pokey commented Oct 17, 2023

@AndreasArvidsson I think this one is good to go when you get a minute

@AndreasArvidsson
Copy link
Member

There are a lot of unfinished tasks on this pr and, but you're still happy to merge?

@pokey pokey added this pull request to the merge queue Oct 19, 2023
Merged via the queue into main with commit ac53e4b Oct 19, 2023
13 checks passed
@pokey pokey deleted the pokey/add-access-scope-type branch October 19, 2023 11:51
@auscompgeek auscompgeek added lang-typescript TypeScript/JavaScript grammar support lang-python Issues related to Python programming language support labels Oct 19, 2023
@pokey
Copy link
Member Author

pokey commented Oct 19, 2023

yeah I should prob check them, but I left them because this PR is really kind of unfinished but we want to merge it as a private feature to get some feedback from real use

cursorless-bot pushed a commit that referenced this pull request Oct 19, 2023
- Implements #707 for Typescript
- Implements #707 for Python

## Questions

- [ ] Unfortunately, both the queries and tests are almost identically
duplicated between Typescript and Python 😕.
- [ ] I wonder if we should support some kind of templating language, eg
handlebars, along with a meta-updater-style approach where we keep the
generated files in source control as well
- [ ] For the test cases, we could maybe support a list of language ids
in the recorded test yaml 🤷‍♂️
- [ ] Also, should the `.` be considered part of the content range, or
just the removal range?
- [ ] Should a function call on its own be considered `"access"`? eg
`foo()`. What about an identifier on its own, eg `foo`?

## Checklist

- [ ] Make it so eg `bar` or `foo()` on its own is an access? That might
cover a lot of things 🤔. Eg what happens with something in parens? That
could end up as part of access, eg `(a + b).c`
- [ ] What does happen with `(a + b).c`?
- [x] I have added
[tests](https://www.cursorless.org/docs/contributing/test-case-recorder/)
- [x] 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)
- [x] I have not broken the cheatsheet
fidgetingbits pushed a commit to fidgetingbits/cursorless that referenced this pull request Nov 3, 2023
- Implements cursorless-dev#707 for Typescript
- Implements cursorless-dev#707 for Python

## Questions

- [ ] Unfortunately, both the queries and tests are almost identically
duplicated between Typescript and Python 😕.
- [ ] I wonder if we should support some kind of templating language, eg
handlebars, along with a meta-updater-style approach where we keep the
generated files in source control as well
- [ ] For the test cases, we could maybe support a list of language ids
in the recorded test yaml 🤷‍♂️
- [ ] Also, should the `.` be considered part of the content range, or
just the removal range?
- [ ] Should a function call on its own be considered `"access"`? eg
`foo()`. What about an identifier on its own, eg `foo`?

## Checklist

- [ ] Make it so eg `bar` or `foo()` on its own is an access? That might
cover a lot of things 🤔. Eg what happens with something in parens? That
could end up as part of access, eg `(a + b).c`
- [ ] What does happen with `(a + b).c`?
- [x] I have added
[tests](https://www.cursorless.org/docs/contributing/test-case-recorder/)
- [x] 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)
- [x] I have not broken the cheatsheet
thetomcraig-aya pushed a commit to thetomcraig/cursorless that referenced this pull request Mar 27, 2024
- Implements cursorless-dev#707 for Typescript
- Implements cursorless-dev#707 for Python

## Questions

- [ ] Unfortunately, both the queries and tests are almost identically
duplicated between Typescript and Python 😕.
- [ ] I wonder if we should support some kind of templating language, eg
handlebars, along with a meta-updater-style approach where we keep the
generated files in source control as well
- [ ] For the test cases, we could maybe support a list of language ids
in the recorded test yaml 🤷‍♂️
- [ ] Also, should the `.` be considered part of the content range, or
just the removal range?
- [ ] Should a function call on its own be considered `"access"`? eg
`foo()`. What about an identifier on its own, eg `foo`?

## Checklist

- [ ] Make it so eg `bar` or `foo()` on its own is an access? That might
cover a lot of things 🤔. Eg what happens with something in parens? That
could end up as part of access, eg `(a + b).c`
- [ ] What does happen with `(a + b).c`?
- [x] I have added
[tests](https://www.cursorless.org/docs/contributing/test-case-recorder/)
- [x] 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)
- [x] I have not broken the cheatsheet
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
lang-python Issues related to Python programming language support lang-typescript TypeScript/JavaScript grammar support
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants