use of org.eclipse.xtext.xbase.XExpression in project xtext-xtend by eclipse.
the class ErrorTest method testErrorModel_012.
@Test
public void testErrorModel_012() throws Exception {
StringConcatenation _builder = new StringConcatenation();
_builder.append("class Y {");
_builder.newLine();
_builder.append(" ");
_builder.append("static def <T> IExpectationSetters<T> expect(T value) {");
_builder.newLine();
_builder.append(" ");
_builder.append("}");
_builder.newLine();
_builder.append(" ");
_builder.append("HeaderAccess<?> unboundedMockHeaderAccess");
_builder.newLine();
_builder.append(" ");
_builder.append("def test() {");
_builder.newLine();
_builder.append(" ");
_builder.append("val Object header = unboundedMockHeaderAccess.header");
_builder.newLine();
_builder.append(" ");
_builder.append("val IExpectationSettersObject> exp1 = expect(header)");
_builder.newLine();
_builder.append(" ");
_builder.append("val IExpectationSetters<Object> exp2 = expect(unboundedMockHeaderAccess.getHeader())");
_builder.newLine();
_builder.append(" ");
_builder.append("}");
_builder.newLine();
_builder.append("}");
_builder.newLine();
_builder.append("interface HeaderAccess<T> {");
_builder.newLine();
_builder.append(" ");
_builder.append("def T getHeader();");
_builder.newLine();
_builder.append("}");
_builder.newLine();
_builder.append("interface IExpectationSetters<T> {}");
_builder.newLine();
final XtendFile file = this.processWithoutException(_builder);
final XtendTypeDeclaration y = IterableExtensions.<XtendTypeDeclaration>head(file.getXtendTypes());
XtendMember _get = y.getMembers().get(3);
final XtendField exp1 = ((XtendField) _get);
final XExpression initializer = exp1.getInitialValue();
final IResolvedTypes resolvedTypes = this.typeResolver.resolveTypes(initializer);
Assert.assertNotNull(resolvedTypes.getActualType(initializer));
}
use of org.eclipse.xtext.xbase.XExpression in project xtext-xtend by eclipse.
the class ErrorTest method testErrorModel_011.
@Test
public void testErrorModel_011() throws Exception {
StringConcatenation _builder = new StringConcatenation();
_builder.append("annotation { ");
_builder.newLine();
_builder.append("\t");
_builder.append("val inferred = \'bar\'");
_builder.newLine();
_builder.append("}");
_builder.newLine();
final XtendFile file = this.processWithoutException(_builder);
final XtendTypeDeclaration annotation = IterableExtensions.<XtendTypeDeclaration>last(file.getXtendTypes());
XtendMember _head = IterableExtensions.<XtendMember>head(annotation.getMembers());
final XtendField field = ((XtendField) _head);
final XExpression initializer = field.getInitialValue();
final IResolvedTypes resolvedTypes = this.typeResolver.resolveTypes(initializer);
Assert.assertNotNull(resolvedTypes.getActualType(initializer));
}
use of org.eclipse.xtext.xbase.XExpression in project xtext-xtend by eclipse.
the class ErrorTest method testErrorModel_020.
@Test
public void testErrorModel_020() throws Exception {
StringConcatenation _builder = new StringConcatenation();
_builder.append("package x");
_builder.newLine();
_builder.append("class Y {");
_builder.newLine();
_builder.append("\t");
_builder.append("@com.google.inject.Inject extension test.GenericExtensionMethods<String,Integer> x");
_builder.newLine();
_builder.append("\t");
_builder.append("def foo(String arg) {");
_builder.newLine();
_builder.append("\t\t");
_builder.append("arg.method");
_builder.newLine();
_builder.append("\t");
_builder.append("}");
_builder.newLine();
_builder.append("}");
_builder.newLine();
final XtendFile file = this.processWithoutException(_builder);
final XtendTypeDeclaration y = IterableExtensions.<XtendTypeDeclaration>head(file.getXtendTypes());
XtendMember _last = IterableExtensions.<XtendMember>last(y.getMembers());
final XtendFunction function = ((XtendFunction) _last);
XExpression _expression = function.getExpression();
final XBlockExpression body = ((XBlockExpression) _expression);
XExpression _head = IterableExtensions.<XExpression>head(body.getExpressions());
final XMemberFeatureCall featureCall = ((XMemberFeatureCall) _head);
XExpression _implicitReceiver = featureCall.getImplicitReceiver();
final XMemberFeatureCall implicitReceiver = ((XMemberFeatureCall) _implicitReceiver);
final XExpression this_ = implicitReceiver.getMemberCallTarget();
final IResolvedTypes resolvedTypes = this.typeResolver.resolveTypes(this_);
Assert.assertNotNull(resolvedTypes.getActualType(this_));
}
use of org.eclipse.xtext.xbase.XExpression in project xtext-xtend by eclipse.
the class AssignmentFeatureCallArgumentsTest method test_02.
@Test
public void test_02() {
final AssignmentFeatureCallArguments arguments = this.toArguments("String s", "\"\"");
Assert.assertTrue(arguments.hasUnprocessedArguments());
Assert.assertEquals(1, arguments.getArgumentCount());
final IFeatureCallArgumentSlot singleSlot = arguments.getNextUnprocessedArgumentSlot();
Assert.assertEquals("String", singleSlot.getDeclaredType().getSimpleName());
Assert.assertFalse(singleSlot.isVarArg());
Assert.assertFalse(singleSlot.isSuperfluous());
XExpression _argumentExpression = singleSlot.getArgumentExpression();
Assert.assertTrue((_argumentExpression instanceof XStringLiteral));
singleSlot.markProcessed();
Assert.assertFalse(arguments.hasUnprocessedArguments());
}
use of org.eclipse.xtext.xbase.XExpression in project xtext-xtend by eclipse.
the class AssignmentFeatureCallArgumentsTest method test_01.
@Test
public void test_01() {
final AssignmentFeatureCallArguments arguments = this.toArguments("", "null");
Assert.assertTrue(arguments.hasUnprocessedArguments());
final IFeatureCallArgumentSlot singleSlot = arguments.getNextUnprocessedArgumentSlot();
Assert.assertNull(singleSlot.getDeclaredType());
Assert.assertFalse(singleSlot.isVarArg());
Assert.assertFalse(singleSlot.isSuperfluous());
XExpression _argumentExpression = singleSlot.getArgumentExpression();
Assert.assertTrue((_argumentExpression instanceof XNullLiteral));
singleSlot.markProcessed();
Assert.assertFalse(arguments.hasUnprocessedArguments());
}
Aggregations