| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Sorry, something went wrong.
|
I may need guidance on tests, I have not yet ventured in to any of the tests so far. |
Sorry, something went wrong.
|
I do not find any tests for keywords. |
Sorry, something went wrong.
|
As for tests, it looks like, adding to test\powershell\language\parser\parsing.tests.ps1, some ParseInput expressions could be constructed to test the tokenizer results of a sample switch statement. I am referencing the ternary operator parsing tests that Dongbo Wang (@daxian-dbw) added. |
Sorry, something went wrong.
|
I rebased, and have updated the commits to reflect creating the default keyword token. I have also included a potential test, after correcting an existing one that changed because of the error records no longer being the same. Please provide an initial review of this approach, and if there is any other testing that should be done. |
Sorry, something went wrong.
Add `Default` token for switch statement `default` condition clause keyword, allowing token based syntax highlighting to indicate `default` is a keyword. Adjusted SwitchStatementRule to utilize new token. clauseCondition is no longer produced for the `Default` clause.
Correct 'switch statement parsing' test for change in error output due to `default` now being a keyword.
Add tests for parsing 'limited' keywords, `default`, `hidden`, `in`, and `static` to check the token results as expected for syntax high- lighting applications. Validates the keywords can be used as function names. This is preliminary (WIP) concept.
|
I have revised the commits again, though the bulk of changes is now in the tests. I still have the feeling the tests are still a work in progress, though they are closer to what I was first expecting. |
Sorry, something went wrong.
|
I'm removing the WIP prefix, as I think this is ready for review. I am quite interested for feedback. |
Sorry, something went wrong.
|
Dongbo Wang (@daxian-dbw) James Truher (@JamesWTruher) Aditya Patwardhan (@adityapatwardhan) Please review the PR. |
Sorry, something went wrong.
|
This pull request has been automatically marked as Review Needed because it has been there has not been any activity for 7 days. |
Sorry, something went wrong.
There was a problem hiding this comment.
Looks like a started a review on this PR some time ago but didn't post it... Comments left unchanged
Sorry, something went wrong.
| Test-ErrorStmt 'switch (1) {foo}' 'switch (1) {foo' 'foo' '1' '1' '1' | ||
| Test-ErrorStmt 'switch (1) {foo {bar}' 'switch (1) {foo {bar}' 'foo' '{bar}' 'bar' 'bar' 'bar' '1' '1' '1' | ||
| Test-ErrorStmt 'switch (1) {default {9} default{2}' 'switch (1) {default {9} default{2}' 'default' '{9}' '9' '9' '9' 'default' '{2}' '2' '2' '2' '1' '1' '1' | ||
| Test-ErrorStmt 'switch (1) {default {9} default{2}' 'switch (1) {default {9} default{2}' '{9}' '9' '9' '9' '{2}' '2' '2' '2' '1' '1' '1' |
There was a problem hiding this comment.
It seems like keeping 'default' in as a clause is important. We should have a test for that.
switch ('default')
{
'default' { 'Hi' }
default { 'Bye' }
}is valid PowerShell (returns Hi)
Sorry, something went wrong.
There was a problem hiding this comment.
I think the answer here is keep the test as it now is, plus add a success test to ensure that a block like the one above remains valid (and returns the correct result)
Sorry, something went wrong.
There was a problem hiding this comment.
Ok, the code here looks good to me. Thanks for adding thorough tests!
Sorry, something went wrong.
There was a problem hiding this comment.
Carl Morris (@msftrncs) Sorry that this PR has been overlooked for sooo long ...
The changes look good to me. I made some minor changes to keep the backward compatibility around the ErrorStatement case.
Sorry, something went wrong.
|
Carl Morris (@msftrncs) Thanks for your contribution! |
Sorry, something went wrong.
|
🎉v7.1.0-preview.4 has been released which incorporates this pull request.:tada: Handy links: |
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
PR Summary
Flag the switch statement condition clause default token as a keyword
token to facilitate (PSReadLine) highlighting it as a keyword. Closes #10470.
This change is to treat the default clause keyword as a full keyword token, and as such token based highlighters will see it as a keyword.
PR Context
Flagging the default condition clause token of the switch statement as a keyword will facilitate highlighting of the keyword to better contrast against other bareword string literal conditions.
A simple (partial) example:
Highlighting of the default keyword in the above example makes it easier to distinguish the special condition clause from the other bareword conditions.
PR Checklist