Re: MweReader class [message #480661] |
Tue, 18 August 2009 07:19 |
Sebastian Zarnekow Messages: 3118 Registered: July 2009 |
Senior Member |
|
|
Hi Ouakib,
as the last question is related to EMF, I'll add the respective
newsgroup to this post.
You may want to refer to the Diagnostic API of EMF to get an idea about
navigating and printing them.
Regards,
Sebastian
--
Need professional support for Eclipse Modeling?
Go visit: http://xtext.itemis.com
Am 17.08.09 19:05, schrieb ouakib:
> Hi ,
> I manage to generate the model from a string Here is my code :
>
> protected void invokeInternal(WorkflowContext ctx, ProgressMonitor
> monitor, Issues issues) {
> XtextResourceSet set = injector.getInstance(XtextResourceSet.class);
> set.setClasspathURIContext(getClasspathURIContext());
> set.addLoadOption(XtextResource.OPTION_RESOLVE_ALL, Boolean.TRUE);
>
> Resource resource = set.createResource(URI.createURI("dummy:/mydsl.math"));
> InputStream in = new ByteArrayInputStream("log(1)/".getBytes());
> try {
> resource.load(in, set.getLoadOptions());
> } catch (IOException e) {
> // TODO Auto-generated catch block
> e.printStackTrace();
> }
> EObject value= resource.getContents().get(0);
> System.out.println(resource.getErrors().get(0).getMessage()) ;
> ctx.set(outputSlot, value);
> registerIssues(set,issues);
> if (validate) {
> Diagnostic diagnostic = Diagnostician.INSTANCE.validate(value,
> getContext());
> registerIssues(diagnostic, issues);
> System.out.println(diagnostic.getMessage());
> System.out.println(diagnostic.getChildren().get(0).getMessag e());
> }
> }
>
>
>
> To get the syntax errors I write :
> resource.getErrors().get(0).getMessage()
> that 's works fine.
> But I have problems to get EMF problems which I make with check validation.
> I write : diagnostic.getChildren().get(0).getMessage()
> but I have as result something like :Diagnosis of
> mailto:math.impl.Model00Impl@1edc4ee{dummy:/mydsl.math#/}
>
|
|
|
Re: MweReader class [message #480679 is a reply to message #480661] |
Tue, 18 August 2009 08:20 |
Ed Merks Messages: 33141 Registered: July 2009 |
Senior Member |
|
|
Diagnostics form a tree structure, so you'll want to visit all of them.
Sebastian Zarnekow wrote:
> Hi Ouakib,
>
> as the last question is related to EMF, I'll add the respective
> newsgroup to this post.
> You may want to refer to the Diagnostic API of EMF to get an idea
> about navigating and printing them.
>
> Regards,
> Sebastian
Ed Merks
Professional Support: https://www.macromodeling.com/
|
|
|
Powered by
FUDForum. Page generated in 0.02854 seconds