Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoratikhomirov2010-04-30 19:44:12 +0000
committeratikhomirov2010-04-30 19:44:12 +0000
commit5e124b35f5fc85e513362f1f9549301058c58676 (patch)
tree2363671c77617199b525fe60a424ae24b830a160 /plugins
parent99a6704f47b1295a39391b8640f695c442c55986 (diff)
downloadorg.eclipse.gmf-tooling-5e124b35f5fc85e513362f1f9549301058c58676.tar.gz
org.eclipse.gmf-tooling-5e124b35f5fc85e513362f1f9549301058c58676.tar.xz
org.eclipse.gmf-tooling-5e124b35f5fc85e513362f1f9549301058c58676.zip
[188329] Java 5 code.
Minor refactoring, including duplicated getSourceEdges fix
Diffstat (limited to 'plugins')
-rw-r--r--plugins/org.eclipse.gmf.codegen/templates/CodeStyle.xpt3
-rw-r--r--plugins/org.eclipse.gmf.codegen/templates/xpt/editor/DiagramEditorUtil.xpt81
-rw-r--r--plugins/org.eclipse.gmf.codegen/templates/xpt/editor/ValidateAction.xpt17
-rwxr-xr-xplugins/org.eclipse.gmf.codegen/templates/xpt/providers/MetricProvider.xpt32
4 files changed, 67 insertions, 66 deletions
diff --git a/plugins/org.eclipse.gmf.codegen/templates/CodeStyle.xpt b/plugins/org.eclipse.gmf.codegen/templates/CodeStyle.xpt
index f0de4308c..75830de87 100644
--- a/plugins/org.eclipse.gmf.codegen/templates/CodeStyle.xpt
+++ b/plugins/org.eclipse.gmf.codegen/templates/CodeStyle.xpt
@@ -29,6 +29,9 @@
// XXX perhaps, varName should go first, to be consistent with iterate?
«DEFINE newGenericInstance(String type, String typeArgument, String varName) FOR gmfgen::GenCommonBase»«EXPAND G(type, typeArgument)» «varName» = new «EXPAND G(type, typeArgument)»«ENDDEFINE»
+// new HashMap<Object, String>
+«DEFINE newGenericInstance2(String varName, String type, String typeArgument1, String typeArgument2) FOR gmfgen::GenCommonBase»«EXPAND G2(type, typeArgument1, typeArgument2)» «varName»= new «EXPAND G2(type, typeArgument1, typeArgument2)»«ENDDEFINE»
+
// new HashMap<Object, List<String>>
«DEFINE newGenericInstance2(String varName, String type, String typeArgument1, String typeArgument2, String typeArgument3) FOR gmfgen::GenCommonBase»«EXPAND _g2_3(type, typeArgument1, typeArgument2, typeArgument3)» «varName»= new «EXPAND _g2_3(type, typeArgument1, typeArgument2, typeArgument3)»«ENDDEFINE»
diff --git a/plugins/org.eclipse.gmf.codegen/templates/xpt/editor/DiagramEditorUtil.xpt b/plugins/org.eclipse.gmf.codegen/templates/xpt/editor/DiagramEditorUtil.xpt
index 4e99448d4..9962e60fc 100644
--- a/plugins/org.eclipse.gmf.codegen/templates/xpt/editor/DiagramEditorUtil.xpt
+++ b/plugins/org.eclipse.gmf.codegen/templates/xpt/editor/DiagramEditorUtil.xpt
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2007, 2009 Borland Software Corporation
+ * Copyright (c) 2007, 2010 Borland Software Corporation and others
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
@@ -103,8 +103,8 @@ public class «diagramEditorUtilClassName» {
«DEFINE saveOptions FOR gmfgen::GenDiagram-»
«EXPAND xpt::Common::generatedMemberComment»
- public static java.util.Map getSaveOptions() {
- java.util.Map saveOptions = new java.util.HashMap();
+ public static «EXPAND CodeStyle::G2('java.util.Map', '?', '?')» getSaveOptions() {
+ «EXPAND CodeStyle::newGenericInstance2('saveOptions', 'java.util.HashMap', 'String', 'Object')»();
saveOptions.put(org.eclipse.emf.ecore.xmi.XMLResource.OPTION_ENCODING, "UTF-8"); «EXPAND xpt::Common::nonNLS»
saveOptions.put(org.eclipse.emf.ecore.resource.Resource.OPTION_SAVE_ONLY_IF_CHANGED, org.eclipse.emf.ecore.resource.Resource.OPTION_SAVE_ONLY_IF_CHANGED_MEMORY_BUFFER);
return saveOptions;
@@ -259,14 +259,16 @@ public class «diagramEditorUtilClassName» {
}
«ENDDEFINE»
+// FIXME only metrics and audits use selectElementsInDiagram and findView (and hence LazyElement2ViewMap and findElementsInDiagramByID)
+// methods, thus it's reasonable to generate these methods iff Metrics or Audits are enabled.
+
«DEFINE selectElementsMethod FOR gmfgen::GenDiagram»
«EXPAND xpt::Common::generatedMemberComment»
- public static void selectElementsInDiagram(org.eclipse.gmf.runtime.diagram.ui.parts.IDiagramWorkbenchPart diagramPart, java.util.List/*EditPart*/ editParts) {
+ public static void selectElementsInDiagram(org.eclipse.gmf.runtime.diagram.ui.parts.IDiagramWorkbenchPart diagramPart, «EXPAND CodeStyle::G('java.util.List', 'org.eclipse.gef.EditPart')» editParts) {
diagramPart.getDiagramGraphicalViewer().deselectAll();
org.eclipse.gef.EditPart firstPrimary = null;
- for (java.util.Iterator it = editParts.iterator(); it.hasNext();) {
- org.eclipse.gef.EditPart nextPart = (org.eclipse.gef.EditPart) it.next();
+ «EXPAND CodeStyle::iterate('nextPart', 'org.eclipse.gef.EditPart', 'editParts')-»
diagramPart.getDiagramGraphicalViewer().appendSelection(nextPart);
if(firstPrimary == null && nextPart instanceof org.eclipse.gmf.runtime.diagram.ui.editparts.IPrimaryEditPart) {
firstPrimary = nextPart;
@@ -281,7 +283,7 @@ public class «diagramEditorUtilClassName» {
«DEFINE findElementsMethod FOR gmfgen::GenDiagram»
«EXPAND xpt::Common::generatedMemberComment»
- private static int findElementsInDiagramByID(org.eclipse.gmf.runtime.diagram.ui.editparts.DiagramEditPart diagramPart, org.eclipse.emf.ecore.EObject element, java.util.List editPartCollector) {
+ private static int findElementsInDiagramByID(org.eclipse.gmf.runtime.diagram.ui.editparts.DiagramEditPart diagramPart, org.eclipse.emf.ecore.EObject element, «EXPAND CodeStyle::G('java.util.List', 'org.eclipse.gef.EditPart')» editPartCollector) {
org.eclipse.gmf.runtime.diagram.ui.parts.IDiagramGraphicalViewer viewer = (org.eclipse.gmf.runtime.diagram.ui.parts.IDiagramGraphicalViewer) diagramPart.getViewer();
final int intialNumOfEditParts = editPartCollector.size();
@@ -294,10 +296,10 @@ public class «diagramEditorUtilClassName» {
}
String elementID = org.eclipse.gmf.runtime.emf.core.util.EMFCoreUtil.getProxyID(element);
- java.util.List associatedParts = viewer.findEditPartsForElement(elementID, org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart.class);
+ «EXPAND CodeStyle::SuppressWarnings('"unchecked"')-»
+ «EXPAND CodeStyle::G('java.util.List', 'org.eclipse.gef.EditPart')» associatedParts = viewer.findEditPartsForElement(elementID, org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart.class);
// perform the possible hierarchy disjoint -> take the top-most parts only
- for (java.util.Iterator editPartIt = associatedParts.iterator(); editPartIt.hasNext();) {
- org.eclipse.gef.EditPart nextPart = (org.eclipse.gef.EditPart) editPartIt.next();
+ «EXPAND CodeStyle::iterate('nextPart', 'org.eclipse.gef.EditPart', 'associatedParts')-»
org.eclipse.gef.EditPart parentPart = nextPart.getParent();
while (parentPart != null && !associatedParts.contains(parentPart)) {
parentPart = parentPart.getParent();
@@ -309,7 +311,7 @@ public class «diagramEditorUtilClassName» {
if (intialNumOfEditParts == editPartCollector.size()) {
if (!associatedParts.isEmpty()) {
- editPartCollector.add(associatedParts.iterator().next());
+ editPartCollector.add(associatedParts.get(0));
} else {
if (element.eContainer() != null) {
return findElementsInDiagramByID(diagramPart, element.eContainer(), editPartCollector);
@@ -329,48 +331,44 @@ public class «diagramEditorUtilClassName» {
}
org.eclipse.gmf.runtime.notation.View view = null;
+ «EXPAND CodeStyle::newGenericInstance('java.util.LinkedList', 'org.eclipse.gef.EditPart', 'editPartHolder')»();
if(hasStructuralURI && !lazyElement2ViewMap.getElement2ViewMap().isEmpty()) {
- view = (org.eclipse.gmf.runtime.notation.View)lazyElement2ViewMap.getElement2ViewMap().get(targetElement);
- } else if (findElementsInDiagramByID(diagramEditPart, targetElement, lazyElement2ViewMap.editPartTmpHolder) > 0) {
- org.eclipse.gef.EditPart editPart = (org.eclipse.gef.EditPart) lazyElement2ViewMap.editPartTmpHolder.get(0);
- lazyElement2ViewMap.editPartTmpHolder.clear();
+ view = «EXPAND CodeStyle::castTyped('org.eclipse.gmf.runtime.notation.View')»lazyElement2ViewMap.getElement2ViewMap().get(targetElement);
+ } else if (findElementsInDiagramByID(diagramEditPart, targetElement, editPartHolder) > 0) {
+ org.eclipse.gef.EditPart editPart = editPartHolder.get(0);
view = editPart.getModel() instanceof org.eclipse.gmf.runtime.notation.View ? (org.eclipse.gmf.runtime.notation.View) editPart.getModel() : null;
}
return (view == null) ? diagramEditPart.getDiagramView() : view;
}
- «EXPAND xpt::Common::generatedMemberComment»
+ «EXPAND xpt::Common::generatedMemberComment('XXX This is quite suspicious code (especially editPartTmpHolder) and likely to be removed soon')»
public static class LazyElement2ViewMap {
«EXPAND xpt::Common::generatedMemberComment»
- private java.util.Map element2ViewMap;
+ private «EXPAND CodeStyle::G2('java.util.Map', 'org.eclipse.emf.ecore.EObject', 'org.eclipse.gmf.runtime.notation.View')» element2ViewMap;
«EXPAND xpt::Common::generatedMemberComment»
private org.eclipse.gmf.runtime.notation.View scope;
«EXPAND xpt::Common::generatedMemberComment»
- private java.util.Set elementSet;
-
- «EXPAND xpt::Common::generatedMemberComment»
- public final java.util.List editPartTmpHolder = new java.util.ArrayList();
+ private «EXPAND CodeStyle::G('java.util.Set', '? extends org.eclipse.emf.ecore.EObject')» elementSet;
«EXPAND xpt::Common::generatedMemberComment»
- public LazyElement2ViewMap(org.eclipse.gmf.runtime.notation.View scope, java.util.Set elements) {
+ public LazyElement2ViewMap(org.eclipse.gmf.runtime.notation.View scope, «EXPAND CodeStyle::G('java.util.Set', '? extends org.eclipse.emf.ecore.EObject')» elements) {
this.scope = scope;
this.elementSet = elements;
}
«EXPAND xpt::Common::generatedMemberComment»
- public final java.util.Map getElement2ViewMap() {
+ public final «EXPAND CodeStyle::G2('java.util.Map', 'org.eclipse.emf.ecore.EObject', 'org.eclipse.gmf.runtime.notation.View')» getElement2ViewMap() {
if(element2ViewMap == null) {
- element2ViewMap = new java.util.HashMap();
+ element2ViewMap = new «EXPAND CodeStyle::G2('java.util.HashMap', 'org.eclipse.emf.ecore.EObject', 'org.eclipse.gmf.runtime.notation.View')»();
// map possible notation elements to itself as these can't be found by view.getElement()
- for (java.util.Iterator it = elementSet.iterator(); it.hasNext();) {
- org.eclipse.emf.ecore.EObject element = (org.eclipse.emf.ecore.EObject) it.next();
+ «EXPAND CodeStyle::iterate('element', 'org.eclipse.emf.ecore.EObject', 'elementSet')-»
if(element instanceof org.eclipse.gmf.runtime.notation.View) {
org.eclipse.gmf.runtime.notation.View view = (org.eclipse.gmf.runtime.notation.View) element;
if(view.getDiagram() == scope.getDiagram()) {
- element2ViewMap.put(element, element); // take only those that part of our diagram
+ element2ViewMap.put(element, view); // take only those that part of our diagram
}
}
}
@@ -380,27 +378,28 @@ public class «diagramEditorUtilClassName» {
return element2ViewMap;
}
«EXPAND xpt::Common::generatedMemberComment»
- static java.util.Map buildElement2ViewMap(org.eclipse.gmf.runtime.notation.View parentView, java.util.Map element2ViewMap, java.util.Set elements) {
- if(elements.size() == element2ViewMap.size()) return element2ViewMap;
+ private static boolean buildElement2ViewMap(org.eclipse.gmf.runtime.notation.View parentView, «EXPAND CodeStyle::G2('java.util.Map', 'org.eclipse.emf.ecore.EObject', 'org.eclipse.gmf.runtime.notation.View')» element2ViewMap, «EXPAND CodeStyle::G('java.util.Set', '? extends org.eclipse.emf.ecore.EObject')» elements) {
+ if (elements.size() == element2ViewMap.size()) {
+ return true;
+ }
if(parentView.isSetElement() && !element2ViewMap.containsKey(parentView.getElement()) && elements.contains(parentView.getElement())) {
element2ViewMap.put(parentView.getElement(), parentView);
- if(elements.size() == element2ViewMap.size()) return element2ViewMap;
+ if (elements.size() == element2ViewMap.size()) {
+ return true;
+ }
}
-
- for (java.util.Iterator it = parentView.getChildren().iterator(); it.hasNext();) {
- buildElement2ViewMap((org.eclipse.gmf.runtime.notation.View) it.next(), element2ViewMap, elements);
- if(elements.size() == element2ViewMap.size()) return element2ViewMap;
+ boolean complete = false;
+ for («EXPAND CodeStyle::G('java.util.Iterator', '?')» it = parentView.getChildren().iterator(); it.hasNext() && !complete;) {
+ complete = buildElement2ViewMap((org.eclipse.gmf.runtime.notation.View) it.next(), element2ViewMap, elements);
}
- for (java.util.Iterator it = parentView.getSourceEdges().iterator(); it.hasNext();) {
- buildElement2ViewMap((org.eclipse.gmf.runtime.notation.View) it.next(), element2ViewMap, elements);
- if(elements.size() == element2ViewMap.size()) return element2ViewMap;
+ for («EXPAND CodeStyle::G('java.util.Iterator', '?')» it = parentView.getSourceEdges().iterator(); it.hasNext() && !complete;) {
+ complete = buildElement2ViewMap((org.eclipse.gmf.runtime.notation.View) it.next(), element2ViewMap, elements);
}
- for (java.util.Iterator it = parentView.getSourceEdges().iterator(); it.hasNext();) {
- buildElement2ViewMap((org.eclipse.gmf.runtime.notation.View) it.next(), element2ViewMap, elements);
- if(elements.size() == element2ViewMap.size()) return element2ViewMap;
+ for («EXPAND CodeStyle::G('java.util.Iterator', '?')» it = parentView.getTargetEdges().iterator(); it.hasNext() && !complete;) {
+ complete = buildElement2ViewMap((org.eclipse.gmf.runtime.notation.View) it.next(), element2ViewMap, elements);
}
- return element2ViewMap;
+ return complete;
}
} //LazyElement2ViewMap
«ENDDEFINE»
diff --git a/plugins/org.eclipse.gmf.codegen/templates/xpt/editor/ValidateAction.xpt b/plugins/org.eclipse.gmf.codegen/templates/xpt/editor/ValidateAction.xpt
index df72b2f07..18d0e4ff7 100644
--- a/plugins/org.eclipse.gmf.codegen/templates/xpt/editor/ValidateAction.xpt
+++ b/plugins/org.eclipse.gmf.codegen/templates/xpt/editor/ValidateAction.xpt
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2007, 2009 Borland Software Corporation
+ * Copyright (c) 2007, 2010 Borland Software Corporation and others
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
@@ -210,10 +210,9 @@ public class «EXPAND className» extends org.eclipse.jface.action.Action {
}
final org.eclipse.core.runtime.IStatus rootStatus = validationStatus;
java.util.List allStatuses = new java.util.ArrayList();
- «getDiagramEditorUtilQualifiedClassName()».LazyElement2ViewMap element2ViewMap =
- new «getDiagramEditorUtilQualifiedClassName()».LazyElement2ViewMap(
+ «getDiagramEditorUtilQualifiedClassName()».LazyElement2ViewMap element2ViewMap = new «getDiagramEditorUtilQualifiedClassName()».LazyElement2ViewMap(
diagramEditPart.getDiagramView(),
- collectTargetElements(rootStatus, new java.util.HashSet(), allStatuses));
+ collectTargetElements(rootStatus, new «EXPAND CodeStyle::G('java.util.HashSet', 'org.eclipse.emf.ecore.EObject')»(), allStatuses));
for (java.util.Iterator it = allStatuses.iterator(); it.hasNext();) {
org.eclipse.emf.validation.model.IConstraintStatus nextStatus =
(org.eclipse.emf.validation.model.IConstraintStatus) it.next();
@@ -242,7 +241,7 @@ public class «EXPAND className» extends org.eclipse.jface.action.Action {
«getDiagramEditorUtilQualifiedClassName()».LazyElement2ViewMap element2ViewMap =
new «getDiagramEditorUtilQualifiedClassName()».LazyElement2ViewMap(
diagramEditPart.getDiagramView(),
- collectTargetElements(rootStatus, new java.util.HashSet(), allDiagnostics));
+ collectTargetElements(rootStatus, new «EXPAND CodeStyle::G('java.util.HashSet', 'org.eclipse.emf.ecore.EObject')»(), allDiagnostics));
for (java.util.Iterator it = emfValidationStatus.getChildren().iterator(); it.hasNext();) {
org.eclipse.emf.common.util.Diagnostic nextDiagnostic = (org.eclipse.emf.common.util.Diagnostic) it.next();
java.util.List data = nextDiagnostic.getData();
@@ -299,8 +298,8 @@ public class «EXPAND className» extends org.eclipse.jface.action.Action {
«DEFINE collectTargetElementsFromStatus FOR gmfgen::GenDiagram-»
«EXPAND xpt::Common::generatedMemberComment»
- private static java.util.Set collectTargetElements(org.eclipse.core.runtime.IStatus status,
- java.util.Set targetElementCollector, java.util.List allConstraintStatuses) {
+ private static «EXPAND CodeStyle::G('java.util.Set', 'org.eclipse.emf.ecore.EObject')» collectTargetElements(org.eclipse.core.runtime.IStatus status,
+ «EXPAND CodeStyle::G('java.util.Set', 'org.eclipse.emf.ecore.EObject')» targetElementCollector, java.util.List allConstraintStatuses) {
if (status instanceof org.eclipse.emf.validation.model.IConstraintStatus) {
targetElementCollector.add(((org.eclipse.emf.validation.model.IConstraintStatus) status).getTarget());
allConstraintStatuses.add(status);
@@ -318,8 +317,8 @@ public class «EXPAND className» extends org.eclipse.jface.action.Action {
«DEFINE collectTargetElementsFromDiagnostic FOR gmfgen::GenDiagram-»
«EXPAND xpt::Common::generatedMemberComment»
- private static java.util.Set collectTargetElements(org.eclipse.emf.common.util.Diagnostic diagnostic,
- java.util.Set targetElementCollector, java.util.List allDiagnostics) {
+ private static «EXPAND CodeStyle::G('java.util.Set', 'org.eclipse.emf.ecore.EObject')» collectTargetElements(org.eclipse.emf.common.util.Diagnostic diagnostic,
+ «EXPAND CodeStyle::G('java.util.Set', 'org.eclipse.emf.ecore.EObject')» targetElementCollector, java.util.List allDiagnostics) {
java.util.List data = diagnostic.getData();
org.eclipse.emf.ecore.EObject target = null;
if (data != null && !data.isEmpty() && data.get(0) instanceof org.eclipse.emf.ecore.EObject) {
diff --git a/plugins/org.eclipse.gmf.codegen/templates/xpt/providers/MetricProvider.xpt b/plugins/org.eclipse.gmf.codegen/templates/xpt/providers/MetricProvider.xpt
index 1c620ce63..ab30a128d 100755
--- a/plugins/org.eclipse.gmf.codegen/templates/xpt/providers/MetricProvider.xpt
+++ b/plugins/org.eclipse.gmf.codegen/templates/xpt/providers/MetricProvider.xpt
@@ -90,14 +90,14 @@ public class «metricProviderClassName» {
public void run() {
org.eclipse.gmf.runtime.notation.Diagram diagram = diagramEditPart.getDiagramView();
- java.util.ArrayList/*<ElementMetrics>*/ metrics = new java.util.ArrayList/*<ElementMetrics>*/(50);
-«IF not getNotationMetrics(editorGen.metrics)->isEmpty()-»
+ «EXPAND CodeStyle::newGenericInstance('java.util.ArrayList', 'ElementMetrics', 'metrics')»(50);
+«IF getNotationMetrics(editorGen.metrics)->notEmpty()-»
calculateNotationElementMetrics(diagram, metrics);
«ENDIF-»
-«IF not getDiagramMetrics(editorGen.metrics)->isEmpty()-»
+«IF getDiagramMetrics(editorGen.metrics)->notEmpty()-»
calculateDiagramElementMetrics(diagram, metrics);
«ENDIF-»
-«IF not getDomainMetrics(editorGen.metrics)->isEmpty()-»
+«IF getDomainMetrics(editorGen.metrics)->notEmpty()-»
calculateSemanticElementMetrics(diagramEditPart, metrics);
«ENDIF-»
setResult(metrics);
@@ -108,9 +108,9 @@ public class «metricProviderClassName» {
}
}
-«IF not getNotationMetrics(editorGen.metrics)->isEmpty()»«EXPAND calcNotationMetricsMethod FOR editorGen»«ENDIF»
-«IF not getDiagramMetrics(editorGen.metrics)->isEmpty()»«EXPAND calcDiagramMetricsMethod FOR editorGen»«ENDIF»
-«IF not getDomainMetrics(editorGen.metrics)->isEmpty()»«EXPAND calcDomainMetricsMethod FOR editorGen»«ENDIF»
+«IF getNotationMetrics(editorGen.metrics)->notEmpty()»«EXPAND calcNotationMetricsMethod FOR editorGen»«ENDIF»
+«IF getDiagramMetrics(editorGen.metrics)->notEmpty()»«EXPAND calcDiagramMetricsMethod FOR editorGen»«ENDIF»
+«IF getDomainMetrics(editorGen.metrics)->notEmpty()»«EXPAND calcDomainMetricsMethod FOR editorGen»«ENDIF»
«ENDDEFINE»
@@ -207,10 +207,10 @@ public class «metricProviderClassName» {
«DEFINE calcNotationMetricsMethod FOR gmfgen::GenEditorGenerator-»
«EXPAND xpt::Common::generatedMemberComment»
- static void calculateNotationElementMetrics(org.eclipse.gmf.runtime.notation.Diagram diagram, java.util.List/*<ElementMetrics>*/ metricsList) {
+ static void calculateNotationElementMetrics(org.eclipse.gmf.runtime.notation.Diagram diagram, «EXPAND CodeStyle::G('java.util.List', 'ElementMetrics') FOR diagram» metricsList) {
ElementMetrics row = null;
«LET getNotationMetrics(metrics)->select(m | m.target.oclAsType(gmfgen::GenNotationElementTarget).element.ecoreClass.name = 'Diagram') AS diagramMetrics-»
-«IF not diagramMetrics->isEmpty()-»
+«IF diagramMetrics->notEmpty()-»
row = new ElementMetrics(diagram, formatViewName(diagram), new Metric[] {
«EXPAND metricResult('diagram', false) FOREACH diagramMetrics SEPARATOR ',\n'»
});
@@ -221,7 +221,7 @@ public class «metricProviderClassName» {
«LET getNotationMetrics(metrics)->collect(m | m.target.oclAsType(gmfgen::GenNotationElementTarget).element)->asOrderedSet() AS notationTargets»
for (java.util.Iterator it = diagram.eAllContents(); it.hasNext(); ) {
Object next = it.next();
-«FOREACH (notationTargets)[genmodel::GenClass]->asSequence() AS nt-»
+«FOREACH notationTargets[genmodel::GenClass] AS nt-»
if («EXPAND MetaModel::IsInstance('next') FOR nt») {
«EXPAND MetaModel::DeclareAndAssign('_' + nt.ecoreClass.name.toLower(), 'next', true) FOR nt»
row = new ElementMetrics(«'_' + nt.ecoreClass.name.toLower()», formatViewName(«'_' + nt.ecoreClass.name.toLower()»), new Metric[] {«-»
@@ -240,7 +240,7 @@ public class «metricProviderClassName» {
«DEFINE calcDiagramMetricsMethod FOR gmfgen::GenEditorGenerator-»
«EXPAND xpt::Common::generatedMemberComment»
- static void calculateDiagramElementMetrics(org.eclipse.gmf.runtime.notation.Diagram diagram, java.util.List/*<ElementMetrics>*/ metricsList) {
+ static void calculateDiagramElementMetrics(org.eclipse.gmf.runtime.notation.Diagram diagram, «EXPAND CodeStyle::G('java.util.List', 'ElementMetrics') FOR diagram» metricsList) {
org.eclipse.emf.ecore.EObject next = diagram;
java.util.Iterator/*<EObject>*/ it = diagram.eAllContents();
do {
@@ -278,16 +278,16 @@ public class «metricProviderClassName» {
*/
«DEFINE calcDomainMetricsMethod FOR gmfgen::GenEditorGenerator»
«EXPAND xpt::Common::generatedMemberComment('NOTE: metrics are being collected for domain elements contained in the semantic element associated with diagram view, actual diagram content (elements present there) is not taken into account.')»
- static void calculateSemanticElementMetrics(org.eclipse.gmf.runtime.diagram.ui.editparts.DiagramEditPart diagramEditPart, java.util.List/*<ElementMetrics>*/ metricsList) {
+ static void calculateSemanticElementMetrics(org.eclipse.gmf.runtime.diagram.ui.editparts.DiagramEditPart diagramEditPart, «EXPAND CodeStyle::G('java.util.List', 'ElementMetrics') FOR diagram» metricsList) {
org.eclipse.gmf.runtime.notation.Diagram diagram = diagramEditPart.getDiagramView();
org.eclipse.emf.ecore.EObject next = diagram.getElement();
java.util.Iterator/*<EObject>*/ it = next != null ? next.eAllContents() : java.util.Collections.EMPTY_LIST.iterator();
- java.util.HashMap/*<EObject, ElementMetrics>*/ target2row = new java.util.HashMap/*<EObject, ElementMetrics>*/();
+ «EXPAND CodeStyle::newGenericInstance2('target2row', 'java.util.HashMap', 'org.eclipse.emf.ecore.EObject', 'ElementMetrics') FOR diagram»();
while (next != null) {
- java.util.ArrayList/*<Metric>*/ res = new java.util.ArrayList/*<Metric>*/(5);
-«FOREACH ((metrics.metrics.target)[gmfgen::GenDomainElementTarget].element->asOrderedSet()->asSequence())[genmodel::GenClass] AS e-»
+ «EXPAND CodeStyle::newGenericInstance('java.util.ArrayList','Metric', 'res') FOR diagram»(5);
+«FOREACH metrics.metrics.target[gmfgen::GenDomainElementTarget].element[genmodel::GenClass] AS e-»
if («EXPAND MetaModel::MetaClass FOR e».isInstance(next)) {
-«FOREACH metrics.metrics->select(m | m.target.getContext() = e)->asSequence() AS m-»
+«FOREACH metrics.metrics->select(m | m.target.getContext() = e) AS m-»
res.add(«EXPAND metricResult('next', true) FOR m»);
«ENDFOREACH-»
}

Back to the top