Beispiel #1
0
 public Method getMethod(JvmOperation operation) {
   Class<?> rawType = getRawType(operation.getDeclaringType());
   if (rawType == null) return null;
   Class<?>[] paramTypes = getParamTypes(operation);
   try {
     return rawType.getDeclaredMethod(operation.getSimpleName(), paramTypes);
   } catch (Exception e) {
     LOG.error("Can't find " + operation.getIdentifier(), e);
     return null;
   }
 }
Beispiel #2
0
 @Test
 public void testEnumArtificialMethods() {
   try {
     StringConcatenation _builder = new StringConcatenation();
     _builder.append("package bar");
     _builder.newLine();
     _builder.newLine();
     _builder.append("enum Foo {");
     _builder.newLine();
     _builder.append("}");
     _builder.newLine();
     String _string = _builder.toString();
     XtendEnum _enumeration = this.enumeration(_string);
     JvmEnumerationType _inferredEnumerationType =
         this._iXtendJvmAssociations.getInferredEnumerationType(_enumeration);
     final EList<JvmMember> inferred = _inferredEnumerationType.getMembers();
     int _size = inferred.size();
     Assert.assertEquals(2, _size);
     JvmMember _get = inferred.get(0);
     final JvmOperation values = ((JvmOperation) _get);
     String _identifier = values.getIdentifier();
     Assert.assertEquals("bar.Foo.values()", _identifier);
     boolean _isStatic = values.isStatic();
     Assert.assertTrue(_isStatic);
     JvmVisibility _visibility = values.getVisibility();
     Assert.assertEquals(JvmVisibility.PUBLIC, _visibility);
     JvmMember _get_1 = inferred.get(1);
     final JvmOperation valueOf = ((JvmOperation) _get_1);
     String _identifier_1 = valueOf.getIdentifier();
     Assert.assertEquals("bar.Foo.valueOf(java.lang.String)", _identifier_1);
     boolean _isStatic_1 = valueOf.isStatic();
     Assert.assertTrue(_isStatic_1);
     JvmVisibility _visibility_1 = valueOf.getVisibility();
     Assert.assertEquals(JvmVisibility.PUBLIC, _visibility_1);
   } catch (Throwable _e) {
     throw Exceptions.sneakyThrow(_e);
   }
 }