use of org.eclipse.xtext.common.types.JvmGenericArrayTypeReference in project xtext-xtend by eclipse.
the class XtendJvmModelInferrer method computeFieldName.
/* @Nullable */
protected String computeFieldName(XtendField field) {
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;
}
Aggregations