use of org.eclipse.xtext.xbase.XExpression in project xtext-eclipse by eclipse.
the class Oven method fireproof.
public void fireproof(final String input) throws Exception {
try {
final EObject file = this._parseHelper.parse(input);
final IResolvedTypes resolvedTypes = this.typeResolver.resolveTypes(file);
Assert.assertNotNull(resolvedTypes);
if ((file != null)) {
Iterable<EObject> _iterable = IteratorExtensions.<EObject>toIterable(file.eAllContents());
for (final EObject content : _iterable) {
boolean _matched = false;
if (content instanceof XAbstractFeatureCall) {
_matched = true;
this.assertExpressionTypeIsResolved(((XExpression) content), resolvedTypes);
XExpression _implicitReceiver = ((XAbstractFeatureCall) content).getImplicitReceiver();
boolean _tripleNotEquals = (_implicitReceiver != null);
if (_tripleNotEquals) {
this.assertExpressionTypeIsResolved(((XAbstractFeatureCall) content).getImplicitReceiver(), resolvedTypes);
}
XExpression _implicitFirstArgument = ((XAbstractFeatureCall) content).getImplicitFirstArgument();
boolean _tripleNotEquals_1 = (_implicitFirstArgument != null);
if (_tripleNotEquals_1) {
this.assertExpressionTypeIsResolved(((XAbstractFeatureCall) content).getImplicitFirstArgument(), resolvedTypes);
}
}
if (!_matched) {
if (content instanceof XClosure) {
_matched = true;
this.assertExpressionTypeIsResolved(((XExpression) content), resolvedTypes);
final Consumer<JvmFormalParameter> _function = (JvmFormalParameter it) -> {
this.assertIdentifiableTypeIsResolved(it, resolvedTypes);
};
((XClosure) content).getImplicitFormalParameters().forEach(_function);
}
}
if (!_matched) {
if (content instanceof XExpression) {
_matched = true;
this.assertExpressionTypeIsResolved(((XExpression) content), resolvedTypes);
}
}
if (!_matched) {
if (content instanceof JvmIdentifiableElement) {
_matched = true;
this.assertIdentifiableTypeIsResolved(((JvmIdentifiableElement) content), resolvedTypes);
}
}
}
}
} catch (final Throwable _t) {
if (_t instanceof Throwable) {
final Throwable e = (Throwable) _t;
String _message = e.getMessage();
final ComparisonFailure error = new ComparisonFailure(_message, input, "");
error.setStackTrace(e.getStackTrace());
throw error;
} else {
throw Exceptions.sneakyThrow(_t);
}
}
}
use of org.eclipse.xtext.xbase.XExpression in project xtext-eclipse by eclipse.
the class AbstractXbaseContentAssistTest method expression.
protected XExpression expression(String string) throws Exception {
XtextResource resource = getResourceFor(new StringInputStream(string));
assertEquals(resource.getErrors().toString(), 0, resource.getErrors().size());
XExpression result = (XExpression) resource.getContents().get(0);
return result;
}
use of org.eclipse.xtext.xbase.XExpression in project xtext-eclipse by eclipse.
the class AbstractXbaseUITestCase method expression.
protected XExpression expression(String string) throws Exception {
XtextResource resource = getResourceFor(new StringInputStream(string));
assertEquals(resource.getErrors().toString(), 0, resource.getErrors().size());
XExpression result = (XExpression) resource.getContents().get(0);
return result;
}
use of org.eclipse.xtext.xbase.XExpression in project xtext-eclipse by eclipse.
the class AbstractXbaseContentAssistTest method expression.
protected XExpression expression(String string) throws Exception {
XtextResource resource = getResourceFor(new StringInputStream(string));
assertEquals(resource.getErrors().toString(), 0, resource.getErrors().size());
XExpression result = (XExpression) resource.getContents().get(0);
return result;
}
use of org.eclipse.xtext.xbase.XExpression in project xtext-eclipse by eclipse.
the class RuleEngineFormatter method _format.
@Override
protected void _format(final XSwitchExpression expr, @Extension final IFormattableDocument document) {
final Procedure1<IHiddenRegionFormatter> _function = (IHiddenRegionFormatter it) -> {
it.indent();
};
document.set(this.textRegionExtensions.previousHiddenRegion(expr.getSwitch()), this.textRegionExtensions.nextHiddenRegion(expr), _function);
final Procedure1<IHiddenRegionFormatter> _function_1 = (IHiddenRegionFormatter it) -> {
it.oneSpace();
};
document.append(this.textRegionExtensions.regionFor(expr).keyword("switch"), _function_1);
final Procedure1<IHiddenRegionFormatter> _function_2 = (IHiddenRegionFormatter it) -> {
it.newLine();
};
document.<XExpression>format(document.<XExpression>append(expr.getSwitch(), _function_2));
EList<XCasePart> _cases = expr.getCases();
for (final XCasePart c : _cases) {
{
if (((c.getTypeGuard() != null) && (c.getCase() != null))) {
final Procedure1<IHiddenRegionFormatter> _function_3 = (IHiddenRegionFormatter it) -> {
it.oneSpace();
};
document.<JvmTypeReference>append(c.getTypeGuard(), _function_3);
final Procedure1<IHiddenRegionFormatter> _function_4 = (IHiddenRegionFormatter it) -> {
it.noSpace();
};
document.<XExpression>append(c.getCase(), _function_4);
} else {
JvmTypeReference _typeGuard = c.getTypeGuard();
boolean _tripleNotEquals = (_typeGuard != null);
if (_tripleNotEquals) {
final Procedure1<IHiddenRegionFormatter> _function_5 = (IHiddenRegionFormatter it) -> {
it.noSpace();
};
document.<JvmTypeReference>append(c.getTypeGuard(), _function_5);
} else {
XExpression _case = c.getCase();
boolean _tripleNotEquals_1 = (_case != null);
if (_tripleNotEquals_1) {
final Procedure1<IHiddenRegionFormatter> _function_6 = (IHiddenRegionFormatter it) -> {
it.oneSpace();
};
final Procedure1<IHiddenRegionFormatter> _function_7 = (IHiddenRegionFormatter it) -> {
it.noSpace();
};
document.<XExpression>append(document.<XExpression>prepend(c.getCase(), _function_6), _function_7);
}
}
}
final Procedure1<IHiddenRegionFormatter> _function_8 = (IHiddenRegionFormatter it) -> {
it.noSpace();
};
final Procedure1<IHiddenRegionFormatter> _function_9 = (IHiddenRegionFormatter it) -> {
it.newLine();
};
document.append(document.prepend(this.textRegionExtensions.regionFor(c).feature(XbasePackage.Literals.XCASE_PART__FALL_THROUGH), _function_8), _function_9);
document.<XExpression>format(c.getCase());
if ((Objects.equal(c, IterableExtensions.<XCasePart>last(expr.getCases())) && (expr.getDefault() == null))) {
this.formatBody(c.getThen(), true, document);
} else {
this.formatBodyParagraph(c.getThen(), document);
}
}
}
XExpression _default = expr.getDefault();
boolean _tripleNotEquals = (_default != null);
if (_tripleNotEquals) {
final Procedure1<IHiddenRegionFormatter> _function_3 = (IHiddenRegionFormatter it) -> {
it.noSpace();
};
document.append(this.textRegionExtensions.regionFor(expr).keyword("default"), _function_3);
this.formatBody(expr.getDefault(), true, document);
}
}
Aggregations