use of org.eclipse.xtend.core.jvmmodel.DispatchHelper.DispatchSignature 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.xtend.core.jvmmodel.DispatchHelper.DispatchSignature 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.xtend.core.jvmmodel.DispatchHelper.DispatchSignature 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());
}
use of org.eclipse.xtend.core.jvmmodel.DispatchHelper.DispatchSignature in project xtext-xtend by eclipse.
the class DispatchHelperTest method testSort_00.
@Test
public void testSort_00() throws Exception {
XtendClass clazz = clazz("class X {\n" + " def dispatch foo(Integer i) {null}" + " def dispatch foo(Comparable<?> i) {null}" + " def dispatch foo(java.io.Serializable i) {null}" + " def dispatch foo(String i) {null}" + " def dispatch foo(Number i) {null}" + " def dispatch foo(Object i) {null}" + " def dispatch foo(CharSequence 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(Number.class.getName(), i.next().getParameters().get(0).getParameterType().getIdentifier());
assertEquals(String.class.getName(), i.next().getParameters().get(0).getParameterType().getIdentifier());
assertEquals(Serializable.class.getName(), i.next().getParameters().get(0).getParameterType().getIdentifier());
assertEquals(CharSequence.class.getName(), i.next().getParameters().get(0).getParameterType().getIdentifier());
assertEquals(Comparable.class.getName(), i.next().getParameters().get(0).getParameterType().getType().getIdentifier());
assertEquals(Object.class.getName(), i.next().getParameters().get(0).getParameterType().getIdentifier());
assertFalse(i.hasNext());
}
use of org.eclipse.xtend.core.jvmmodel.DispatchHelper.DispatchSignature in project xtext-xtend by eclipse.
the class DispatchHelperTest method testVisibility_01.
@Test
public void testVisibility_01() throws Exception {
XtendClass superClazz = clazz("class Super {\n" + " def 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(3, list.size());
}
Aggregations