File tree 6 files changed +18
-4
lines changed
src/PowerShellEditorServices
6 files changed +18
-4
lines changed Original file line number Diff line number Diff line change @@ -70,7 +70,9 @@ public PsesLanguageServer(
70
70
/// cref="PsesServiceCollectionExtensions.AddPsesLanguageServices"/>.
71
71
/// </remarks>
72
72
/// <returns>A task that completes when the server is ready and listening.</returns>
73
+ #pragma warning disable CA1506 // Coupling complexity we don't care about
73
74
public async Task StartAsync ( )
75
+ #pragma warning restore CA1506
74
76
{
75
77
LanguageServer = await OmniSharp . Extensions . LanguageServer . Server . LanguageServer . From ( options =>
76
78
{
Original file line number Diff line number Diff line change @@ -123,6 +123,7 @@ private PssaCmdletAnalysisEngine(
123
123
124
124
/// <summary>
125
125
/// Format a script given its contents.
126
+ /// TODO: This needs to be cancellable.
126
127
/// </summary>
127
128
/// <param name="scriptDefinition">The full text of a script.</param>
128
129
/// <param name="formatSettings">The formatter settings to use.</param>
Original file line number Diff line number Diff line change @@ -244,6 +244,11 @@ public static async Task<AliasMap> GetAliasesAsync(
244
244
245
245
foreach ( AliasInfo aliasInfo in aliases . Cast < AliasInfo > ( ) )
246
246
{
247
+ if ( cancellationToken . IsCancellationRequested )
248
+ {
249
+ break ;
250
+ }
251
+
247
252
// TODO: When we move to netstandard2.1, we can use another overload which generates
248
253
// static delegates and thus reduces allocations.
249
254
s_cmdletToAliasCache . AddOrUpdate (
Original file line number Diff line number Diff line change @@ -54,7 +54,7 @@ commandAst.InvocationOperator is not (TokenKind.Dot or TokenKind.Ampersand) &&
54
54
/// <returns>true if the CommandAst represents a Pester command, false otherwise</returns>
55
55
private static bool IsPesterCommand ( CommandAst commandAst )
56
56
{
57
- if ( commandAst == null )
57
+ if ( commandAst is null )
58
58
{
59
59
return false ;
60
60
}
@@ -94,7 +94,7 @@ private static PesterSymbolReference ConvertPesterAstToSymbolReference(ScriptFil
94
94
95
95
string commandName = CommandHelpers . StripModuleQualification ( pesterCommandAst . GetCommandName ( ) , out _ ) ;
96
96
PesterCommandType ? commandType = PesterSymbolReference . GetCommandType ( commandName ) ;
97
- if ( commandType == null )
97
+ if ( commandType is null )
98
98
{
99
99
return null ;
100
100
}
@@ -247,10 +247,11 @@ internal PesterSymbolReference(
247
247
248
248
internal static PesterCommandType ? GetCommandType ( string commandName )
249
249
{
250
- if ( commandName == null || ! PesterKeywords . TryGetValue ( commandName , out PesterCommandType pesterCommandType ) )
250
+ if ( commandName is null || ! PesterKeywords . TryGetValue ( commandName , out PesterCommandType pesterCommandType ) )
251
251
{
252
252
return null ;
253
253
}
254
+
254
255
return pesterCommandType ;
255
256
}
256
257
Original file line number Diff line number Diff line change @@ -34,6 +34,7 @@ internal class SymbolDetails
34
34
35
35
#region Constructors
36
36
37
+ // TODO: This should take a cancellation token!
37
38
internal static async Task < SymbolDetails > CreateAsync (
38
39
SymbolReference symbolReference ,
39
40
IRunspaceInfo currentRunspace ,
Original file line number Diff line number Diff line change @@ -187,7 +187,11 @@ public async Task<IEnumerable<SymbolReference>> ScanForReferencesOfSymbolAsync(
187
187
foreach ( string targetIdentifier in allIdentifiers )
188
188
{
189
189
await Task . Yield ( ) ;
190
- cancellationToken . ThrowIfCancellationRequested ( ) ;
190
+ if ( cancellationToken . IsCancellationRequested )
191
+ {
192
+ break ;
193
+ }
194
+
191
195
symbols . AddRange ( file . References . TryGetReferences ( symbol with { Id = targetIdentifier } ) ) ;
192
196
}
193
197
}
You can’t perform that action at this time.
0 commit comments