Bug 502090 - Add debug info for missing type
The cause is very likely something changed in the underlying frameworks.
In this specific example, methods were removed from a class and the
class was changed to inherit the methods from a super class.
Change-Id: I94114d61fb40b1fceabd863d769b5eb2c14a0459
Signed-off-by: Gunnar Wagenknecht <gunnar@wagenknecht.org>
diff --git a/bundles/org.eclipse.swt.tools/Mac Generation/org/eclipse/swt/tools/internal/MacGenerator.java b/bundles/org.eclipse.swt.tools/Mac Generation/org/eclipse/swt/tools/internal/MacGenerator.java
index dc4fb12..4875e6b 100644
--- a/bundles/org.eclipse.swt.tools/Mac Generation/org/eclipse/swt/tools/internal/MacGenerator.java
+++ b/bundles/org.eclipse.swt.tools/Mac Generation/org/eclipse/swt/tools/internal/MacGenerator.java
@@ -1720,11 +1720,47 @@
Node javaType = attributes.getNamedItem("swt_java_type");
if (javaType != null) return javaType.getNodeValue();
Node type = attributes.getNamedItem("type");
- if (type == null) return "notype";
+ if (type == null) {
+ System.err.printf("Unable to detect type. Check bridge file! It might have been removed, inheritance changed, etc. Location: %s %n", toDebugLocation(node));
+ return "notype";
+ }
String code = type.getNodeValue();
return getType(code, attributes, false);
}
+private String toDebugLocation(Node location) {
+ StringBuilder result = new StringBuilder();
+ while(location != null) {
+ if(result.length() > 0) {
+ result.insert(0, " > ");
+ }
+ result.insert(0, getNodeInfo(location));
+ location = location.getParentNode();
+ }
+ return result.toString();
+}
+
+private String getNodeInfo(Node location) {
+ String name = location.getNodeName();
+ if (name != null) {
+ NamedNodeMap attributes = location.getAttributes();
+ if (attributes != null) {
+ StringBuilder info = new StringBuilder();
+ info.append(name).append("[");
+ for (int i = 0; i < attributes.getLength(); i++) {
+ Node attribute = attributes.item(i);
+ if (i > 0) {
+ info.append(", ");
+ }
+ info.append(attribute.getNodeName()).append("=").append(attribute.getNodeValue());
+ }
+ return info.append("]").toString();
+ }
+ return name;
+ }
+ return location.toString();
+}
+
String getType64(Node node) {
NamedNodeMap attributes = node.getAttributes();
Node javaType = attributes.getNamedItem("swt_java_type");