Skip to content

Commit

Permalink
FIX: Fixed a problem where type parameters were not added to array ED…
Browse files Browse the repository at this point in the history
…ataTypes.
  • Loading branch information
tsaglam committed Apr 5, 2017
1 parent 87e005f commit cceec82
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 9 deletions.
6 changes: 3 additions & 3 deletions src/main/java/eme/extractor/DataTypeExtractor.java
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,9 @@ public ExtractedField extractField(IField field, IType type) throws JavaModelExc
String signature = field.getTypeSignature(); // get return type signature
int arrayCount = Signature.getArrayCount(signature);
String name = field.getElementName(); // name of the field
ExtractedField attribute = new ExtractedField(name, getFullName(signature, type), arrayCount);
attribute.setGenericArguments(extractGenericArguments(signature, type));
return attribute;
ExtractedField extractedField = new ExtractedField(name, getFullName(signature, type), arrayCount);
extractedField.setGenericArguments(extractGenericArguments(signature, type));
return extractedField;
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/eme/generator/EDataTypeGenerator.java
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ private EDataType generateExternalType(ExtractedDataType extractedDataType) {
EDataType eDataType = ecoreFactory.createEDataType();
eDataType.setName(extractedDataType.getType());
eDataType.setInstanceTypeName(extractedDataType.getFullType()); // set full name
String dataTypeName = extractedDataType.getFullType(); // get type name
String dataTypeName = extractedDataType.getFullArrayType(); // get type name without array brackets.
if (model.containsExternal(dataTypeName)) {
addTypeParameters(eDataType, model.getExternalType(dataTypeName)); // add parameters from external type
} else if (!extractedDataType.getGenericArguments().isEmpty()) { // if external type is unknown
Expand Down
8 changes: 4 additions & 4 deletions src/main/java/eme/generator/MemberGenerator.java
Original file line number Diff line number Diff line change
Expand Up @@ -116,10 +116,10 @@ private void addReturnType(EOperation operation, ExtractedDataType returnType, T
* Builds a structural feature from an extracted attribute and adds it to an EClass. A structural feature can be an
* EAttribute or an EReference. If it is a reference, containment has to be set manually.
*/
private void addStructuralFeature(EStructuralFeature feature, ExtractedField attribute, EClass eClass) {
feature.setName(attribute.getIdentifier()); // set name
feature.setChangeable(!attribute.isFinal()); // make unchangeable if final
typeGenerator.addDataType(feature, attribute, new TypeParameterSource(eClass)); // add type to attribute
private void addStructuralFeature(EStructuralFeature feature, ExtractedField field, EClass eClass) {
feature.setName(field.getIdentifier()); // set name
feature.setChangeable(!field.isFinal()); // make unchangeable if final
typeGenerator.addDataType(feature, field, new TypeParameterSource(eClass)); // add type to attribute
eClass.getEStructuralFeatures().add(feature); // add feature to EClass
}

Expand Down
14 changes: 13 additions & 1 deletion src/main/java/eme/model/datatypes/ExtractedDataType.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,17 @@ public int getArrayDimension() {
return arrayDimension;
}

/**
* accessor for the full array type name, which includes the packages but NOT array brackets.
* @return the full type name.
*/
public String getFullArrayType() { // TODO (MEDIUM) remove this and move [] naming to generator.
if (isArray()) {
return fullTypeName.substring(0, fullTypeName.length() - 2 * arrayDimension);
}
return fullTypeName;
}

/**
* accessor for the full type name, which includes the packages and the array brackets.
* @return the full type name.
Expand All @@ -54,7 +65,8 @@ public List<ExtractedDataType> getGenericArguments() {
}

/**
* accessor for the simple type name, which is the basic name.
* accessor for the simple type name, which is the basic name. If it is an array it is the special array name which
* does not match the Java code (e.g. intArray2D).
* @return the simple type name or, if it is an array type, the array type name.
*/
public String getType() {
Expand Down

0 comments on commit cceec82

Please sign in to comment.