在 Xtend 中,是否可以中断循环或检查以中断循环?
\n\n\xc2\xabFOR e:d.entitys\xc2\xbb\n \xc2\xabFOR a:e.attributes\xc2\xbb\n \xc2\xabIF a.eClass.name.contentEquals(\'Something\')\xc2\xbb\n \xc2\xabe.name\xc2\xbb "This output should be output one for each Entity e"\n \xc2\xabENDIF\xc2\xbb\n \xc2\xabENDFOR\xc2\xbb\n\xc2\xabENDFOR\xc2\xbb\nRun Code Online (Sandbox Code Playgroud)\n\n我的输出是:
\n\nEntity 1 "This output should be output one for each Entity e"\nEntity 1 "This output should be output one for each Entity e"\nEntity 1 "This output should be output one for each Entity e"\nEntity 2 "This output should be output one for each Entity e"\nEntity 4 "This output should be output one for each …Run Code Online (Sandbox Code Playgroud) 我知道有一个简单的解决方案,但我不知道如何实现它.
我正在寻找如何实现答案而不是我需要做的事情.答案的一半已经在这个页面上: Xtext交叉引用和范围
我的问题是下面的语法:
DomainModel:
"DOMAINMODEL" name=ID "{"
"ENTITYS" "{"
(Entitys+=Entity)*
"}"
"ENTITY_RELATIONSHIP" "{"
(Relationships+=Relationship)*
"}"
"}";
Entity:
name=ID "{"
(Attributes+=Attribute)*
"}";
Attribute:
StringAttribute | NumberAttribute | ImageAttribute;
StringAttribute:
"STRING" name=ID;
NumberAttribute:
"NUMBER" name=ID;
ImageAttribute:
"IMAGE" name=ID;
// Relationship = [new table name] : [shared key name] -> ref_table(ref_id)
Relationship:
name=ID ":" newEntityName=ID "->" refEntityName=[Entity|ID]"("refName=[Attribute|ID]")"; // <- Problem here
Run Code Online (Sandbox Code Playgroud)
当我编写模型时,我无法获得"refName = [Attribute | ID]"来引用实体内部的属性.在下面的代码中
DOMAINMODEL auctionHouse{
ENTITYS {
lots{
NUMBER id0
NUMBER lotNo
STRING name
STRING priceEstimate
STRING description …Run Code Online (Sandbox Code Playgroud)