Skip to content

Commit 6452afc

Browse files
committed
Handle PowerShell keywords case-insensitively (#1482)
1 parent 745669b commit 6452afc

2 files changed

Lines changed: 3 additions & 2 deletions

File tree

src/CodeIndex/Indexer/References/ReferenceExtractor.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ private static bool IsFunctionLikeSymbolKind(string kind)
222222
"import", "importFrom", "export", "exportClasses", "exportMethods", "S3method", "useDynLib",
223223
},
224224
// PowerShell keywords / PowerShell キーワード
225-
["powershell"] = new HashSet<string>(StringComparer.Ordinal)
225+
["powershell"] = new HashSet<string>(StringComparer.OrdinalIgnoreCase)
226226
{
227227
"function", "filter", "configuration", "workflow", "class", "enum",
228228
"param", "begin", "process", "end", "dynamicparam",

tests/CodeIndex.Tests/ReferenceExtractorTests.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18308,6 +18308,7 @@ function MyFunction {
1830818308
filter Select-Valid {
1830918309
process { if ($_.IsValid) { return $_ } }
1831018310
}
18311+
IF ($true) { RETURN "ok" }
1831118312

1831218313
function Process-Items {
1831318314
param([array]$Items)
@@ -18341,7 +18342,7 @@ function Process-Items {
1834118342
Assert.Contains(references, r => r.SymbolName == "Invoke-RestMethod" && r.ReferenceKind == "call");
1834218343
Assert.Contains(references, r => r.SymbolName == "ForEach-Object" && r.ReferenceKind == "call");
1834318344
Assert.Contains(references, r => r.SymbolName == "Where-Object" && r.ReferenceKind == "call");
18344-
Assert.DoesNotContain(references, r => r.SymbolName is "function" or "filter" or "if" or "return");
18345+
Assert.DoesNotContain(references, r => r.SymbolName is "function" or "filter" or "if" or "IF" or "return" or "RETURN");
1834518346
Assert.DoesNotContain(references, r => r.SymbolName == "lt");
1834618347
}
1834718348

0 commit comments

Comments
 (0)