Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Strange errors using Xtext in a plugin
Strange errors using Xtext in a plugin [message #724332] Mon, 12 September 2011 06:29 Go to next message
Daniel Trierweiler is currently offline Daniel TrierweilerFriend
Messages: 67
Registered: June 2011
Member
Hey guys!

I've previously made some posts to this topic, which really helped me resolve some errors, but now I am stuck again and don't know where to search for a solution...

I've made a plugin for eclipse, which uses a table-framework to show the model-data. I've used the plugin wizard to create a MultiPageEditor and started from there. My Editor-code looks like that:

IEditorInput editorInput;
	XtextResource resource = null;
	static Injector injector = null;
	
	public NatTableEditor() {
		super();
		ResourcesPlugin.getWorkspace().addResourceChangeListener(this);
	}
	
	void createPage() throws IOException {
		if(injector == null)
			injector = new ConfiguratorStandaloneSetup().createInjectorAndDoEMFRegistration();
		
		URI uri = URI.createURI("platform:/resource/zf.pios.test/"+getEditorInput().getName());
		setPartName(getEditorInput().getName());
		
		XtextResourceSet rs = injector.getInstance(XtextResourceSet.class);
		IResourceFactory resourceFactory = injector.getInstance(IResourceFactory.class);
		resource = (XtextResource) resourceFactory.createResource(uri);
		rs.addLoadOption(XtextResource.OPTION_RESOLVE_ALL, Boolean.TRUE);
		rs.getResources().add(resource);
		resource.load(rs.getLoadOptions());

		EcoreUtil.resolveAll(resource);		
		
		EList<EObject> list = resource.getContents();
		Configuration eObj = (Configuration)list.get(0);
	}

And everything is working fine. I can view and browse the data in the way I want. BUT... when I close the editor and reopen it, it gives me errors which I can't resolve:

http://pastebin.com/x93qwwcs

Does anyone have an idea what this could be? Or what it could be related with?
Thanks a lot!

Greetings,
Daniel

[Updated on: Mon, 12 September 2011 06:34]

Report message to a moderator

Re: Strange errors using Xtext in a plugin [message #724347 is a reply to message #724332] Mon, 12 September 2011 07:00 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
Hi, without having any look on your problem: calling StandaloneSetup from eclipse is a bad idea. Regards Christian

Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Strange errors using Xtext in a plugin [message #724351 is a reply to message #724347] Mon, 12 September 2011 07:03 Go to previous messageGo to next message
Daniel Trierweiler is currently offline Daniel TrierweilerFriend
Messages: 67
Registered: June 2011
Member
Hi Christian!

I have read that a few times now, but I have never found any other way to get the injector, which suits my needs.
The link provided here, for example
http://www.eclipse.org/forums/index.php/m/685909/?srch=createInjectorAndDoEMFRegistration#msg_685909
doesn't help me either, cause I don't have a Activator class in my Xtext projects.
Re: Strange errors using Xtext in a plugin [message #724354 is a reply to message #724351] Mon, 12 September 2011 07:10 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
Hi, what about using yourdslexecutableextensionfactory in your plugin.xml to get stuff injected to your editor class. BTW why don't you have that activated class.

Twitter : @chrdietrich
Blog : https://www.dietrich-it.de

[Updated on: Mon, 12 September 2011 07:13]

Report message to a moderator

Re: Strange errors using Xtext in a plugin [message #724374 is a reply to message #724354] Mon, 12 September 2011 08:31 Go to previous messageGo to next message
Daniel Trierweiler is currently offline Daniel TrierweilerFriend
Messages: 67
Registered: June 2011
Member
Ah I'm sorry. Of course I have an activator class. I was using the wrong working set Smile

I have found something related to my problem here: http://coopology.com/2011/06/easily-load-xtext-files-and-objects-in-eclipse-plugin-or-rcp-projects-using-adapters/

But I wasn't sure if that is the right way, because I haven't heard anything about adapters yet.

I have also seen your blog post about xtext 2.0 and Uml Christian, but that's why I thought the yourdslexecutableextensionfactory is only for xtext 2.0.

Do you have any more input on this? How I have to add it to the plugin xml?
Re: Strange errors using Xtext in a plugin [message #724378 is a reply to message #724374] Mon, 12 September 2011 08:44 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
Hi, I don't understand your question. The factory is already used a thousand times in the plugin xml so using it a 1001st time should be no problem.

 <extension
            point="org.eclipse.ui.editors">
        <editor
            class="org.xtext.example.mydsl.ui.MyDslExecutableExtensionFactory:org.eclipse.xtext.ui.editor.XtextEditor"
            contributorClass="org.eclipse.ui.editors.text.TextEditorActionContributor"
            default="true"
            extensions="mydsl"
            id="org.xtext.example.mydsl.MyDsl"
            name="MyDsl Editor">
        </editor>
    </extension>


~Christian


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de

[Updated on: Mon, 12 September 2011 08:50]

Report message to a moderator

Re: Strange errors using Xtext in a plugin [message #724394 is a reply to message #724378] Mon, 12 September 2011 09:18 Go to previous messageGo to next message
Daniel Trierweiler is currently offline Daniel TrierweilerFriend
Messages: 67
Registered: June 2011
Member
I guess we are talking about different plugin.xml files. I was talking about my plugin's xml and not about the one from the xtext ui project Smile But you are right, is the "org.eclipse.xtext.extension_resourceServiceProvider" which uses the "ConfiguratorExecutableExtensionFactory".
But what should I do now? How can I use it in my project?

I tried
@Inject
private XtextResourceSetProvider resourceSetProvider;

but it leaves the resourceSetProvider empty.
Re: Strange errors using Xtext in a plugin [message #724395 is a reply to message #724394] Mon, 12 September 2011 09:22 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
HI,

why not build a MyWhateverPluginExecutableExtensionFactory??? or just using the activator from your xtext project? am still not quite sure what you are doing.

~Christian


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de

[Updated on: Mon, 12 September 2011 09:23]

Report message to a moderator

Re: Strange errors using Xtext in a plugin [message #724396 is a reply to message #724395] Mon, 12 September 2011 09:25 Go to previous messageGo to next message
Daniel Trierweiler is currently offline Daniel TrierweilerFriend
Messages: 67
Registered: June 2011
Member
I have tried the activator-way with:

final private static Injector injector = ConfiguratorActivator.getInstance().getInjector("zf.pios.Configurator");

Actually, I get exactly the same errors.

0 [main] ERROR org.eclipse.xtext.parser.DefaultEcoreElementFactory -
java.lang.NullPointerException
at org.eclipse.xtext.parser.DefaultEcoreElementFactory.add(DefaultEcoreElementFactory.java:103)
.
.
.
.
Re: Strange errors using Xtext in a plugin [message #724398 is a reply to message #724396] Mon, 12 September 2011 09:29 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
Hi,

same problem: if i cannot reproduce this i cannot help. debugging does not provide you any clue? what is actually null in you case? the eobject? its eclass? how does the complete trace look like?

~Christian


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de

[Updated on: Mon, 12 September 2011 09:35]

Report message to a moderator

Re: Strange errors using Xtext in a plugin [message #724400 is a reply to message #724398] Mon, 12 September 2011 09:36 Go to previous messageGo to next message
Daniel Trierweiler is currently offline Daniel TrierweilerFriend
Messages: 67
Registered: June 2011
Member
I know.. but I don't know what to do to help reproduce the example if I don't know to what the error is related to.
Actually I forgot to show another error which also occurs everytime I open the editor twice:
http://pastebin.com/vQysuLBY

It is clearly related to a Parser issue.. probably this helps.
I'll debug again and report back!
Re: Strange errors using Xtext in a plugin [message #724402 is a reply to message #724400] Mon, 12 September 2011 09:42 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
Hi,

how does your grammar arround InputSignal look like?

~Christian


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Strange errors using Xtext in a plugin [message #724404 is a reply to message #724402] Mon, 12 September 2011 09:53 Go to previous messageGo to next message
Daniel Trierweiler is currently offline Daniel TrierweilerFriend
Messages: 67
Registered: June 2011
Member
The grammar looks like:

http://pastebin.com/jKurWjB3
Re: Strange errors using Xtext in a plugin [message #724407 is a reply to message #724404] Mon, 12 September 2011 09:56 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
HI,

looks ok so far. what did debugging told? why is null passed from the parser?

~Christian


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Strange errors using Xtext in a plugin [message #724415 is a reply to message #724407] Mon, 12 September 2011 10:06 Go to previous messageGo to next message
Daniel Trierweiler is currently offline Daniel TrierweilerFriend
Messages: 67
Registered: June 2011
Member
It happens for example with the object "OutputConfigSubsystemPWMKTXImpl". The call for:
EStructuralFeature eFeature = eClass().getEStructuralFeature(featureID);
returns null which results in the npe. I have added a screenshot from what the object looks like in the debugger.
http://dl.dropbox.com/u/6522495/xtext_prob.jpg

Re: Strange errors using Xtext in a plugin [message #724424 is a reply to message #724415] Mon, 12 September 2011 10:26 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
Hi,

and why does it return null? are you sure you are not using any standalonesetups anymore?

~Christian


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de

[Updated on: Mon, 12 September 2011 10:26]

Report message to a moderator

Re: Strange errors using Xtext in a plugin [message #724435 is a reply to message #724424] Mon, 12 September 2011 11:12 Go to previous messageGo to next message
Daniel Trierweiler is currently offline Daniel TrierweilerFriend
Messages: 67
Registered: June 2011
Member
I'm 100% sure I don't use Standalonesetup anymore.

I've debugged a little further and found, that the object which is created in the ConfiguratorFactoryImpl "OutputConfigSubsystemPWMKTX" via createOutputConfigSubsystemPWMKTX() has only one of the four attributes resolved. OutputConfigSubsystemPWMKTX belongs to a supertype OutputDriverType which has 3 of the four attributes. It looks like it doesn't resolve those attributes which are in the supertype. And therefore there is a npe... I guess calling getEAllStructuralFeature would solve the issue. Any ideas?
Re: Strange errors using Xtext in a plugin [message #724441 is a reply to message #724435] Mon, 12 September 2011 11:27 Go to previous messageGo to next message
Daniel Trierweiler is currently offline Daniel TrierweilerFriend
Messages: 67
Registered: June 2011
Member
Btw:

This is the part of the grammar:

OutputSubsystems: {OutputSubsystems}
        (outputNull = OutputConfigSubsystemNull)?
        (outputCAN = OutputConfigSubsystemCAN)?
        (outputDigital = OutputConfigSubsystemDigital)?
        (outputPWM += OutputConfigSubsystemPWM)*
        (outputPWMKTX = OutputConfigSubsystemPWMKTX)?
        (outputConfigSubsystem += OutputConfigSubsystemItem)*
;

GenericSubsystem:
    InputDriverType | OutputDriverType;

OutputDriverType:
  OutputConfigSubsystemNull | OutputConfigSubsystemCAN  | OutputConfigSubsystemDigital | OutputConfigSubsystemPWMKTX | OutputConfigSubsystemItem |
  OutputConfigSubsystemPWM
;


The GenericSubsystemis only used in the ConfiguratorScopeProvider, but not elsewhere in the grammar. Probably that's a problem?
Re: Strange errors using Xtext in a plugin [message #724443 is a reply to message #724441] Mon, 12 September 2011 11:31 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
Hi,

no this should be no problem

~Christian


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Strange errors using Xtext in a plugin [message #724446 is a reply to message #724443] Mon, 12 September 2011 11:37 Go to previous messageGo to next message
Daniel Trierweiler is currently offline Daniel TrierweilerFriend
Messages: 67
Registered: June 2011
Member
Then I am as clueless as before =)
Re: Strange errors using Xtext in a plugin [message #724463 is a reply to message #724446] Mon, 12 September 2011 12:27 Go to previous messageGo to next message
Daniel Trierweiler is currently offline Daniel TrierweilerFriend
Messages: 67
Registered: June 2011
Member
Another thought...
Could it be a bug? I really can't get behind this issue... I just get an incomplete OutputConfigSubsystemPWMKTX object back... but why? I can't see why in the debugger.
Re: Strange errors using Xtext in a plugin [message #724475 is a reply to message #724463] Mon, 12 September 2011 12:45 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
How does the OutputConfigSubsystemPWMKTX rule look like?

Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Strange errors using Xtext in a plugin [message #724476 is a reply to message #724475] Mon, 12 September 2011 12:46 Go to previous messageGo to next message
Daniel Trierweiler is currently offline Daniel TrierweilerFriend
Messages: 67
Registered: June 2011
Member
OutputConfigSubsystemPWMKTX:
    name = ID
    '{'
    'SortingIndex' sortingIndex = UINT
    'ShortName ' shortName = 'OAim_Ktx'
    'UsedForSourceCode' usedForSourceCode = BOOL
    '}'
;
Re: Strange errors using Xtext in a plugin [message #724478 is a reply to message #724476] Mon, 12 September 2011 12:52 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
seems ok. in which respect is it incomplete? attributes missing? you should be still able to find out through debugging why they are not set. have you valueconverters for bool and uint?

~Christian


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Strange errors using Xtext in a plugin [message #724519 is a reply to message #724478] Mon, 12 September 2011 13:56 Go to previous messageGo to next message
Sebastian Zarnekow is currently offline Sebastian ZarnekowFriend
Messages: 3118
Registered: July 2009
Senior Member
Without having had a look at the grammar: Is the supertype, that has the
unresolveable attributes, defined in the same EPackage and are the
feature types themselves defined the very same package? If not: Is the
super-type-package registered in a plugin.xml?

Regards,
Sebastian
--
Need professional support for Eclipse Modeling?
Go visit: http://xtext.itemis.com

On 12.09.11 14:52, Christian Dietrich wrote:
> seems ok. in which respect is it incomplete? attributes missing? you
> should be still able to find out through debugging why they are not set.
> have you valueconverters for bool and uint?
>
> ~Christian
Re: Strange errors using Xtext in a plugin [message #724762 is a reply to message #724519] Tue, 13 September 2011 05:43 Go to previous messageGo to next message
Daniel Trierweiler is currently offline Daniel TrierweilerFriend
Messages: 67
Registered: June 2011
Member
Christian:

I debugged till I get to the point where the class gets loaded in the DefaultClassLoader and then the createOutputConfigSubsystemPWMKTX() is called in the ConfiguratorFactoryImpl.
Somehow I can't look in the Java ClassLoader cause of missing sources, which is strange, cause I have added the sources from the java.net website.
Anyhow, with incomplete I mean missing attributes and no eContainer like in the screenshot: http://dl.dropbox.com/u/6522495/xtext_prob.jpg
I guess they are not set, because the eContainer is not set. And no, I don't have valueconverters. BOOL and UINT look like that in the grammar:

enum BOOL:
  True | False;

terminal UINT returns ecore::EInt:
    ('0'..'9')+(('e'|'E') ('-'|'+')? ('0'..'9')+ )?;


Sebastian:

Yes, everything is in the Configurator EPackage.
Re: Strange errors using Xtext in a plugin [message #724902 is a reply to message #724762] Tue, 13 September 2011 13:16 Go to previous messageGo to next message
Daniel Trierweiler is currently offline Daniel TrierweilerFriend
Messages: 67
Registered: June 2011
Member
Hey guys,

I've got some news... more debugging lead me to another insight. It appears that the value, which causes the npe is the eFeatureof the eObjects class as you can see in the screenshot. But I still don't know, why there is no eFeature...

http://dl.dropbox.com/u/6522495/xtext_prob2.jpg
Re: Strange errors using Xtext in a plugin [message #724960 is a reply to message #724902] Tue, 13 September 2011 15:19 Go to previous message
Sebastian Zarnekow is currently offline Sebastian ZarnekowFriend
Messages: 3118
Registered: July 2009
Senior Member
Hi Daniel,

does your EClass OutputConfigSubsystemPWMKTX have any super types? If
yes, could you please double-check in the debugger that
OutputConfigSubsystemPWMKTX instance = ..
instance.eClass().getEAllSuperTypes() is not empty and does not contain
any objects that are marked as eIsProxy() == true?

Regards,
Sebastian
--
Need professional support for Eclipse Modeling?
Go visit: http://xtext.itemis.com

On 13.09.11 15:16, Daniel Trierweiler wrote:
> Hey guys,
>
> I've got some news... more debugging lead me to another insight. It
> appears that the value, which causes the npe is the eFeatureof the
> eObjects class as you can see in the screenshot. But I still don't know,
> why there is no eFeature...
>
> http://dl.dropbox.com/u/6522495/xtext_prob2.jpg
Previous Topic:Can't serialize model with boolean attribute
Next Topic:Validating model in Eclipse UI context before interpreting it
Goto Forum:
  


Current Time: Thu Apr 25 14:29:40 GMT 2024

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

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

Back to the top