how to make a query with proparse.NET from OpeneEdge

Hello,

I'm trying to port a parsing tool from the old proparse.p api to the new .NET api, but I don't understand how I can call the query method on a JPNode. The javadocs say it returns a generic type (java.util.ArrayList) and (as far as I know) generics are not supported in ABL yet.

Thanks in advance!

Jan

DEFINE INPUT PARAMETER icFileName AS CHARACTER NO-UNDO.

USING org.prorefactor.refactor.* FROM assembly.
USING org.prorefactor.treeparser.* FROM assembly.
USING org.prorefactor.core.* FROM assembly.

DEFINE VARIABLE prSession AS CLASS RefactorSession.
DEFINE VARIABLE pu AS CLASS ParseUnit.
DEFINE VARIABLE topNode AS JPNode.

prsession = RefactorSession:getInstance().
pu = NEW ParseUnit(NEW java.io.File(icFileName)).
pu:treeParser01().
topNode = pu:getTopNode().

/* HOW TO CALL topNode:query(... here? */


Comment viewing options

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

Re: how to make a query with proparse.NET from OpeneEdge

Hi Jan, sorry, the javadocs are a little out of date. It's on my 'to-do' list to make them part of the regular release process.

When building the new API for Prolint (for Proparse.Net) I added a new method to JPNode:

/** This variant is primarily for ease of use from ABL. */
public JPNode [] query(String typeName)

HTH!
John


Thanks (+ extra change)

Aha, that helps a lot. I've now also downloaded the code to understand better what's happening.
Could you add the following method to JPNode (I did to make my life easier, it allows me to map my old code to the new parser much faster):

/** This variant is primarily for ease of use from ABL. */
public JPNode [] getDirectChildrenArray() {
ArrayList<JPNode> list = getDirectChildren();
JPNode [] ret = new JPNode[list.size()];
list.toArray(ret);
return ret;
}


john's picture

Re: Thanks (+ extra change)

Hi Jan, good one. Thanks for the submission. I added it to SVN, and it will be in the next release.
Cheers, John.