Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Xtext: Couldn't resolve reference to JvmType 'String'
Xtext: Couldn't resolve reference to JvmType 'String' [message #1012559] Thu, 21 February 2013 19:45 Go to next message
Dustin Steiner is currently offline Dustin SteinerFriend
Messages: 10
Registered: October 2012
Junior Member
I already posted it on Stackoverflow but was hoping to reach more experts here Smile

For our master project at university we created multiple DSLs using Xtext. One of the DSLs is a model entity DSL which allows the user to create a class with properties and methods.

We reuse Xbase because, of course, we want the methods to have a real programming language without reinventing the wheel:
grammar ... with org.eclipse.xtext.xbase.Xbase

generate ...

EntityModel:
    'package' importedNamespace=QualifiedName
    ...
    implementation=Entity;

Entity:
    'entity' name=ValidID '{'
        features+=Feature*
    '}';

Feature:
    LocalVariable | ...;

LocalVariable:
    'var' (isStatic?='static')? name=ValidID ':' type=JvmTypeReference;


For some reason, even though the type of the LocalVariable is set to JvmTypeReference, when using String (in an actual implementation), it will always show the error
Quote:
Xtext: Couldn't resolve reference to JvmType 'String'

package com.example
Entity foo {
    var bar: String
}


We already tried using a ImportedNamespaceAwareLocalScopeProvider which in getImportedNamespaceResolvers adds java.lang.* like that:
List<ImportNormalizer> implicitImports = super.getImportedNamespaceResolvers(context, ignoreCase);
List<ImportNormalizer> javaLangImports = singletonList(new ImportNormalizer(QualifiedName.create("java", "lang"), true, ignoreCase));
implicitImports.addAll(javaLangImports);
return implicitImports;


Even thought that method is called a lot of times, the imports still don't work. When inspecting the EObject context parameter, it sometimes returns java.lang.String (which I guess is for the JvmTypeReference but it still displays an error.

In the RuntimeModule the new scope provider is configured like that:
public void configureIScopeProviderDelegate(com.google.inject.Binder binder) {
    binder.bind(org.eclipse.xtext.scoping.IScopeProvider.class).annotatedWith(com.google.inject.name.Names.named(org.eclipse.xtext.scoping.impl.AbstractDeclarativeScopeProvider.NAMED_DELEGATE)).to(MasterDSLImportedNamespaceAwareLocalScopeProvider.class);
}


In the Workflow we configured
fragment = scoping.ImportNamespacesScopingFragment {}
fragment = exporting.QualifiedNamesFragment {}
fragment = builder.BuilderIntegrationFragment {}
fragment = xbase.XbaseGeneratorFragment {}
fragment = types.TypesGeneratorFragment {}


The rest of the project is quite complex already (4 Xtext DSLs in one project and multiple generators). But except for completely different DSLs, they use almost the same workflow and RuntimeModule configuration. Another DSL also uses JvmTypeReference and also doesn't find e.g. boolean or anything else.

The question of course is: are we doing something wrong or is there something else we have to do. It used to work when we had a significantly smaller project but after some major changes suddenly this stopped working.

The model implementations (*.model) can be highlighted and everything but those imports just won't work Sad
Also, some parts of XExpression (like !=) are highlighted as not being recognized from the parser.
Re: Xtext: Couldn't resolve reference to JvmType 'String' [message #1012565 is a reply to message #1012559] Thu, 21 February 2013 20:09 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14661
Registered: July 2009
Senior Member
Hi,

please note: the model project (with you my.mydsl file within) has to be a java project. needed libs (e.g. xbase.lib) have to be on the classpath
then it will work out of the box without any mods.


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Xtext: Couldn't resolve reference to JvmType 'String' [message #1012579 is a reply to message #1012565] Thu, 21 February 2013 20:46 Go to previous messageGo to next message
Dustin Steiner is currently offline Dustin SteinerFriend
Messages: 10
Registered: October 2012
Junior Member
It is a Java project (or alternatively uses a custom project wizard) and I already checked that it includes the Java rt.jar (and manually included the xtend library). But still, it doesn't work anymore. Is it possible that I accidentally overwrote configuration (maybe there is some important property you are not supposed to change? Wink which prevents the whole runtime from recognizing the classpath or something?

I forgot to mention that we're using Xtext 2.3. Can using Java 7 be the problem?
Re: Xtext: Couldn't resolve reference to JvmType 'String' [message #1012741 is a reply to message #1012579] Fri, 22 February 2013 06:48 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14661
Registered: July 2009
Senior Member
Hi hard to say I'd try to create a new project and adopt your changes
step by step to see what causes the problem

--
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: Xtext: Couldn't resolve reference to JvmType 'String' [message #1013036 is a reply to message #1012741] Fri, 22 February 2013 16:38 Go to previous messageGo to next message
Dustin Steiner is currently offline Dustin SteinerFriend
Messages: 10
Registered: October 2012
Junior Member
The problem is, that we're using 3 DSLs in a single project and separate projects for generators so by now our project is quite huge and I'm kind of afraid to recreate all the projects Wink

BTW. is there a right way of having multiple (4) DSLs and a single project for that? We're using one workflow with multiple Generator components ("component = Generator"). Or would have be using multiple projects be easier (two times two DSLs are depending on one another)?
Re: Xtext: Couldn't resolve reference to JvmType 'String' [message #1013038 is a reply to message #1013036] Fri, 22 February 2013 16:42 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14661
Registered: July 2009
Senior Member
Hi,

is there a specific reason to do so? it is supported but usually not done.
what kind of dependency is this "depending to each other"?


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Xtext: Couldn't resolve reference to JvmType 'String' [message #1013040 is a reply to message #1013038] Fri, 22 February 2013 16:49 Go to previous messageGo to next message
Dustin Steiner is currently offline Dustin SteinerFriend
Messages: 10
Registered: October 2012
Junior Member
Have have different DSLs for different parts of our project (UI, BL, Model, Config DSLs) and the Config DSL defines the entrance point via a reference to the BL DSL. The UI DSL has a reference to the code-behind BL DSL as well as Handler-Functions in the BL.
Re: Xtext: Couldn't resolve reference to JvmType 'String' [message #1013043 is a reply to message #1013040] Fri, 22 February 2013 16:53 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14661
Registered: July 2009
Senior Member
Hi,

so the dependency is on metamodel level only? if so a manually maintained may help to split up.
but as i said before: i think it should work with one project too.

~Christian


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Xtext: Couldn't resolve reference to JvmType 'String' [message #1013284 is a reply to message #1013043] Sat, 23 February 2013 07:42 Go to previous messageGo to next message
Dustin Steiner is currently offline Dustin SteinerFriend
Messages: 10
Registered: October 2012
Junior Member
Thanks for the help. We also prefer the single project to keep it "simple" Wink
Re: Xtext: Couldn't resolve reference to JvmType 'String' [message #1015151 is a reply to message #1012559] Wed, 27 February 2013 15:25 Go to previous messageGo to next message
Aaron Digulla is currently offline Aaron DigullaFriend
Messages: 258
Registered: July 2009
Location: Switzerland
Senior Member
Does it work with

var bar: java.lang.String


?
Re: Xtext: Couldn't resolve reference to JvmType 'String' [message #1101006 is a reply to message #1015151] Tue, 03 September 2013 22:46 Go to previous messageGo to next message
ferry ferry is currently offline ferry ferryFriend
Messages: 1
Registered: September 2013
Junior Member
hi all,

I got the same problem when using the EmbeddedEditor. the content assist for the JvmTypeReference in the EmbeddedEditor doesn't work as well although it works in the normal editor.

any idea?

thanks in advance for the advise.

cheers,
Ferry
Re: Xtext: Couldn't resolve reference to JvmType 'String' [message #1101189 is a reply to message #1101006] Wed, 04 September 2013 05:42 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14661
Registered: July 2009
Senior Member
Do you have a backing java project. The content assist uses jdt to
propose.

--
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: Xtext: Couldn't resolve reference to JvmType 'String' [message #1101663 is a reply to message #1101189] Wed, 04 September 2013 19:49 Go to previous message
Ian McDevitt is currently offline Ian McDevittFriend
Messages: 70
Registered: December 2012
Location: Belfast
Member
If still no solution to the original point, here's the few lines where I did something very similar in my delegate scope provider which extends ImportedNamespaceAwareLocalScopeProvider.
It looks like the same idea as you have but is slightly different
static val JAVA_LANG = QualifiedName::create("java","lang")
static val builtinList = newArrayList(
		 new ImportNormalizer(JAVA_LANG, true, false)
		)

override List<ImportNormalizer> getImplicitImports(boolean ignoreCase) {
	    return builtinList
	}

This is xtend and you may have Java but I did have it in Java originally in Xtext 2.3 and it worked there.
Previous Topic:Unique identifiers across XText resources
Next Topic:View Toolbar
Goto Forum:
  


Current Time: Thu Mar 28 08:51:55 GMT 2024

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

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

Back to the top