Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Validating namespace imports?
Validating namespace imports? [message #1446054] Thu, 16 October 2014 09:43 Go to next message
Stephan Herrmann is currently offline Stephan HerrmannFriend
Messages: 1853
Registered: July 2009
Senior Member
Has anyone written a validator that would flag unresolved and/or unused namespace imports?

I wonder if normalizers could keep track of which imports have been used during resolution, but it seems that the necessary information is too far spread. Perhaps an EObjectDescription would need a link back to the import whose normalizer was used to create it? Then successful resolution using a particular EObjectDescription could go back and mark the import as used.

If we could identify unused imports, we could then perform more expensive search to distinguish unresolved from plain unused.

Nothing of this looks trivial to me (if performance is taken into account), hence the question: does anything like this exist somewhere?

TIA,
Stephan
Re: Validating namespace imports? [message #1446099 is a reply to message #1446054] Thu, 16 October 2014 11:00 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7655
Registered: July 2009
Senior Member
Hi

It is possible to use OCL to define custom validation rules that can be
loaded into unsuspecting EMF applications.

The Complete OCL tutorial in the OCL documentation demonstrates how a
couple of style rules can be added to Xtext.

Regards

Ed Willink



On 16/10/2014 10:43, Stephan Herrmann wrote:
> Has anyone written a validator that would flag unresolved and/or unused
> namespace imports?
>
> I wonder if normalizers could keep track of which imports have been used
> during resolution, but it seems that the necessary information is too
> far spread. Perhaps an EObjectDescription would need a link back to the
> import whose normalizer was used to create it? Then successful
> resolution using a particular EObjectDescription could go back and mark
> the import as used.
>
> If we could identify unused imports, we could then perform more
> expensive search to distinguish unresolved from plain unused.
>
> Nothing of this looks trivial to me (if performance is taken into
> account), hence the question: does anything like this exist somewhere?
>
> TIA,
> Stephan
>
Re: Validating namespace imports? [message #1446130 is a reply to message #1446099] Thu, 16 October 2014 12:02 Go to previous messageGo to next message
Stephan Herrmann is currently offline Stephan HerrmannFriend
Messages: 1853
Registered: July 2009
Senior Member
Ed Willink wrote on Thu, 16 October 2014 13:00
Hi

It is possible to use OCL to define custom validation rules that can be
loaded into unsuspecting EMF applications.

The Complete OCL tutorial in the OCL documentation demonstrates how a
couple of style rules can be added to Xtext.


Thanks for the suggestion. For this particular situation, can you say a word on performance? My intuition is, that anything that's not closely integrated with the way how Xtext evaluates imports will be prohibitively slow in projects with many hundrets of models, since each validation for an individual import will have to search the entire universe of model elements, no?

In particular, it would be cool to have a strategy that is fast without requiring an index, since in some cases I'd want to run this validation at application runtime (i.e. outside Eclipse).

thanks,
Stephan
Re: Validating namespace imports? [message #1446139 is a reply to message #1446130] Thu, 16 October 2014 12:18 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7655
Registered: July 2009
Senior Member
Hi

An add-on to Xtext certainly won't compare in performance with something
integrated.

Particularly not if execution uses an interpreted approach.

For an occasional interactive how are we doing, the OCL approach should
work fine. If you want it integrated in a frequent auto-build, you may
need to work harder.

Regards

Ed Willink


On 16/10/2014 13:02, Stephan Herrmann wrote:
> Ed Willink wrote on Thu, 16 October 2014 13:00
>> Hi
>>
>> It is possible to use OCL to define custom validation rules that can
>> be loaded into unsuspecting EMF applications.
>>
>> The Complete OCL tutorial in the OCL documentation demonstrates how a
>> couple of style rules can be added to Xtext.
>
>
> Thanks for the suggestion. For this particular situation, can you say a
> word on performance? My intuition is, that anything that's not closely
> integrated with the way how Xtext evaluates imports will be
> prohibitively slow in projects with many hundrets of models, since each
> validation for an individual import will have to search the entire
> universe of model elements, no?
>
> In particular, it would be cool to have a strategy that is fast without
> requiring an index, since in some cases I'd want to run this validation
> at application runtime (i.e. outside Eclipse).
>
> thanks,
> Stephan
>
Re: Validating namespace imports? [message #1446158 is a reply to message #1446054] Thu, 16 October 2014 12:46 Go to previous messageGo to next message
Sebastian Zarnekow is currently offline Sebastian ZarnekowFriend
Messages: 3118
Registered: July 2009
Senior Member
Hi Stephan,

yes, someone has already implemented such a validator for customers. And
yes, the approach was pretty close to what you describe wrt to
EObjectDescriptions that mark imports as used during linking.

In short: what you describe works exactly like that. No, the code is not
publicly available, though.

Best,
Sebastian
--
Looking for professional support for Xtext, Xtend or Eclipse Modeling?
Go visit: http://xtext.itemis.com
Re: Validating namespace imports? [message #1446173 is a reply to message #1446158] Thu, 16 October 2014 13:04 Go to previous message
Stephan Herrmann is currently offline Stephan HerrmannFriend
Messages: 1853
Registered: July 2009
Senior Member
Hi Sebastian,

I wasn't sure if my idea makes sense, but your answer sounds encouraging,
I'll try to flesh it out then...

thanks,
Stephan
Previous Topic:Concept to avoid lengthy generator steps?
Next Topic:Resolving partially imported types
Goto Forum:
  


Current Time: Fri Apr 26 17:12:18 GMT 2024

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

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

Back to the top