RomanYankovsky / DelphiAST

Abstract syntax tree builder for Delphi
Mozilla Public License 2.0
271 stars 116 forks source link

Class method resolutions are not properly captured #233

Open JBontes opened 6 years ago

JBontes commented 6 years ago

The following construct:

  x = class(TInterfacedObject, IntfX)
  private
    class function A = B;  //class method resolution with 'class' prefix
   procedure X = Y; //same without prefix

Does not get captured properly.

Here's the fix:

procedure TPasSyntaxTreeBuilder.ClassMethodResolution;
var
  PrevNode: TSyntaxNode;
begin
  PrevNode:= FStack.Peek; //Get the ntMethod node above
  PrevNode.Attribute[anKind]:= FLexer.Token;  //add 'proc/func etc.
  FStack.Push(ntResolutionClause);
  try
    inherited;
  finally
    FStack.Pop;
  end;
end;