|
Re: Begginer on Xtext Validation [message #1838715 is a reply to message #1838700] |
Thu, 04 March 2021 05:24 |
|
You'll need to find that through the Xtext index when the Labels that reference an input could potentially be defined in another file.
Inject an IResourceDescriptionsProvider. This grants you access to the right IResourceDescriptions instance (AKA the 'index').
From there iterate over getAllResourceDescriptions() and for each IResourceDescription loop over getReferenceDescriptions().
For an IReferenceDescription collect the target references. If you don't find any where the target is a given Label then its is unreferenced.
This is a costly validation, you should mark the Check with CheckType NORMAL, otherwise it would run with each edit.
|
|
|
Re: Begginer on Xtext Validation [message #1838732 is a reply to message #1838715] |
Thu, 04 March 2021 09:00 |
|
this usecase is the most advanced usecase you can find at least when you use more than one file (which this answer and karstens assume)
please note: getReferenceDescriptions wont work during build as they may not be available yet
thus you would have to store the names of the Entity in the user data of index entry of the Label (retriving the text using NodeModelUtils) via DefaultResourceDescriptionStrategy.
and then query the index in the validation and check if there is an index entry which index entries contain the Entity and if none error it.
the approach karsten proposed works in an expensive validation only and not in a not in CheckType FAST or CheckTYPE NORMAL
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
[Updated on: Thu, 04 March 2021 09:01] Report message to a moderator
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.03200 seconds