Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Null Context in quickfix
Null Context in quickfix [message #1076374] Wed, 31 July 2013 09:18 Go to next message
Clerc Paul is currently offline Clerc PaulFriend
Messages: 1
Registered: July 2013
Junior Member
Hi,

I have a problem with a quickfix in an embeddedEditor.
My quickfix is detected and appears in the editor but context.getXtextDocument()is null.

Someone has an idea ?
Re: Null Context in quickfix [message #1076713 is a reply to message #1076374] Wed, 31 July 2013 19:24 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14716
Registered: July 2009
Senior Member
did you debug into org.eclipse.xtext.ui.editor.model.edit.IssueModificationContext.getXtextDocument(URI)

Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Null Context in quickfix [message #1076734 is a reply to message #1076713] Wed, 31 July 2013 19:55 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14716
Registered: July 2009
Senior Member
Btw the following works for me

public Class<? extends IssueModificationContext> bindIssueModificationContext() {
		return MyDslIssueModificationContext.class;
	}


public class MyDslIssueModificationContext extends IssueModificationContext {

	@Override
	public IXtextDocument getXtextDocument(URI uri) {
		// TODO Auto-generated method stub
		IXtextDocument result = super.getXtextDocument(uri);
		if (result == null && URI.createURI("dummy/test.mydsl").equals(uri.trimFragment())) {
			for (IViewReference r : PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getViewReferences()) {
				if (r.getId().equals("org.eclipse.xtext.mqrepl.ui.views.ModelQueryLanguageView")) {
					ModelQueryLanguageView view = (ModelQueryLanguageView)r.getView(false);
					if (view != null) {
						return view.getEmbeddedEditor().getDocument();
					}
				}
			}
		}
		return null;
	}
	
}


public class ModelQueryLanguageEditedResourceProvider implements IEditedResourceProvider {

	@Inject Provider<ResourceSet> rsp;

	@Override
	public XtextResource createResource() {
		return (XtextResource) rsp.get().createResource(URI.createURI("dummy/test.mydsl"));
	}

}


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Null Context in quickfix [message #1087491 is a reply to message #1076734] Thu, 15 August 2013 18:34 Go to previous messageGo to next message
Chris Ainsley is currently offline Chris AinsleyFriend
Messages: 78
Registered: March 2010
Location: UK
Member
I'm having the same issue, getting a null context in the quickfix provider.

Line 44 of org.eclipse.xtext.ui.editor.model.edit.IssueModificationContext returns null. Doesn't throw an exception but the following is logged:

org.eclipse.ui.PartInitException: Unable to open editor, unknown editor ID: com.consoli.pint.PintEditor

I'll try Christian's solution but wondering if this is a bug in my code or in XText (2.4.0)?
Re: Null Context in quickfix [message #1087803 is a reply to message #1087491] Fri, 16 August 2013 05:44 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14716
Registered: July 2009
Senior Member
Hi did you debug back to the point the context comes from

--
Need training, onsite consulting or any other kind of help for Xtext?
Go visit http://xtext.itemis.com or send a mail to xtext at itemis dot de


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Null Context in quickfix [message #1089565 is a reply to message #1087803] Mon, 19 August 2013 00:03 Go to previous message
Chris Ainsley is currently offline Chris AinsleyFriend
Messages: 78
Registered: March 2010
Location: UK
Member
Christian Dietrich wrote on Fri, 16 August 2013 14:44
Hi did you debug back to the point the context comes from

--
Need training, onsite consulting or any other kind of help for Xtext?
Go visit http://xtext.itemis.com or send a mail to xtext at itemis dot de



Short story - it was my fault, although it took a quite a while to discover it.

FYI, the null pointer was coming from org.eclipse.ui.internal.registry.findEditor(...), and it was looking up an editor that did not exist. It seems that a rename refactor I did a couple of weeks (!) ago of the package of the project had caused a mess and the editor in my debug Eclipse was an using an old package id and when it came to looking up the reference back to the editor it wasn't in the "mapIDToEditor" map.

Feels good to get the quickfixes back.
Previous Topic:Missing ecore file with standalone generation
Next Topic:How to check whether an XFeatureCall actually refers to something
Goto Forum:
  


Current Time: Thu Sep 19 18:09:06 GMT 2024

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

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

Back to the top