Jump to content
Stano

Format uses clause

Recommended Posts

I used Format uses clause. I would like FireDAC.xx.yy to form a separate group as a System.xx, Vcl.xx and etc.

That there is them:classic_sad:
  FireDAC.Comp.Client, BasalForm, FireDAC.Stan.Param, FireDAC.Comp.DataSet, FireDAC.Stan.Intf, FireDAC.Stan.Option,
  FireDAC.Stan.Error, FireDAC.DatS, FireDAC.Phys.Intf, FireDAC.DApt.Intf, FireDAC.Stan.Async, FireDAC.DApt,

Share this post


Link to post

You can define the group names per project in MMX Properties - Project options:

image.thumb.png.dfad3a41ccd380556a51cb2a0be0b952.png

A single identifier is treated as a group prefix which has to be followed by a dot (like System, VCL, FireDAC).

You can also use wildcards like Rz* for all units from Raize Components (KSVC).

Unit names not covered in one of the schemes above can be listet in brackets.

 

This is the setting for MMX itself: 

(ToolsApi,DesignIntf,DCCStrs,DockForm,TabDock);Winapi;System.Win;System;Xml;Vcl;VirtualTrees*;Rz*;Tb*;Png*;MMX

The settings are stored in the dproj file.

  • Like 5

Share this post


Link to post

Excellent. I missed it, I didn't notice. He didn't understand.

Share this post


Link to post

Question on a similar frain..

I have the following in the Uses Clause Sorting..

"WinApi;System.Win;System;Data;Vcl;Vcl.ww;LMD*;js*;rz*;pp*;da*;sc*;adv*;edb*;nlh*;id*;esbpcs*"

It doesn't seem to respect the Vcl vs Vcl.ww*

Should it or is this simply a case of confusion buy the sorter??

 

Regards & TIA,

Ian

Share this post


Link to post

I'm not sure if I understand that right. You might add a sample uses clause showing what you expect and what you get. (That would also make it easier to create a new test case)

 

As I read the value shown, there is no "Vcl.ww*", but "Vcl.ww" which is handled as "Vcl.ww.*". Entries without a trailing star specify a unit scope.

Share this post


Link to post

Hi Uwe,

By way of example.  This is what I have..

  Vcl.Printers, Vcl.Graphics, Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.DBCtrls, Vcl.ComCtrls, Vcl.StdCtrls, Vcl.Buttons, Vcl.ExtCtrls, Vcl.Menus,
  vcl.wwdbgrid, Vcl.wwIDlg, Vcl.wwdbdlg, vcl.wwdblook, vcl.wwdbnavigator, vcl.Wwdbedit, vcl.Wwkeycb, vcl.Wwdbcomb, vcl.Wwfltdlg, Vcl.Mask,
  Vcl.NumberBox, vcl.Wwmemo, Vcl.ImgList, Vcl.Grids, vcl.wwDialog, vcl.Wwdotdot, vcl.wwdbigrd, vcl.wwspeedbutton, vcl.wwclearpanel,

This is what I would like to see..

  Vcl.Printers, Vcl.Graphics, Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.DBCtrls, Vcl.ComCtrls, Vcl.StdCtrls, Vcl.Buttons, Vcl.ExtCtrls, Vcl.Menus,
  Vcl.Mask, Vcl.NumberBox, Vcl.ImgList, Vcl.Grids,
  vcl.wwdbgrid, Vcl.wwIDlg, Vcl.wwdbdlg, vcl.wwdblook, vcl.wwdbnavigator, vcl.Wwdbedit, vcl.Wwkeycb, vcl.Wwdbcomb, vcl.Wwfltdlg, vcl.Wwmemo,
  vcl.wwDialog, vcl.Wwdotdot, vcl.wwdbigrd, vcl.wwspeedbutton, vcl.wwclearpanel,

Regards,

Ian

Share this post


Link to post

Thanks, now I see what you are after. The Vcl entry collects also the Vcl.ww* ones and the latter somewhat acts as a subgroup. Seems like the algorithm has to be fine tuned a bit. I will add that test case to the suite and see how I can make it green.

  • Like 1

Share this post


Link to post

Hi Uwe,

 

Since the grouping setting ist stores per project inside the DPROJ file: Is it possible to define a standard for new projects? We have some self-writte libs we would like to see at the end of the grouping, even in a newly created project. Currently it looks like the grouping is switched to the default when creating a new project.

 

Thanks in advance,

Ralf

Share this post


Link to post
1 hour ago, Ralf Kaiser said:

Is it possible to define a standard for new projects?

Good suggestion! I will note a feature request for it.

  • Like 1
  • Thanks 2

Share this post


Link to post

I would like to second this and suggest perhaps the option to make whatever is in the groups field persistent.

I use the same groups all the time sometimes I pull up an older project that hasn't been 'grouped' so I keep a copy of my MMX groups in a text editor that is persistent between uses.

Perhaps add a check box 'Make Groups persistent' so Users can make what they have in there persistent between projects, or not.

Share this post


Link to post

I thought about a global setting, that is taken when the project setting is empty, and omit populating the project settings with the hardcoded default.

Share this post


Link to post

Hi Uwe,

any news regarding the global setting already?

 

I recognized that units not belonging in a group get correctly placed after the groups, but are not sorted in alphabetical order. Is this a missing case?

Share this post


Link to post
37 minutes ago, TheDelphiCoder said:

I recognized that units not belonging in a group get correctly placed after the groups, but are not sorted in alphabetical order. Is this a missing case?

No, that is intended. Sorting is only done on the group level, but keeps the order inside that group intact. That still allows for some control over the unit order - at least inside a group.

Share this post


Link to post
19 hours ago, Uwe Raabe said:

No, that is intended. Sorting is only done on the group level, but keeps the order inside that group intact. That still allows for some control over the unit order - at least inside a group.

What about making that an option?

Share this post


Link to post

I have my doubts that this will ever be switched on - at least not for a longer time. The option will be all or nothing. It will affect all uses clauses in all units, even in all projects if it were not restricted to the Project options. Especially when the Auto Format option is enabled it will kick in whenever MMX manipulates any of the uses clause.

 

A possible way out of this could be to offer another MMX menu command instead of an always effective option (similar to the Format Uses - Alternate command). As long as the units are already sorted alphabetically, any subsequent format will keep that order.

 

Nevertheless, if the demand for such an option is high enough I can see what can be done.

Share this post


Link to post
Guest

(I apologise if I'm missing the context here.)

 

Automatically and unconditionally sorting units alphabetically doesn't seem to be a good idea. If you have multiple units exposing the same identifier then changing the order of units in the uses clause changes how they are resolved, probably leading to unintended changes to runtime behaviour of your code.

Share this post


Link to post

@Uwe Raabe Another issue: While sorting and grouping the uses clause the unit names are expanded to their full name, e.g.

SysUtils

becomes

System.SysUtils

This does NOT work for the Forms unit, it should become Vcl.Forms (in a VCL project, of course)! Other VCL units do not have this problem.

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×