Jump to content
PeterPanettone

List of all uses clause items in the whole project

Recommended Posts

I have filed a new feature request in the GExperts ticket-list:

 

#58 List of all uses clause items in the whole project

 

Please create a GExperts expert to create a merged list of all uses clause items in the whole project without duplicates.

 

EXAMPLE:

 

Project1 contains Unit1 and Unit2.

 

Unit1 interface uses clause contains: 
Vcl.Forms, Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, System.Actions, System.ImageList, hyieutils;
Unit1 implementation uses clause contains: 
Vcl.Graphics, Vcl.Controls;
Unit2 interface uses clause contains: 
Vcl.Forms, Vcl.Dialogs, Vcl.ExtCtrls, Vcl.ActnList, Vcl.ImgList;
Unit2 implementation uses clause contains: 
hyieutils, iesettings, iexRulers;

The list created by the expert would then look like this:

Vcl.Forms, Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, System.Actions, System.ImageList, Vcl.Graphics, Vcl.Controls, Vcl.Dialogs, Vcl.ExtCtrls, Vcl.ActnList, Vcl.ImgList, hyieutils, iesettings, iexRulers;

 

Of course, it should be possible to copy the list to the clipboard, save it as text, etc.

Edited by PeterPanettone

Share this post


Link to post

So the idea is simply to get a list of all units linked into the project? That can be done by parsing the map file, if one is being created. And that's a lot easier and faster.

  • Like 1

Share this post


Link to post
10 minutes ago, dummzeuch said:

So the idea is simply to get a list of all units linked into the project? That can be done by parsing the map file, if one is being created. And that's a lot easier and faster.

Thank you for your idea!

 

The map file for my project is 93 MB. For what should I look?

Share this post


Link to post
20 minutes ago, dummzeuch said:

That can be done by parsing the map file, if one is being created.

The MMX Module Analyzer actually uses this approach.

In the other hand there is the Unit Dependency Analyzer that actually parses the uses clauses to build the dependency tree.

  • Like 1

Share this post


Link to post

I have this line in the map file:

 

0001:0033B2E8 000073E8 C=CODE     S=.text    G=(none)   M=Vcl.Buttons ACBP=A9

 

But the unit Vcl.Buttons is not EXPLICITLY inside a uses clause inside my project. So I suppose the unit Vcl.Buttons is IMPLICITLY inside a used unit.

 

How to differentiate between explicit and implicit units?

Share this post


Link to post

The Unit Dependency Analyzer shows the used units per project unit. But not a merged list for the whole project.

Edited by PeterPanettone

Share this post


Link to post
6 minutes ago, PeterPanettone said:

The MMX Module Analyzer has the same problem: It lists BOTH explicit and implicit units.

Yes, that is intended. It lists all modules in the compiled exe (i.e. listed in the map file).

 

The Unit Dependency Analyzer lists only units in the uses clauses. Unless there is a search path to scan those units, you should get the list you are asking for.

 

2 minutes ago, PeterPanettone said:

The Unit Dependency Analyzer shows the used units per project unit. But not a merged list.

Well, it does! The ListView to the left contains all used units found in the search paths and all units not found, but mentioned in the uses clauses. You have to enable Show not found units to see that.

 

Can you provide a sample project with the desired result list?

Share this post


Link to post

Here is the list:

 

image.png.16c70671dadfb411aaf7dc08e1b47e48.png

 

There is no way to copy or save the list.

Edited by PeterPanettone

Share this post


Link to post
25 minutes ago, PeterPanettone said:

There is no way to copy or save the list.

Have you tried clicking the print button?

Share this post


Link to post

The Print feature seems to have a bug: With the only Show not found units filter switch activated, also the Show Found units items are output.

 

Even with no filters activated, all items are output.

Edited by PeterPanettone

Share this post


Link to post

So the Print button in the Unit Dependency Analyzer will become my preferred workaround solution. I just need to write a small tool to format the list in the way I need it (as a uses clause list).

Edited by PeterPanettone

Share this post


Link to post
30 minutes ago, PeterPanettone said:

Even with no filters activated, all items are output.

Not a bug - simply as designed!

Share this post


Link to post
5 minutes ago, Uwe Raabe said:

Not a bug - simply as designed!

Is this logical? Because the Print dialog does not mention this. One would expect that the report outputs the same list as shown in the pane.

Share this post


Link to post
1 hour ago, PeterPanettone said:

One would expect that the report outputs the same list as shown in the pane.

At least I for myself would not.

 

The report is not bound to the list and takes the complete scan result as output. Its position in the main toolbar instead of the list toolbar even suggests that it is not bound to the list. (I am just realizing that this may not be true for the official version, so I'll add a screenshot of the development version).
image.png.6013d9edd22f5194fbfab24046407c58.png

 

The list can be filtered with a handful of buttons or with the Show item of its context menu, as well as sorted in two different ways and displayed as List or Report view (in the sense of TListView.ViewStyle). The printed report is unaffected of all of these three settings.

 

If we assume you were right, then the Cycles Report button would not make sense anymore, as it could be achieved with the standard report when the list is filtered for cycles. 

 

So, yes, that is logical.

Share this post


Link to post
14 hours ago, PeterPanettone said:

I have this line in the map file:

 

0001:0033B2E8 000073E8 C=CODE     S=.text    G=(none)   M=Vcl.Buttons ACBP=A9

 

But the unit Vcl.Buttons is not EXPLICITLY inside a uses clause inside my project. So I suppose the unit Vcl.Buttons is IMPLICITLY inside a used unit.

 

How to differentiate between explicit and implicit units?

You can't. Why would you want to?

I can only think of a few uses for such a list:

  • Check if a unit is added that should not (e.g. it is being phased out / deprecated)
  • Get a list of 3rd party components to e.g. add to an about box (But that is better done at runtime.)
  • Search all used units for some string (What GExperts Grep now does and the GExperts Open File has been doing for a while)

All of these would want to include units that were indirectly added to a project.

 

(I know, I am a bit late to the conversation)

Share this post


Link to post
11 hours ago, Uwe Raabe said:

The report is not bound to the list and takes the complete scan result as output. Its position in the main toolbar instead of the list toolbar even suggests that it is not bound to the list. (I am just realizing that this may not be true for the official version, so I'll add a screenshot of the development version).

 

YOU KNOW that the two toolbars each have a different functionality scope, but for the USER this is not visually evident. There should be a visual distinction between the two toolbars.

 

BTW, the "Print" button could be easily overlooked as it has a grey color: image.png.babe61c5dace33a983c7fe61a9a53bac.png , so it seems to be a disabled button. Enabled buttons should be colored to distinguish them from disabled buttons.

 

Also, why using a "Printer" image for a REPORT functionality? This is clearly misleading.

 

And why are the buttons so tiny? For example, these two buttons cannot be visually distinguished:

 

image.png.27fde80914146e873772a350567edd5a.png

Share this post


Link to post
29 minutes ago, dummzeuch said:

I can only think of a few uses for such a list:

  • Check if a unit is added that should not (e.g. it is being phased out / deprecated)
  • Get a list of 3rd party components to e.g. add to an about box (But that is better done at runtime.)
  • Search all used units for some string (What GExperts Grep now does and the GExperts Open File has been doing for a while)
 
 
 

 

There is another one which seems to be the most obvious: When migrating a project (maybe a legacy project or a project received from another developer) it is important to have a complete overview of which units are used in the whole project.

Edited by PeterPanettone

Share this post


Link to post

Your original request has been 

17 hours ago, PeterPanettone said:

create a merged list of all uses clause items in the whole project without duplicates.

At the moment you are ranting about button colors, images and image sizes. I am out now.

Share this post


Link to post

Sorry for making the impression of "ranting". It was REALLY meant as objective and constructive feedback. Discussions can have ramifications. Peace!

 

"colors, images and image sizes" are not irrelevant. They are an (often overlooked) essential part of the user interface and thus of the program's functionality in the wider sense. Do you want me to file a feature request for this?

Edited by PeterPanettone

Share this post


Link to post
12 minutes ago, PeterPanettone said:

 

There is another one which seems to be the most obvious: When migrating a project (maybe a legacy project or a project received from another developer) it is important to have a complete overview of which units are used in the whole project.

For which again you would want to get a complete list, including those units indirectly used.

Share this post


Link to post
13 minutes ago, dummzeuch said:

For which again you would want to get a complete list, including those units indirectly used.

I agree for very few cases. In most cases, the directly used units would be enough.

 

Maybe an option (a checkbox) "Include indirectly used units" would be the optimal solution?

Edited by PeterPanettone

Share this post


Link to post
3 hours ago, PeterPanettone said:

I agree for very few cases. In most cases, the directly used units would be enough.

 

Maybe an option (a checkbox) "Include indirectly used units" would be the optimal solution?

For the user: yes, for the programmer: no.

Share this post


Link to post
16 minutes ago, dummzeuch said:

For the user: yes, for the programmer: no.

Having such a flexible option IMO would be useful in EVERY case.

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
×