Search in sources :

Example 11 with IResolvedTypes

use of org.eclipse.xtext.xbase.typesystem.IResolvedTypes 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));
}
Also used : XtendFile(org.eclipse.xtend.core.xtend.XtendFile) XtendMember(org.eclipse.xtend.core.xtend.XtendMember) IResolvedTypes(org.eclipse.xtext.xbase.typesystem.IResolvedTypes) StringConcatenation(org.eclipse.xtend2.lib.StringConcatenation) XtendTypeDeclaration(org.eclipse.xtend.core.xtend.XtendTypeDeclaration) XExpression(org.eclipse.xtext.xbase.XExpression) XtendField(org.eclipse.xtend.core.xtend.XtendField) Test(org.junit.Test)

Example 12 with IResolvedTypes

use of org.eclipse.xtext.xbase.typesystem.IResolvedTypes in project xtext-xtend by eclipse.

the class ErrorTest method testErrorModel_016.

@Test
public void testErrorModel_016() throws Exception {
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("class <T> {");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("val String s");
    _builder.newLine();
    _builder.append("    ");
    _builder.append("new(String ^new) {");
    _builder.newLine();
    _builder.append("        ");
    _builder.append("s = ^new");
    _builder.newLine();
    _builder.append("    ");
    _builder.append("}");
    _builder.newLine();
    _builder.append("}");
    _builder.newLine();
    final XtendFile file = this.processWithoutException(_builder);
    final XtendTypeDeclaration unnamed = IterableExtensions.<XtendTypeDeclaration>head(file.getXtendTypes());
    XtendMember _last = IterableExtensions.<XtendMember>last(unnamed.getMembers());
    final XtendConstructor constructor = ((XtendConstructor) _last);
    XExpression _expression = constructor.getExpression();
    final XBlockExpression body = ((XBlockExpression) _expression);
    XExpression _head = IterableExtensions.<XExpression>head(body.getExpressions());
    final XAssignment assignment = ((XAssignment) _head);
    final IResolvedTypes resolvedTypes = this.typeResolver.resolveTypes(assignment);
    Assert.assertNotNull(resolvedTypes.getActualType(assignment));
}
Also used : XtendFile(org.eclipse.xtend.core.xtend.XtendFile) XBlockExpression(org.eclipse.xtext.xbase.XBlockExpression) XtendMember(org.eclipse.xtend.core.xtend.XtendMember) XtendConstructor(org.eclipse.xtend.core.xtend.XtendConstructor) IResolvedTypes(org.eclipse.xtext.xbase.typesystem.IResolvedTypes) StringConcatenation(org.eclipse.xtend2.lib.StringConcatenation) XtendTypeDeclaration(org.eclipse.xtend.core.xtend.XtendTypeDeclaration) XExpression(org.eclipse.xtext.xbase.XExpression) XAssignment(org.eclipse.xtext.xbase.XAssignment) Test(org.junit.Test)

Example 13 with IResolvedTypes

use of org.eclipse.xtext.xbase.typesystem.IResolvedTypes in project xtext-xtend by eclipse.

the class ErrorTest method testErrorModel_077.

@Test
public void testErrorModel_077() throws Exception {
    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("try return \'literal\' as as Boolean");
    _builder.newLine();
    _builder.append("\t\t  ");
    _builder.append("catch(NullPointerException e) return \'second thing is thrown\'\t\t  ");
    _builder.newLine();
    _builder.append("\t\t  ");
    _builder.append("catch(ClassCastException e) throw new NullPointerException()");
    _builder.newLine();
    _builder.append("    ");
    _builder.append("}");
    _builder.newLine();
    _builder.append("}");
    _builder.newLine();
    final XtendFile file = this.processWithoutException(_builder);
    final IResolvedTypes resolvedTypes = this.typeResolver.resolveTypes(file);
    final XCastedExpression casted = IteratorExtensions.<XCastedExpression>last(Iterators.<XCastedExpression>filter(file.eAllContents(), XCastedExpression.class));
    Assert.assertNull(casted.getType());
    Assert.assertNotNull(resolvedTypes.getActualType(casted));
}
Also used : XtendFile(org.eclipse.xtend.core.xtend.XtendFile) XCastedExpression(org.eclipse.xtext.xbase.XCastedExpression) IResolvedTypes(org.eclipse.xtext.xbase.typesystem.IResolvedTypes) StringConcatenation(org.eclipse.xtend2.lib.StringConcatenation) Test(org.junit.Test)

Example 14 with IResolvedTypes

use of org.eclipse.xtext.xbase.typesystem.IResolvedTypes 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_));
}
Also used : XtendFile(org.eclipse.xtend.core.xtend.XtendFile) XtendFunction(org.eclipse.xtend.core.xtend.XtendFunction) XBlockExpression(org.eclipse.xtext.xbase.XBlockExpression) XtendMember(org.eclipse.xtend.core.xtend.XtendMember) IResolvedTypes(org.eclipse.xtext.xbase.typesystem.IResolvedTypes) XMemberFeatureCall(org.eclipse.xtext.xbase.XMemberFeatureCall) StringConcatenation(org.eclipse.xtend2.lib.StringConcatenation) XtendTypeDeclaration(org.eclipse.xtend.core.xtend.XtendTypeDeclaration) XExpression(org.eclipse.xtext.xbase.XExpression) Test(org.junit.Test)

Example 15 with IResolvedTypes

use of org.eclipse.xtext.xbase.typesystem.IResolvedTypes in project xtext-xtend by eclipse.

the class ErrorTest method testErrorModel_005.

@Test
public void testErrorModel_005() throws Exception {
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("@");
    _builder.newLine();
    final XtendFile file = this.processWithoutException(_builder);
    final XtendTypeDeclaration typeDeclaration = IterableExtensions.<XtendTypeDeclaration>head(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)));
}
Also used : XtendFile(org.eclipse.xtend.core.xtend.XtendFile) IResolvedTypes(org.eclipse.xtext.xbase.typesystem.IResolvedTypes) StringConcatenation(org.eclipse.xtend2.lib.StringConcatenation) XtendTypeDeclaration(org.eclipse.xtend.core.xtend.XtendTypeDeclaration) XAnnotation(org.eclipse.xtext.xbase.annotations.xAnnotations.XAnnotation) Test(org.junit.Test)

Aggregations

IResolvedTypes (org.eclipse.xtext.xbase.typesystem.IResolvedTypes)32 StringConcatenation (org.eclipse.xtend2.lib.StringConcatenation)25 Test (org.junit.Test)25 XtendFile (org.eclipse.xtend.core.xtend.XtendFile)21 XtendTypeDeclaration (org.eclipse.xtend.core.xtend.XtendTypeDeclaration)19 XtendMember (org.eclipse.xtend.core.xtend.XtendMember)14 XExpression (org.eclipse.xtext.xbase.XExpression)14 XAnnotation (org.eclipse.xtext.xbase.annotations.xAnnotations.XAnnotation)11 JvmOperation (org.eclipse.xtext.common.types.JvmOperation)9 XtendFunction (org.eclipse.xtend.core.xtend.XtendFunction)7 EObject (org.eclipse.emf.ecore.EObject)6 LightweightTypeReference (org.eclipse.xtext.xbase.typesystem.references.LightweightTypeReference)6 JvmFormalParameter (org.eclipse.xtext.common.types.JvmFormalParameter)5 XtendField (org.eclipse.xtend.core.xtend.XtendField)4 AnonymousClass (org.eclipse.xtend.core.xtend.AnonymousClass)3 XtendClass (org.eclipse.xtend.core.xtend.XtendClass)3 JvmDeclaredType (org.eclipse.xtext.common.types.JvmDeclaredType)3 JvmIdentifiableElement (org.eclipse.xtext.common.types.JvmIdentifiableElement)3 XClosure (org.eclipse.xtext.xbase.XClosure)3 XMemberFeatureCall (org.eclipse.xtext.xbase.XMemberFeatureCall)3