Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Couldnt resolve reference to JvmMember(Need help with scoping)
Couldnt resolve reference to JvmMember [message #1090459] Tue, 20 August 2013 06:52 Go to next message
Rickard Eklind is currently offline Rickard EklindFriend
Messages: 1
Registered: August 2013
Junior Member
I am currently working on a project where I want to create java classes and map properties from existing java classes. I got the IntelliSense working fine in Eclipse but when i save my dsl file I get an error saying "Couldn't resolve reference to JvmMember". It feels like my scope provider is working fine with the IntelliSence but whenn saving the dsl another scope provider is being used and I do not know how to fix it. I am using Xtext 2.4.2.v201306120542

My grammar looks like this.
grammar org.example.domainmodel.Domainmodel with
                                      org.eclipse.xtext.xbase.Xbase
 
generate domainmodel "http_://www.example.org/domainmodel/Domainmodel"

import "http://www.eclipse.org/xtext/xbase/Xbase" as xbase
import "http://www.eclipse.org/xtext/common/JavaVMTypes" as jvmTypes

Domainmodel:
  importSection=XImportSection?
  elements+=AbstractElement*;
 
AbstractElement:
  PackageDeclaration | Entity ;
 
PackageDeclaration:
  'package' name=QualifiedName '{'
    elements+=AbstractElement*
  '}';


Entity:
	(abstract ?= 'abstract')?
	'entity' name=ID ('extends' superType = [Entity])?
	from = From
	('properties' properties += Property)
	('map' mappings += MappingDef+)?
;

From returns xbase::XVariableDeclaration:
	{xbase::XVariableDeclaration}
	writeable?='from' type=JvmTypeReference name=ValidID;

MappingDef:
	Reference
;

Reference:
	'virtual' type = [Property] '=' fromRef = [jvmTypes::JvmMember]
;

Property:
  name=ValidID ':' type=JvmTypeReference
;


My dsl looks like this

import se.cambio.test.A;

package se.cambio.test.gen
{
	entity PatientDto
		from A a 
		properties
			description: String
		map 
			virtual description = getDesc
}


Where A is a plain java class with the method
String getDesc()
.

The scope provider looks like this and is making us of the depricated XbaseScopeProvider.
public class MyScopProvider extends XbaseScopeProvider {

	@Override
	public IScope getScope(EObject context, EReference reference) {
		if (reference != null && context != null) {
			if (context instanceof Reference) {
				Reference ref = (Reference) context;
				EObject a = ref.eContainer();
				if (a instanceof Entity) {
					Entity entity = (Entity) a;
					XVariableDeclaration decl = entity.getFrom();

					XMemberFeatureCallImplCustom e = new XMemberFeatureCallImplCustom();
					JvmType type = decl.getType().getType();
					if (type instanceof JvmGenericType) {
						JvmGenericType genericType = (JvmGenericType) type;
						EList<JvmMember> members = genericType.getMembers();
						IScope s = Scopes.scopeFor(members, QualifiedName
								.wrapper(SimpleAttributeResolver.newResolver(
										String.class, "simpleName")),
								IScope.NULLSCOPE);
						return s;
					}
				}
			}
		}
		return super.getScope(context, reference);
	}
}


Finally I bind my scope provider in the runtime module like this
    @Override
    public Class<? extends IScopeProvider> bindIScopeProvider() {
        return MyScopProvider.class;
    }


Does anyone have any suggestions of what I am doing wrong?
Re: Couldnt resolve reference to JvmMember [message #1091501 is a reply to message #1090459] Wed, 21 August 2013 15:50 Go to previous message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
Hi,

using Xbase you must customize the BatchScopeProvider too.


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Previous Topic:How to get access to an IXtextDocument (IWriteAccess) from within an IDerivedStateComputer?
Next Topic:dot-path upside down
Goto Forum:
  


Current Time: Thu Apr 25 13:51:08 GMT 2024

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

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

Back to the top