Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion ColorCode.Core/Common/ScopeName.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down
20 changes: 17 additions & 3 deletions ColorCode.Core/Compilation/Languages/PowerShell.cs
Original file line number Diff line number Diff line change
Expand Up @@ -78,11 +78,17 @@ public IList<LanguageRule> 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<int, string>
{
{1, ScopeName.Keyword}
}),
new LanguageRule(
@"\b(\w+\-\w+)\b",
new Dictionary<int, string>
{
{1, ScopeName.PowerShellCommand}
}),
new LanguageRule(
@"-(?:c|i)?(?:eq|ne|gt|ge|lt|le|notlike|like|notmatch|match|notcontains|contains|replace)",
new Dictionary<int, string>
Expand All @@ -98,7 +104,14 @@ public IList<LanguageRule> Rules
}
),
new LanguageRule(
@"(?:\+=|-=|\*=|/=|%=|=|\+\+|--|\+|-|\*|/|%)",
@"-\w+\d*\w*",
new Dictionary<int, string>
{
{0, ScopeName.PowerShellParameter}
}
),
new LanguageRule(
@"(?:\+=|-=|\*=|/=|%=|=|\+\+|--|\+|-|\*|/|%|\||,)",
new Dictionary<int, string>
{
{0, ScopeName.PowerShellOperator}
Expand All @@ -112,7 +125,7 @@ public IList<LanguageRule> Rules
}
),
new LanguageRule(
@"(?s)\[(CmdletBinding)[^\]]+\]",
@"(?is)\[(cmdletbinding|alias|outputtype|parameter|validatenotnull|validatenotnullorempty|validatecount|validateset|allownull|allowemptycollection|allowemptystring|validatescript|validaterange|validatepattern|validatelength|supportswildcards)[^\]]+\]",
new Dictionary<int, string>
{
{1, ScopeName.PowerShellAttribute}
Expand All @@ -136,6 +149,7 @@ public bool HasAlias(string lang)
{
case "posh":
case "ps1":
case "pwsh":
return true;

default:
Expand Down
10 changes: 10 additions & 0 deletions ColorCode.Core/Styling/StyleDictionary.DefaultDark.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down
10 changes: 10 additions & 0 deletions ColorCode.Core/Styling/StyleDictionary.DefaultLight.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down