Skip to content

Commit dee632c

Browse files
committed
skip function ast visit for FunctionMemberAst
1 parent 7d94efa commit dee632c

File tree

4 files changed

+23
-1
lines changed

4 files changed

+23
-1
lines changed

src/PowerShellEditorServices/Services/Symbols/Vistors/FindDeclarationVisitor.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,13 @@ public FindDeclarationVisitor(SymbolReference symbolRef)
3636
/// or a decision to continue if it wasn't found</returns>
3737
public override AstVisitAction VisitFunctionDefinition(FunctionDefinitionAst functionDefinitionAst)
3838
{
39+
// Extent for constructors and method trigger both this and VisitFunctionMember(). Covered in the latter.
40+
// This will not exclude nested functions as they have ScriptBlockAst as parent
41+
if (functionDefinitionAst.Parent is FunctionMemberAst)
42+
{
43+
return AstVisitAction.Continue;
44+
}
45+
3946
// Get the start column number of the function name,
4047
// instead of the the start column of 'function' and create new extent for the functionName
4148
int startColumnNumber =

src/PowerShellEditorServices/Services/Symbols/Vistors/FindReferencesVisitor.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,13 @@ public override AstVisitAction VisitCommand(CommandAst commandAst)
117117
/// <returns>A visit action that continues the search for references</returns>
118118
public override AstVisitAction VisitFunctionDefinition(FunctionDefinitionAst functionDefinitionAst)
119119
{
120+
// Extent for constructors and method trigger both this and VisitFunctionMember(). Covered in the latter.
121+
// This will not exclude nested functions as they have ScriptBlockAst as parent
122+
if (functionDefinitionAst.Parent is FunctionMemberAst)
123+
{
124+
return AstVisitAction.Continue;
125+
}
126+
120127
(int startColumnNumber, int startLineNumber) = VisitorUtils.GetNameStartColumnAndLineNumbersFromAst(functionDefinitionAst);
121128

122129
IScriptExtent nameExtent = new ScriptExtent()

src/PowerShellEditorServices/Services/Symbols/Vistors/FindSymbolVisitor.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,13 @@ public override AstVisitAction VisitCommand(CommandAst commandAst)
5858
/// or a decision to continue if it wasn't found</returns>
5959
public override AstVisitAction VisitFunctionDefinition(FunctionDefinitionAst functionDefinitionAst)
6060
{
61+
// Extent for constructors and method trigger both this and VisitFunctionMember(). Covered in the latter.
62+
// This will not exclude nested functions as they have ScriptBlockAst as parent
63+
if (functionDefinitionAst.Parent is FunctionMemberAst)
64+
{
65+
return AstVisitAction.Continue;
66+
}
67+
6168
int startLineNumber = functionDefinitionAst.Extent.StartLineNumber;
6269
int startColumnNumber = functionDefinitionAst.Extent.StartColumnNumber;
6370
int endLineNumber = functionDefinitionAst.Extent.EndLineNumber;

src/PowerShellEditorServices/Services/Symbols/Vistors/FindSymbolsVisitor.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@ public override AstVisitAction VisitFunctionDefinition(FunctionDefinitionAst fun
2525
{
2626
// Extent for constructors and method trigger both this and VisitFunctionMember(). Covered in the latter.
2727
// This will not exclude nested functions as they have ScriptBlockAst as parent
28-
if (functionDefinitionAst.Parent is FunctionMemberAst) {
28+
if (functionDefinitionAst.Parent is FunctionMemberAst)
29+
{
2930
return AstVisitAction.Continue;
3031
}
3132

0 commit comments

Comments
 (0)