@@ -39,8 +39,6 @@ internal class SymbolsService
39
39
40
40
private readonly ConcurrentDictionary < string , ICodeLensProvider > _codeLensProviders ;
41
41
private readonly ConcurrentDictionary < string , IDocumentSymbolProvider > _documentSymbolProviders ;
42
- private readonly Dictionary < String , List < String > > _cmdletToAliasDictionary ;
43
- private readonly Dictionary < String , String > _aliasToCmdletDictionary ;
44
42
#endregion
45
43
46
44
#region Constructors
@@ -85,10 +83,6 @@ public SymbolsService(
85
83
{
86
84
_documentSymbolProviders . TryAdd ( documentSymbolProvider . ProviderId , documentSymbolProvider ) ;
87
85
}
88
-
89
- _cmdletToAliasDictionary = new Dictionary < String , List < String > > ( StringComparer . OrdinalIgnoreCase ) ;
90
- _aliasToCmdletDictionary = new Dictionary < String , String > ( StringComparer . OrdinalIgnoreCase ) ;
91
- GetAliases ( ) ;
92
86
}
93
87
94
88
#endregion
@@ -191,6 +185,8 @@ public List<SymbolReference> FindReferencesOfSymbol(
191
185
return null ;
192
186
}
193
187
188
+ ( ConcurrentDictionary < string , List < string > > cmdletToAliases , ConcurrentDictionary < string , string > aliasToCmdlets ) = await CommandHelpers . GetAliasesAsync ( _executionService ) . ConfigureAwait ( false ) ;
189
+
194
190
// We want to look for references first in referenced files, hence we use ordered dictionary
195
191
// TODO: File system case-sensitivity is based on filesystem not OS, but OS is a much cheaper heuristic
196
192
var fileMap = RuntimeInformation . IsOSPlatform ( OSPlatform . Linux )
@@ -224,8 +220,8 @@ public List<SymbolReference> FindReferencesOfSymbol(
224
220
IEnumerable < SymbolReference > references = AstOperations . FindReferencesOfSymbol (
225
221
file . ScriptAst ,
226
222
foundSymbol ,
227
- _cmdletToAliasDictionary ,
228
- _aliasToCmdletDictionary ) ;
223
+ cmdletToAliases ,
224
+ aliasToCmdlets ) ;
229
225
230
226
foreach ( SymbolReference reference in references )
231
227
{
@@ -494,36 +490,6 @@ await CommandHelpers.GetCommandInfoAsync(
494
490
return foundDefinition ;
495
491
}
496
492
497
- /// <summary>
498
- /// Gets all aliases found in the runspace
499
- /// </summary>
500
- private async void GetAliases ( )
501
- {
502
- IEnumerable < CommandInfo > aliases = await _executionService . ExecuteDelegateAsync < IEnumerable < CommandInfo > > (
503
- nameof ( GetAliases ) ,
504
- PowerShell . Execution . ExecutionOptions . Default ,
505
- ( pwsh , _ ) =>
506
- {
507
- CommandInvocationIntrinsics invokeCommand = pwsh . Runspace . SessionStateProxy . InvokeCommand ;
508
- return invokeCommand . GetCommands ( "*" , CommandTypes . Alias , nameIsPattern : true ) ;
509
- } ,
510
- System . Threading . CancellationToken . None ) . ConfigureAwait ( false ) ;
511
-
512
- foreach ( AliasInfo aliasInfo in aliases )
513
- {
514
- if ( ! _cmdletToAliasDictionary . ContainsKey ( aliasInfo . Definition ) )
515
- {
516
- _cmdletToAliasDictionary . Add ( aliasInfo . Definition , new List < String > ( ) { aliasInfo . Name } ) ;
517
- }
518
- else
519
- {
520
- _cmdletToAliasDictionary [ aliasInfo . Definition ] . Add ( aliasInfo . Name ) ;
521
- }
522
-
523
- _aliasToCmdletDictionary . Add ( aliasInfo . Name , aliasInfo . Definition ) ;
524
- }
525
- }
526
-
527
493
/// <summary>
528
494
/// Gets a path from a dot-source symbol.
529
495
/// </summary>
0 commit comments