Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » How to customize the scope of a reference
How to customize the scope of a reference [message #1861630] Tue, 24 October 2023 06:08 Go to next message
peppa nwpu is currently offline peppa nwpuFriend
Messages: 15
Registered: October 2023
Junior Member
Hello Xtext Community,
I tried to define an architecture description language, but when I use cross-reference, I can't write the correct Scope method. Can you give me some help? Below is part of my Xtext syntax.
Model:
	(componentTypes+=ComponentType | componentImpls+=ComponentImpl)*
;

ComponentType returns ComponentType:
	( SystemType
	| SubSystemType
	)
;

ComponentImpl returns ComponentImpl:
	SystemImpl 
;
/***************************************************************/
Feature : 
	PortFeature | AccessFeature
;
PortFeature returns PortFeature:  
	isSync?='sync'? isAsync?='async'? portDirection=('input' | 'output' | 'inout') type=PortType 'port' name=ID ';'
;

PortType returns PortType:
	{PortType} 'time' | {PortType} 'event' | {PortType} 'data' | {PortType} ('event' 'data')
;

AccessFeature returns AccessFeature: 
	accessDirection=('provide' | 'require') 'data' 'access' name=ID ';'
;

Property returns Property: 
	Period | Variable | Reference
;
Period returns Period: 
	'period' period=NumericValue 'ms' ';'
;
Variable returns Variable: 
	(isStateVal?='stateval')? variableType=VariableType name=ID ';'
;
Reference returns Reference: 
	variableType=VariableType '&' refName+=ID (',' '&' refName+=ID)* '->' ('system' | 'subsystem' | 'activity') componentType=ID sourceName=ID ';'
;
/*************************************************************************/
SystemType returns SystemType: 
	'system' name=ID
		('features' features+=Feature+ )?
		('properties' properties+=Property+)? 
	'end'
;

SubSystemType returns SubSystemType: 
	'subsystem' name=ID
		('features' features+=Feature+ )?
		('properties' properties+=Property+)? 
	'end'
;

/*********************************************************/
Init returns Init: 
	variableName=ID '=' value=ID ';'
;
SubSystemSubComponent returns SubSystemSubComponent: 
	'subsystem' subSystemSubComponentType=[SubSystemType|ID] '.' implName=ID componentName=ID ';'
;

DataSubComponent returns DataSubComponent:
	'data' dataSubComponentType=[DataComponentType|ID] '.' implName=ID componentName=ID ';'
;


SubComponent returns SubComponent:
	SubSystemSubComponent | DataSubComponent
;


Channel : 
	PortChannel 
;
PortChannel returns PortChannel: 
	portchannelName=ID '[' variableName=ID ']'':' portType=PortType 'port' sourceSubComponent=[SubComponent|ID] '.' sourcePort=[PortFeature|ID] ('<-'|'->'|'<->') sinkSubComponent=[SubComponent|ID] '.' sinkPort=[PortFeature|ID]';'
;

Realization returns Realization:
	implemented=[ComponentType|ID];
/*************************************************************************/
SystemImpl:
	'system' 'implementation' ownedRealization=Realization '.' name=ID
		('init' inits+=Init+)? 
		('properties' properties+=Property+)? 
		( 'components'
			(ownedSubSystemSubComponent+=SubSystemSubComponent
			)+
		)? 
		('channels' channels+=Channel+)?
	'end'
;



The following is what goes wrong.
index.php/fa/43626/0/

When I write names that use references in the editor, the editor will report an error, so I think there is a problem with the reference range, but I don't know how to customize the reference range.
Below is my ECore metamodel and the Scope I tried to write.
index.php/fa/43627/0/
index.php/fa/43628/0/
  • Attachment: 1.png
    (Size: 33.39KB, Downloaded 142 times)
  • Attachment: 2.png
    (Size: 67.87KB, Downloaded 146 times)
  • Attachment: 3.png
    (Size: 126.90KB, Downloaded 145 times)
Re: How to customize the scope of a reference [message #1861635 is a reply to message #1861630] Tue, 24 October 2023 10:41 Go to previous message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14738
Registered: July 2009
Senior Member
i assume the main problem is that your stuff does not have names
but things like

implName=ID componentName=ID ';'

thus you need to use the overloads of Scopes.scopeFor that take a name computation
and do a proper name calculation there


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Day Job: https://www.everest-systems.com
Previous Topic:Problem:Hierarchical Presentation of Referential Syntax in the Outline.
Next Topic:Content validation depending on file extension
Goto Forum:
  


Current Time: Fri Dec 13 22:05:24 GMT 2024

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

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

Back to the top