Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / lazarus / 2010-02

JEDI code formatting

10 messages · 4 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Bernd Kreuss

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hello,

does anybody know details about how exactly the JEDI code formatter works? I think i have found a bug and i want to fix it. Although i already filed a bug with the JCF project i think it will take some time until it is fixed in Lazarus too and I think it is only a few lines of code, so i can make my own workaround until then (and maybe send the patches to jcf if i'm faster than them).

Here is the bug: when i have a program

program foo;
const
    x = 1;
begin
end.

the code formatter will remove the indentation before the x which looks quite ugly. indentation of const blocks work only in units, not in programs or libraries (tested with the current download of jcf from their sourceforge page).

I think this should be easy to fix if I only knew where to look in all the many source files of the jcf. Can anybody point me into the right direction?

Bernd
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iD8DBQFLdh+FxT6R4jlFoh0RAmhKAKDM+DQQa6xVH+rU9X7cweBT3AKOFQCg5i0K hAFiHTbxiwZzpbkGr+kVAXY=
=bh78
-----END PGP SIGNATURE-----

Reply by email

Paul Ishenin
to Bernd Kreuss
Show quoted text 7 lines
does anybody know details about how exactly the JEDI code formatter works? I think i have found a bug and i want to fix it. Although i already filed a bug with the JCF project i think it will take some time until it is fixed in Lazarus too and I think it is only a few lines of code, so i can make my own workaround until then (and maybe send the patches to jcf if i'm faster than them).

If the bug is fixed in the JCF code repository then I will update lazarus version. I do this from time to time.

Best regards,
Paul Ishenin.

Reply by email

Bernd Kreuss
to Paul Ishenin

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Paul Ishenin wrote
If the bug is fixed in the JCF code repository then I will update lazarus version. I do this from time to time.

I have found the bug and fixed it. Here is the fix:

C:\lazarus\components\jcf2\Process\Indent\Indenter.pas starting in line 113:

Show quoted text 5 lines
function InGlobalTypeOrVarSection(const pt: TSourceToken): Boolean; begin // are we in a type or var section? if not pt.HasParentNode([nTypeSection, nVarSection]) then begin

change this to:

Show quoted text 7 lines
function InGlobalTypeOrVarSection(const pt: TSourceToken): Boolean; begin // are we in a type or var section? // EXPERIMENTAL: added CONST section to this list, // maybe rename the whole function now? It is used only once. if not pt.HasParentNode([nTypeSection, nVarSection, nConstSection]) then begin

This is only called once near the end of the file at line 638 and seems to be part of another prior bugfix. The bug in the bugfix 1898723 and my fix for the fix will only ever happen if the setting "indent for procedures in library" is DISabled, else all this code won't be executed at all.

I'll continue to test this a bit although I think it is safe and could already be sent upstream.

Bernd
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iD8DBQFLdq2ixT6R4jlFoh0RArzKAJ96SN143sG8RpPTJzT4AS8mWKRFIwCffITQ m5r/8Z7sz7uont0zX0oAWQA=
=E/5A
-----END PGP SIGNATURE-----

Reply by email

Guionardo Furlan
to Bernd Kreuss

Well, I see another problem:

jcf doesn't recognize operator overloading.

2010/2/13 Bernd Kreuss :

Show quoted text 54 lines
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Paul Ishenin wrote: > If the bug is fixed in the JCF code repository then I will update > lazarus version. I do this from time to time. I have found the bug and fixed it. Here is the fix: C:\lazarus\components\jcf2\Process\Indent\Indenter.pas starting in line 113: > function InGlobalTypeOrVarSection(const pt: TSourceToken): Boolean; > begin > ? // are we in a type or var section? > ? if not pt.HasParentNode([nTypeSection, nVarSection]) then > ? begin change this to: > function InGlobalTypeOrVarSection(const pt: TSourceToken): Boolean; > begin > ? // are we in a type or var section? > ? // EXPERIMENTAL: added CONST section to this list, > ? // maybe rename the whole function now? It is used only once. > ? if not pt.HasParentNode([nTypeSection, nVarSection, nConstSection]) then > ? begin This is only called once near the end of the file at line 638 and seems to be part of another prior bugfix. The bug in the bugfix 1898723 and my fix for the fix will only ever happen if the setting "indent for procedures in library" is DISabled, else all this code won't be executed at all. I'll continue to test this a bit although I think it is safe and could already be sent upstream. Bernd -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.6 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iD8DBQFLdq2ixT6R4jlFoh0RArzKAJ96SN143sG8RpPTJzT4AS8mWKRFIwCffITQ m5r/8Z7sz7uont0zX0oAWQA= =E/5A -----END PGP SIGNATURE----- -- _______________________________________________ Lazarus mailing list http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
Timeo hominem unius libri Cogito ergo sum - Carpe diem []s Guionardo Furlan http://guionardo.blogspot.com http://www.guionardofurlan.com.br

Reply by email

Guionardo Furlan
to Paul Ishenin

Sure. I've created a new form to demonstrate:

unit Unit1;
{$mode objfpc}{$H+}
interface

uses
Classes, SysUtils, FileUtil, LResources, Forms, Controls, Graphics, Dialogs,
StdCtrls;

type

{ TForm1 }

 TForm1 = class(TForm)
   Button1: TButton;
   procedure Button1Click(Sender: TObject);
 private
   { private declarations }
 public
   { public declarations }
 end;
var
 Form1: TForm1;
operator ** (b1: byte; b2: byte): integer;
implementation
operator**(b1: byte; b2: byte): integer;
var i : Integer;
begin
  Result:=1;
  for i:=1 to b2 do
    Result:=Result*b1;
end;

{ TForm1 }

procedure TForm1.Button1Click(Sender: TObject);
var
 i:      integer;
 b1, b2: byte;
begin
 b1 := 10;
 b2 := 3;
 i  := b1 ** b2;
 ShowMessage(IntToStr(i));
end;
initialization
 {$I unit1.lrs}
end.

The code is OK, and compiles 100%.

When I command Ctrl-D, I get this from JCF:

http://picasaweb.google.com/lh/photo/_ixt2_gM792PLJ9-ISZ4uw?feat=directlink [image: jcf.png]

2010/2/15 Paul Ishenin :

Show quoted text 7 lines
16.02.2010 3:02, Guionardo Furlan wrote: > > Well, I see another problem: > > jcf doesn't recognize operator overloading. Actually, this was implemented. Can you give an example of code which is

not

Show quoted text 12 lines
recognized? Best regards, Paul Ishenin. -- _______________________________________________ Lazarus mailing list http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
Timeo hominem unius libri Cogito ergo sum - Carpe diem []s Guionardo Furlan http://guionardo.blogspot.com http://www.guionardofurlan.com.br -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20100216/3f6b97ca/attachment.html>

Reply by email

Paul Ishenin
to Paul Ishenin
Paul Ishenin wrote 5 lines
16.02.2010 20:51, Guionardo Furlan wrote: > operator**(b1: byte; b2: byte): integer; Yes, I see. The error happens only when you have operator in the interface section.

Fixed in r23718. I will push this upstream later.

Best regards,
Paul Ishenin.

Reply by email

Raistware
to Paul Ishenin

I have found another bug on JCF:
I have copied the minium code to reproduce error, only the offending line: ----
unit Unit1;

{$mode objfpc}
interface
uses
   Classes, SysUtils;
implementation
initialization
ShowMessage('Est? soportado. Solicite m?s informaci?n en la p?gina del
proyecto. Gracias');
end.
------

JCF: unit1.pas Exception Exception Spaces to end is -1 on ) at on line 13 position 94 line is
ShowMessage('Est? soportado. Solicite m?s informaci?n en la p?gina del proyecto. Gracias');
JCF: IDE Aborted due to error

Seems to be related with a with an acute.

Reply by email

Guionardo Furlan
to Paul Ishenin: Fixed in r23718. I will push this upstream later. Paul Ishenin.

Thanks, Paul.

2010/2/16 Paul Ishenin

Show quoted text 23 lines
16.02.2010 21:11, Paul Ishenin wrote: > 16.02.2010 20:51, Guionardo Furlan wrote: > >> operator**(b1: byte; b2: byte): integer; >> > > Yes, I see. The error happens only when you have operator in the interface > section. > Fixed in r23718. I will push this upstream later. Best regards, Paul Ishenin. -- _______________________________________________ Lazarus mailing list http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
Timeo hominem unius libri Cogito ergo sum - Carpe diem []s Guionardo Furlan http://guionardo.blogspot.com http://www.guionardofurlan.com.br -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20100217/4a4b46e1/attachment.html>

Reply by email