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.
	(componentTypes+=ComponentType | componentImpls+=ComponentImpl)*

ComponentType returns ComponentType:
	( SystemType
	| SubSystemType

ComponentImpl returns ComponentImpl:
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+)? 

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

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

Realization returns Realization:
	'system' 'implementation' ownedRealization=Realization '.' name=ID
		('init' inits+=Init+)? 
		('properties' properties+=Property+)? 
		( 'components'
		('channels' channels+=Channel+)?

The following is what goes wrong.

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.
  • Attachment: 1.png
    (Size: 33.39KB, Downloaded 115 times)
  • Attachment: 2.png
    (Size: 67.87KB, Downloaded 124 times)
  • Attachment: 3.png
    (Size: 126.90KB, Downloaded 120 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: 14695
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 :
Previous Topic:Problem:Hierarchical Presentation of Referential Syntax in the Outline.
Next Topic:Content validation depending on file extension
Goto Forum:

Current Time: Mon Jul 15 11:56:52 GMT 2024

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

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

Back to the top