Search code examples
adagnatgnat-studio

Ada - How to generate a list of package variables from GNAT Pro Studio?


I'd like to use the xref information from a GPS Ada project to generate lists of the variables defined for each package spec and body. I need to exclude any variables defined inside of subprograms.

I can see this information in GPS's "Project View" which shows the literals, package, pragmas, types, and variables defined in each file. However, the information is not selectable for cut/paste. How do I generate this in text form?


Solution

  • GPS is customised using Python. The provided scripts are in {installation}/share/gps/library; it looks as though unused_entities.py might be a good start. Or, there's a chapter on "Customizing and Extending GPS" in the GPS documentation.

    [Edit]

    Or, even better, look at the example globals.py in {installation}/share/examples/gps/python. A quick poke through the documentation (accessed in GPS via Help/Python extensions) suggests you're looking for GPS.Entities e where e.category() is "object".