Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Couldn't resolve reference to JvmOperation
Couldn't resolve reference to JvmOperation [message #714052] Tue, 09 August 2011 17:24 Go to next message
steven reinisch is currently offline steven reinischFriend
Messages: 33
Registered: July 2009
Member
hi folks,

I have a grammar that involves a reference to a JVMOperation:

ToolInvocation returns process::ToolInvocation:
	'invoke' 
	operation = [jvmTypes::JvmOperation | QualifiedName]
	description = STRING
;
.

If I start a runtime workbench, open the corresponding editor and create a model, java methods can perfectly be referenced. But if I start a mwe2 workflow in the same runtime workbench, the org.eclipse.xtext.mwe.Reader stops with the following error:

Couldn't resolve reference to JvmOperation '...'
The feature 'operation' of '...' contains an unresolved proxy 'org.eclipse.xtext.common.types.impl.JvmOperationImpl@5673cc11


Why can't the JVMOperation be resolved in the mwe2 workflow but in the editor? What am I missing?

regards,

steven
Re: Couldn't resolve reference to JvmOperation [message #714094 is a reply to message #714052] Tue, 09 August 2011 19:28 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14716
Registered: July 2009
Senior Member
Hi,

how do you the scoping for the operation? please note that the types come from classpath in standalone mode so having .java files won't be successful.

~Christian


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Couldn't resolve reference to JvmOperation [message #714107 is a reply to message #714094] Tue, 09 August 2011 19:56 Go to previous messageGo to next message
steven reinisch is currently offline steven reinischFriend
Messages: 33
Registered: July 2009
Member
hi,

in order to handle my problem I adapted the domain model example to do some experiments referencing a JvmOperation. I did the following changes to the domain model. I added an EReference 'opRef' to Entity and added a rule 'OperationRef' that defines the reference to a JvmOperation:

grammar org.eclipse.xtext.example.domainmodel.Domainmodel with org.eclipse.xtext.xbase.Xbase

import "platform:/resource/org.eclipse.xtext.common.types/model/JavaVMTypes.ecore" as types

generate domainmodel "http://www.xtext.org/example/Domainmodel"

Entity:
  'entity' name=ValidID ('extends' superType=JvmTypeReference)? '{'
		features+=Feature*
		opRefs+=OperationRef*
  '}'
;

OperationRef:
	'opRef' opRef = [types::JvmOperation]
;


If I test the editor in a runtime workbench, no proposals are made for opRef. I am a little bit baffled because of the missing proposals. In my previous example I did not implement scoping - the generated ScopeProvider is a AbstractDeclarativeScopeProvider and I could refenrence JvmOperations out of the box. In the adapted domain model example, no references are possible out of the box. So in general, how should JvmOperations be referenced - how should a ScopeProvider behave?

regards,

steven
Re: Couldn't resolve reference to JvmOperation [message #714113 is a reply to message #714107] Tue, 09 August 2011 20:25 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14716
Registered: July 2009
Senior Member
Hi,

i guess referencing jvm ops is no out of the box usecase. so you have to take care for scoping yourself.

~Christian


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Couldn't resolve reference to JvmOperation [message #718736 is a reply to message #714113] Thu, 25 August 2011 08:17 Go to previous messageGo to next message
steven reinisch is currently offline steven reinischFriend
Messages: 33
Registered: July 2009
Member

hi,

so, how can I retrieve the list of all available JvmOperations in my scopeProvider?

regards,

steven
Re: Couldn't resolve reference to JvmOperation [message #718750 is a reply to message #718736] Thu, 25 August 2011 08:53 Go to previous messageGo to next message
Sven Efftinge is currently offline Sven EfftingeFriend
Messages: 1823
Registered: July 2009
Senior Member
You only want the JvmOperations of the extended type, don't you? So you'll have to implement scoping just like that.
Have a look at org.eclipse.xtext.common.types.util.FeatureOverridesService, it might be useful.

Sven
Re: Couldn't resolve reference to JvmOperation [message #719485 is a reply to message #718750] Sat, 27 August 2011 12:41 Go to previous messageGo to next message
steven reinisch is currently offline steven reinischFriend
Messages: 33
Registered: July 2009
Member
hi,

I am able to retrieve the JvmOperations in my ScopeProvider with the following code:

JvmType jvmType = tool.getAClass();
if (jvmType instanceof JvmDeclaredType) {
	for(JvmMember member: ((JvmDeclaredType) jvmType).getMembers()){
		if (member instanceof JvmOperation) {
			scopedElements.add(EObjectDescription.create(member.getQualifiedName(), member));
		}
	}
}


The JvmOperations are proposed in the editor but it complains with the error message 'Couldn't resolve reference to JvmOperation '...''' if I select any of the proposed operations.
Why is the editor not able to resolve the reference? The reference to the containing JvmType can be resolved in another model in the same project.

regards,

steven
Re: Couldn't resolve reference to JvmOperation [message #719723 is a reply to message #719485] Sun, 28 August 2011 15:59 Go to previous messageGo to next message
steven reinisch is currently offline steven reinischFriend
Messages: 33
Registered: July 2009
Member
hi,

I found a way to get it working.
Instead of creating the EObjectDescription with the qualified name:

scopedElements.add(EObjectDescription.create(member.getQualifiedName(), member));


I am using the simple name:

scopedElements.add(EObjectDescription.create(member.getSimpleName(), member));


What is the explanation for this behaviour?

thx,

steven
Re: Couldn't resolve reference to JvmOperation [message #719724 is a reply to message #719723] Sun, 28 August 2011 16:18 Go to previous messageGo to next message
steven reinisch is currently offline steven reinischFriend
Messages: 33
Registered: July 2009
Member
hi,

a related question to my last post.
If I use the simple name for the EObjectDescription and multiple JvmOperations have the same simple name, I can only select one of those. If I construct my own qualified name:

String separator = "::";
String name = jvmType.getSimpleName() + separator + op.getSimpleName();
scopedElements.add(EObjectDescription.create(name, op));


the editor and the generator again complain that the JvmOperation cannot be referenced.
They only complain if separator is "::" or ".". If I use "_", everything works fine.

I guess there is a clash with the built-in qualified name concept/computation.
How can use "::" or "." as a separator in my editor without breaking the linking?

regards,

steven
Re: Couldn't resolve reference to JvmOperation [message #719732 is a reply to message #719724] Sun, 28 August 2011 17:13 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14716
Registered: July 2009
Senior Member
Hi,

opRef = [types::JvmOperation] is short for opRef = [types::JvmOperation|ID] and means: reference a JvmOperation and parse an ID,
an ID allows an _ but not a :: or a .

e.g.

FQN: ID ("::" ID)*;
opRef = [types::JvmOperation|FQN]

might help

~Christian


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Couldn't resolve reference to JvmOperation [message #719881 is a reply to message #719732] Mon, 29 August 2011 10:15 Go to previous message
steven reinisch is currently offline steven reinischFriend
Messages: 33
Registered: July 2009
Member
hi,

in order to use qualified names in the editor I have to create a QualifiedName in the ScopeProvider:

QualifiedName qName = QualifiedName.create(jvmType.getSimpleName(), op.getSimpleName());
scopedElements.add(EObjectDescription.create(qName, op));


regards,

steven
Previous Topic:[Xtend] Cannot refer to a non-final variable ... inside an inner class
Next Topic:Too many constants error in generated internalXXXParser.java
Goto Forum:
  


Current Time: Fri Sep 20 13:02:45 GMT 2024

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

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

Back to the top