コード例 #1
0
 protected void transform(XtendField source, JvmGenericType container) {
   if ((source.isExtension() || source.getName() != null) && source.getType() != null) {
     JvmField field = typesFactory.createJvmField();
     field.setSimpleName(computeFieldName(source, container));
     container.getMembers().add(field);
     associator.associatePrimary(source, field);
     field.setVisibility(source.getVisibility());
     field.setStatic(source.isStatic());
     field.setType(cloneWithProxies(source.getType()));
     jvmTypesBuilder.translateAnnotationsTo(source.getAnnotationInfo().getAnnotations(), field);
     jvmTypesBuilder.setDocumentation(field, jvmTypesBuilder.getDocumentation(source));
     jvmTypesBuilder.setInitializer(field, source.getInitialValue());
   }
 }
コード例 #2
0
 protected String computeFieldName(XtendField field, JvmGenericType declaringType) {
   if (field.getName() != null) return field.getName();
   JvmTypeReference type = field.getType();
   String name = null;
   if (type != null) {
     while (type instanceof JvmGenericArrayTypeReference) {
       type = ((JvmGenericArrayTypeReference) type).getComponentType();
     }
     if (type instanceof JvmParameterizedTypeReference) {
       List<INode> nodes =
           NodeModelUtils.findNodesForFeature(
               type, TypesPackage.Literals.JVM_PARAMETERIZED_TYPE_REFERENCE__TYPE);
       if (!nodes.isEmpty()) {
         String typeName = nodes.get(0).getText().trim();
         int lastDot = typeName.lastIndexOf('.');
         if (lastDot != -1) {
           typeName = typeName.substring(lastDot + 1);
         }
         name = "_" + Strings.toFirstLower(typeName);
       }
     }
   }
   return name;
 }