use of org.eclipse.xtext.EnumLiteralDeclaration in project xtext-core by eclipse.
the class XtextTransientValueService method isTransient.
@Override
public boolean isTransient(EObject owner, EStructuralFeature feature, int index) {
if (feature == XtextPackage.eINSTANCE.getTypeRef_Metamodel()) {
final TypeRef typeRef = (TypeRef) owner;
final AbstractMetamodelDeclaration m = typeRef.getMetamodel();
if (m == null || Strings.isEmpty(m.getAlias()))
return true;
} else if (feature == XtextPackage.eINSTANCE.getAbstractRule_Type()) {
final AbstractRule rule = (AbstractRule) owner;
if (rule instanceof ParserRule || rule instanceof EnumRule) {
final TypeRef returnType = rule.getType();
if (returnType == null || returnType.getClassifier() == null)
return true;
else if (rule.getName().equals(returnType.getClassifier().getName())) {
return isTransient(returnType, XtextPackage.eINSTANCE.getTypeRef_Metamodel(), -1);
} else if (GrammarUtil.isDatatypeRule(rule)) {
return NodeModelUtils.getNode(returnType) == null;
}
} else if (rule instanceof TerminalRule) {
final TypeRef returnType = rule.getType();
return ((TerminalRule) rule).isFragment() || returnType == null || GrammarUtil.findEString(GrammarUtil.getGrammar(owner)).equals(rule.getType().getClassifier());
}
} else if (feature == XtextPackage.eINSTANCE.getCrossReference_Terminal()) {
final CrossReference ref = (CrossReference) owner;
if (ref.getTerminal() instanceof RuleCall && ((RuleCall) ref.getTerminal()).getRule() != null && "ID".equals(((RuleCall) ref.getTerminal()).getRule().getName()))
return true;
} else if (feature == XtextPackage.eINSTANCE.getEnumLiteralDeclaration_Literal()) {
final EnumLiteralDeclaration decl = (EnumLiteralDeclaration) owner;
return decl.getEnumLiteral() != null && decl.getLiteral() != null && Strings.equal(decl.getLiteral().getValue(), decl.getEnumLiteral().getName());
} else if (feature == XtextPackage.eINSTANCE.getRuleCall_ExplicitlyCalled()) {
return true;
} else if (feature == XtextPackage.eINSTANCE.getNamedArgument_Parameter()) {
return !((NamedArgument) owner).isCalledByName();
}
return super.isTransient(owner, feature, index);
}
Aggregations