-
-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Language.Filter(s) ( Fixes #1080 )
- Loading branch information
James Brundage
committed
Mar 20, 2024
1 parent
db904da
commit 8dcc458
Showing
2 changed files
with
32 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
@{ | ||
Templates = 'Template' | ||
Functions = 'Function' | ||
Filters = 'Filter' | ||
Aliases = 'Alias' | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
<# | ||
.SYNOPSIS | ||
Gets Language Filters | ||
.DESCRIPTION | ||
Gets Filters related to a language. | ||
Filters are a special type of function that are used to filter or transform data. | ||
These are filters that either match a language's `.FilePattern` or start with a language name, followed by punctuation. | ||
#> | ||
if (-not $global:AllFunctionsAndAliases) { | ||
$global:AllFunctionsAndAliases = $global:ExecutionContext.SessionState.InvokeCommand.GetCommand('*','Function',$true) | ||
} | ||
$FunctionsForThisLanguage = [Ordered]@{PSTypeName='Language.Functions'} | ||
if ($this.FilePattern) { | ||
foreach ($FunctionForLanguage in $global:AllFunctionsAndAliases -match $this.FilePattern) { | ||
if (-not $FunctionsForThisLanguage.IsFilter) {continue } | ||
$FunctionsForThisLanguage["$FunctionForLanguage"] = $FunctionForLanguage | ||
} | ||
} | ||
if ($this.LanguageName) { | ||
foreach ($FunctionForLanguage in $global:AllFunctionsAndAliases -match "(?<=(?>^|[\p{P}-[\\]]))$([Regex]::Escape($this.LanguageName))[\p{P}-[\\]]") { | ||
if (-not $FunctionsForThisLanguage.IsFilter) {continue } | ||
$FunctionsForThisLanguage["$FunctionForLanguage"] = $FunctionForLanguage | ||
} | ||
} | ||
|
||
$FunctionsForThisLanguage = [PSCustomObject]$FunctionsForThisLanguage | ||
$FunctionsForThisLanguage.pstypenames.insert(0,"$($this.LanguageName).Functions") | ||
$FunctionsForThisLanguage | ||
|