Skip to content

Commit cdfe0ab

Browse files
committed
Add symbols across multi-root workspace unit test
1 parent 8de9fb5 commit cdfe0ab

File tree

2 files changed

+31
-0
lines changed

2 files changed

+31
-0
lines changed

src/PowerShellEditorServices/Services/Symbols/SymbolReference.cs

+14
Original file line numberDiff line numberDiff line change
@@ -66,5 +66,19 @@ public SymbolReference(
6666
}
6767
IsDeclaration = isDeclaration;
6868
}
69+
70+
/// <summary>
71+
/// This is only used for unit tests!
72+
/// </summary>
73+
internal SymbolReference(string id, SymbolType type)
74+
{
75+
Id = id;
76+
Type = type;
77+
Name = "";
78+
NameRegion = new("", "", 0, 0, 0, 0, 0, 0);
79+
ScriptRegion = NameRegion;
80+
SourceLine = "";
81+
FilePath = "";
82+
}
6983
}
7084
}

test/PowerShellEditorServices.Test/Language/SymbolsServiceTests.cs

+17
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,23 @@ public async Task FindsReferencesOnFunction()
229229
});
230230
}
231231

232+
[Fact]
233+
public async Task FindsReferenceAcrossMultiRootWorkspace()
234+
{
235+
workspace.WorkspaceFolders = new[] { "Debugging", "ParameterHints", "SymbolDetails" }
236+
.Select(i => new WorkspaceFolder
237+
{
238+
Uri = DocumentUri.FromFileSystemPath(TestUtilities.GetSharedPath(i))
239+
}).ToList();
240+
241+
SymbolReference symbol = new("fn Get-Process", SymbolType.Function);
242+
IEnumerable<SymbolReference> symbols = await symbolsService.ScanForReferencesOfSymbolAsync(symbol).ConfigureAwait(true);
243+
Assert.Collection(symbols.OrderBy(i => i.FilePath),
244+
i => Assert.EndsWith("VariableTest.ps1", i.FilePath),
245+
i => Assert.EndsWith("ParamHints.ps1", i.FilePath),
246+
i => Assert.EndsWith("SymbolDetails.ps1", i.FilePath));
247+
}
248+
232249
[Fact]
233250
public async Task FindsReferencesOnFunctionIncludingAliases()
234251
{

0 commit comments

Comments
 (0)