use of org.eclipse.xtend.core.xtend.XtendFile in project xtext-xtend by eclipse.
the class AmbiguityValidationTest method getParsedXtendFile.
protected XtendFile getParsedXtendFile(final CharSequence contents) {
try {
final XtendFile file = this._parseHelper.parse(contents);
final EList<Resource.Diagnostic> errors = file.eResource().getErrors();
Assert.assertTrue(errors.toString(), errors.isEmpty());
EcoreUtil.resolveAll(file);
return file;
} catch (Throwable _e) {
throw Exceptions.sneakyThrow(_e);
}
}
use of org.eclipse.xtend.core.xtend.XtendFile in project xtext-xtend by eclipse.
the class AmbiguityValidationTest method assertAmbiguous.
protected void assertAmbiguous(final CharSequence contents, final String... messageParts) {
final XtendFile file = this.getParsedXtendFile(contents);
final EList<Resource.Diagnostic> errors = file.eResource().getErrors();
Assert.assertEquals(errors.toString(), 1, errors.size());
Resource.Diagnostic _head = IterableExtensions.<Resource.Diagnostic>head(errors);
final AbstractDiagnostic singleError = ((AbstractDiagnostic) _head);
Assert.assertEquals(singleError.getMessage(), IssueCodes.AMBIGUOUS_FEATURE_CALL, singleError.getCode());
final Function1<String, String> _function = (String it) -> {
return Strings.toUnixLineSeparator(it);
};
final Consumer<String> _function_1 = (String it) -> {
final String message = singleError.getMessage();
boolean _contains = message.contains(it);
boolean _not = (!_contains);
if (_not) {
Assert.assertEquals(it, message);
}
};
ListExtensions.<String, String>map(((List<String>) Conversions.doWrapArray(messageParts)), _function).forEach(_function_1);
final XtendTypeDeclaration firstType = IterableExtensions.<XtendTypeDeclaration>head(file.getXtendTypes());
XtendMember _head_1 = IterableExtensions.<XtendMember>head(firstType.getMembers());
final XtendFunction firstMember = ((XtendFunction) _head_1);
XExpression _expression = firstMember.getExpression();
final XBlockExpression block = ((XBlockExpression) _expression);
XExpression _last = IterableExtensions.<XExpression>last(block.getExpressions());
final XAbstractFeatureCall featureCall = ((XAbstractFeatureCall) _last);
final IFeatureLinkingCandidate linkingCandidate = this._iBatchTypeResolver.resolveTypes(file).getLinkingCandidate(featureCall);
Assert.assertTrue((linkingCandidate instanceof IAmbiguousLinkingCandidate));
}
use of org.eclipse.xtend.core.xtend.XtendFile in project xtext-xtend by eclipse.
the class BatchLinkingServiceTest method testBug464762.
@Test
public void testBug464762() {
try {
StringConcatenation _builder = new StringConcatenation();
_builder.append("class Foo {");
_builder.newLine();
_builder.append("\t");
_builder.append("def void bar() {");
_builder.newLine();
_builder.append("\t\t");
_builder.append("__UNRESOLVABLE_SuperDuper_()");
_builder.newLine();
_builder.append("\t");
_builder.append("}");
_builder.newLine();
_builder.append("}");
_builder.newLine();
final XtendFile file = this.file(_builder.toString(), false);
Assert.assertNull(file.eResource().getEObject("|0"));
} catch (Throwable _e) {
throw Exceptions.sneakyThrow(_e);
}
}
use of org.eclipse.xtend.core.xtend.XtendFile in project xtext-xtend by eclipse.
the class ErrorTest method testErrorModel_015.
@Test
public void testErrorModel_015() throws Exception {
StringConcatenation _builder = new StringConcatenation();
_builder.append("@ class Node {");
_builder.newLine();
_builder.append("}");
_builder.newLine();
final XtendFile file = this.processWithoutException(_builder);
final XtendTypeDeclaration node = IterableExtensions.<XtendTypeDeclaration>head(file.getXtendTypes());
final XAnnotation annotation = IterableExtensions.<XAnnotation>head(node.getAnnotations());
final IResolvedTypes resolvedTypes = this.typeResolver.resolveTypes(annotation);
Assert.assertNotNull(resolvedTypes.getActualType(annotation));
}
use of org.eclipse.xtend.core.xtend.XtendFile in project xtext-xtend by eclipse.
the class ErrorTest method testErrorModel_007.
@Test
public void testErrorModel_007() throws Exception {
StringConcatenation _builder = new StringConcatenation();
_builder.append("@Data class A {}");
_builder.newLine();
_builder.append("@Data class");
_builder.newLine();
final XtendFile file = this.processWithoutException(_builder);
final XtendTypeDeclaration typeDeclaration = IterableExtensions.<XtendTypeDeclaration>last(file.getXtendTypes());
final EList<XAnnotation> annotations = typeDeclaration.getAnnotations();
final IResolvedTypes resolvedTypes = this.typeResolver.resolveTypes(IterableExtensions.<XAnnotation>head(annotations));
Assert.assertNotNull(resolvedTypes.getActualType(IterableExtensions.<XAnnotation>head(annotations)));
}
Aggregations