Getting table usage and function usage from proparse/prorefactor xml.

Hello,

I've managed to set up the code to xml groovy script published on this website and would like to use it to determine the following:

  • Find out where a specific table X is used.

    • If possible, find out what values are searched for for field Y of table X (if the code contains FIND FIRST x WHERE x.y = "thisIsWhatINeed" NO-ERROR. I need to know the code looks for thisIsWhatINeed.) I only need to know this for 2 specific fields in 2 specific tables, not for any field in any table.
    • If possible, I would like to know in what specific internal function/procedure the table is used.
  • Find out where a specific function X is used (using a DYNAMIC-FUNCTION call). If possible not only the file in which it is used but also the internal function/procedure.

Given the tools I see in prorefactor I think that should be feasible. Now I would also like to do the following, is it realistic to try or will I just be wasting my time:

We've got an internal procedure runPersistent which takes a procedure and appserver name as parameter and returns a handle. The first parameter is the procedure which needs to be started persistently on the appsever. I want to know what functions are called from a program in what persistent procedure.

Could someone point me in the right direction to find out this information from the xml files generated by prorefactor? A few hints to what to look for or where to look would already make me very happy, I don't necessarily need ready code (although I would obviously not complain if I got some ;-)).

Thanks in advance,

Jan


Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
john's picture

Re: Getting table and function usage from ProRefactor XML

Hi Jan,

Thanks for trying out the code to xml groovy script. I'm glad you were able to get it working.

All of the tasks you have listed are certainly possible. I've written scripts for similar tasks for some of my customers, but I was using Groovy scripting directly with ProRefactor, rather than using the code to xml output.

In terms of function X used in DYNAMIC-FUNCTION, this should be straightforward for things like:

dynamic-function('X', ...)

but if you need to find things like:

def var funcname as character initial 'X'.
dynamic-function(funcname, ...)

then it would require more effort. This is the sort of thing that Analyst does.

The flow analysis you want to do for your runPersistent is realistic. The same as doing it by hand, your script would have to look for calls to runPersistent, then look at the uses of the handle returned from runPersistent to see how that handle is used. Again, a lot of this is done system-wide by Analyst, but it shouldn't be too hard to write scripts to examine the specific case you've described.

The next step in the whole code-to-xml idea is to build an xml parser which makes some sense of that raw xml output. Once that is done, then it will be relatively straightforward to do the kinds of analysis tasks that you have described. Nobody has started the xml parser though, and I expect it's going to take a bit of effort.

So, there's a bit of a disconnect. The next step in code-to-xml is a bit of a longer term goal that hasn't been tackled yet. It sounds to me like your tasks are much more immediate requirements.

I don't suppose you are fluent in any of the languages that run on the JVM? (Java, Groovy, Ruby, Python) If yes, then you would find it more expedient to work directly with ProRefactor.

What do you think Jan? Would you like to try to work with that raw xml output, or would you like to try working directly with ProRefactor? If you are really happy to work with the xml, then I could start taking a look at it, and try to explain what is in there.


Re: Getting table and function usage from ProRefactor XML

Thanks for your feedback John! I've been reading up on proparse and prorefactor and it's documentation yesterday and noticed that I could do everything I wanted with just proparse alone.
I'm working on it right now, and my hopes are very high, it's a complex matter but so far everything I tried seams to work exactly as I want.
Indeed the requirements for this specific task can't really wait for a complete parser for the XML (especially given it's already possible with proparse.)


john's picture

Re: Getting table and function usage from ProRefactor XML

Hi Jan, I'm glad you found that you could do what you wanted with Proparse alone. That was another alternative that I gave some consideration, but I didn't suggest it. ProRefactor creates 'sybmol tables' and scoping information in a secondary parsing phase, which I felt could make your tasks easier. But, you are right, you can probably accomplish your goals with Proparse alone.


Re: Getting table and function usage from ProRefactor XML

I've solved the problem using proparse. Thanks again for your help and for providing this wonderfull tool to the community.


tamhas's picture

This sounds like something

This sounds like something that would fit in nicely with this proposed project http://www.oehive.org/node/1112


Re: This sounds like something

Indeed, it does, however the problem was too urgent to wait for a complete implementation of an XML parser.


tamhas's picture

Ah, but there is always a

Ah, but there is always a next time ...