use of org.eclipse.xtext.Action in project xtext-core by eclipse.
the class NodeModelBasedRegionAccessBuilder method process.
protected void process(INode node, NodeModelBasedRegionAccess access) {
NodeEObjectRegion tokens = stack.peek();
boolean creator = isEObjectRoot(node);
if (creator || tokens == null) {
tokens = createTokens(access, node);
tokens.setLeadingHiddenRegion(lastHidden);
NodeEObjectRegion parent = stack.peek();
if (parent != null) {
parent.addChild(tokens);
}
stack.push(tokens);
}
if (tokens.getSemanticElement() == null) {
if (node.getParent() == null) {
tokens.setSemanticElement(resource.getContents().get(0));
EObject element = node.getGrammarElement();
if (element instanceof Action)
element = ((ICompositeNode) node).getFirstChild().getGrammarElement();
tokens.setGrammarElement(element);
} else if (node.hasDirectSemanticElement()) {
tokens.setSemanticElement(node.getSemanticElement());
tokens.setGrammarElement(findGrammarElement(node, tokens.getSemanticElement()));
}
}
if (include(node)) {
if (node instanceof ICompositeNode) {
for (ILeafNode leaf : node.getLeafNodes()) if (leaf.isHidden())
this.add(access, leaf);
else
break;
}
this.add(access, node);
} else if (node instanceof ICompositeNode) {
for (INode child : ((ICompositeNode) node).getChildren()) process(child, access);
}
if (creator) {
NodeEObjectRegion popped = stack.pop();
popped.setTrailingHiddenRegion(lastHidden);
EObject semanticElement = popped.getSemanticElement();
if (semanticElement == null)
throw new IllegalStateException();
if (!stack.isEmpty() && semanticElement.eContainer() != stack.peek().getSemanticElement())
throw new IllegalStateException();
EObject grammarElement = popped.getGrammarElement();
if (grammarElement == null) {
throw new IllegalStateException();
}
NodeEObjectRegion old = eObjToTokens.put(semanticElement, popped);
if (old != null)
throw new IllegalStateException();
}
}
use of org.eclipse.xtext.Action in project xtext-core by eclipse.
the class TerminalsSemanticSequencer method sequence.
@Override
public void sequence(ISerializationContext context, EObject semanticObject) {
EPackage epackage = semanticObject.eClass().getEPackage();
ParserRule rule = context.getParserRule();
Action action = context.getAssignedAction();
Set<Parameter> parameters = context.getEnabledBooleanParameters();
if (errorAcceptor != null)
errorAcceptor.accept(diagnosticProvider.createInvalidContextOrTypeDiagnostic(semanticObject, context));
}
use of org.eclipse.xtext.Action in project xtext-core by eclipse.
the class XtextValidationTest method testCheckActionInUnorderedGroup_01.
@Test
public void testCheckActionInUnorderedGroup_01() throws Exception {
XtextValidator validator = get(XtextValidator.class);
UnorderedGroup unorderedGroup = XtextFactory.eINSTANCE.createUnorderedGroup();
Action action = XtextFactory.eINSTANCE.createAction();
unorderedGroup.getElements().add(action);
ValidatingMessageAcceptor messageAcceptor = new ValidatingMessageAcceptor(action, true, false);
configureValidator(validator, messageAcceptor, action);
validator.checkActionInUnorderedGroup(action);
messageAcceptor.validate();
}
use of org.eclipse.xtext.Action in project xtext-core by eclipse.
the class XtextValidationTest method testBug318424_02.
@Test
public void testBug318424_02() throws Exception {
XtextValidator validator = get(XtextValidator.class);
Action action = XtextFactory.eINSTANCE.createAction();
TypeRef typeRef = XtextFactory.eINSTANCE.createTypeRef();
action.setType(typeRef);
typeRef.setClassifier(EcorePackage.Literals.EBOOLEAN);
ValidatingMessageAcceptor messageAcceptor = new ValidatingMessageAcceptor(typeRef, true, false);
validator.setMessageAcceptor(messageAcceptor);
validator.checkInstantiatedType(action);
messageAcceptor.validate();
}
use of org.eclipse.xtext.Action in project xtext-core by eclipse.
the class GrammarAccessExtensions method getSingleElementDescription.
private List<String> getSingleElementDescription(final AbstractElement ele) {
final ArrayList<String> r = new ArrayList<String>(2);
boolean _matched = false;
if (ele instanceof Keyword) {
_matched = true;
String _value = ((Keyword) ele).getValue();
r.add(_value);
}
if (!_matched) {
if (ele instanceof Assignment) {
_matched = true;
String _feature = ((Assignment) ele).getFeature();
r.add(_feature);
}
}
if (!_matched) {
if (ele instanceof RuleCall) {
_matched = true;
String _name = ((RuleCall) ele).getRule().getName();
r.add(_name);
}
}
if (!_matched) {
if (ele instanceof Action) {
_matched = true;
TypeRef _type = ((Action) ele).getType();
EClassifier _classifier = null;
if (_type != null) {
_classifier = _type.getClassifier();
}
boolean _tripleNotEquals = (_classifier != null);
if (_tripleNotEquals) {
String _name = ((Action) ele).getType().getClassifier().getName();
r.add(_name);
}
boolean _isNullOrEmpty = StringExtensions.isNullOrEmpty(((Action) ele).getFeature());
boolean _not = (!_isNullOrEmpty);
if (_not) {
String _feature = ((Action) ele).getFeature();
r.add(_feature);
}
}
}
if (!_matched) {
if (ele instanceof CrossReference) {
_matched = true;
TypeRef _type = ((CrossReference) ele).getType();
EClassifier _classifier = null;
if (_type != null) {
_classifier = _type.getClassifier();
}
boolean _tripleNotEquals = (_classifier != null);
if (_tripleNotEquals) {
String _name = ((CrossReference) ele).getType().getClassifier().getName();
r.add(_name);
}
}
}
if (!_matched) {
if (ele instanceof EnumLiteralDeclaration) {
_matched = true;
String _name = ((EnumLiteralDeclaration) ele).getEnumLiteral().getName();
r.add(_name);
}
}
return r;
}
Aggregations