Sign in Join

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

Mailing lists / fpc-pascal / 2022-10

CodeTools complete code

9 messages · 3 people · –

Reply by email Subscribe to this list Your subscription

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

Hairy Pixels

I’m trying to use the CompleteCode function in the CodeTools library and doing some formatting I don’t want.

Calling it over the “MyProcedure” method in the class it added a comment and moved the declaration under the variable section instead of directly under the class declaration like I would have expected. Basically I would just like the most minimal amount of changes to implement the method instead of reformatting things.

I see there is a beautifier class but it could it be used for this and if so how may that look?

Starting text:

/////////////////////////////////////////////////////////////////////////////////////////////
type
  TMyClass = class
    procedure MyProcedure;
  end;
var
  i: integer;

Modified text:

/////////////////////////////////////////////////////////////////////////////////////////////
type
  { TMyClass }
  TMyClass = class
    procedure MyProcedure;
  end;
var
  i: integer;
procedure TMyClass.MyProcedure;
begin
end;

Regards,
Ryan Joseph

Reply by email

Mattias Gaertner
to Hairy Pixels
Show quoted text 11 lines
I’m trying to use the CompleteCode function in the CodeTools library and doing some formatting I don’t want. Calling it over the “MyProcedure” method in the class it added a comment and moved the declaration under the variable section instead of directly under the class declaration like I would have expected. Basically I would just like the most minimal amount of changes to implement the method instead of reformatting things. I see there is a beautifier class but it could it be used for this and if so how may that look?

If you don't want the comment above the class, use

with CodeToolBoss.SourceChangeCache.BeautifyCodeOptions do
begin
  ClassHeaderComments:=false;
  ClassImplementationComments:=false;
end;

New procedure bodies are added behind global variables, so they can access them.
At the moment when a class has no method body yet, codetools uses the setting for the procedures. (It would be better, if this has a separate setting).

ForwardProcBodyInsertPolicy

Mattias

Reply by email

Hairy Pixels
to Mattias Gaertner
Show quoted text 10 lines
On Oct 4, 2022, at 2:40 PM, Mattias Gaertner via fpc-pascal wrote: If you don't want the comment above the class, use with CodeToolBoss.SourceChangeCache.BeautifyCodeOptions do begin ClassHeaderComments:=false; ClassImplementationComments:=false; end;

Great thanks.

New procedure bodies are added behind global variables, so they can access them.

Ok so this must apply to program files only. I can live with that I guess. It’s maybe best to make it an option. What do you think? Just because it’s an assumption the global variable will be can also be many global variable sections so that confuses the concept some also.

Show quoted text 5 lines
At the moment when a class has no method body yet, codetools uses the setting for the procedures. (It would be better, if this has a separate setting). ForwardProcBodyInsertPolicy

Regards,
Ryan Joseph

Reply by email

Mattias Gaertner
to Hairy Pixels
Show quoted text 17 lines
> On Oct 4, 2022, at 2:40 PM, Mattias Gaertner via fpc-pascal > wrote: > > If you don't want the comment above the class, use > > with CodeToolBoss.SourceChangeCache.BeautifyCodeOptions do > begin > ClassHeaderComments:=false; > ClassImplementationComments:=false; > end; > Great thanks. > New procedure bodies are added behind global variables, so they can > access them. Ok so this must apply to program files only.

You can define private classes in unit implementations as well.

I can live with that I guess. It’s maybe best to make it an option. What do you think?

A separate option where to start new classes is a good idea.

Just because it’s an assumption the global variable will be can't know that, so it needs manual help here.

In a unit implementation usually all global variables are at the beginning and the classes follow.

There can also be many global variable sections so that confuses the concept some also.

That is a confusing concept anyway. Aka bad coding style?

Mattias

Reply by email

Hairy Pixels
to Mattias Gaertner

Testing now and I found a potential bug in CodeTools. With this code here:

  Request := specialize TLSPStreaming<TCommandParams>.ToJSON(Params);

I get the error "illegal qualifier . found" @ 146:53.

Does CodeTools not understand generic class function calls? Here is the class in question:

  generic TLSPStreaming<T: TPersistent> = class
    class function ToObject(const JSON: TJSONData): T; static;
  end;

Regards,
Ryan Joseph

Reply by email

Bart
to Hairy Pixels
AM Hairy Pixels wrote
Does CodeTools not understand generic class function calls? Here is the class in question:

CodeTools is part of Lazarus.
So, better ask on the Lazarus ML.
(And yes, CodeTools has problems with generics.)

Bart

Reply by email

Hairy Pixels
to Bart
Show quoted text 10 lines
On Oct 5, 2022, at 4:23 PM, Bart via fpc-pascal wrote: On Wed, Oct 5, 2022 at 8:33 AM Hairy Pixels via fpc-pascal wrote: > Does CodeTools not understand generic class function calls? Here is the class in question: CodeTools is part of Lazarus. So, better ask on the Lazarus ML. (And yes, CodeTools has problems with generics.)

Ok thanks. I’m not a Lazarus user so I don’t really follow those forums.

Regards,
Ryan Joseph

Reply by email

Bart
to Hairy Pixels
PM Hairy Pixels wrote
> CodeTools is part of Lazarus.

...

Ok thanks. I’m not a Lazarus user so I don’t really follow those forums.

Ok, that makes me kinf of curious wether you and I mean the same when we refer to CodeTools.
I mean the part of the Lazarus IDE that does code completion etc. Since you don;t use Lazarus, you must mean something else?

Bart

Reply by email

Hairy Pixels
to Bart
Show quoted text 6 lines
On Oct 5, 2022, at 7:19 PM, Bart via fpc-pascal wrote: Ok, that makes me kinf of curious wether you and I mean the same when we refer to CodeTools. I mean the part of the Lazarus IDE that does code completion etc. Since you don;t use Lazarus, you must mean something else?

I have a Language Server for 3rd party IDE’s that uses the library so I use it like that.

Regards,
Ryan Joseph

Reply by email