use of org.eclipse.xtend.core.xtend.XtendFile 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.xtend.core.xtend.XtendFile in project xtext-xtend by eclipse.
the class SuspiciousOverloadValidationTest method assertValid.
protected void assertValid(final CharSequence contents) {
final XtendFile file = this.getParsedXtendFile(contents);
final EList<Resource.Diagnostic> errors = file.eResource().getErrors();
Assert.assertEquals(errors.toString(), 0, errors.size());
this._validationTestHelper.assertNoErrors(file);
}
use of org.eclipse.xtend.core.xtend.XtendFile in project xtext-xtend by eclipse.
the class ValidationBug398302Test method test_03.
@Test
public void test_03() {
try {
StringConcatenation _builder = new StringConcatenation();
_builder.append("import static java.lang.String.*");
_builder.newLine();
_builder.append("class C {");
_builder.newLine();
_builder.append("\t");
_builder.append("def m() {");
_builder.newLine();
_builder.append("\t\t");
_builder.append("CASE_INSENSITIVE_ORDER = null");
_builder.newLine();
_builder.append("\t");
_builder.append("}");
_builder.newLine();
_builder.append("}");
_builder.newLine();
final String s = _builder.toString();
final XtendFile file = this.parser.parse(s);
final String fieldName = "CASE_INSENSITIVE_ORDER";
this.helper.assertError(file, XbasePackage.Literals.XASSIGNMENT, IssueCodes.ASSIGNMENT_TO_FINAL, s.indexOf(fieldName), fieldName.length());
} catch (Throwable _e) {
throw Exceptions.sneakyThrow(_e);
}
}
use of org.eclipse.xtend.core.xtend.XtendFile in project xtext-xtend by eclipse.
the class ValidationBug398302Test method test_01.
@Test
public void test_01() {
try {
StringConcatenation _builder = new StringConcatenation();
_builder.append("class C {");
_builder.newLine();
_builder.append("\t");
_builder.append("def m() {");
_builder.newLine();
_builder.append("\t\t");
_builder.append("String.CASE_INSENSITIVE_ORDER = null");
_builder.newLine();
_builder.append("\t");
_builder.append("}");
_builder.newLine();
_builder.append("}");
_builder.newLine();
final String s = _builder.toString();
final XtendFile file = this.parser.parse(s);
final String fieldName = "CASE_INSENSITIVE_ORDER";
this.helper.assertError(file, XbasePackage.Literals.XASSIGNMENT, IssueCodes.ASSIGNMENT_TO_FINAL, s.indexOf(fieldName), fieldName.length());
} catch (Throwable _e) {
throw Exceptions.sneakyThrow(_e);
}
}
use of org.eclipse.xtend.core.xtend.XtendFile in project xtext-xtend by eclipse.
the class ValidationBug398302Test method test_04.
@Test
public void test_04() {
try {
StringConcatenation _builder = new StringConcatenation();
_builder.append("class C {");
_builder.newLine();
_builder.append("\t");
_builder.append("val string = \'\'");
_builder.newLine();
_builder.append("\t");
_builder.append("def m() {");
_builder.newLine();
_builder.append("\t\t");
_builder.append("string = null");
_builder.newLine();
_builder.append("\t");
_builder.append("}");
_builder.newLine();
_builder.append("}");
_builder.newLine();
final String s = _builder.toString();
final XtendFile file = this.parser.parse(s);
final String assignment = "string = null";
this.helper.assertError(file, XbasePackage.Literals.XASSIGNMENT, IssueCodes.ASSIGNMENT_TO_FINAL, s.indexOf(assignment), 6);
} catch (Throwable _e) {
throw Exceptions.sneakyThrow(_e);
}
}
Aggregations