File tree Expand file tree Collapse file tree 6 files changed +18
-4
lines changed
src/PowerShellEditorServices Expand file tree Collapse file tree 6 files changed +18
-4
lines changed Original file line number Diff line number Diff line change @@ -70,7 +70,9 @@ public PsesLanguageServer(
7070 /// cref="PsesServiceCollectionExtensions.AddPsesLanguageServices"/>.
7171 /// </remarks>
7272 /// <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
7374 public async Task StartAsync ( )
75+ #pragma warning restore CA1506
7476 {
7577 LanguageServer = await OmniSharp . Extensions . LanguageServer . Server . LanguageServer . From ( options =>
7678 {
Original file line number Diff line number Diff line change @@ -123,6 +123,7 @@ private PssaCmdletAnalysisEngine(
123123
124124 /// <summary>
125125 /// Format a script given its contents.
126+ /// TODO: This needs to be cancellable.
126127 /// </summary>
127128 /// <param name="scriptDefinition">The full text of a script.</param>
128129 /// <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(
244244
245245 foreach ( AliasInfo aliasInfo in aliases . Cast < AliasInfo > ( ) )
246246 {
247+ if ( cancellationToken . IsCancellationRequested )
248+ {
249+ break ;
250+ }
251+
247252 // TODO: When we move to netstandard2.1, we can use another overload which generates
248253 // static delegates and thus reduces allocations.
249254 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) &&
5454 /// <returns>true if the CommandAst represents a Pester command, false otherwise</returns>
5555 private static bool IsPesterCommand ( CommandAst commandAst )
5656 {
57- if ( commandAst == null )
57+ if ( commandAst is null )
5858 {
5959 return false ;
6060 }
@@ -94,7 +94,7 @@ private static PesterSymbolReference ConvertPesterAstToSymbolReference(ScriptFil
9494
9595 string commandName = CommandHelpers . StripModuleQualification ( pesterCommandAst . GetCommandName ( ) , out _ ) ;
9696 PesterCommandType ? commandType = PesterSymbolReference . GetCommandType ( commandName ) ;
97- if ( commandType == null )
97+ if ( commandType is null )
9898 {
9999 return null ;
100100 }
@@ -247,10 +247,11 @@ internal PesterSymbolReference(
247247
248248 internal static PesterCommandType ? GetCommandType ( string commandName )
249249 {
250- if ( commandName == null || ! PesterKeywords . TryGetValue ( commandName , out PesterCommandType pesterCommandType ) )
250+ if ( commandName is null || ! PesterKeywords . TryGetValue ( commandName , out PesterCommandType pesterCommandType ) )
251251 {
252252 return null ;
253253 }
254+
254255 return pesterCommandType ;
255256 }
256257
Original file line number Diff line number Diff line change @@ -34,6 +34,7 @@ internal class SymbolDetails
3434
3535 #region Constructors
3636
37+ // TODO: This should take a cancellation token!
3738 internal static async Task < SymbolDetails > CreateAsync (
3839 SymbolReference symbolReference ,
3940 IRunspaceInfo currentRunspace ,
Original file line number Diff line number Diff line change @@ -187,7 +187,11 @@ public async Task<IEnumerable<SymbolReference>> ScanForReferencesOfSymbolAsync(
187187 foreach ( string targetIdentifier in allIdentifiers )
188188 {
189189 await Task . Yield ( ) ;
190- cancellationToken . ThrowIfCancellationRequested ( ) ;
190+ if ( cancellationToken . IsCancellationRequested )
191+ {
192+ break ;
193+ }
194+
191195 symbols . AddRange ( file . References . TryGetReferences ( symbol with { Id = targetIdentifier } ) ) ;
192196 }
193197 }
You can’t perform that action at this time.
0 commit comments