use of org.eclipse.xtext.common.types.JvmTypeReference in project xtext-xtend by eclipse.
the class ValidationBug433213Test method test_03.
@Test
public void test_03() {
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("new Object {");
_builder.newLine();
_builder.append("\t\t\t");
_builder.append("def m2() {");
_builder.newLine();
_builder.append("\t\t\t\t");
_builder.append("new Object {");
_builder.newLine();
_builder.append("\t\t\t\t\t");
_builder.append("def <T> T m3() {}");
_builder.newLine();
_builder.append("\t\t\t\t");
_builder.append("}");
_builder.newLine();
_builder.append("\t\t\t");
_builder.append("}");
_builder.newLine();
_builder.append("\t\t");
_builder.append("}");
_builder.newLine();
_builder.append("\t");
_builder.append("}");
_builder.newLine();
_builder.append("}");
_builder.newLine();
final XtendFile file = this.parser.parse(_builder);
final XtendTypeDeclaration c = IterableExtensions.<XtendTypeDeclaration>head(file.getXtendTypes());
XtendMember _head = IterableExtensions.<XtendMember>head(c.getMembers());
final XtendFunction m = ((XtendFunction) _head);
XExpression _expression = m.getExpression();
final XBlockExpression body = ((XBlockExpression) _expression);
XExpression _head_1 = IterableExtensions.<XExpression>head(body.getExpressions());
final AnonymousClass anon = ((AnonymousClass) _head_1);
XtendMember _head_2 = IterableExtensions.<XtendMember>head(anon.getMembers());
final XtendFunction m2 = ((XtendFunction) _head_2);
XExpression _expression_1 = m2.getExpression();
final XBlockExpression body2 = ((XBlockExpression) _expression_1);
XExpression _head_3 = IterableExtensions.<XExpression>head(body2.getExpressions());
final AnonymousClass anon2 = ((AnonymousClass) _head_3);
XtendMember _head_4 = IterableExtensions.<XtendMember>head(anon2.getMembers());
final XtendFunction m3 = ((XtendFunction) _head_4);
final JvmTypeReference returnType = m3.getReturnType();
final JvmType t = returnType.getType();
Assert.assertNotNull("notNull", t);
Assert.assertFalse("t.eIsProxy", t.eIsProxy());
this.helper.assertNoErrors(file);
} catch (Throwable _e) {
throw Exceptions.sneakyThrow(_e);
}
}
use of org.eclipse.xtext.common.types.JvmTypeReference in project xtext-xtend by eclipse.
the class ValidationBug433213Test method test_06.
@Test
public void test_06() {
try {
StringConcatenation _builder = new StringConcatenation();
_builder.append("class C {");
_builder.newLine();
_builder.append("\t");
_builder.append("def <K> m() {");
_builder.newLine();
_builder.append("\t\t");
_builder.append("new Object {");
_builder.newLine();
_builder.append("\t\t\t");
_builder.append("def <V> m2() {");
_builder.newLine();
_builder.append("\t\t\t\t");
_builder.append("new java.util.AbstractMap<K, V> {");
_builder.newLine();
_builder.append("\t\t\t\t\t");
_builder.append("def Entry<K, V> m() {}");
_builder.newLine();
_builder.append("\t\t\t\t\t");
_builder.append("override entrySet() {}");
_builder.newLine();
_builder.append("\t\t\t\t");
_builder.append("}");
_builder.newLine();
_builder.append("\t\t\t");
_builder.append("}");
_builder.newLine();
_builder.append("\t\t");
_builder.append("}");
_builder.newLine();
_builder.append("\t");
_builder.append("}");
_builder.newLine();
_builder.append("}");
_builder.newLine();
final XtendFile file = this.parser.parse(_builder);
final XtendTypeDeclaration c = IterableExtensions.<XtendTypeDeclaration>head(file.getXtendTypes());
XtendMember _head = IterableExtensions.<XtendMember>head(c.getMembers());
final XtendFunction m = ((XtendFunction) _head);
XExpression _expression = m.getExpression();
final XBlockExpression body = ((XBlockExpression) _expression);
XExpression _head_1 = IterableExtensions.<XExpression>head(body.getExpressions());
final AnonymousClass anon = ((AnonymousClass) _head_1);
XtendMember _head_2 = IterableExtensions.<XtendMember>head(anon.getMembers());
final XtendFunction m2 = ((XtendFunction) _head_2);
XExpression _expression_1 = m2.getExpression();
final XBlockExpression body2 = ((XBlockExpression) _expression_1);
XExpression _head_3 = IterableExtensions.<XExpression>head(body2.getExpressions());
final AnonymousClass anon2 = ((AnonymousClass) _head_3);
XtendMember _head_4 = IterableExtensions.<XtendMember>head(anon2.getMembers());
final XtendFunction m3 = ((XtendFunction) _head_4);
final JvmTypeReference returnType = m3.getReturnType();
final JvmType t = returnType.getType();
Assert.assertNotNull("notNull", t);
Assert.assertFalse("t.eIsProxy", t.eIsProxy());
this.helper.assertNoErrors(file);
} catch (Throwable _e) {
throw Exceptions.sneakyThrow(_e);
}
}
use of org.eclipse.xtext.common.types.JvmTypeReference in project xtext-xtend by eclipse.
the class XtendFunctionImpl method basicSetReturnType.
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public NotificationChain basicSetReturnType(JvmTypeReference newReturnType, NotificationChain msgs) {
JvmTypeReference oldReturnType = returnType;
returnType = newReturnType;
if (eNotificationRequired()) {
ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, XtendPackage.XTEND_FUNCTION__RETURN_TYPE, oldReturnType, newReturnType);
if (msgs == null)
msgs = notification;
else
msgs.add(notification);
}
return msgs;
}
use of org.eclipse.xtext.common.types.JvmTypeReference in project xtext-xtend by eclipse.
the class XtendParameterImpl method basicSetParameterType.
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public NotificationChain basicSetParameterType(JvmTypeReference newParameterType, NotificationChain msgs) {
JvmTypeReference oldParameterType = parameterType;
parameterType = newParameterType;
if (eNotificationRequired()) {
ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, XtendPackage.XTEND_PARAMETER__PARAMETER_TYPE, oldParameterType, newParameterType);
if (msgs == null)
msgs = notification;
else
msgs.add(notification);
}
return msgs;
}
use of org.eclipse.xtext.common.types.JvmTypeReference in project xtext-xtend by eclipse.
the class MemberFromSuperImplementor method getImplementedInterface.
private Procedure1<? super ISourceAppender> getImplementedInterface(final JvmDeclaredType subType, final JvmDeclaredType superInterface) {
if (((superInterface instanceof JvmGenericType) && ((JvmGenericType) superInterface).isInterface())) {
final Function1<JvmTypeReference, Boolean> _function = (JvmTypeReference it) -> {
JvmType _type = it.getType();
return Boolean.valueOf(Objects.equal(_type, superInterface));
};
boolean _exists = IterableExtensions.<JvmTypeReference>exists(subType.getSuperTypes(), _function);
if (_exists) {
final Procedure1<ISourceAppender> _function_1 = (ISourceAppender it) -> {
it.append(superInterface).append(".");
};
return _function_1;
}
final Function1<JvmTypeReference, Boolean> _function_2 = (JvmTypeReference it) -> {
return Boolean.valueOf(this.isInterface(it.getType()));
};
final Function1<JvmTypeReference, JvmDeclaredType> _function_3 = (JvmTypeReference it) -> {
JvmType _type = it.getType();
return ((JvmDeclaredType) _type);
};
final Function1<JvmDeclaredType, Boolean> _function_4 = (JvmDeclaredType it) -> {
Procedure1<? super ISourceAppender> _implementedInterface = this.getImplementedInterface(it, superInterface);
return Boolean.valueOf((_implementedInterface != null));
};
final JvmDeclaredType interfaze = IterableExtensions.<JvmDeclaredType>findFirst(IterableExtensions.<JvmTypeReference, JvmDeclaredType>map(IterableExtensions.<JvmTypeReference>filter(subType.getSuperTypes(), _function_2), _function_3), _function_4);
if ((interfaze != null)) {
final Procedure1<ISourceAppender> _function_5 = (ISourceAppender it) -> {
it.append(interfaze).append(".");
};
return _function_5;
}
}
return null;
}
Aggregations