Skip to content

Refactored PowerShell language definitions#7522

Merged
aeschli merged 1 commit intomicrosoft:masterfrom
gravejester:master
Jun 27, 2016
Merged

Refactored PowerShell language definitions#7522
aeschli merged 1 commit intomicrosoft:masterfrom
gravejester:master

Conversation

@gravejester
Copy link
Copy Markdown
Contributor

This is a total refactoring of the language definitions (.tmlanguage) file.

Notable changes:

  • General clean-up (moved most of the matching rules to the repository, logically grouped rules etc.)
  • Supports the Stop Parsing operator
  • Added some illegal scopes (bad variable names and space after backtick ++)
  • Added comments where I felt it was needed
  • Much better command highlighting, with highlighting of parameters
  • Workaround for highlighting the reserved word 'default' in switch-blocks (Will only highlight the word inside scriptblocks, so will also highlight in {default}
  • Fixed highlighting of comment based help keywords
  • More consequent highlighting of numerical constants
  • Changed some scope names
  • Better type highlighting
  • Highlighting of keywords in classes
  • Added highlighting of built-in aliases and executable files (.ps1, .exe etc)
  • Added highlighting of some missing operators
  • Better highlighting of properties/members

Compare: Old vs New

@daviwil

@mention-bot
Copy link
Copy Markdown

By analyzing the blame information on this pull request, we identified @egamma and @Jaykul to be potential reviewers

@msftclas
Copy link
Copy Markdown

Hi @gravejester, I'm your friendly neighborhood Microsoft Pull Request Bot (You can call me MSBOT). Thanks for your contribution!
You've already signed the contribution license agreement. Thanks!

The agreement was validated by Microsoft and real humans are currently evaluating your PR.

TTYL, MSBOT;

@gravejester gravejester changed the title Refactored language definitions Refactored PowerShell language definitions Jun 10, 2016
@daviwil
Copy link
Copy Markdown
Contributor

daviwil commented Jun 10, 2016

Hey guys,

This PR contains a bunch of really nice improvements to the TextMate syntax definition for PowerShell. @gravejester originally made these changes over at the PowerShell team's new repo to centralize development on our TextMate grammar:

https://github.com/PowerShell/EditorSyntax

I noticed that the Travis CI build failed due to a colorization test that failed due to these changes. Can you tell us where those tests are and how to run them so that @gravejester can fix as part of the PR?

Thanks!

@daviwil
Copy link
Copy Markdown
Contributor

daviwil commented Jun 10, 2016

/cc @aeschli

@aeschli aeschli self-assigned this Jun 10, 2016
@aeschli
Copy link
Copy Markdown
Contributor

aeschli commented Jun 16, 2016

Thanks for the pull request, @gravejester !
To run the colorizer tests, run ./scripts/test-integration.sh
The tests will colorize a test input file and compare the result against the result of the last run, or fail if they differ.
The new result will be written over the old result, so if you agree with the new result, you can just commit the updated file. For powershell, we have a test input file at https://github.com/Microsoft/vscode/blob/master/extensions/powershell/test/colorize-fixtures/test.ps1.
To validate the coloring you can also just open that file in a updated VSCode.
The result file is
https://github.com/Microsoft/vscode/blob/master/extensions/powershell/test/colorize-results/test_ps1.json

Feel free to add more tests or modify the existing one.

Let me know if you want me to just update the test result, or if you want to have a look.

@dilijev
Copy link
Copy Markdown

dilijev commented Jun 24, 2016

Looks awesome! I've been using VSCode for PS a lot lately since it's highlighting is somewhat better than some other editors I usually use, and has been improving. I'd say that this covers the rest of the highlighting cases I felt were missing.

I noticed that $_ is now highlighted correctly. I didn't notice a $? in that test case, however -- will that be correctly highlighted now as well?

Looking forward to trying this in Insider once it is merged in.

@gravejester
Copy link
Copy Markdown
Contributor Author

@dilijev Yes, if you wan to preview changes, you can look at the two links provided in the first post :)

@aeschli
Copy link
Copy Markdown
Contributor

aeschli commented Jun 24, 2016

@gravejester Let me know if you want me to fix the tests by just accepting the new tokens.

@aeschli aeschli added this to the June 2016 milestone Jun 24, 2016
@dilijev
Copy link
Copy Markdown

dilijev commented Jun 24, 2016

@gravejester I meant that $? is not present in the test case used in the two comparison links in the description.

@aeschli aeschli merged commit 8831d19 into microsoft:master Jun 27, 2016
aeschli added a commit that referenced this pull request Jun 27, 2016
@aeschli
Copy link
Copy Markdown
Contributor

aeschli commented Jun 27, 2016

I pushed the PR so todays the last development day for the June release.
I fixed the tests.

@daviwil
Copy link
Copy Markdown
Contributor

daviwil commented Jun 27, 2016

Thanks a lot, Martin! I'm happy this will be in the next release.

@Dragonsong3k
Copy link
Copy Markdown

Hi @gravejester . Total Github noob here so I am not sure this is the place for this but...
I love VSCODE for all of my powershell needs however I updated this morning and found something.

If I have a variable with a comment hashtag, all other lines in the code will not be color coded.

image

In this example, I use an XML object and refer to the value with '#text'.
All other lines below this will be considered a comment for the color coding. If I remove the $ from $myxmlObj, the color coding will return for the following lines.

This was working in the previous release.

@gravejester
Copy link
Copy Markdown
Contributor Author

@Dragonsong3k I'll take a look at it, and push a fix for the next release. Thanks for the heads-up :)

@SeanQuinlan
Copy link
Copy Markdown

Hi, this might be related to the problem that Dragonsong3k reported, but properties that contain a dash also break the syntax highlighting:

git broken

If I remove the dash in the property, then it highlights correctly:

git working

This syntax worked correctly in the previous release.

@github-actions github-actions Bot locked and limited conversation to collaborators Mar 27, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants