[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Newsgroup Home]
[news.eclipse.tools.emf] Re: JMerge customization

Okay,
for everyone, how is interested in this discussion, i've found the problem 
with the ASTJCompilationUnit parser.

1. The parser didn't accept the single line comments in the 
CompilationUnit's content. So, a snippet like this:

    //a comment
    System.out.println("What the hell?");

will cause an exception with the message ("Syntax error.insert } to complete 
class body"). Both inside of a method body and in the class body. But you 
can use the multiline comments.

    /*a comment */
    System.out.println("What the hell?");

produces the correct JAST. Currently, i'm working with EMF 2.3, may be this 
is erased in a later version?
Or is there a flag, which has to be set for enabling // comments? IMHO, this 
kind of parsing is not feasibleö

And thank you very much, Ed, for concrete help.

Thx
Timothy



"Ed Merks" <Ed.Merks@xxxxxxxxx> schrieb im Newsbeitrag 
news:gbb87n$ldt$1@xxxxxxxxxxxxxxxxxxxx
Timonthy,

I doubt the tools are making it up.  The diagnostic that's created has the 
string with the contents, so look closely at those...


Timothy Marc wrote:
Ed,
indeed, you're right. The IProblem says, that the ClassBody contains a
missing "}", but that isn't so in real, because the java file i want to
parse is a valid file in a working project without syntax errors.
Why does this error appears?
Thx
Timothy

"Ed Merks" <Ed.Merks@xxxxxxxxx> schrieb im Newsbeitrag
news:gbarvg$bkt$1@xxxxxxxxxxxxxxxxxxxx

Timothy,

Try setting a breakpoint in ASTFacadeHelper.analyzeCompilationUnit and see
what IProblems are reported.  Perhaps you're generating code with syntax
errors?


Timothy Marc wrote:

Dear Marcelo,

okay, so here is my first question. Before, i tell you, what i planned
with Jmerge to do:

I want to reuse the JAST from JMerge, for manual analyzation of a Java
file. I didn't want to create Target/SourceCompilationUnit, because i
didn't want to use the JMerge algorithm for merging. All i need is a
JCompilationUnit, which i can traverse like i've mentioned in the snippet
below within the for-loop. Therefore, i used the following code snippet:

final File f = new
File("F:/TFH/SE/de.freundwendland.tfh.se.JMergeCodeGeneration/src/jmerge/importWizards/ImportWizardPage.java");
final File rules = new
File("F:/TFH/SE/de.freundwendland.tfh.se.JMergeCodeGeneration/mergeRules.xml");
JControlModel model = new JControlModel();
ASTFacadeHelper helper = new ASTFacadeHelper();
model.initialize(helper, rules.toURI().toString());
JMerger merger = new JMerger(model);
JCompilationUnit unit =
merger.createCompilationUnitForURI(f.toURI().toString()); //causes an
exception
ASTJCompilationUnit junit = helper.createCompilationUnit("Test",
unit.getContents());
for(final JNode o:junit.getChildren()){
    if(o instanceof JMethod){
        System.out.println(o.getQualifiedName());
    }
}

Nothing unusual, as i think. But the process fails with the following,
nut interpretable error message for me:
org.eclipse.emf.common.util.WrappedException:
org.eclipse.emf.common.util.DiagnosticException: A problem was detected
while parsing a Java file

at
org.eclipse.emf.codegen.merge.java.facade.ast.ASTFacadeHelper.createCompilationUnit(ASTFacadeHelper.java:282)

at
org.eclipse.emf.codegen.merge.java.facade.ast.ASTFacadeHelper.createCompilationUnit(ASTFacadeHelper.java:1)

at
org.eclipse.emf.codegen.merge.java.JMerger.createCompilationUnitForURI(JMerger.java:368)

at
org.eclipse.emf.codegen.merge.java.JMerger.createCompilationUnitForURI(JMerger.java:343)


So, does anyone or you know, why that happens? I've introspect the
related codeline in the createCompilationUnit... method, but didn't get
it.

Thx
Timothy