Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Cross-referencing(Making functions with parameters available on content assist)
Cross-referencing [message #952343] Sun, 21 October 2012 11:23
Neeraj Bhusare is currently offline Neeraj BhusareFriend
Messages: 169
Registered: July 2009
Location: Canada
Senior Member
Hi,
I need some help with regard to cross-referencing. I have 3 separate DSL's - 1) Entity DSL for entities and attributes, 2) Function DSL for functions with parameters, and 3) Consumer DSL that cross-references Entities, attribites and the functions from the respective DSL's. Everything works fine - Entities and attributes (specific to entities) are available on content assist. For function, content assist shows the names. I need the function name with parameters, for example (some_function(param1, param2...)).

I have tried something similar to the NameProvider in XText arithmetic example. In the EntityConsumerSwitch.caseFunctionRef(), I get null value for the Function reference - fReference.getFRef(). Any idea how this could be fixed ? My functions are defined in a separate file.

Also, I also saw the following error - Cyclic resolution of lazy links : AttributeRef.aRef->EntityRef.type->AttributeRef.aRef.

Entity DSL
generate entityDSL "http://www.example.org/xtext/entity/dsl/EntityDSL"

Model:
	'namespace' name=QName
	entities+=Entity*
;

Entity:
	'entity' name=ID '{'
		attributes+=Attribute*
	'}'
;

Attribute:
	'attribute' name=ID	
;

QName:
	ID ('.' ID)*
;


Function DSL
generate functionDSL "http://www.example.org/xtext/function/dsl/FunctionDSL"

Model:
	functions+=Function*;
	
Function:
	'func' name=ID '('parameters+=Parameter (',' parameters+=Parameter)* ')'
;

Parameter:
	name=ID ':' type=Type
;

Type:
	'string'
;


Consumer DSL
generate entityConsumer "http://www.example.org/xtext/entityconsumer/dsl/EntityConsumer"

import "http://www.example.org/xtext/entity/dsl/EntityDSL" as entity

import "http://www.example.org/xtext/function/dsl/FunctionDSL" as function

Model:
	eRef+=EntityRef*
;

EntityRef:
	'entity-ref' type=[entity::Entity|QName] '{' 
		afRef+=AFReference (';' afRef+=AFReference)*
	'}'
;

AFReference:
	aRef=AttributeRef '::' fRef=FunctionRef
;

AttributeRef:
	aRef=[entity::Attribute]
;

FunctionRef:
	fRef=[function::Function]
;

QName:
	ID ('.' ID)*
;


Thanks in advance.


Twitter : @NeerajBhusare
Blog : https://nbhusare.github.io/
Best regards, Neeraj
Previous Topic:Setting multiple EMF elements based on one grammar element.
Next Topic:Tuning code generation
Goto Forum:
  


Current Time: Sun Apr 18 22:26:47 GMT 2021

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

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

Back to the top