use of org.eclipse.xtext.common.types.JvmVisibility in project xtext-xtend by eclipse.
the class InferredJvmModelTest method testDispatchFunction_05.
@Test
public void testDispatchFunction_05() throws Exception {
XtendFile xtendFile = file("class Foo {" + " def private dispatch private_private (Integer x) {} def private dispatch private_private (Double x) {}" + " def private dispatch private_protected(Integer x) {} def protected dispatch private_protected(Double x) {}" + " def private dispatch private_public (Integer x) {} def public dispatch private_public (Double x) {}" + " def private dispatch private_default (Integer x) {} def dispatch private_default (Double x) {}" + " def protected dispatch protected_private (Integer x) {} def private dispatch protected_private (Double x) {}" + " def protected dispatch protected_protected(Integer x) {} def protected dispatch protected_protected(Double x) {}" + " def protected dispatch protected_public (Integer x) {} def public dispatch protected_public (Double x) {}" + " def protected dispatch protected_default (Integer x) {} def dispatch protected_default (Double x) {}" + " def public dispatch public_private (Integer x) {} def private dispatch public_private (Double x) {}" + " def public dispatch public_protected(Integer x) {} def protected dispatch public_protected(Double x) {}" + " def public dispatch public_public (Integer x) {} def public dispatch public_public (Double x) {}" + " def public dispatch public_default (Integer x) {} def dispatch public_default (Double x) {}" + " def dispatch default_private (Integer x) {} def private dispatch default_private (Double x) {}" + " def dispatch default_protected(Integer x) {} def protected dispatch default_protected(Double x) {}" + " def dispatch default_public (Integer x) {} def public dispatch default_public (Double x) {}" + " def dispatch default_default (Integer x) {} def dispatch default_default (Double x) {}" + "}");
JvmGenericType inferredType = getInferredType(xtendFile);
for (JvmOperation op : inferredType.getDeclaredOperations()) {
String[] split = op.getSimpleName().toUpperCase().split("_");
JvmVisibility expectedVisibility = null;
if (!op.getSimpleName().startsWith("_")) {
if (equal(split[0], split[1]))
expectedVisibility = "DEFAULT".equals(split[0]) ? JvmVisibility.PUBLIC : JvmVisibility.get(split[0]);
else
expectedVisibility = JvmVisibility.PUBLIC;
} else if (equal(op.getParameters().get(0).getParameterType().getIdentifier(), "java.lang.Integer"))
expectedVisibility = "DEFAULT".equals(split[1]) ? JvmVisibility.PROTECTED : JvmVisibility.get(split[1]);
else
expectedVisibility = "DEFAULT".equals(split[2]) ? JvmVisibility.PROTECTED : JvmVisibility.get(split[2]);
assertEquals(op.getIdentifier(), expectedVisibility, op.getVisibility());
}
}
Aggregations