From 74ceb2d057720d3642eb35bfb8ec15c095f8d676 Mon Sep 17 00:00:00 2001 From: Tyler Leonhardt Date: Fri, 13 Mar 2020 12:33:27 -0700 Subject: [PATCH 1/2] Optimize when we run GetCommandInfoAsync --- .../Services/Symbols/SymbolsService.cs | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/PowerShellEditorServices/Services/Symbols/SymbolsService.cs b/src/PowerShellEditorServices/Services/Symbols/SymbolsService.cs index 65ad2fb07..283cf91d2 100644 --- a/src/PowerShellEditorServices/Services/Symbols/SymbolsService.cs +++ b/src/PowerShellEditorServices/Services/Symbols/SymbolsService.cs @@ -345,7 +345,11 @@ public async Task FindParameterSetsInFileAsync( lineNumber, columnNumber); - if (foundSymbol == null) + // If we are not possibly looking at a Function, we don't + // need to continue because we won't be able to get the + // CommandInfo object. + if (foundSymbol?.SymbolType != SymbolType.Function + && foundSymbol?.SymbolType != SymbolType.Unknown) { return null; } @@ -459,9 +463,12 @@ public async Task GetDefinitionOfSymbolAsync( } } - // if definition is not found in file in the workspace - // look for it in the builtin commands - if (foundDefinition == null) + // if the definition is not found in a file in the workspace + // look for it in the builtin commands but only if the symbol + // we are looking at is possibly a Function. + if (foundDefinition == null + && (foundSymbol.SymbolType == SymbolType.Function + || foundSymbol.SymbolType == SymbolType.Unknown)) { CommandInfo cmdInfo = await CommandHelpers.GetCommandInfoAsync( From d5017244029d3bad3cdfff2ece2f08c9128f35a1 Mon Sep 17 00:00:00 2001 From: Tyler James Leonhardt Date: Sun, 15 Mar 2020 13:02:01 -0700 Subject: [PATCH 2/2] spacing Co-Authored-By: Robert Holt --- .../Services/Symbols/SymbolsService.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/PowerShellEditorServices/Services/Symbols/SymbolsService.cs b/src/PowerShellEditorServices/Services/Symbols/SymbolsService.cs index 283cf91d2..1b638a8c9 100644 --- a/src/PowerShellEditorServices/Services/Symbols/SymbolsService.cs +++ b/src/PowerShellEditorServices/Services/Symbols/SymbolsService.cs @@ -349,7 +349,7 @@ public async Task FindParameterSetsInFileAsync( // need to continue because we won't be able to get the // CommandInfo object. if (foundSymbol?.SymbolType != SymbolType.Function - && foundSymbol?.SymbolType != SymbolType.Unknown) + && foundSymbol?.SymbolType != SymbolType.Unknown) { return null; } @@ -467,8 +467,8 @@ public async Task GetDefinitionOfSymbolAsync( // look for it in the builtin commands but only if the symbol // we are looking at is possibly a Function. if (foundDefinition == null - && (foundSymbol.SymbolType == SymbolType.Function - || foundSymbol.SymbolType == SymbolType.Unknown)) + && (foundSymbol.SymbolType == SymbolType.Function + || foundSymbol.SymbolType == SymbolType.Unknown)) { CommandInfo cmdInfo = await CommandHelpers.GetCommandInfoAsync(