Computation of Column and ValueField datatypes fixed.
Change-Id: I4d9ef3519f13306ebce9a9f9e5d1508608a779f3
Reviewed-on: https://git.eclipse.org/r/22403
Tested-by: Hudson CI
Reviewed-by: Matthias Villiger <mvi@bsiag.com>
IP-Clean: Matthias Villiger <mvi@bsiag.com>
diff --git a/org.eclipse.scout.sdk.util/src/org/eclipse/scout/sdk/util/signature/ITypeGenericMapping.java b/org.eclipse.scout.sdk.util/src/org/eclipse/scout/sdk/util/signature/ITypeGenericMapping.java
index 5e1c8f1..3963742 100644
--- a/org.eclipse.scout.sdk.util/src/org/eclipse/scout/sdk/util/signature/ITypeGenericMapping.java
+++ b/org.eclipse.scout.sdk.util/src/org/eclipse/scout/sdk/util/signature/ITypeGenericMapping.java
@@ -13,26 +13,32 @@
import java.util.Map;
/**
- * <h3>{@link ITypeGenericMapping}</h3> ...
+ * <h3>{@link ITypeGenericMapping}</h3>
*
- * @author Andreas Hoegger
+ * @author Andreas Hoegger
* @since 3.9.0 04.04.2013
*/
public interface ITypeGenericMapping {
/**
- * @return
+ * @return The fully qualified name of the class the generic mappings belong to.
*/
String getFullyQualifiedName();
/**
+ * Gets the signature of the generic parameter with the given name.
+ *
* @param paramName
- * @return
+ * The name of the generic parameter (e.g. "T" or "VALUE_TYPE")
+ * @return The signature of the generic type with the given name or null if the class that belongs to this instance
+ * does not define a generic type with the given name.
*/
String getParameterSignature(String paramName);
/**
- * @return
+ * Gets a unmodifiable map of all generic types with their corresponding signature.
+ *
+ * @return The generic type to signature mapping.
*/
Map<String, String> getParameters();
diff --git a/org.eclipse.scout.sdk.util/src/org/eclipse/scout/sdk/util/signature/internal/TypeGenericMapping.java b/org.eclipse.scout.sdk.util/src/org/eclipse/scout/sdk/util/signature/internal/TypeGenericMapping.java
index 9a23742..6fa9aff 100644
--- a/org.eclipse.scout.sdk.util/src/org/eclipse/scout/sdk/util/signature/internal/TypeGenericMapping.java
+++ b/org.eclipse.scout.sdk.util/src/org/eclipse/scout/sdk/util/signature/internal/TypeGenericMapping.java
@@ -11,8 +11,8 @@
package org.eclipse.scout.sdk.util.signature.internal;
import java.util.Collections;
-import java.util.HashMap;
import java.util.Iterator;
+import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Map.Entry;
@@ -27,11 +27,11 @@
public class TypeGenericMapping implements ITypeGenericMapping {
private final String m_fullyQualifiedName;
- private Map<String /*parameter name*/, String /*param signature*/> m_parameters;
+ private final Map<String /*parameter name*/, String /*param signature*/> m_parameters;
public TypeGenericMapping(String fullyQualliefiedName) {
m_fullyQualifiedName = fullyQualliefiedName;
- m_parameters = new HashMap<String, String>();
+ m_parameters = new LinkedHashMap<String, String>();
}
@Override
@@ -66,10 +66,6 @@
builder.append(" | ").append(e.getKey()).append(" -> ").append(e.getValue());
}
}
-
-// for (Entry<String, String> e : m_parameters.entrySet()) {
-// builder.append(" | ").append(e.getKey()).append(" -> ").append(e.getValue());
-// }
builder.append('}');
return builder.toString();
}
diff --git a/org.eclipse.scout.sdk/src/org/eclipse/scout/sdk/internal/workspace/dto/AbstractTableSourceBuilder.java b/org.eclipse.scout.sdk/src/org/eclipse/scout/sdk/internal/workspace/dto/AbstractTableSourceBuilder.java
index 8642644..38bb365 100644
--- a/org.eclipse.scout.sdk/src/org/eclipse/scout/sdk/internal/workspace/dto/AbstractTableSourceBuilder.java
+++ b/org.eclipse.scout.sdk/src/org/eclipse/scout/sdk/internal/workspace/dto/AbstractTableSourceBuilder.java
@@ -14,6 +14,7 @@
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.jdt.core.IType;
import org.eclipse.jdt.core.Signature;
+import org.eclipse.scout.sdk.extensions.runtime.classes.IRuntimeClasses;
import org.eclipse.scout.sdk.util.signature.SignatureUtility;
import org.eclipse.scout.sdk.util.type.TypeUtility;
import org.eclipse.scout.sdk.util.typecache.ITypeHierarchy;
@@ -36,9 +37,17 @@
}
protected String getColumnSignature(IType type, ITypeHierarchy columnHierarchy) throws IllegalArgumentException, CoreException {
- if (type == null || Object.class.getName().equals(type.getFullyQualifiedName())) {
+ if (!TypeUtility.exists(type) || Object.class.getName().equals(type.getFullyQualifiedName())) {
return null;
}
+
+ // try IColumn first
+ String sig = SignatureUtility.resolveGenericParameterInSuperHierarchy(type, columnHierarchy.getJdtHierarchy(), IRuntimeClasses.IColumn, IRuntimeClasses.TYPE_PARAM_COLUMN_VALUE_TYPE);
+ if (sig != null) {
+ return sig;
+ }
+
+ // try other models
IType superType = columnHierarchy.getSuperclass(type);
if (TypeUtility.exists(superType)) {
if (TypeUtility.isGenericType(superType)) {
diff --git a/org.eclipse.scout.sdk/src/org/eclipse/scout/sdk/workspace/type/ScoutTypeUtility.java b/org.eclipse.scout.sdk/src/org/eclipse/scout/sdk/workspace/type/ScoutTypeUtility.java
index 7a82482..57a2f77 100644
--- a/org.eclipse.scout.sdk/src/org/eclipse/scout/sdk/workspace/type/ScoutTypeUtility.java
+++ b/org.eclipse.scout.sdk/src/org/eclipse/scout/sdk/workspace/type/ScoutTypeUtility.java
@@ -77,6 +77,7 @@
private static final Pattern RETURN_TRUE_PATTERN = Pattern.compile("return\\s*true", Pattern.MULTILINE);
private static final Pattern PREF_REGEX = Pattern.compile("^([\\+\\[]+)(.*)$");
private static final Pattern SUFF_REGEX = Pattern.compile("(^.*)\\;$");
+
private static final Pattern SUFF_CLASS_REGEX = Pattern.compile("\\.class$");
private ScoutTypeUtility() {
@@ -1002,9 +1003,17 @@
}
public static String computeFormFieldGenericType(IType type, ITypeHierarchy formFieldHierarchy) throws CoreException {
- if (type == null || type.getFullyQualifiedName().equals(Object.class.getName())) {
+ if (!TypeUtility.exists(type) || type.getFullyQualifiedName().equals(Object.class.getName())) {
return null;
}
+
+ // try value fields
+ String sig = SignatureUtility.resolveGenericParameterInSuperHierarchy(type, formFieldHierarchy.getJdtHierarchy(), IRuntimeClasses.IValueField, IRuntimeClasses.TYPE_PARAM_VALUEFIELD__VALUE_TYPE);
+ if (sig != null) {
+ return sig;
+ }
+
+ // for own models
IType superType = formFieldHierarchy.getSuperclass(type);
if (TypeUtility.exists(superType)) {
if (TypeUtility.isGenericType(superType)) {