using proparse within an eclipse plugin

hi @all

i have a question about using proparse in an eclipse plugin. i wanna use proparse to create a codeformatter. because of that i need an AST. The AST provided by the openedge architct isnt satisfing, because i cant read the preprocessor statements. that's why i switched to proparse.

now the problem:
proparse checks the file references for included files. is there a simple way to tell proparse not to check such paths, it would be ok that i only get yep this is an include statement?
here my code:


File f = new File(currentUnit.getFileName());
ParseUnit p = new ParseUnit(f);
try {
    p.treeParser01();
} catch (RefactorException e) {
    e.printStackTrace();
} finally {
    System.out.println(p.getTopNode().getNodeNum());
    for(JPNode t : p.getTopNode().getDirectChildren()){
        System.out.println(t.toString());
        for(ProToken pt : t.getHiddenTokens()){
            int tokenType = pt.getType();
            System.out.println(tokenType + "    " + TokenTypes.getTokenName(tokenType)+ "    " + TokenTypes.getDefaultText(tokenType));	
        }
    }
}

i am using openedge architect 10.2 (eclipse 3.6) and proparse from the website with the date july 10, 2010.

best regards
erik


Comment viewing options

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

Re: using proparse within an eclipse plugin

Hi Erik, no there is no way to tell Proparse not to expand include file references.
Regards, John


Thank you John, for your

Thank you John, for your answer.

so i have to tell proparse the PROPATH to get it working well? and how it is be done?

Regards, Erik


john's picture

Ancient history

My old 'ProRefactor' work was an Eclipse plugin, much of which was initially written around 2003. Much of it is obsolete and archived. Eclipse has changed, and so has Proparse. (Proparse was only a C++ DLL at that time, which made it very clumsy to work with.) All of the syntax tree engine work in ProRefactor was merged into Proparse (java), and all of the Eclipse work was archived.

The reason the project config dump utility writes to 'prorefactor/projects/your_project_name' is because of the way I had ProRefactor as an Eclipse plugin working with multiple OpenEdge projects within a single Eclipse session. Before any ProRefactor action would be taken (like parsing a file), it would check to see which project the file was in, and change the project settings within ProRefactor and Proparse if necessary (propath, schema, etc).

I don't think there's much to be salvaged from that old work, but you might look at one file in particular: svn://oehive.org/proparse/archives/archive_prorefactor/home/jgreen/archives/trunk-before-proparsej/org.prorefactor.eclipse/src/org/prorefactor/eclipse/actions/ActionManager.java

It used this method to see which project an Eclipse IResource (file/directory) belonged to:

	protected void checkForProjectChange(IResource theResource) {
		String projName = theResource.getProject().getName();
		if (currProject!=null && projName.equals(currProject)) return;
		try {
			currProject = projName;
			refPack.loadProject(currProject);
		} catch (Throwable e) {
			console("Error Loading Project Settings\n" + e.toString());
			Plugin.log(e);
			return;
		}
	}

john's picture

Yes, Proparse needs a valid

Yes, Proparse needs a valid PROPATH. It must process the include files to build a valid syntax tree.

To configure Proparse with PROPATH and schema:

See http://www.oehive.org/prorefactor/proj_cfg_dump for a utility which dumps your settings (schema, PROPATH, and a few others) out to a directory called prorefactor/projects/your_project_name. Copy it to your working directory for Proparse to find it. Then:

RefactorSession prsession = RefactorSession.getInstance();
prsession.loadProject(your_project_name);

Hi it is me again. i have

Hi it is me again.

i have done my configuration and it works pretty well thank you for that hint.
but i ran into another problem. i have an encrypted source. and proparse tries to resolve the includes in the encrypted file. can i uses proparse to decrypt files? or what is to do to leave out encrypted files?

here my responese from proparse

Can't find/access AST Node typeorg.prorefactor.core.JPNode
Can't find/access AST Node typeorg.prorefactor.core.JPNode
Can't find/access AST Node typeorg.prorefactor.core.JPNode
Can't find/access AST Node typeorg.prorefactor.core.JPNode
org.prorefactor.refactor.RefactorException: java.lang.RuntimeException: java.io.IOException: C:\proalpha\pa\52f\cry\\arch/incl/o__cry00.lib: Could not find include file: TÊÏ...

i hope my problem is clear.

regards
erik


john's picture

Re: Proparse and encrypted source files

Hi,
No, there's no way for Proparse to deal with encrypted source files. You won't be able to parse any programs that are encrypted, or any programs that include encrypted include files. Sorry.
John


Hi, thats pitty. maybe you

Hi,

thats pitty. maybe you know another parser wich can creates me an ast with all componentes, including preprocessor and comments?

or is there an other better way to do a pretty print of the code?

regards
erik


tamhas's picture

If you think about it, the

If you think about it, the encryption wouldn't be very much good if you could parse it to a syntax tree, would it? This isn't a limitation of Proparse, but of logic. The only one I would expect to be able to read encrypted source would be a parser from PSC.


john's picture

No, I'm not aware of

No, I'm not aware of anything that will get around the encrypted source. The only alternative is to create non-encrypted 'stubs' for the encrypted source, but that is labor intensive and often impractical.