Skip to content

Commit

Permalink
Small fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
elamaunt committed May 17, 2024
1 parent cab9f25 commit d4cefbd
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/GDShrapt.Reader/Expressions/GDMethodExpression.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
namespace GDShrapt.Reader
using System.Collections.Generic;
using System.Linq;

namespace GDShrapt.Reader
{
public class GDMethodExpression : GDExpression,
ITokenOrSkipReceiver<GDFuncKeyword>,
Expand Down Expand Up @@ -194,7 +197,10 @@ internal override void Left(IGDVisitor visitor)
{
visitor.Left(this);
}

public override IEnumerable<GDIdentifier> GetMethodScopeDeclarations(int? beforeLine = null)
{
return Parameters.Select(x => x.Identifier).Where(x => x != null);
}
void ITokenReceiver<GDFuncKeyword>.HandleReceivedToken(GDFuncKeyword token)
{
if (_form.IsOrLowerState(State.Func))
Expand Down
21 changes: 21 additions & 0 deletions src/GDShrapt.Reader/SimpleTokens/GDIdentifier.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit d4cefbd

Please sign in to comment.