diff --git a/src/GDShrapt.Reader/Expressions/GDMethodExpression.cs b/src/GDShrapt.Reader/Expressions/GDMethodExpression.cs index fe78956..b2fd499 100644 --- a/src/GDShrapt.Reader/Expressions/GDMethodExpression.cs +++ b/src/GDShrapt.Reader/Expressions/GDMethodExpression.cs @@ -1,4 +1,7 @@ -namespace GDShrapt.Reader +using System.Collections.Generic; +using System.Linq; + +namespace GDShrapt.Reader { public class GDMethodExpression : GDExpression, ITokenOrSkipReceiver, @@ -194,7 +197,10 @@ internal override void Left(IGDVisitor visitor) { visitor.Left(this); } - + public override IEnumerable GetMethodScopeDeclarations(int? beforeLine = null) + { + return Parameters.Select(x => x.Identifier).Where(x => x != null); + } void ITokenReceiver.HandleReceivedToken(GDFuncKeyword token) { if (_form.IsOrLowerState(State.Func)) diff --git a/src/GDShrapt.Reader/SimpleTokens/GDIdentifier.cs b/src/GDShrapt.Reader/SimpleTokens/GDIdentifier.cs index 21b8816..b7cf93a 100644 --- a/src/GDShrapt.Reader/SimpleTokens/GDIdentifier.cs +++ b/src/GDShrapt.Reader/SimpleTokens/GDIdentifier.cs @@ -204,6 +204,27 @@ public bool TryExtractLocalScopeVisibleDeclarationFromParents(out GDIdentifier d continue; } + if (node is GDMethodExpression methodExpr) + { + foreach (var item in node.GetMethodScopeDeclarations(startLine)) + { + if (item == this) + { + declaration = item; + return true; + } + } + + if (methodExpr.Identifier == this) + { + declaration = methodExpr.Identifier; + return true; + } + + node = node.Parent; + continue; + } + foreach (var item in node.GetMethodScopeDeclarations(startLine)) { if (item == this)