3

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?

bubbadoughball
  • 193
  • 2
  • 11

3 Answers3

2

Since you mention GPS, have you tried Tools->Documentation->Generate project? This will generate html, with hyperlinks etc, similar to Javadoc.

egilhh
  • 6,464
  • 1
  • 18
  • 19
2

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".

Simon Wright
  • 25,108
  • 2
  • 35
  • 62
  • I was hoping there was an existing Python module that would do this for me. Unfortunately I don't have the time right now to learn the API to write my own. – bubbadoughball Nov 14 '12 at 20:59
  • I ended up looking for GPS.Entities `e` where `e.category()` is `"object"` or `"literal"` and `e.full_name()` is equal to the source filename + `e.name()`. This gives me what I want and the only false positives I've seen are loop iterators used in elaboration routines. – bubbadoughball Nov 27 '12 at 15:45
2

SciTools' Understand product can extract this information, although it's rather pricey. Though if you're working with a mound of legacy code, it's well worth the money--it has saved my bacon on more than one occasion.

Marc C
  • 8,664
  • 1
  • 24
  • 29