diff --git a/ColorCode.Core/Common/ScopeName.cs b/ColorCode.Core/Common/ScopeName.cs index abecad1..6267bda 100644 --- a/ColorCode.Core/Common/ScopeName.cs +++ b/ColorCode.Core/Common/ScopeName.cs @@ -22,10 +22,12 @@ public class ScopeName public const string Keyword = "Keyword"; public const string LanguagePrefix = "&"; public const string PlainText = "Plain Text"; - public const string PowerShellAttribute = "PowerShell PowerShellAttribute"; + public const string PowerShellAttribute = "PowerShell Attribute"; public const string PowerShellOperator = "PowerShell Operator"; public const string PowerShellType = "PowerShell Type"; public const string PowerShellVariable = "PowerShell Variable"; + public const string PowerShellCommand = "PowerShell Command"; + public const string PowerShellParameter = "PowerShell Parameter"; public const string PreprocessorKeyword = "Preprocessor Keyword"; public const string SqlSystemFunction = "SQL System Function"; public const string String = "String"; diff --git a/ColorCode.Core/Compilation/Languages/PowerShell.cs b/ColorCode.Core/Compilation/Languages/PowerShell.cs index 43bed86..1f0a57e 100644 --- a/ColorCode.Core/Compilation/Languages/PowerShell.cs +++ b/ColorCode.Core/Compilation/Languages/PowerShell.cs @@ -78,11 +78,17 @@ public IList Rules {0, ScopeName.PowerShellVariable} }), new LanguageRule( - @"\b(begin|break|catch|continue|data|do|dynamicparam|elseif|else|end|exit|filter|finally|foreach|for|from|function|if|in|param|process|return|switch|throw|trap|try|until|while)\b", + @"(?i)\b(begin|break|catch|continue|data|do|dynamicparam|elseif|else|end|exit|filter|finally|foreach|for|from|function|if|in|param|process|return|switch|throw|trap|try|until|while)\b", new Dictionary { {1, ScopeName.Keyword} }), + new LanguageRule( + @"\b(\w+\-\w+)\b", + new Dictionary + { + {1, ScopeName.PowerShellCommand} + }), new LanguageRule( @"-(?:c|i)?(?:eq|ne|gt|ge|lt|le|notlike|like|notmatch|match|notcontains|contains|replace)", new Dictionary @@ -98,7 +104,14 @@ public IList Rules } ), new LanguageRule( - @"(?:\+=|-=|\*=|/=|%=|=|\+\+|--|\+|-|\*|/|%)", + @"-\w+\d*\w*", + new Dictionary + { + {0, ScopeName.PowerShellParameter} + } + ), + new LanguageRule( + @"(?:\+=|-=|\*=|/=|%=|=|\+\+|--|\+|-|\*|/|%|\||,)", new Dictionary { {0, ScopeName.PowerShellOperator} @@ -112,7 +125,7 @@ public IList Rules } ), new LanguageRule( - @"(?s)\[(CmdletBinding)[^\]]+\]", + @"(?is)\[(cmdletbinding|alias|outputtype|parameter|validatenotnull|validatenotnullorempty|validatecount|validateset|allownull|allowemptycollection|allowemptystring|validatescript|validaterange|validatepattern|validatelength|supportswildcards)[^\]]+\]", new Dictionary { {1, ScopeName.PowerShellAttribute} @@ -136,6 +149,7 @@ public bool HasAlias(string lang) { case "posh": case "ps1": + case "pwsh": return true; default: diff --git a/ColorCode.Core/Styling/StyleDictionary.DefaultDark.cs b/ColorCode.Core/Styling/StyleDictionary.DefaultDark.cs index 093affd..3ff666b 100644 --- a/ColorCode.Core/Styling/StyleDictionary.DefaultDark.cs +++ b/ColorCode.Core/Styling/StyleDictionary.DefaultDark.cs @@ -197,6 +197,16 @@ public static StyleDictionary DefaultDark Foreground = OrangeRed, ReferenceName = "powershellVariable" }, + new Style(ScopeName.PowerShellCommand) + { + Foreground = Yellow, + ReferenceName = "powershellCommand" + }, + new Style(ScopeName.PowerShellParameter) + { + Foreground = VSDarkGray, + ReferenceName = "powershellParameter" + }, new Style(ScopeName.Type) { diff --git a/ColorCode.Core/Styling/StyleDictionary.DefaultLight.cs b/ColorCode.Core/Styling/StyleDictionary.DefaultLight.cs index 47a0192..dd0b59b 100644 --- a/ColorCode.Core/Styling/StyleDictionary.DefaultLight.cs +++ b/ColorCode.Core/Styling/StyleDictionary.DefaultLight.cs @@ -181,6 +181,16 @@ public static StyleDictionary DefaultLight Foreground = OrangeRed, ReferenceName = "powershellVariable" }, + new Style(ScopeName.PowerShellCommand) + { + Foreground = Navy, + ReferenceName = "powershellCommand" + }, + new Style(ScopeName.PowerShellParameter) + { + Foreground = Gray, + ReferenceName = "powershellParameter" + }, new Style(ScopeName.Type) {