use of org.eclipse.xtext.common.types.JvmOperation in project xtext-xtend by eclipse.
the class DispatchHelperTest method testIgnoreVoidInParameterTypeInferrence_02.
@Test
public void testIgnoreVoidInParameterTypeInferrence_02() throws Exception {
XtendClass clazz = clazz("class X {\n" + " def dispatch foo(Number n, Void v) {null}" + " def dispatch foo(Void ignore, Object o) {null}" + "}");
JvmGenericType type = associations.getInferredType(clazz);
JvmOperation dispatchMethod = dispatchHelper.getDispatcherOperation(type, new DispatchHelper.DispatchSignature("foo", 2));
JvmFormalParameter firstParameter = dispatchMethod.getParameters().get(0);
assertEquals("java.lang.Number", firstParameter.getParameterType().getIdentifier());
JvmFormalParameter secondParameter = dispatchMethod.getParameters().get(1);
assertEquals("java.lang.Object", secondParameter.getParameterType().getIdentifier());
}
use of org.eclipse.xtext.common.types.JvmOperation in project xtext-xtend by eclipse.
the class DispatchHelperTest method testVisibility_00.
@Test
public void testVisibility_00() throws Exception {
XtendClass superClazz = clazz("class Super {\n" + " def private dispatch foo(Object x) {} \n" + "}");
Resource subResource = superClazz.eResource().getResourceSet().createResource(URI.createURI("Sub.xtend", true));
subResource.load(new StringInputStream("class Sub extends Super {\n" + " def dispatch foo(String x) {}\n" + " def dispatch foo(Number x) {}\n" + "}"), null);
JvmGenericType type = (JvmGenericType) subResource.getContents().get(1);
ListMultimap<DispatchSignature, JvmOperation> multimap = dispatchHelper.getDeclaredOrEnhancedDispatchMethods(type);
List<JvmOperation> list = multimap.get(new DispatchHelper.DispatchSignature("foo", 1));
assertEquals(2, list.size());
}
use of org.eclipse.xtext.common.types.JvmOperation in project xtext-xtend by eclipse.
the class DispatchHelperTest method testSort_02.
@Test
public void testSort_02() throws Exception {
XtendClass clazz = clazz("class X {\n" + " def dispatch foo(int a, String b) {null}" + " def dispatch foo(Boolean i, Object b) {null}" + " def dispatch foo(Object i, String b) {null}" + "}");
JvmGenericType type = associations.getInferredType(clazz);
ListMultimap<DispatchSignature, JvmOperation> multimap = dispatchHelper.getDeclaredOrEnhancedDispatchMethods(type);
List<JvmOperation> list = multimap.get(new DispatchHelper.DispatchSignature("foo", 2));
Iterator<JvmOperation> i = list.iterator();
assertEquals(Integer.TYPE.getName(), i.next().getParameters().get(0).getParameterType().getIdentifier());
assertEquals(Boolean.class.getName(), i.next().getParameters().get(0).getParameterType().getIdentifier());
assertEquals(Object.class.getName(), i.next().getParameters().get(0).getParameterType().getIdentifier());
}
use of org.eclipse.xtext.common.types.JvmOperation in project xtext-xtend by eclipse.
the class DispatchHelperTest method testIgnoreVoidInParameterTypeInferrence_03.
@Test
public void testIgnoreVoidInParameterTypeInferrence_03() throws Exception {
XtendClass clazz = clazz("class X {\n" + " def dispatch foo(String n, Void v) {null}" + " def dispatch foo(Integer i, Void v) {null}" + "}");
JvmGenericType type = associations.getInferredType(clazz);
JvmOperation dispatchMethod = dispatchHelper.getDispatcherOperation(type, new DispatchHelper.DispatchSignature("foo", 2));
JvmFormalParameter firstParameter = dispatchMethod.getParameters().get(0);
assertEquals("java.lang.Object", firstParameter.getParameterType().getIdentifier());
JvmFormalParameter secondParameter = dispatchMethod.getParameters().get(1);
assertEquals("java.lang.Object", secondParameter.getParameterType().getIdentifier());
}
use of org.eclipse.xtext.common.types.JvmOperation in project xtext-xtend by eclipse.
the class DispatchHelperTest method testSort_01.
@Test
public void testSort_01() throws Exception {
XtendClass clazz = clazz("class X {\n" + " def dispatch foo(Integer i) {null}" + " def dispatch foo(Boolean i) {null}" + " def dispatch foo(String i) {null}" + "}");
JvmGenericType type = associations.getInferredType(clazz);
ListMultimap<DispatchSignature, JvmOperation> multimap = dispatchHelper.getDeclaredOrEnhancedDispatchMethods(type);
List<JvmOperation> list = multimap.get(new DispatchHelper.DispatchSignature("foo", 1));
Iterator<JvmOperation> i = list.iterator();
assertEquals(Integer.class.getName(), i.next().getParameters().get(0).getParameterType().getIdentifier());
assertEquals(Boolean.class.getName(), i.next().getParameters().get(0).getParameterType().getIdentifier());
assertEquals(String.class.getName(), i.next().getParameters().get(0).getParameterType().getIdentifier());
}
Aggregations