[unrelated] Clearer debug aids/declarations
diff --git a/plugins/org.eclipse.ocl.pivot/src/org/eclipse/ocl/pivot/utilities/LabelUtil.java b/plugins/org.eclipse.ocl.pivot/src/org/eclipse/ocl/pivot/utilities/LabelUtil.java
index ce6ea62..68d4e3d 100644
--- a/plugins/org.eclipse.ocl.pivot/src/org/eclipse/ocl/pivot/utilities/LabelUtil.java
+++ b/plugins/org.eclipse.ocl.pivot/src/org/eclipse/ocl/pivot/utilities/LabelUtil.java
@@ -4,7 +4,7 @@
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
- *
+ *
* Contributors:
* E.D.Willink - initial API and implementation
* E.D.Willink - Bug 360072
@@ -45,16 +45,16 @@
import org.eclipse.ocl.pivot.labels.LabelGeneratorRegistry;
public class LabelUtil
-{
+{
/**
- * The global QUALIFIED_NAME_REGISTRY is used by qualifiedNameFor to generate qualified names
+ * The global QUALIFIED_NAME_REGISTRY is used by qualifiedNameFor to generate qualified names
* for objects; typically a :: separted hierarchical name. The QUALIFIED_NAME_REGISTRY delegates unsupported
* label generation to the SIMPLE_NAME_REGISTRY.
*/
public static ILabelGenerator.@NonNull Registry QUALIFIED_NAME_REGISTRY = new LabelGeneratorRegistry(ILabelGenerator.Registry.INSTANCE);
/**
- * The global SIMPLE_NAME_REGISTRY is used by simpleNameFor to generate simple names
+ * The global SIMPLE_NAME_REGISTRY is used by simpleNameFor to generate simple names
* for objects; typically the name property. The SIMPLE_NAME_REGISTRY delegates unsupported
* label generation to the global ILabelGenerator.Registry.INSTANCE.
*/
@@ -83,7 +83,7 @@
}
}
});
-
+
/**
* Install an ENamedElement label generator that :: separates hierarchical names.
*/
@@ -126,24 +126,24 @@
* Returns null if there are no unresolved URIs.
* <br>
* Returns a String containing a title line containing the contextURI and
- * subsequent lines identifying each distinct unresolved URI.
+ * subsequent lines identifying each distinct unresolved URI.
*/
public static @Nullable String diagnoseUnresolvedProxies(@NonNull URI contextURI, @NonNull Map<EObject, Collection<EStructuralFeature.Setting>> map) {
- if (map.isEmpty())
- return null;
- Map<String, Map.Entry<EObject, Collection<EStructuralFeature.Setting>>> unresolvedURIs = new HashMap<String, Map.Entry<EObject, Collection<EStructuralFeature.Setting>>>(map.size());
- for (Map.Entry<EObject, Collection<EStructuralFeature.Setting>> entry : map.entrySet()) {
- EObject key = entry.getKey();
- URI uri = EcoreUtil.getURI(key);
+ if (map.isEmpty())
+ return null;
+ Map<String, Map.Entry<EObject, Collection<EStructuralFeature.Setting>>> unresolvedURIs = new HashMap<String, Map.Entry<EObject, Collection<EStructuralFeature.Setting>>>(map.size());
+ for (Map.Entry<EObject, Collection<EStructuralFeature.Setting>> entry : map.entrySet()) {
+ EObject key = entry.getKey();
+ URI uri = EcoreUtil.getURI(key);
String uriString = uri.toString();
if (!unresolvedURIs.containsKey(uriString))
unresolvedURIs.put(uriString, entry);
- }
- StringBuilder s = new StringBuilder();
+ }
+ StringBuilder s = new StringBuilder();
s.append("Unresolved URIs in '" + String.valueOf(contextURI) + "' :");
- for (Map.Entry<String, Map.Entry<EObject, Collection<EStructuralFeature.Setting>>> unresolvedURI : unresolvedURIs.entrySet())
- s.append("\n '" + unresolvedURI.getKey() + "'");
- return s.toString();
+ for (Map.Entry<String, Map.Entry<EObject, Collection<EStructuralFeature.Setting>>> unresolvedURI : unresolvedURIs.entrySet())
+ s.append("\n '" + unresolvedURI.getKey() + "'");
+ return s.toString();
}
public static @Nullable <T extends Adapter> T getAdapter(@Nullable Notifier notifier, Class<T> adapterClass) {
@@ -151,7 +151,7 @@
return null;
return getAdapter(notifier.eAdapters(), adapterClass);
}
-
+
@SuppressWarnings("unchecked")
public static <T extends Adapter> T getAdapter(List<Adapter> eAdapters, Class<T> adapterClass) {
return (T) EcoreUtil.getAdapter(eAdapters, adapterClass);
@@ -160,7 +160,7 @@
/**
* Return the specialised value of feature.getEType() resolving any type parameters
* from the specialised type of the sourceObject of the feature.
- *
+ *
* @param sourceObject
* @param feature
*/
@@ -188,7 +188,7 @@
/**
* Return the Ecore EStringToStringMapEntry that realises a given Constraint.
- *
+ *
* @param constraint the constraint
* @return the annotation detail entry, null if not found
*
@@ -235,7 +235,7 @@
EMap<String, String> details = eAnnotation.getDetails();
if (keyName != null) {
int indexOfKey = details.indexOfKey(keyName);
- if (indexOfKey >= 0) {
+ if (indexOfKey >= 0) {
return details.get(indexOfKey);
}
}
@@ -272,7 +272,7 @@
/**
* Return a simple readable description of eObject using an IItemLabelProvider if possible.
*/
- public static String getLabel(@Nullable Object object) {
+ public static @NonNull String getLabel(@Nullable Object object) {
if (object instanceof Labelable) {
String text = ((Labelable)object).getText();
if (text != null) {
diff --git a/plugins/org.eclipse.ocl.pivot/src/org/eclipse/ocl/pivot/utilities/ToStringVisitor.java b/plugins/org.eclipse.ocl.pivot/src/org/eclipse/ocl/pivot/utilities/ToStringVisitor.java
index 7ca9429..c1a28f7 100644
--- a/plugins/org.eclipse.ocl.pivot/src/org/eclipse/ocl/pivot/utilities/ToStringVisitor.java
+++ b/plugins/org.eclipse.ocl.pivot/src/org/eclipse/ocl/pivot/utilities/ToStringVisitor.java
@@ -182,7 +182,7 @@
* want just <code>"null"</code> because that would look like the OclVoid
* literal.
*/
- protected static @NonNull String NULL_PLACEHOLDER = "\"<null>\""; //$NON-NLS-1$
+ protected static @NonNull String NULL_PLACEHOLDER = "«null»"; //$NON-NLS-1$
/**
* Initializes me.
@@ -417,7 +417,14 @@
append(NULL_PLACEHOLDER);
}
else {
- v.accept(this);
+ try {
+ v.accept(this);
+ }
+ catch (Throwable e) {
+ append("«");
+ append(e.getMessage());
+ append("»");
+ }
}
return null;
}
diff --git a/tests/org.eclipse.ocl.examples.xtext.tests/src/org/eclipse/ocl/examples/pivot/tests/EvaluateUMLTest4.java b/tests/org.eclipse.ocl.examples.xtext.tests/src/org/eclipse/ocl/examples/pivot/tests/EvaluateUMLTest4.java
index 455c407..f052c7d 100644
--- a/tests/org.eclipse.ocl.examples.xtext.tests/src/org/eclipse/ocl/examples/pivot/tests/EvaluateUMLTest4.java
+++ b/tests/org.eclipse.ocl.examples.xtext.tests/src/org/eclipse/ocl/examples/pivot/tests/EvaluateUMLTest4.java
@@ -171,8 +171,8 @@
MyOCL ocl = createOCL();
ocl.initStateMachinePackage(getTestModelURI("model/StateMachines.uml"),
new @NonNull String[] {
- "The 'Feature::TypeIsNotNull' constraint is violated for 'Model::C1::o1() : \"<null>\"[1]'",
- "The 'Feature::TypeIsNotNull' constraint is violated for 'Model::C2::o2() : \"<null>\"[1]'"
+ "The 'Feature::TypeIsNotNull' constraint is violated for 'Model::C1::o1() : «null»[1]'",
+ "The 'Feature::TypeIsNotNull' constraint is violated for 'Model::C2::o2() : «null»[1]'"
});
MetamodelManager metamodelManager = ocl.getMetamodelManager();
EObject context = ocl.statefulEFactory.create(ocl.c1Class);
diff --git a/tests/org.eclipse.ocl.examples.xtext.tests/src/org/eclipse/ocl/examples/test/xtext/SerializeTests.java b/tests/org.eclipse.ocl.examples.xtext.tests/src/org/eclipse/ocl/examples/test/xtext/SerializeTests.java
index 5bf7832..feb15a3 100644
--- a/tests/org.eclipse.ocl.examples.xtext.tests/src/org/eclipse/ocl/examples/test/xtext/SerializeTests.java
+++ b/tests/org.eclipse.ocl.examples.xtext.tests/src/org/eclipse/ocl/examples/test/xtext/SerializeTests.java
@@ -479,26 +479,26 @@
public void testSerialize_Expressions() throws Exception {
OCL ocl = OCL.newInstance(getProjectMap());
- String testFile =
- "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" +
- "<ecore:EPackage xmi:version=\"2.0\" xmlns:xmi=\"http://www.omg.org/XMI\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\n" +
- " xmlns:ecore=\"http://www.eclipse.org/emf/2002/Ecore\" name=\"b\" nsURI=\"bbb\" nsPrefix=\"bb\">\n" +
- " <eAnnotations source=\"http://www.eclipse.org/emf/2002/Ecore\">\n" +
- " <details key=\"invocationDelegates\" value=\"http://www.eclipse.org/emf/2002/Ecore/OCL/Pivot\"/>\n" +
- " <details key=\"settingDelegates\" value=\"http://www.eclipse.org/emf/2002/Ecore/OCL/Pivot\"/>\n" +
- " <details key=\"validationDelegates\" value=\"http://www.eclipse.org/emf/2002/Ecore/OCL/Pivot\"/>\n" +
- " </eAnnotations>\n" +
- " <eClassifiers xsi:type=\"ecore:EClass\" name=\"Expressions\">\n" +
- " <eAnnotations source=\"http://www.eclipse.org/emf/2002/Ecore\">\n" +
- " <details key=\"constraints\" value=\"SimpleIf SingleElseIf DoubleElseIf\"/>\n" +
- " </eAnnotations>\n" +
- " <eAnnotations source=\"http://www.eclipse.org/emf/2002/Ecore/OCL/Pivot\">\n" +
- " <details key=\"SimpleIf\" value=\"if true then 1 else 2 endif <> 0\"/>\n" +
- " <details key=\"SingleElseIf\" value=\"if true then 1 elseif true then 2 else 3 endif <> 0\"/>\n" +
- " <details key=\"DoubleElseIf\" value=\"if true then 1 elseif true then 2 elseif true then 3 else 4 endif <> 0\"/>\n" +
- " </eAnnotations>\n" +
- " </eClassifiers>\n" +
- "</ecore:EPackage>\n";
+ String testFile =
+ "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" +
+ "<ecore:EPackage xmi:version=\"2.0\" xmlns:xmi=\"http://www.omg.org/XMI\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\n" +
+ " xmlns:ecore=\"http://www.eclipse.org/emf/2002/Ecore\" name=\"b\" nsURI=\"bbb\" nsPrefix=\"bb\">\n" +
+ " <eAnnotations source=\"http://www.eclipse.org/emf/2002/Ecore\">\n" +
+ " <details key=\"invocationDelegates\" value=\"http://www.eclipse.org/emf/2002/Ecore/OCL/Pivot\"/>\n" +
+ " <details key=\"settingDelegates\" value=\"http://www.eclipse.org/emf/2002/Ecore/OCL/Pivot\"/>\n" +
+ " <details key=\"validationDelegates\" value=\"http://www.eclipse.org/emf/2002/Ecore/OCL/Pivot\"/>\n" +
+ " </eAnnotations>\n" +
+ " <eClassifiers xsi:type=\"ecore:EClass\" name=\"Expressions\">\n" +
+ " <eAnnotations source=\"http://www.eclipse.org/emf/2002/Ecore\">\n" +
+ " <details key=\"constraints\" value=\"SimpleIf SingleElseIf DoubleElseIf\"/>\n" +
+ " </eAnnotations>\n" +
+ " <eAnnotations source=\"http://www.eclipse.org/emf/2002/Ecore/OCL/Pivot\">\n" +
+ " <details key=\"SimpleIf\" value=\"if true then 1 else 2 endif <> 0\"/>\n" +
+ " <details key=\"SingleElseIf\" value=\"if true then 1 elseif true then 2 else 3 endif <> 0\"/>\n" +
+ " <details key=\"DoubleElseIf\" value=\"if true then 1 elseif true then 2 elseif true then 3 else 4 endif <> 0\"/>\n" +
+ " </eAnnotations>\n" +
+ " </eClassifiers>\n" +
+ "</ecore:EPackage>\n";
createOCLinEcoreFile("Expressions.ecore", testFile);
doSerialize(ocl, "Expressions");
ocl.dispose();
@@ -603,8 +603,8 @@
UMLStandaloneSetup.init();
OCL ocl = OCL.newInstance(getProjectMap());
doSerializeUML(ocl, "StateMachines", new @NonNull String[] {
- "The 'Feature::TypeIsNotNull' constraint is violated for 'Model::C1::o1() : \"<null>\"[1]'",
- "The 'Feature::TypeIsNotNull' constraint is violated for 'Model::C2::o2() : \"<null>\"[1]'"
+ "The 'Feature::TypeIsNotNull' constraint is violated for 'Model::C1::o1() : «null»[1]'",
+ "The 'Feature::TypeIsNotNull' constraint is violated for 'Model::C2::o2() : «null»[1]'"
});
ocl.dispose();
}