|Re: Evaluating "If" condition in Acceleo/Sirius [message #1776819 is a reply to message #1776452]
||Tue, 21 November 2017 23:01
| Jad El-khoury
Registered: August 2015
It is odd that the operation works as expected if loadedVocabularies is not empty, so it cannot be that Vocabulary is not imported. |
Worth noting also that loadedVocabularies is a result of a java service call that is to return a list of Vocabulary eClass instances.
Could it be that when the returned list is empty, the compiler does not recognise that the (empty) list is expected to be of type Vocabulary, hence it complains "Unknown type (Vocabulary)"?
In the end, what worked is the following:
[loadedVocabularies->select(v | v.oclAsType(vocabulary::Vocabulary).terms->select(t | t.oclIsTypeOf(vocabulary::Class))->notEmpty() ) /]
1. As suggested above, we replaced "v : Vocabulary" with simply 'v', to avoid the compilation error.
2. But then we need to replace "v.terms" with " v.oclAsType(vocabulary::Vocabulary).terms", since the compiler complained that it did not recognise 'terms', unless we tell it what the type of 'v' is first.
This change works for both empty, and non-empty loadedVocabularies.
But it is still not 100% clear why the compiler fails.
Powered by FUDForum
. Page generated in 0.02183 seconds