org.eclipse.xtext.Extensions.ext Maven / Gradle / Ivy
/*******************************************************************************
* Copyright (c) 2008 itemis AG and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
*******************************************************************************/
import org::eclipse::xtext;
extension org::eclipse::xtext::GrammarUtil reexport;
extension org::eclipse::xtext::EcoreUtils;
// ***********************************************************************************
// Shortcuts
ParserRule calledParserRule(RuleCall this) :
if ParserRule.isInstance(rule) then rule;
EnumRule calledEnumRule(RuleCall this) :
if EnumRule.isInstance(rule) then rule;
boolean isKeywordAssignment(Assignment a) :
Keyword.isInstance(a.terminal) ||
a.allContents().forAll(e | !(RuleCall.isInstance(e)));
boolean isRuleAssignment(Assignment a) :
RuleCall.isInstance(a.terminal);
boolean isParserRuleAssignment(Assignment a) :
a.isRuleAssignment() && ((RuleCall) a.terminal).calledParserRule() != null;
boolean isEnumRuleAssignment(Assignment a) :
a.isRuleAssignment() && ((RuleCall) a.terminal).calledEnumRule() != null;
Boolean isBoolean(Assignment a) :
a.operator == "?="
;
Boolean isMultiple(Assignment a) :
a.operator == "+="
;
boolean isQualified(String name) :
name.contains("::")
;
String getAlias(String fqn) :
isQualified(fqn) ? fqn.split("::").first() : null
;
© 2015 - 2025 Weber Informatics LLC | Privacy Policy