protected void _createChildren(IOutlineNode parentNode, XtendClass xtendClass) { JvmGenericType inferredType = associations.getInferredType(xtendClass); if (inferredType != null) { Set<XtendFunction> dispatchFunctions = newHashSet(); for (XtendMember member : xtendClass.getMembers()) { if (!dispatchFunctions.contains(member) && member instanceof XtendFunction && ((XtendFunction) member).isDispatch()) { for (JvmOperation inferredOperation : filter(associations.getJvmElements(member), JvmOperation.class)) { if (dispatchUtil.isDispatcherFunction(inferredOperation)) { createEObjectNode(parentNode, inferredOperation); final Set<EObject> xtendFunctions = associations.getSourceElements(inferredOperation); dispatchFunctions.addAll(newArrayList(filter(xtendFunctions, XtendFunction.class))); } } } } for (XtendMember member : xtendClass.getMembers()) { if (!dispatchFunctions.contains(member)) createEObjectNode(parentNode, member); } } else { for (XtendMember member : xtendClass.getMembers()) createEObjectNode(parentNode, member); } }
protected void addDefaultConstructor(XtendClass source, JvmGenericType target) { boolean declaredConstructor = false; for (XtendMember member : source.getMembers()) { if (member instanceof XtendConstructor) { declaredConstructor = true; break; } } if (!declaredConstructor) { JvmConstructor constructor = typesFactory.createJvmConstructor(); target.getMembers().add(constructor); associator.associatePrimary(source, constructor); constructor.setSimpleName(source.getName()); constructor.setVisibility(JvmVisibility.PUBLIC); } }
protected JvmGenericType transform(XtendClass source, boolean prelinkingPhase) { JvmGenericType inferredJvmType = typesFactory.createJvmGenericType(); source.eResource().getContents().add(inferredJvmType); associator.associatePrimary(source, inferredJvmType); inferredJvmType.setPackageName(source.getPackageName()); inferredJvmType.setSimpleName(source.getName()); inferredJvmType.setVisibility(JvmVisibility.PUBLIC); if (!prelinkingPhase) { JvmAnnotationType annotation = (JvmAnnotationType) typeReferences.findDeclaredType(SuppressWarnings.class, source); if (annotation != null) { JvmAnnotationReference suppressWarnings = typesFactory.createJvmAnnotationReference(); suppressWarnings.setAnnotation(annotation); JvmStringAnnotationValue annotationValue = typesFactory.createJvmStringAnnotationValue(); annotationValue.getValues().add("all"); suppressWarnings.getValues().add(annotationValue); inferredJvmType.getAnnotations().add(suppressWarnings); } addDefaultConstructor(source, inferredJvmType); if (source.getExtends() == null) { JvmTypeReference typeRefToObject = typeReferences.getTypeForName(Object.class, source); if (typeRefToObject != null) inferredJvmType.getSuperTypes().add(typeRefToObject); } else { inferredJvmType.getSuperTypes().add(cloneWithProxies(source.getExtends())); } for (JvmTypeReference intf : source.getImplements()) { inferredJvmType.getSuperTypes().add(cloneWithProxies(intf)); } copyAndFixTypeParameters(source.getTypeParameters(), inferredJvmType); for (XtendMember member : source.getMembers()) { if (member instanceof XtendField || (member instanceof XtendFunction && ((XtendFunction) member).getName() != null) || member instanceof XtendConstructor) { transform(member, inferredJvmType); } } appendSyntheticDispatchMethods(source, inferredJvmType); computeInferredReturnTypes(inferredJvmType); jvmTypesBuilder.translateAnnotationsTo(source.getAnnotations(), inferredJvmType); jvmTypesBuilder.setDocumentation(inferredJvmType, jvmTypesBuilder.getDocumentation(source)); nameClashResolver.resolveNameClashes(inferredJvmType); } return inferredJvmType; }