Recent

Author Topic: PToP Lazarus integration available  (Read 3333 times)

Leledumbo

  • Hero Member
  • *****
  • Posts: 8757
  • Programming + Glam Metal + Tae Kwon Do = Me
PToP Lazarus integration available
« on: February 09, 2016, 12:31:36 am »
Despite we have JCF ported and available by default, it works as a parser. That means, when it sees syntax error, it will stop formatting. The downside of such approach is that if the parser is not updated with bleeding edge language feature supported by the compiler, such a code will fail to format.

PToP is a solution in such a case because it works as a lexer, formatting is done based on token options only. No matter how broken your code is, PToP won't throw any error and format as far as it can (of course, wrong formatting could happen in such a case).

PToP is the original FPC beautifier written by Michael van Canneyt, one of FPC core developers, ported from other code which can be read in ptopu unit. I present you a Lazarus package that integrates PToP to our lovely IDE. You can directly format active window by pressing Ctrl+Shift+Alt+D or by choosing any of the option in Source->PToP. A settings dialog is available either from Source->PToP->Format Settings or Options->PToP->Settings whose screenshot can be seen attached. The package is hosted on bitbucket and is managed using Mercurial. No direct download is available ATM because I state the package now as alpha quality. Feel free to report for bugs.

There is one oddity currently: in order the settings to be populated, you must run one of the formatting option once. I need someone who has more experience in writing IDE integration package to take a look and tell me what I do wrong.

frakno

  • Jr. Member
  • **
  • Posts: 88
Re: PToP Lazarus integration available
« Reply #1 on: February 09, 2016, 10:17:54 am »
Good approach.
No problems to install.

Little troubles with type helper
Code: Pascal  [Select][+][-]
  1. Type
  2.   myrecordty = Record
  3.     a : integer;
  4.     b : integer;
  5.   End;
  6.   pmyrecordty = ^myrecordty;
  7.   myrecordarty = array Of myrecordty;
  8.  
  9. Type TFoo = array Of Integer;
  10.   TFooHelper =
  11.  
  12.                Type helper For TFoo
  13.                                Procedure SetMyArray(  Const Items: Array Of integer);
  14.                                End;
  15.                                tmainfo = Class(TObject)
  16.                                Private
  17.                                fitems: myrecordarty;
  18.                                Public
  19.                                Constructor Create; overload;
  20.                                End;
  21.  
  22.                                Type
  23.   { TForm1 }
  24.                                TForm1 = Class ( TForm )
  25.                                Button1 : TButton;
  26.                                Edit1 : TEdit;      


Thank you very much for your efforts
Lazarus 1.6 FPC 3.0 Windows 10

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 11452
  • FPC developer.
Re: PToP Lazarus integration available
« Reply #2 on: February 09, 2016, 11:02:53 am »
I'm not sure how updated ptop is for post D7 language extensions

Leledumbo

  • Hero Member
  • *****
  • Posts: 8757
  • Programming + Glam Metal + Tae Kwon Do = Me
Re: PToP Lazarus integration available
« Reply #3 on: February 09, 2016, 11:53:25 am »
Good approach.
No problems to install.

Little troubles with type helper
I'm not sure on how to fix this, probably helper should be added to the reserved word list then you can add options for it.
I'm not sure how updated ptop is for post D7 language extensions
Looking at the commit log, it's practically stops at whatever the language has in 2008.

@Michael (in case you read this):
I took ptopu from utils because I need to move certain things from implementation to interface and provide property for some private fields. Feel free to tell me if you have a better idea.

Thaddy

  • Hero Member
  • *****
  • Posts: 14373
  • Sensorship about opinions does not belong here.
Re: PToP Lazarus integration available
« Reply #4 on: February 09, 2016, 12:19:50 pm »
What my smallest comment to date could do ;) Great effort and it works.
I will try and shoot holes in it.

Many tnx!
Object Pascal programmers should get rid of their "component fetish" especially with the non-visuals.

 

TinyPortal © 2005-2018