* * *

Author Topic: Jedi Code Formatter: class destructor  (Read 440 times)

CCRDude

  • Sr. Member
  • ****
  • Posts: 297
Jedi Code Formatter: class destructor
« on: May 03, 2017, 11:43:23 am »
The JCF integrated into Lazarus 1.6.4 does not support class destructors. Since this leads to many of my units having issues, I checked the JCF code and propose this patch:

Code: Pascal  [Select]
  1. --- C:/Development/lazarus-1.6.4-fpc-3.0.2/components/jcf2/Parse/BuildParseTree.pas     Sun Jul 03 21:41:10 2016
  2. +++ C:/Development/lazarus-1.6.4-fpc-3.0.2/components/jcf2/Parse/BuildParseTree.pas     Wed May 03 11:39:15 2017
  3. @@ -3593,14 +3593,16 @@
  4.        case fcTokenList.SolidTokenType(2) of
  5.          ttProcedure:
  6.            RecogniseProcedureDecl(false);
  7.          ttFunction:
  8.            RecogniseFunctionDecl(false);
  9.          ttConstructor:
  10.            RecogniseConstructorDecl;
  11. +        ttDestructor:
  12. +          RecogniseDestructorDecl;
  13.          ttOperator:
  14.            RecogniseClassOperator(True);
  15.          else
  16.            raise TEParseError.Create('expected class procedure or class function', lc);
  17.        end;
  18.      end;
  19.      else
  20. @@ -4096,14 +4098,17 @@
  21.  end;
  22.  
  23.  procedure TBuildParseTree.RecogniseDestructorHeading(const pbDeclaration: boolean);
  24.  begin
  25.    //DestructorHeading -> DESTRUCTOR Ident [FormalParameters]
  26.    PushNode(nDestructorHeading);
  27.  
  28. +  if fcTokenList.FirstSolidTokenType = ttClass then
  29. +    Recognise(ttClass);
  30. +
  31.    Recognise(ttDestructor);
  32.    RecogniseMethodName( not pbDeclaration);
  33.    if fcTokenList.FirstSolidTokenType = ttOpenBracket then
  34.      RecogniseFormalParameters;
  35.  
  36.    RecogniseProcedureDirectives;
  37.  
  38. @@ -4384,14 +4389,16 @@
  39.              RecogniseClassVars;
  40.            ttProperty:
  41.            begin
  42.              RecogniseProperty;
  43.            end;
  44.            ttConstructor:
  45.              RecogniseConstructorHeading(True);
  46. +          ttDestructor:
  47. +            RecogniseDestructorHeading(True);
  48.            ttOperator:
  49.              RecogniseClassOperator(False);
  50.            else
  51.              raise TEParseError.Create('Expected class procedure or class function', lc);
  52.          end;
  53.  
  54.        end;
  55.  

Ondrej Pokorny

  • Full Member
  • ***
  • Posts: 110
Re: Jedi Code Formatter: class destructor
« Reply #1 on: May 03, 2017, 04:09:23 pm »
Please post it to bugs.freepascal.org. Thanks.

CCRDude

  • Sr. Member
  • ****
  • Posts: 297
Re: Jedi Code Formatter: class destructor
« Reply #2 on: May 03, 2017, 04:33:13 pm »

 

Recent

Get Lazarus at SourceForge.net. Fast, secure and Free Open Source software downloads Open Hub project report for Lazarus