Help with MWE Reader [message #696359] |
Wed, 13 July 2011 19:18 |
Rafael Angarita Messages: 94 Registered: November 2010 |
Member |
|
|
Hello,
I'm having a problem with my MWE Reader. It was working well until I did a major reorganization of my grammars and .xtetx files. This is the code with comments and questions:
public List<Table> loadTablesMwe() throws Exception {
String pathfolder = ResourcesPlugin.getWorkspace().getRoot().getProject(projectName).getLocation().toOSString();
Reader reader = new Reader();
reader.addRegister(new AGStandaloneSetup());
UriFilter filter = new UriFilter() {
@Override
public boolean matches(URI uri) {
if (uri != null) {
//I filter by file extension
if( Services.isProcedureSource(uri.toFileString()) ||
Services.isSDTSource(uri.toFileString())
)
return false;
}
return true;
}
};
reader.setUriFilter(filter);
reader.addPath(pathfolder);
SlotEntry se = new SlotEntry();
se.setSlot("tables");
//What should be here in Type? The language name? the EObject type?
se.setType("Table");
IWorkflowContext ctx = new WorkflowContextImpl();
reader.setSkipOnErrors(true);
try {
reader.invoke(ctx);
} catch(WorkflowInterruptedException e) {
System.out.println(e.getMessage());
return null;
}
List<Table> tables = (List<Table>) ctx.get("tables");
return tables;
}
I'm getting this exception:
java.lang.NullPointerException
at com.google.common.base.Preconditions.checkNotNull(Preconditions.java:180)
at com.google.common.collect.ImmutableMultimap$Builder.put(ImmutableMultimap.java:149)
at com.google.common.collect.ImmutableListMultimap$Builder.put(ImmutableListMultimap.java:161)
at com.google.common.collect.Multimaps.index(Multimaps.java:1223)
at org.eclipse.xtext.mwe.Validator.groupByURI(Validator.java:148)
at org.eclipse.xtext.mwe.Validator.appendMessages(Validator.java:121)
at org.eclipse.xtext.mwe.Validator.toString(Validator.java:104)
at org.eclipse.xtext.mwe.Validator.validate(Validator.java:88)
at org.eclipse.xtext.mwe.Reader.invokeInternal(Reader.java:165)
at org.eclipse.emf.mwe.core.lib.AbstractWorkflowComponent.invoke(AbstractWorkflowComponent.java:126)
at org.eclipse.emf.mwe.core.lib.Mwe2Bridge.invoke(Mwe2Bridge.java:34)
at org.eclipse.emf.mwe.core.lib.AbstractWorkflowComponent.invoke(AbstractWorkflowComponent.java:201)
at altagracia.parser.XtextResourceLoader.loadTablesMwe(XtextResourceLoader.java:454)
at altagracia.plugin.popup.actions.Test.run(Test.java:35)
at org.eclipse.ui.actions.ActionDelegate.runWithEvent(ActionDelegate.java:70)
at org.eclipse.ui.internal.PluginAction.runWithEvent(PluginAction.java:241)
at org.eclipse.jface.action.ActionContributionItem.handleWidgetSelection(ActionContributionItem.java:584)
at org.eclipse.jface.action.ActionContributionItem.access$2(ActionContributionItem.java:501)
at org.eclipse.jface.action.ActionContributionItem$5.handleEvent(ActionContributionItem.java:411)
at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1258)
at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:3586)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3207)
at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:2696)
at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2660)
at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:2494)
at org.eclipse.ui.internal.Workbench$7.run(Workbench.java:674)
at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:667)
at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149)
at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:123)
at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:110)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:79)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:344)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:179)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:616)
at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:622)
at org.eclipse.equinox.launcher.Main.basicRun(Main.java:577)
at org.eclipse.equinox.launcher.Main.run(Main.java:1410)
at org.eclipse.equinox.launcher.Main.main(Main.java:1386)
The exception is thrown at "reader.invoke(ctx);" line.
I don't know what else I can do to fix this.
I would really appreciate your help!
Thank you very much!
[Updated on: Wed, 13 July 2011 19:21] Report message to a moderator
|
|
|
|
|
|
Re: Help with MWE Reader [message #696368 is a reply to message #696366] |
Wed, 13 July 2011 19:50 |
|
Hi,
another Point: Are you sure you did the Xtext 2.0.0 migration of your Validators right. Seems Xtext cannot create a uri to the problems.
yes definitive the
result.putAll(Multimaps.index(Arrays.asList(diagnostic), new Function<MWEDiagnostic, URI>() {
public URI apply(MWEDiagnostic from) {
Issue issue = (Issue) from.getElement();
URI uriToProblem = issue.getUriToProblem();
return uriToProblem != null ? uriToProblem.trimFragment() : null;
}
}));
in line 148 is not nullsafe. but as said above: the uri should not be null.
youu you have to debug and find out why uriToProblem is null(org.eclipse.xtext.xtext.XtextDiagnosticConverter and its superclasses)
~Christian
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
[Updated on: Wed, 13 July 2011 20:16] Report message to a moderator
|
|
|
|
Powered by
FUDForum. Page generated in 0.04076 seconds