Skip to content

Commit 3010065

Browse files
committed
Rename SymbolReference fields
1 parent fd04c34 commit 3010065

File tree

10 files changed

+248
-248
lines changed

10 files changed

+248
-248
lines changed

src/PowerShellEditorServices/Services/CodeLens/ReferencesCodeLensProvider.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ public CodeLens[] ProvideCodeLenses(ScriptFile scriptFile, CancellationToken can
6262
cancellationToken.ThrowIfCancellationRequested();
6363
// TODO: Can we support more here?
6464
if (symbol.IsDeclaration &&
65-
symbol.SymbolType is
65+
symbol.Type is
6666
SymbolType.Function or
6767
SymbolType.Class or
6868
SymbolType.Enum)

src/PowerShellEditorServices/Services/Symbols/ReferenceTable.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,8 @@ internal IEnumerable<SymbolReference> TryGetReferences(SymbolReference? symbol)
4646
{
4747
EnsureInitialized();
4848
return symbol is not null
49-
&& _symbolReferences.TryGetValue(symbol.SymbolName, out ConcurrentBag<SymbolReference>? bag)
50-
? bag.Where(i => SymbolTypeUtils.SymbolTypeMatches(symbol.SymbolType, i.SymbolType))
49+
&& _symbolReferences.TryGetValue(symbol.Id, out ConcurrentBag<SymbolReference>? bag)
50+
? bag.Where(i => SymbolTypeUtils.SymbolTypeMatches(symbol.Type, i.Type))
5151
: Enumerable.Empty<SymbolReference>();
5252
}
5353

@@ -90,7 +90,7 @@ private AstVisitAction AddReference(SymbolReference symbol)
9090
}
9191

9292
_symbolReferences.AddOrUpdate(
93-
symbol.SymbolName,
93+
symbol.Id,
9494
_ => new ConcurrentBag<SymbolReference> { symbol },
9595
(_, existing) =>
9696
{

src/PowerShellEditorServices/Services/Symbols/SymbolDetails.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,10 @@ internal static async Task<SymbolDetails> CreateAsync(
4444
SymbolReference = symbolReference
4545
};
4646

47-
if (symbolReference.SymbolType is SymbolType.Function)
47+
if (symbolReference.Type is SymbolType.Function)
4848
{
4949
CommandInfo commandInfo = await CommandHelpers.GetCommandInfoAsync(
50-
symbolReference.SymbolName,
50+
symbolReference.Id,
5151
currentRunspace,
5252
executionService).ConfigureAwait(false);
5353

@@ -60,7 +60,7 @@ await CommandHelpers.GetCommandSynopsisAsync(
6060

6161
if (commandInfo.CommandType == CommandTypes.Application)
6262
{
63-
symbolDetails.SymbolReference = symbolReference with { DisplayString = $"(application) ${symbolReference.DisplayString}" };
63+
symbolDetails.SymbolReference = symbolReference with { Name = $"(application) ${symbolReference.Name}" };
6464
}
6565
}
6666
}

src/PowerShellEditorServices/Services/Symbols/SymbolReference.cs

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,14 @@ namespace Microsoft.PowerShell.EditorServices.Services.Symbols
1212
/// <summary>
1313
/// A class that holds the type, name, script extent, and source line of a symbol
1414
/// </summary>
15-
[DebuggerDisplay("SymbolType = {SymbolType}, SymbolName = {SymbolName}")]
15+
[DebuggerDisplay("Type = {Type}, Id = {Id}, Name = {Name}")]
1616
internal record SymbolReference
1717
{
18-
public SymbolType SymbolType { get; init; }
18+
public SymbolType Type { get; init; }
1919

20-
public string SymbolName { get; init; }
20+
public string Id { get; init; }
2121

22-
public string DisplayString { get; init; }
22+
public string Name { get; init; }
2323

2424
public ScriptRegion NameRegion { get; init; }
2525

@@ -34,25 +34,25 @@ internal record SymbolReference
3434
/// <summary>
3535
/// Constructs and instance of a SymbolReference
3636
/// </summary>
37-
/// <param name="symbolType">The higher level type of the symbol</param>
38-
/// <param name="symbolName">The name of the symbol</param>
39-
/// <param name="displayString">The string used by outline, hover, etc.</param>
37+
/// <param name="type">The higher level type of the symbol</param>
38+
/// <param name="id">The name of the symbol</param>
39+
/// <param name="name">The string used by outline, hover, etc.</param>
4040
/// <param name="nameExtent">The extent of the symbol's name</param>
4141
/// <param name="scriptExtent">The script extent of the symbol</param>
4242
/// <param name="file">The script file that has the symbol</param>
4343
/// <param name="isDeclaration">True if this reference is the definition of the symbol</param>
4444
public SymbolReference(
45-
SymbolType symbolType,
46-
string symbolName,
47-
string displayString,
45+
SymbolType type,
46+
string id,
47+
string name,
4848
IScriptExtent nameExtent,
4949
IScriptExtent scriptExtent,
5050
ScriptFile file,
5151
bool isDeclaration)
5252
{
53-
SymbolType = symbolType;
54-
SymbolName = symbolName;
55-
DisplayString = displayString;
53+
Type = type;
54+
Id = id;
55+
Name = name;
5656
NameRegion = new(nameExtent);
5757
ScriptRegion = new(scriptExtent);
5858
FilePath = file.FilePath;

src/PowerShellEditorServices/Services/Symbols/SymbolsService.cs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -170,25 +170,25 @@ public async Task<IEnumerable<SymbolReference>> ScanForReferencesOfSymbolAsync(
170170
_executionService,
171171
cancellationToken).ConfigureAwait(false);
172172

173-
string targetName = symbol.SymbolName;
174-
if (symbol.SymbolType is SymbolType.Function
175-
&& aliases.AliasToCmdlets.TryGetValue(symbol.SymbolName, out string aliasDefinition))
173+
string targetName = symbol.Id;
174+
if (symbol.Type is SymbolType.Function
175+
&& aliases.AliasToCmdlets.TryGetValue(symbol.Id, out string aliasDefinition))
176176
{
177177
targetName = aliasDefinition;
178178
}
179179

180180
await ScanWorkspacePSFiles(cancellationToken).ConfigureAwait(false);
181181

182182
List<SymbolReference> symbols = new();
183-
string[] allIdentifiers = GetIdentifiers(targetName, symbol.SymbolType, aliases);
183+
string[] allIdentifiers = GetIdentifiers(targetName, symbol.Type, aliases);
184184

185185
foreach (ScriptFile file in _workspaceService.GetOpenedFiles())
186186
{
187187
foreach (string targetIdentifier in allIdentifiers)
188188
{
189189
await Task.Yield();
190190
cancellationToken.ThrowIfCancellationRequested();
191-
symbols.AddRange(file.References.TryGetReferences(symbol with { SymbolName = targetIdentifier }));
191+
symbols.AddRange(file.References.TryGetReferences(symbol with { Id = targetIdentifier }));
192192
}
193193
}
194194

@@ -239,15 +239,15 @@ public static IEnumerable<SymbolReference> FindOccurrencesInFile(
239239
// If we are not possibly looking at a Function, we don't
240240
// need to continue because we won't be able to get the
241241
// CommandInfo object.
242-
if (symbol?.SymbolType is not SymbolType.Function
242+
if (symbol?.Type is not SymbolType.Function
243243
and not SymbolType.Unknown)
244244
{
245245
return null;
246246
}
247247

248248
CommandInfo commandInfo =
249249
await CommandHelpers.GetCommandInfoAsync(
250-
symbol.SymbolName,
250+
symbol.Id,
251251
_runspaceContext.CurrentRunspace,
252252
_executionService).ConfigureAwait(false);
253253

src/PowerShellEditorServices/Services/TextDocument/Handlers/DocumentSymbolHandler.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ public override async Task<SymbolInformationOrDocumentSymbolContainer> Handle(Do
6969
//
7070
// TODO: We should also include function invocations that are part of DSLs (like
7171
// Invoke-Build etc.).
72-
if (!r.IsDeclaration || r.SymbolType is SymbolType.Parameter)
72+
if (!r.IsDeclaration || r.Type is SymbolType.Parameter)
7373
{
7474
continue;
7575
}
@@ -88,13 +88,13 @@ public override async Task<SymbolInformationOrDocumentSymbolContainer> Handle(Do
8888
symbols.Add(new SymbolInformationOrDocumentSymbol(new SymbolInformation
8989
{
9090
ContainerName = containerName,
91-
Kind = SymbolTypeUtils.GetSymbolKind(r.SymbolType),
91+
Kind = SymbolTypeUtils.GetSymbolKind(r.Type),
9292
Location = new Location
9393
{
9494
Uri = DocumentUri.From(r.FilePath),
9595
Range = new Range(r.NameRegion.ToRange().Start, r.ScriptRegion.ToRange().End) // Jump to name start, but keep whole range to support symbol tree in outline
9696
},
97-
Name = r.DisplayString
97+
Name = r.Name
9898
}));
9999
}
100100

src/PowerShellEditorServices/Services/TextDocument/Handlers/HoverHandler.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ await _symbolsService.FindSymbolDetailsAtLocationAsync(
5959

6060
List<MarkedString> symbolInfo = new()
6161
{
62-
new MarkedString("PowerShell", symbolDetails.SymbolReference.DisplayString)
62+
new MarkedString("PowerShell", symbolDetails.SymbolReference.Name)
6363
};
6464

6565
if (!string.IsNullOrEmpty(symbolDetails.Documentation))

src/PowerShellEditorServices/Services/Workspace/Handlers/WorkspaceSymbolsHandler.cs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -44,48 +44,48 @@ public override async Task<Container<SymbolInformation>> Handle(WorkspaceSymbolP
4444
// TODO: Need to compute a relative path that is based on common path for all workspace files
4545
string containerName = Path.GetFileNameWithoutExtension(scriptFile.FilePath);
4646

47-
foreach (SymbolReference foundOccurrence in foundSymbols)
47+
foreach (SymbolReference symbol in foundSymbols)
4848
{
4949
// This async method is pretty dense with synchronous code
5050
// so it's helpful to add some yields.
5151
await Task.Yield();
5252
cancellationToken.ThrowIfCancellationRequested();
5353

54-
if (!foundOccurrence.IsDeclaration)
54+
if (!symbol.IsDeclaration)
5555
{
5656
continue;
5757
}
5858

59-
if (foundOccurrence.SymbolType is SymbolType.Parameter)
59+
if (symbol.Type is SymbolType.Parameter)
6060
{
6161
continue;
6262
}
6363

64-
if (!IsQueryMatch(request.Query, foundOccurrence.SymbolName))
64+
if (!IsQueryMatch(request.Query, symbol.Id))
6565
{
6666
continue;
6767
}
6868

6969
// Exclude Pester setup/teardown symbols as they're unnamed
70-
if (foundOccurrence is PesterSymbolReference pesterSymbol &&
70+
if (symbol is PesterSymbolReference pesterSymbol &&
7171
!PesterSymbolReference.IsPesterTestCommand(pesterSymbol.Command))
7272
{
7373
continue;
7474
}
7575

7676
Location location = new()
7777
{
78-
Uri = DocumentUri.From(foundOccurrence.FilePath),
79-
Range = foundOccurrence.NameRegion.ToRange()
78+
Uri = DocumentUri.From(symbol.FilePath),
79+
Range = symbol.NameRegion.ToRange()
8080
};
8181

8282
// TODO: This should be a WorkplaceSymbol now as SymbolInformation is deprecated.
8383
symbols.Add(new SymbolInformation
8484
{
8585
ContainerName = containerName,
86-
Kind = SymbolTypeUtils.GetSymbolKind(foundOccurrence.SymbolType),
86+
Kind = SymbolTypeUtils.GetSymbolKind(symbol.Type),
8787
Location = location,
88-
Name = foundOccurrence.DisplayString
88+
Name = symbol.Name
8989
});
9090
}
9191
}

0 commit comments

Comments
 (0)