Skip to content
Draft
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
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ public override AstVisitAction VisitCommand(CommandAst commandAst)

public override AstVisitAction VisitFunctionDefinition(FunctionDefinitionAst functionDefinitionAst)
{
// Treat filter the same as function: both get SymbolType.Function so they appear in the
// outline and support child symbols (variables, nested functions, etc.) in the hierarchy.
SymbolType symbolType = functionDefinitionAst.IsWorkflow
? SymbolType.Workflow
: SymbolType.Function;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ $Script:ScriptVar2 = 2

function script:AFunction {}

filter AFilter {$_}
filter AFilter { $FilterVar = $_ }

function AnAdvancedFunction {
begin {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -773,9 +773,9 @@ public void FindsSymbolsInFile()
IEnumerable<SymbolReference> symbols = FindSymbolsInFile(FindSymbolsInMultiSymbolFile.SourceDetails);

Assert.Equal(7, symbols.Count(i => i.Type == SymbolType.Function));
Assert.Equal(8, symbols.Count(i => i.Type == SymbolType.Variable));
Assert.Equal(9, symbols.Count(i => i.Type == SymbolType.Variable));
Assert.Equal(4, symbols.Count(i => i.Type == SymbolType.Parameter));
Assert.Equal(12, symbols.Count(i => i.Id.StartsWith("var ")));
Assert.Equal(13, symbols.Count(i => i.Id.StartsWith("var ")));
Assert.Equal(2, symbols.Count(i => i.Id.StartsWith("prop ")));

SymbolReference symbol = symbols.First(i => i.Type == SymbolType.Function);
Expand All @@ -788,6 +788,12 @@ public void FindsSymbolsInFile()
Assert.Equal("filter AFilter ()", symbol.Name);
Assert.True(symbol.IsDeclaration);

// Verify that a variable declared inside a filter is tracked as a declaration,
// allowing it to appear as a child of the filter in the LSP outline hierarchy.
symbol = Assert.Single(symbols, i => i.Id == "var FilterVar");
Assert.Equal("$FilterVar", symbol.Name);
Assert.True(symbol.IsDeclaration);

symbol = symbols.Last(i => i.Type == SymbolType.Variable);
Assert.Equal("var nestedVar", symbol.Id);
Assert.Equal("$nestedVar", symbol.Name);
Expand Down
Loading