Skip to content

Commit

Permalink
Add symbols across multi-root workspace unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
andyleejordan committed Feb 13, 2023
1 parent 8de9fb5 commit cdfe0ab
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/PowerShellEditorServices/Services/Symbols/SymbolReference.cs
Original file line number Diff line number Diff line change
Expand Up @@ -66,5 +66,19 @@ public SymbolReference(
}
IsDeclaration = isDeclaration;
}

/// <summary>
/// This is only used for unit tests!
/// </summary>
internal SymbolReference(string id, SymbolType type)
{
Id = id;
Type = type;
Name = "";
NameRegion = new("", "", 0, 0, 0, 0, 0, 0);
ScriptRegion = NameRegion;
SourceLine = "";
FilePath = "";
}
}
}
17 changes: 17 additions & 0 deletions test/PowerShellEditorServices.Test/Language/SymbolsServiceTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,23 @@ public async Task FindsReferencesOnFunction()
});
}

[Fact]
public async Task FindsReferenceAcrossMultiRootWorkspace()
{
workspace.WorkspaceFolders = new[] { "Debugging", "ParameterHints", "SymbolDetails" }
.Select(i => new WorkspaceFolder
{
Uri = DocumentUri.FromFileSystemPath(TestUtilities.GetSharedPath(i))
}).ToList();

SymbolReference symbol = new("fn Get-Process", SymbolType.Function);
IEnumerable<SymbolReference> symbols = await symbolsService.ScanForReferencesOfSymbolAsync(symbol).ConfigureAwait(true);
Assert.Collection(symbols.OrderBy(i => i.FilePath),
i => Assert.EndsWith("VariableTest.ps1", i.FilePath),
i => Assert.EndsWith("ParamHints.ps1", i.FilePath),
i => Assert.EndsWith("SymbolDetails.ps1", i.FilePath));
}

[Fact]
public async Task FindsReferencesOnFunctionIncludingAliases()
{
Expand Down

0 comments on commit cdfe0ab

Please sign in to comment.