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

Test: new when-clauses parser #177738

Closed
2 tasks done
ulugbekna opened this issue Mar 20, 2023 · 4 comments
Closed
2 tasks done

Test: new when-clauses parser #177738

ulugbekna opened this issue Mar 20, 2023 · 4 comments

Comments

@ulugbekna
Copy link
Contributor

ulugbekna commented Mar 20, 2023

Refs: #91473

Complexity: 3

Create Issue


Summary

We rewrote the parser for when-clauses (docs, new parser changes) with various new features - most important of which are

  • support for parenthesized expressions, eg (a || b) && c or !(a || b)
  • linter for when clauses in an extension manifest file package.json

Testing

  1. Clone https://github.com/ulugbekna/ctxkey-extension
  2. Run yarn inside the cloned repo
  3. Run vscode instance with that extension - just pressing F5 should launch such an instance
  4. In the newly open vscode instance:

test 1

  1. Open a json file (just creating a new untitled file (cmd+n) and selecting language JSON should suffice)
  2. Search "hello" in command palette - you should only see "Hello world - present 1" command

test 2

  1. Open any file but not json and not python
  2. Search "hello" in command palette - you should only see "Hello world - present 2" and "Hello world - present 3" commands
  3. Open a python file
  4. Search "hello" in command palette - you should not see "Hello world - present 3"

test 3

  1. Go back to vscode instance with the cloned repo
  2. Edit the "when" clauses according to the docs and notice if the reported errors look good to you
       {
          "command": "ctxkey-extension.helloWorld1",
          "when": "!(editorLangId === json || editorLangId === python)" // <- this is a when clause; you want to edit the value of this field, e.g., remove a closing parenthesis, etc. 
        },
@vscodenpa vscodenpa added this to the March 2023 milestone Mar 20, 2023
@ghost ghost assigned eleanorjboyd and alexr00 Mar 21, 2023
@alexr00 alexr00 removed their assignment Mar 21, 2023
@alexr00
Copy link
Member

alexr00 commented Mar 21, 2023

Works very nicely! I've cleaned up some of the whens in GHPRI: microsoft/vscode-pull-request-github#4651

@ulugbekna
Copy link
Contributor Author

@eleanorjboyd: Alex proposed that she rather cleans up when-clauses in the extension she maintains and verifies the contributions still work with the new parser & the linter reports good errors in package.json -- if you prefer, you can do the same rather than using the sample-extension that I provide.

@eleanorjboyd
Copy link
Member

@ulugbekna, thanks for the sample extension! I used it and it went great!

@ulugbekna
Copy link
Contributor Author

@eleanorjboyd thanks for verifying and sorry for the wrong instruction!

@github-actions github-actions bot locked and limited conversation to collaborators May 5, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants