Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » References from other file not working(xtext scoping problem)
References from other file not working [message #1006177] Wed, 30 January 2013 11:02 Go to next message
Mr Manner is currently offline Mr MannerFriend
Messages: 26
Registered: January 2013
Junior Member
I have a simple json grammer that has support for referencing to "named object" by using the "uses" attribute.

grammar com.example.Json with org.eclipse.xtext.common.Terminals

generate json "http://eclipse.org"

Object:
	'{'
		(members+=Member)?
		(',' members+=Member)*
	'}';

Member:
	GenericMember | NamedMember | UsesMember;

GenericMember:
	key=STRING ':' name=Value;

NamedMember:
	key='\"name\"' ':' name=STRING;

UsesMember:
	key='\"uses\"' ':' name=[NamedMember | STRING];

Value:
	Object | STRING | Array | Boolean | Null | Number;
 
Array:
	'[' (values+=Value)? (',' values+=Value)* ']';
 	
Boolean:
  'true' | 'false';
 
Null:
  'null';
 
terminal Number:
	'-'? INT? '.' INT (('E'|'e') '-'? INT)?;


An example of the json:

{
	"obj1": {
		"name": "name1"
	},
	"obj2": {
		"uses": "name1"
	}
}


The content assistance only displays the named object of the current file.
From what I can tell from the video the cross file referencing should work out of the box.

I tried changing my workflow but without success:

                // scoping and exporting API
                fragment = scoping.ImportURIScopingFragment {}
                fragment = exporting.SimpleNamesFragment {}
    
                // scoping and exporting API
                fragment = scoping.ImportNamespacesScopingFragment {}
                fragment = exporting.QualifiedNamesFragment {}
                fragment = builder.BuilderIntegrationFragment {}


I am a bit lost as to where I should start fixing this.
Most tutorials are about how to change the scoping behaviour but not on how to allow scoping cross file without any imports.
Re: References from other file not working [message #1006191 is a reply to message #1006177] Wed, 30 January 2013 12:06 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
HI,

dont mix that fragments.

fragment = scoping.ImportNamespacesScopingFragment {}
fragment = exporting.QualifiedNamesFragment {}
fragment = builder.BuilderIntegrationFragment {}

should be fine and enable global visbility.


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: References from other file not working [message #1006297 is a reply to message #1006177] Wed, 30 January 2013 17:47 Go to previous messageGo to next message
Mr Manner is currently offline Mr MannerFriend
Messages: 26
Registered: January 2013
Junior Member
I still have the same problem after I modified the workflow fragments.

Could this be related to the scope provider?

public class JsonScopeProvider extends AbstractDeclarativeScopeProvider {

}


Maybe there something wrong with my grammar.
It is difficult to know what xtext is "thinking" is there a way to know more about this during run-time.
Now I am just left with knowing it is not working but no real methodology to get to the hard of the problem.
Re: References from other file not working [message #1006313 is a reply to message #1006297] Wed, 30 January 2013 19:11 Go to previous message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
Hi,

(1) create a new project using the wizard
(2) paste the grammar and run the workflow
(3) launch runtime eclipse and create a new project
(4) create .mydsl files and have fun


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Previous Topic:JvmModelInferrer refer to a java class not in the model
Next Topic:Retrieve info from EMF model in UI action and then use it to modify the model itself
Goto Forum:
  


Current Time: Wed Apr 24 22:15:07 GMT 2024

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

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

Back to the top