Skip to main content



      Home
Home » Modeling » TMF (Xtext) » Help with MWE Reader
Help with MWE Reader [message #696359] Wed, 13 July 2011 15:18 Go to next message
Eclipse UserFriend
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 15:21] by Moderator

Re: Help with MWE Reader [message #696362 is a reply to message #696359] Wed, 13 July 2011 15:27 Go to previous messageGo to next message
Eclipse UserFriend
Hi, the problem may Be that you call a StandaloneSetup from within an Eclipse Application which is a Bad idea since this will destroy you emf registry.

Regards
Christian
Re: Help with MWE Reader [message #696364 is a reply to message #696362] Wed, 13 July 2011 15:36 Go to previous messageGo to next message
Eclipse UserFriend
Hi Christian. Thank you for your answer.

I comment the StandaloneSetup call and I still have the same problem. What do you recommend?
Re: Help with MWE Reader [message #696366 is a reply to message #696364] Wed, 13 July 2011 15:46 Go to previous messageGo to next message
Eclipse UserFriend
Did you get any hints through debugging. does the validation work from the ui? does the code (including the standalonesetup) work if run ist as Java Application?

~Christian
Re: Help with MWE Reader [message #696368 is a reply to message #696366] Wed, 13 July 2011 15:50 Go to previous messageGo to next message
Eclipse UserFriend
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

[Updated on: Wed, 13 July 2011 16:16] by Moderator

Re: Help with MWE Reader [message #696376 is a reply to message #696368] Wed, 13 July 2011 16:19 Go to previous message
Eclipse UserFriend
Thank you Christian!

I solved it thanks to your hint of the ui validation. At first I thought it would not be a problem, but it was!

Thank you very much!
Previous Topic:Cross referencing from Xtext to Xmi
Next Topic:Validator error method and EStructuralFeature
Goto Forum:
  


Current Time: Tue Jul 08 11:37:37 EDT 2025

Powered by FUDForum. Page generated in 0.06782 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top