Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEtienne Allogo2021-03-11 08:31:26 +0000
committerVincent Lorenzo2021-03-22 10:01:13 +0000
commitd8140231351889d3d1b114b277210e96af87bb21 (patch)
tree2485cf431b86ed36b9643e19b67a1c70f3be9c7a
parent1895b8caacf51d58a1b9b51de0575e3e6f0d0cbf (diff)
downloadorg.eclipse.papyrus-bugs/571960-sirius-integration.tar.gz
org.eclipse.papyrus-bugs/571960-sirius-integration.tar.xz
org.eclipse.papyrus-bugs/571960-sirius-integration.zip
Bug 569174: [Toolsmiths] Papyrus integration of GMF Toolingbugs/571960-sirius-integration
[1.2] Use project or worksapce preference as new line character(s) during gmf code generation Signed-off-by: Etienne Allogo <etienne.allogo@artal.fr> Change-Id: Ibca99ed382b077241f9605eb96bde722f3aed6ff Signed-off-by: Vincent Lorenzo <vincent.lorenzo@cea.fr>
-rw-r--r--plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/src/org/eclipse/papyrus/gmf/codegen/util/MergeFileSystemAccess.java10
-rw-r--r--plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/src/org/eclipse/papyrus/gmf/codegen/util/Xtend2ClassEmitter.java16
-rw-r--r--plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/src/org/eclipse/papyrus/gmf/codegen/util/Xtend2Emitter.java22
-rw-r--r--plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen/src/org/eclipse/papyrus/gmf/codegen/util/CodegenEmitters.java23
-rw-r--r--plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen/src/org/eclipse/papyrus/gmf/codegen/util/Generator.java20
-rw-r--r--plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.common/META-INF/MANIFEST.MF3
-rw-r--r--plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.common/src/org/eclipse/papyrus/gmf/common/codegen/OutputFormatterUtil.java60
-rw-r--r--plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.common/src/org/eclipse/papyrus/gmf/internal/common/codegen/DefaultTextMerger.java16
-rw-r--r--plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.common/src/org/eclipse/papyrus/gmf/internal/common/codegen/GeneratorBase.java23
-rw-r--r--plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.common/src/org/eclipse/papyrus/gmf/internal/common/codegen/JETEmitterAdapter.java3
-rw-r--r--plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.common/src/org/eclipse/papyrus/gmf/internal/common/codegen/JavaClassEmitter.java5
-rw-r--r--plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.common/src/org/eclipse/papyrus/gmf/internal/common/codegen/TextEmitter.java5
-rw-r--r--plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.common/src/org/eclipse/papyrus/gmf/internal/common/codegen/TextMerger.java44
-rw-r--r--plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.common/src/org/eclipse/papyrus/gmf/internal/common/codegen/XpandClassEmitter.java11
-rw-r--r--plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.common/src/org/eclipse/papyrus/gmf/internal/common/codegen/XpandTextEmitter.java5
-rw-r--r--plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.graphdef.codegen/src/org/eclipse/papyrus/gmf/graphdef/codegen/FigureGenerator.java5
-rw-r--r--plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.graphdef.codegen/src/org/eclipse/papyrus/gmf/graphdef/codegen/StandaloneGenerator.java7
17 files changed, 197 insertions, 81 deletions
diff --git a/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/src/org/eclipse/papyrus/gmf/codegen/util/MergeFileSystemAccess.java b/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/src/org/eclipse/papyrus/gmf/codegen/util/MergeFileSystemAccess.java
index f1fc493c901..7fd071c49a0 100644
--- a/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/src/org/eclipse/papyrus/gmf/codegen/util/MergeFileSystemAccess.java
+++ b/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/src/org/eclipse/papyrus/gmf/codegen/util/MergeFileSystemAccess.java
@@ -11,6 +11,7 @@
* Contributors:
* Guillaume Hillairet (Montages A.G.) : initial implementation
* Aurelien Didier (ARTAL) - aurelien.didier51@gmail.com - Bug 569174
+ * Etienne ALLOGO (ARTAL) - etienne.allogo@artal.fr - Bug 569174 - Use project or worksapce preference as new line characters
*****************************************************************************/
package org.eclipse.papyrus.gmf.codegen.util;
@@ -36,6 +37,7 @@ import org.eclipse.emf.codegen.merge.java.JMerger;
import org.eclipse.emf.codegen.util.CodeGenUtil;
import org.eclipse.emf.common.util.URI;
import org.eclipse.papyrus.gmf.codegen.util.MergeFileSystemAccess;
+import org.eclipse.papyrus.gmf.common.codegen.OutputFormatterUtil;
import org.eclipse.papyrus.gmf.internal.common.codegen.DefaultTextMerger;
import org.eclipse.papyrus.gmf.internal.common.codegen.TextMerger;
import org.eclipse.xtext.generator.AbstractFileSystemAccess;
@@ -49,7 +51,6 @@ import com.google.inject.Inject;
*
* @author ghillairet
*/
-@SuppressWarnings("restriction")
public class MergeFileSystemAccess extends AbstractFileSystemAccess {
@Inject
@@ -186,7 +187,7 @@ public class MergeFileSystemAccess extends AbstractFileSystemAccess {
}
private InputStream getMergedContent(IFile file, String newContentAsString, String defaultCharset) {
- final TextMerger textMerger = createMergeService();
+ final TextMerger textMerger = createMergeService(file);
final String oldContentAsString = getStringContent(file, defaultCharset);
final String mergedString = textMerger.mergeJava(oldContentAsString, newContentAsString);
StringInputStream mergedContent = null;
@@ -198,7 +199,7 @@ public class MergeFileSystemAccess extends AbstractFileSystemAccess {
return mergedContent;
}
- protected TextMerger createMergeService() {
+ protected TextMerger createMergeService(IFile file) {
URL controlFile = getJMergeControlFile();
if (controlFile != null) {
JControlModel controlModel = new JControlModel();
@@ -206,7 +207,8 @@ public class MergeFileSystemAccess extends AbstractFileSystemAccess {
if (!controlModel.canMerge()) {
throw new IllegalStateException("Can not initialize JControlModel");
}
- return new DefaultTextMerger(controlModel);
+ //Bug 569174 - Use project or worksapce preference as new line characters
+ return new DefaultTextMerger(OutputFormatterUtil.getDefaultLineSeparator(file.getProject()),controlModel);
}
return null;
}
diff --git a/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/src/org/eclipse/papyrus/gmf/codegen/util/Xtend2ClassEmitter.java b/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/src/org/eclipse/papyrus/gmf/codegen/util/Xtend2ClassEmitter.java
index 381a639a827..ae5f7975113 100644
--- a/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/src/org/eclipse/papyrus/gmf/codegen/util/Xtend2ClassEmitter.java
+++ b/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/src/org/eclipse/papyrus/gmf/codegen/util/Xtend2ClassEmitter.java
@@ -1,5 +1,5 @@
/******************************************************************************
- * Copyright (c) 2015, 2020 Borland Software Corporation, CEA LIST, Artal and others
+ * Copyright (c) 2015, 2020, 2021 Borland Software Corporation, CEA LIST, Artal and others
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -11,6 +11,7 @@
* Contributors:
* Svyatoslav Kovalsky (Montages) - initial API and implementation
* Aurelien Didier (ARTAL) - aurelien.didier51@gmail.com - Bug 569174
+ * Etienne ALLOGO (ARTAL) - etienne.allogo@artal.fr - Bug 569174 - Use project or worksapce preference as new line characters
*****************************************************************************/
package org.eclipse.papyrus.gmf.codegen.util;
@@ -30,18 +31,19 @@ public class Xtend2ClassEmitter extends Xtend2Emitter implements JavaClassEmitte
}
@Override
- public String getQualifiedClassName(Object... input) throws UnexpectedBehaviourException {
- return getQualifiedClassName("qualifiedClassName", input);
+ public String getQualifiedClassName(String lineSeparator, Object... input) throws UnexpectedBehaviourException {
+ return getQualifiedClassName("qualifiedClassName", lineSeparator, input);
}
@Override
- public String getQualifiedClassName(String FQNMethodName, Object... input) throws UnexpectedBehaviourException {
- return getText(FQNMethodName, input);
+ public String getQualifiedClassName(String FQNMethodName, String lineSeparator, Object... input) throws UnexpectedBehaviourException {
+ return getText(FQNMethodName, lineSeparator, input);
}
- private String getText(String method, Object... input) throws UnexpectedBehaviourException {
+ private String getText(String method, String lineSeparator, Object... input) throws UnexpectedBehaviourException {
try {
- return this.generate(new NullProgressMonitor(), method, input);
+ // Use project or worksapce preference as new line characters
+ return this.generate(new NullProgressMonitor(), method, input, lineSeparator);
} catch (InvocationTargetException e) {
throw new UnexpectedBehaviourException("Invocation method exception "+ method + " on class " + getTemplateClass().getName(), e);
} catch (InterruptedException e) {
diff --git a/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/src/org/eclipse/papyrus/gmf/codegen/util/Xtend2Emitter.java b/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/src/org/eclipse/papyrus/gmf/codegen/util/Xtend2Emitter.java
index de628b6dd36..46f6604e7cb 100644
--- a/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/src/org/eclipse/papyrus/gmf/codegen/util/Xtend2Emitter.java
+++ b/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen.xtend/src/org/eclipse/papyrus/gmf/codegen/util/Xtend2Emitter.java
@@ -1,5 +1,5 @@
/******************************************************************************
- * Copyright (c) 2015, 2020 Borland Software Corporation, CEA LIST, Artal and others
+ * Copyright (c) 2015, 2020, 2021 Borland Software Corporation, CEA LIST, Artal and others
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -11,6 +11,7 @@
* Contributors:
* Svyatoslav Kovalsky (Montages) - initial API and implementation
* Aurelien Didier (ARTAL) - aurelien.didier51@gmail.com - Bug 569174
+ * Etienne ALLOGO (ARTAL) - etienne.allogo@artal.fr - Bug 569174 - Use project or worksapce preference as new line characters
*****************************************************************************/
package org.eclipse.papyrus.gmf.codegen.util;
@@ -22,6 +23,7 @@ import java.util.List;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.papyrus.gmf.common.UnexpectedBehaviourException;
import org.eclipse.papyrus.gmf.internal.common.codegen.TextEmitter;
+import org.eclipse.xtend2.lib.StringConcatenation;
import com.google.inject.Injector;
@@ -40,11 +42,11 @@ public class Xtend2Emitter implements TextEmitter {
}
@Override
- public String generate(IProgressMonitor monitor, Object[] arguments) throws InterruptedException, InvocationTargetException, UnexpectedBehaviourException {
- return generate(monitor, myMethodName, arguments);
+ public String generate(IProgressMonitor monitor, Object[] arguments, String lineSeparator) throws InterruptedException, InvocationTargetException, UnexpectedBehaviourException {
+ return generate(monitor, myMethodName, arguments, lineSeparator);
}
- protected String generate(IProgressMonitor monitor, String methodName, Object[] arguments) throws InterruptedException, InvocationTargetException, UnexpectedBehaviourException {
+ protected String generate(IProgressMonitor monitor, String methodName, Object[] arguments, String lineSeparator) throws InterruptedException, InvocationTargetException, UnexpectedBehaviourException {
if (monitor != null && monitor.isCanceled()) {
throw new InterruptedException();
}
@@ -70,7 +72,13 @@ public class Xtend2Emitter implements TextEmitter {
if (result == null) {
throw new UnexpectedBehaviourException("Xtend generator returned null for " + this);
}
- return String.valueOf(result);
+
+ // Bug 569174 - Use project or worksapce preference as new line characters
+ // - here it is at creation time (!= merge if already exist)
+ // -- -- use post processing instead of intrusive changes in APIs
+ StringConcatenation _builder = new StringConcatenation(lineSeparator);
+ _builder.append(result);
+ return _builder.toString();
}
private Object instantiateGenerator() throws UnexpectedBehaviourException {
@@ -112,11 +120,11 @@ public class Xtend2Emitter implements TextEmitter {
assert arguments != null && arguments.length > 0;
return arguments[0];
}
-
+
protected Injector getInjector() {
return myInjector;
}
-
+
protected Class<?> getTemplateClass() {
return myXtendGenerator;
}
diff --git a/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen/src/org/eclipse/papyrus/gmf/codegen/util/CodegenEmitters.java b/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen/src/org/eclipse/papyrus/gmf/codegen/util/CodegenEmitters.java
index bb0927db439..30091330e30 100644
--- a/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen/src/org/eclipse/papyrus/gmf/codegen/util/CodegenEmitters.java
+++ b/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen/src/org/eclipse/papyrus/gmf/codegen/util/CodegenEmitters.java
@@ -1,5 +1,5 @@
/******************************************************************************
- * Copyright (c) 2005, 2020 Borland Software Corporation, CEA LIST, Artal and others
+ * Copyright (c) 2005, 2020, 2021 Borland Software Corporation, CEA LIST, Artal and others
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -11,6 +11,7 @@
* Contributors:
* Artem Tikhomirov (Borland) - initial API and implementation
* Aurelien Didier (ARTAL) - aurelien.didier51@gmail.com - Bug 569174
+ * Etienne ALLOGO (ARTAL) - etienne.allogo@artal.fr - Bug 569174 - Use project or worksapce preference as new line characters
*****************************************************************************/
package org.eclipse.papyrus.gmf.codegen.util;
@@ -22,15 +23,10 @@ import java.util.Map;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.Status;
-import org.eclipse.emf.codegen.merge.java.JControlModel;
-import org.eclipse.emf.codegen.merge.java.JMerger;
-import org.eclipse.emf.codegen.util.CodeGenUtil;
import org.eclipse.emf.common.util.URI;
import org.eclipse.papyrus.gmf.common.UnexpectedBehaviourException;
-import org.eclipse.papyrus.gmf.internal.common.codegen.DefaultTextMerger;
import org.eclipse.papyrus.gmf.internal.common.codegen.JavaClassEmitter;
import org.eclipse.papyrus.gmf.internal.common.codegen.TextEmitter;
-import org.eclipse.papyrus.gmf.internal.common.codegen.TextMerger;
import org.eclipse.papyrus.gmf.internal.common.codegen.XpandClassEmitter;
import org.eclipse.papyrus.gmf.internal.xpand.ResourceManager;
import org.eclipse.papyrus.gmf.internal.xpand.util.BundleResourceManager;
@@ -69,21 +65,6 @@ public class CodegenEmitters {
myGlobals = globals;
}
- /**
- * @return null if no merger is needed
- */
- public TextMerger createMergeService() {
- URL controlFile = getJMergeControlFile();
- if (controlFile != null) {
- JControlModel controlModel = new JControlModel();
- controlModel.initialize(CodeGenUtil.instantiateFacadeHelper(JMerger.DEFAULT_FACADE_HELPER_CLASS), controlFile.toString());
- if (!controlModel.canMerge()) {
- throw new IllegalStateException("Can not initialize JControlModel");
- }
- return new DefaultTextMerger(controlModel);
- }
- return null;
- }
private static Bundle getTemplatesBundle() {
return Platform.getBundle("org.eclipse.papyrus.gmf.codegen"); //$NON-NLS-1$
diff --git a/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen/src/org/eclipse/papyrus/gmf/codegen/util/Generator.java b/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen/src/org/eclipse/papyrus/gmf/codegen/util/Generator.java
index 68c84d88357..d5f658272bb 100644
--- a/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen/src/org/eclipse/papyrus/gmf/codegen/util/Generator.java
+++ b/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.codegen/src/org/eclipse/papyrus/gmf/codegen/util/Generator.java
@@ -11,9 +11,11 @@
* Contributors:
* Artem Tikhomirov (Borland) - initial API and implementation
* Aurelien Didier (ARTAL) - aurelien.didier51@gmail.com - Bug 569174
+ * Etienne ALLOGO (ARTAL) - etienne.allogo@artal.fr - Bug 569174 - Use project or worksapce preference as new line characters
*****************************************************************************/
package org.eclipse.papyrus.gmf.codegen.util;
+import java.net.URL;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
@@ -30,6 +32,8 @@ import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.Path;
+import org.eclipse.emf.codegen.merge.java.JControlModel;
+import org.eclipse.emf.codegen.merge.java.JMerger;
import org.eclipse.emf.codegen.util.CodeGenUtil;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.EcorePackage;
@@ -93,6 +97,7 @@ import org.eclipse.papyrus.gmf.codegen.gmfgen.StandardPreferencePages;
import org.eclipse.papyrus.gmf.codegen.gmfgen.TypeLinkModelFacet;
import org.eclipse.papyrus.gmf.common.UnexpectedBehaviourException;
import org.eclipse.papyrus.gmf.internal.common.codegen.CodeFormatterFactory;
+import org.eclipse.papyrus.gmf.internal.common.codegen.DefaultTextMerger;
import org.eclipse.papyrus.gmf.internal.common.codegen.GeneratorBase;
import org.eclipse.papyrus.gmf.internal.common.codegen.JavaClassEmitter;
import org.eclipse.papyrus.gmf.internal.common.codegen.TextEmitter;
@@ -136,9 +141,16 @@ public class Generator extends GeneratorBase implements Runnable {
@Override
protected TextMerger createMergeService() {
- TextMerger service = myEmitters.createMergeService();
- if (service != null) {
- return service;
+ // Bug 569174 - Use project or worksapce preference as new line characters
+ // don't delegate to emitter the merger configuration
+ URL controlFile = myEmitters.getJMergeControlFile();
+ if (controlFile != null) {
+ JControlModel controlModel = new JControlModel();
+ controlModel.initialize(CodeGenUtil.instantiateFacadeHelper(JMerger.DEFAULT_FACADE_HELPER_CLASS), controlFile.toString());
+ if (!controlModel.canMerge()) {
+ throw new IllegalStateException("Can not initialize JControlModel");
+ }
+ return new DefaultTextMerger(getLocalLineSeparator(), controlModel);
}
return super.createMergeService();
}
@@ -1068,7 +1080,7 @@ public class Generator extends GeneratorBase implements Runnable {
for (Object nextTemplateInput : templateInputs) {
String nextFqn;
try {
- nextFqn = fqnEmitter.generate(new NullProgressMonitor(), new Object[] { nextTemplateInput });
+ nextFqn = fqnEmitter.generate(new NullProgressMonitor(), new Object[] { nextTemplateInput }, getLocalLineSeparator());
} catch (Exception e) {
handleException(new UnexpectedBehaviourException(//
"Error computing FQN for invocation " + invocation + //
diff --git a/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.common/META-INF/MANIFEST.MF b/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.common/META-INF/MANIFEST.MF
index 89c8bd2dce2..22c5922b9df 100644
--- a/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.common/META-INF/MANIFEST.MF
+++ b/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.common/META-INF/MANIFEST.MF
@@ -57,7 +57,8 @@ Require-Bundle: org.eclipse.core.runtime;bundle-version="[3.3.0,4.0.0)",
org.eclipse.jdt.core;bundle-version="[3.3.0,4.0.0)",
org.eclipse.jface.text;bundle-version="[3.3.0,4.0.0)",
org.eclipse.jface;bundle-version="[3.3.0,4.0.0)",
- org.eclipse.papyrus.gmf.xpand;bundle-version="[2.1.0,3.0.0)"
+ org.eclipse.papyrus.gmf.xpand;bundle-version="[2.1.0,3.0.0)",
+ org.eclipse.xtext.xbase.lib;bundle-version="[2.24.0,3.0.0)"
Bundle-RequiredExecutionEnvironment: JavaSE-11
Bundle-Activator: org.eclipse.papyrus.gmf.internal.common.Activator
Bundle-ActivationPolicy: lazy
diff --git a/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.common/src/org/eclipse/papyrus/gmf/common/codegen/OutputFormatterUtil.java b/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.common/src/org/eclipse/papyrus/gmf/common/codegen/OutputFormatterUtil.java
new file mode 100644
index 00000000000..97cb39e8011
--- /dev/null
+++ b/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.common/src/org/eclipse/papyrus/gmf/common/codegen/OutputFormatterUtil.java
@@ -0,0 +1,60 @@
+/******************************************************************************
+ * Copyright (c) 2021 CEA LIST, Artal
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License 2.0
+ * which accompanies this distribution, and is available at
+ * https://www.eclipse.org/legal/epl-2.0/
+ *
+ * SPDX-License-Identifier: EPL-2.0
+ *
+ * Contributors:
+ * Etienne ALLOGO (ARTAL) - etienne.allogo@artal.fr - initial API and implementation
+ * Etienne ALLOGO (ARTAL) - etienne.allogo@artal.fr - Bug 569174 - Use project or worksapce preference as new line characters
+ *****************************************************************************/
+package org.eclipse.papyrus.gmf.common.codegen;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.ProjectScope;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.core.runtime.preferences.IScopeContext;
+import org.eclipse.core.runtime.preferences.InstanceScope;
+
+
+/**
+ * OutputFormatterUtil class provides utility methods to correctly format the files produced when generating diagrams.
+ *
+ * @author allogo
+ */
+public class OutputFormatterUtil {
+
+ /**
+ * Gets the default line separator from project or workspace.
+ *
+ * @param project
+ * the project
+ * @return the default line separator
+ */
+ public static String getDefaultLineSeparator(IProject project) {
+ if (Platform.isRunning()) {
+ // line delimiter in project preference
+ IScopeContext[] scopeContext;
+ String lineSeparator;
+ if (project != null) {
+ scopeContext = new IScopeContext[] { new ProjectScope(project) };
+ lineSeparator = Platform.getPreferencesService().getString(Platform.PI_RUNTIME, Platform.PREF_LINE_SEPARATOR, null, scopeContext);
+ if (lineSeparator != null) {
+ return lineSeparator;
+ }
+ }
+
+ // line delimiter in workspace preference
+ scopeContext = new IScopeContext[] { InstanceScope.INSTANCE };
+ lineSeparator = Platform.getPreferencesService().getString(Platform.PI_RUNTIME, Platform.PREF_LINE_SEPARATOR, null, scopeContext);
+ if (lineSeparator != null) {
+ return lineSeparator;
+ }
+ }
+ return System.lineSeparator(); // default old behavior -> from OS default
+ }
+}
diff --git a/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.common/src/org/eclipse/papyrus/gmf/internal/common/codegen/DefaultTextMerger.java b/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.common/src/org/eclipse/papyrus/gmf/internal/common/codegen/DefaultTextMerger.java
index f8f1df9e287..810baaaa5b9 100644
--- a/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.common/src/org/eclipse/papyrus/gmf/internal/common/codegen/DefaultTextMerger.java
+++ b/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.common/src/org/eclipse/papyrus/gmf/internal/common/codegen/DefaultTextMerger.java
@@ -1,5 +1,5 @@
/******************************************************************************
- * Copyright (c) 2006, 2020 Borland Software Corporation, CEA LIST, Artal
+ * Copyright (c) 2006, 2020, 2021 Borland Software Corporation, CEA LIST, Artal
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -11,6 +11,7 @@
* Contributors:
* Artem Tikhomirov (Borland) - initial API and implementation
* Aurelien Didier (ARTAL) - aurelien.didier51@gmail.com - Bug 569174
+ * Etienne ALLOGO (ARTAL) - etienne.allogo@artal.fr - Bug 569174 - Use project or worksapce preference as new line characters
*****************************************************************************/
package org.eclipse.papyrus.gmf.internal.common.codegen;
@@ -36,7 +37,8 @@ public class DefaultTextMerger extends TextMerger {
private final ManifestFileMerge myManifestMerge;
- public DefaultTextMerger(JControlModel jModel) {
+ public DefaultTextMerger(String localLineSeparator, JControlModel jModel) {
+ super(localLineSeparator);
assert jModel != null;
myControlModel = jModel;
myXmlMerger = new TaggedTextMerger("<!-- " + BEGIN_TAG + " -->", "<!-- " + END_TAG + " -->");
@@ -53,7 +55,7 @@ public class DefaultTextMerger extends TextMerger {
jMerge.setSourceCompilationUnit(jMerge.createCompilationUnitForContents(newText));
jMerge.setTargetCompilationUnit(jMerge.createCompilationUnitForContents(oldText));
jMerge.merge();
- return jMerge.getTargetCompilationUnitContents();
+ return toLocalLineSeparator(jMerge.getTargetCompilationUnitContents());
}
@Override
@@ -62,25 +64,25 @@ public class DefaultTextMerger extends TextMerger {
propertyMerger.setSourceProperties(newText);
propertyMerger.setTargetProperties(oldText);
propertyMerger.merge();
- return propertyMerger.getTargetProperties();
+ return toLocalLineSeparator(propertyMerger.getTargetProperties());
}
@Override
public String mergeXML(String oldText, String newText) {
- return myXmlMerger.process(oldText, newText);
+ return toLocalLineSeparator(myXmlMerger.process(oldText, newText));
}
@Override
public String mergePluginXML(String oldText, String newText) {
if (myPluginXmlMerger.isRecognizedDocument(oldText)) {
- return myPluginXmlMerger.process(oldText, newText);
+ return toLocalLineSeparator(myPluginXmlMerger.process(oldText, newText));
}
return mergeXML(oldText, newText);
}
@Override
public String mergeManifestMF(String oldText, String newText) {
- return myManifestMerge.process(oldText, newText);
+ return toLocalLineSeparator(myManifestMerge.process(oldText, newText));
}
private JControlModel getJControlModel() {
diff --git a/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.common/src/org/eclipse/papyrus/gmf/internal/common/codegen/GeneratorBase.java b/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.common/src/org/eclipse/papyrus/gmf/internal/common/codegen/GeneratorBase.java
index b7315d3e4b8..5d6784ccf85 100644
--- a/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.common/src/org/eclipse/papyrus/gmf/internal/common/codegen/GeneratorBase.java
+++ b/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.common/src/org/eclipse/papyrus/gmf/internal/common/codegen/GeneratorBase.java
@@ -1,5 +1,5 @@
/******************************************************************************
- * Copyright (c) 2005, 2020 Borland Software Corporation, CEA LIST, Artal and others
+ * Copyright (c) 2005, 2020, 2021 Borland Software Corporation, CEA LIST, Artal and others
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -11,6 +11,7 @@
* Contributors:
* Artem Tikhomirov (Borland) - initial API and implementation
* Aurelien Didier (ARTAL) - aurelien.didier51@gmail.com - Bug 569174
+ * Etienne ALLOGO (ARTAL) - etienne.allogo@artal.fr - Bug 569174 - Use project or worksapce preference as new line characters
*****************************************************************************/
package org.eclipse.papyrus.gmf.internal.common.codegen;
@@ -57,6 +58,7 @@ import org.eclipse.jface.text.Document;
import org.eclipse.jface.text.IDocument;
import org.eclipse.papyrus.gmf.common.UnexpectedBehaviourException;
import org.eclipse.papyrus.gmf.common.codegen.ImportAssistant;
+import org.eclipse.papyrus.gmf.common.codegen.OutputFormatterUtil;
import org.eclipse.papyrus.gmf.internal.common.Activator;
import org.eclipse.text.edits.TextEdit;
@@ -272,7 +274,7 @@ public abstract class GeneratorBase implements Runnable {
pm.beginTask(null, 5);
IPath containerPath = myDestProject.getFullPath().append(filePath.removeLastSegments(1));
EclipseUtil.findOrCreateContainer(containerPath, false, (IPath) null, new SubProgressMonitor(pm, 1));
- String genText = emitter.generate(new SubProgressMonitor(pm, 1), param);
+ String genText = emitter.generate(new SubProgressMonitor(pm, 1), param, getLocalLineSeparator());
IFile f = myDestProject.getFile(filePath);
final boolean propertyFile = "properties".equals(filePath.getFileExtension());
String charset = propertyFile ? "ISO-8859-1" : "UTF-8";
@@ -348,7 +350,7 @@ public abstract class GeneratorBase implements Runnable {
protected final void doGenerate(JavaClassEmitter emitter, Object... input) throws InterruptedException, UnexpectedBehaviourException {
if (emitter != null) {
- doGenerateJavaClass(emitter, emitter.getQualifiedClassName(input), input);
+ doGenerateJavaClass(emitter, emitter.getQualifiedClassName(getLocalLineSeparator(), input), input);
}
}
@@ -372,7 +374,7 @@ public abstract class GeneratorBase implements Runnable {
return;
}
try {
- String genText = emitter.generate(new SubProgressMonitor(pm, 2), input);
+ String genText = emitter.generate(new SubProgressMonitor(pm, 2), input, getLocalLineSeparator());
IPackageFragment pf = myDestRoot.createPackageFragment(packageName, true, new SubProgressMonitor(pm, 1));
ICompilationUnit cu = pf.getCompilationUnit(className + ".java"); //$NON-NLS-1$
if (cu.exists()) {
@@ -482,7 +484,16 @@ public abstract class GeneratorBase implements Runnable {
* @return facility to perform merges, should never return null.
*/
protected TextMerger createMergeService() {
- return new TextMerger();
+ return new TextMerger(getLocalLineSeparator());
+ }
+
+ /**
+ * Gets the right local line separator.
+ *
+ * @return the local line separator output project or workspace settings
+ */
+ protected String getLocalLineSeparator() {
+ return OutputFormatterUtil.getDefaultLineSeparator(myDestProject);
}
protected void setProgressTaskName(String text) {
@@ -491,7 +502,7 @@ public abstract class GeneratorBase implements Runnable {
protected final String formatCode(String text) {
IDocument doc = new Document(text);
- TextEdit edit = getCodeFormatter().format(CodeFormatter.K_COMPILATION_UNIT, doc.get(), 0, doc.get().length(), 0, null);
+ TextEdit edit = getCodeFormatter().format(CodeFormatter.K_COMPILATION_UNIT, doc.get(), 0, doc.get().length(), 0, getLocalLineSeparator());
try {
// check if text formatted successfully
diff --git a/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.common/src/org/eclipse/papyrus/gmf/internal/common/codegen/JETEmitterAdapter.java b/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.common/src/org/eclipse/papyrus/gmf/internal/common/codegen/JETEmitterAdapter.java
index e73c613a779..3f5c366bd26 100644
--- a/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.common/src/org/eclipse/papyrus/gmf/internal/common/codegen/JETEmitterAdapter.java
+++ b/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.common/src/org/eclipse/papyrus/gmf/internal/common/codegen/JETEmitterAdapter.java
@@ -11,6 +11,7 @@
* Contributors:
* Artem Tikhomirov (Borland) - initial API and implementation
* Aurelien Didier (ARTAL) - aurelien.didier51@gmail.com - Bug 569174
+ * Etienne ALLOGO (ARTAL) - etienne.allogo@artal.fr - Bug 569174 - newline characters preference api consistency
*****************************************************************************/
package org.eclipse.papyrus.gmf.internal.common.codegen;
@@ -30,7 +31,7 @@ public class JETEmitterAdapter implements TextEmitter {
myEmitter = emitter;
}
- public String generate(IProgressMonitor monitor, Object[] params) throws InterruptedException, InvocationTargetException {
+ public String generate(IProgressMonitor monitor, Object[] params, String lineSeparator) throws InterruptedException, InvocationTargetException {
try {
if (monitor != null && monitor.isCanceled()) {
throw new InterruptedException();
diff --git a/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.common/src/org/eclipse/papyrus/gmf/internal/common/codegen/JavaClassEmitter.java b/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.common/src/org/eclipse/papyrus/gmf/internal/common/codegen/JavaClassEmitter.java
index 0f4e7aa4400..4e6ae68e555 100644
--- a/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.common/src/org/eclipse/papyrus/gmf/internal/common/codegen/JavaClassEmitter.java
+++ b/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.common/src/org/eclipse/papyrus/gmf/internal/common/codegen/JavaClassEmitter.java
@@ -11,6 +11,7 @@
* Contributors:
* Svyatoslav Kovalsky (Montages) - initial API and implementation
* Aurelien Didier (ARTAL) - aurelien.didier51@gmail.com - Bug 569174
+ * Etienne ALLOGO (ARTAL) - etienne.allogo@artal.fr - Bug 569174 - newline characters preference api consistency
*****************************************************************************/
package org.eclipse.papyrus.gmf.internal.common.codegen;
@@ -20,7 +21,7 @@ import org.eclipse.papyrus.gmf.common.UnexpectedBehaviourException;
public interface JavaClassEmitter extends TextEmitter {
- public String getQualifiedClassName(Object... input) throws UnexpectedBehaviourException;
+ public String getQualifiedClassName(String lineSeparator, Object... input) throws UnexpectedBehaviourException;
- public String getQualifiedClassName(String fqnMethodName, Object... input) throws UnexpectedBehaviourException;
+ public String getQualifiedClassName(String fqnMethodName, String lineSeparator, Object... input) throws UnexpectedBehaviourException;
}
diff --git a/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.common/src/org/eclipse/papyrus/gmf/internal/common/codegen/TextEmitter.java b/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.common/src/org/eclipse/papyrus/gmf/internal/common/codegen/TextEmitter.java
index ba9787a881c..2a56f91cf2a 100644
--- a/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.common/src/org/eclipse/papyrus/gmf/internal/common/codegen/TextEmitter.java
+++ b/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.common/src/org/eclipse/papyrus/gmf/internal/common/codegen/TextEmitter.java
@@ -1,5 +1,5 @@
/******************************************************************************
- * Copyright (c) 2006, 2020 Borland Software Corporation, CEA LIST, Artal
+ * Copyright (c) 2006, 2020, 2021 Borland Software Corporation, CEA LIST, Artal
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -11,6 +11,7 @@
* Contributors:
* Artem Tikhomirov (Borland) - initial API and implementation
* Aurelien Didier (ARTAL) - aurelien.didier51@gmail.com - Bug 569174
+ * Etienne ALLOGO (ARTAL) - etienne.allogo@artal.fr - Bug 569174 - newline characters preference api consistency
*****************************************************************************/
package org.eclipse.papyrus.gmf.internal.common.codegen;
@@ -23,5 +24,5 @@ import org.eclipse.papyrus.gmf.common.UnexpectedBehaviourException;
* @author artem
*/
public interface TextEmitter {
- String generate(IProgressMonitor monitor, Object[] arguments) throws InterruptedException, InvocationTargetException, UnexpectedBehaviourException;
+ String generate(IProgressMonitor monitor, Object[] arguments, String lineSeparator) throws InterruptedException, InvocationTargetException, UnexpectedBehaviourException;
}
diff --git a/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.common/src/org/eclipse/papyrus/gmf/internal/common/codegen/TextMerger.java b/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.common/src/org/eclipse/papyrus/gmf/internal/common/codegen/TextMerger.java
index b3b4a8c7153..97ea6a6480a 100644
--- a/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.common/src/org/eclipse/papyrus/gmf/internal/common/codegen/TextMerger.java
+++ b/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.common/src/org/eclipse/papyrus/gmf/internal/common/codegen/TextMerger.java
@@ -1,5 +1,5 @@
/******************************************************************************
- * Copyright (c) 2006, 2020 Borland Software Corporation, CEA LIST, Artal
+ * Copyright (c) 2006, 2020, 2021 Borland Software Corporation, CEA LIST, Artal
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -11,36 +11,64 @@
* Contributors:
* Dmitri Stadnik (Borland) - initial API and implementation
* Aurelien Didier (ARTAL) - aurelien.didier51@gmail.com - Bug 569174
+ * Etienne ALLOGO (ARTAL) - etienne.allogo@artal.fr - Bug 569174 - Use project or worksapce preference as new line characters
*****************************************************************************/
package org.eclipse.papyrus.gmf.internal.common.codegen;
+import org.eclipse.xtend2.lib.StringConcatenation;
+
/**
* @author dstadnik
*/
public class TextMerger {
+
+ private final String lineDelimiter;
+
+ public TextMerger(String lineDelimiter) {
+ super();
+ this.lineDelimiter = lineDelimiter;
+ }
+
public String mergeJava(String oldText, String newText) {
- return newText;
+ return toLocalLineSeparator(newText);
+ }
+
+ /**
+ * Convert line delimiters to local line separator.
+ * Bug 569174 - Allow Use project or worksapce preference as new line characters
+
+ *
+ * @param newText text with wrong line delimiters
+ * @return the cleaned text
+ */
+ protected final String toLocalLineSeparator(String newText) {
+ // Bug 569174 - Use project or worksapce preference as new line characters
+ // - here it is at merge - if already exist (!= creation time)
+ // -- -- use post processing instead of intrusive changes in APIs
+ final StringConcatenation lineConcatener = new StringConcatenation(lineDelimiter);
+ lineConcatener.append(newText);
+ return lineConcatener.toString();
}
public String mergeProperties(String oldText, String newText) {
- return newText;
+ return toLocalLineSeparator(newText);
}
public String mergeXML(String oldText, String newText) {
- return newText;
+ return toLocalLineSeparator(newText);
}
public String mergePluginXML(String oldText, String newText) {
- return newText;
+ return toLocalLineSeparator(newText);
}
public String mergeManifestMF(String oldText, String newText) {
- return newText;
+ return toLocalLineSeparator(newText);
}
public String process(String fileName, String oldText, String newText) {
if (fileName == null) {
- return newText;
+ return toLocalLineSeparator(newText);
}
if (fileName.endsWith(".java")) {
return mergeJava(oldText, newText);
@@ -54,6 +82,6 @@ public class TextMerger {
} else if (fileName.equals("MANIFEST.MF")) {
return mergeManifestMF(oldText, newText);
}
- return newText;
+ return toLocalLineSeparator(newText);
}
}
diff --git a/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.common/src/org/eclipse/papyrus/gmf/internal/common/codegen/XpandClassEmitter.java b/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.common/src/org/eclipse/papyrus/gmf/internal/common/codegen/XpandClassEmitter.java
index 36d6a145e63..b0e7499bcac 100644
--- a/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.common/src/org/eclipse/papyrus/gmf/internal/common/codegen/XpandClassEmitter.java
+++ b/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.common/src/org/eclipse/papyrus/gmf/internal/common/codegen/XpandClassEmitter.java
@@ -1,5 +1,5 @@
/******************************************************************************
- * Copyright (c) 2013, 2020 Borland Software Corporation, CEA LIST, Artal
+ * Copyright (c) 2013, 2020, 2021 Borland Software Corporation, CEA LIST, Artal
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -11,6 +11,7 @@
* Contributors:
* Svyatoslav Kovalsky (Montages) - initial API and implementation
* Aurelien Didier (ARTAL) - aurelien.didier51@gmail.com - Bug 569174
+ * Etienne ALLOGO (ARTAL) - etienne.allogo@artal.fr - Bug 569174 - newline characters preference api consistency
*****************************************************************************/
package org.eclipse.papyrus.gmf.internal.common.codegen;
@@ -32,12 +33,12 @@ public class XpandClassEmitter extends XpandTextEmitter implements JavaClassEmit
super(manager, templateFQN, methodToInvoke, globals);
}
- public String getQualifiedClassName(Object... input) throws UnexpectedBehaviourException {
- return getQualifiedClassName("qualifiedClassName", input);
+ public String getQualifiedClassName(String lineSeparator, Object... input) throws UnexpectedBehaviourException {
+ return getQualifiedClassName("qualifiedClassName", lineSeparator, input);
}
- public String getQualifiedClassName(String fqnMethodName, Object... input) throws UnexpectedBehaviourException {
- return getText(fqnMethodName, input);
+ public String getQualifiedClassName(String fqnMethodName, String lineSeparator, Object... input) throws UnexpectedBehaviourException {
+ return getText(fqnMethodName, lineSeparator, input);
}
private String getText(String method,Object... input) throws UnexpectedBehaviourException {
diff --git a/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.common/src/org/eclipse/papyrus/gmf/internal/common/codegen/XpandTextEmitter.java b/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.common/src/org/eclipse/papyrus/gmf/internal/common/codegen/XpandTextEmitter.java
index 853f7f7680c..5d9b65d8510 100644
--- a/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.common/src/org/eclipse/papyrus/gmf/internal/common/codegen/XpandTextEmitter.java
+++ b/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.common/src/org/eclipse/papyrus/gmf/internal/common/codegen/XpandTextEmitter.java
@@ -1,5 +1,5 @@
/******************************************************************************
- * Copyright (c) 2007, 2020 Borland Software Corporation, CEA LIST, Artal
+ * Copyright (c) 2007, 2020, 2021 Borland Software Corporation, CEA LIST, Artal
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -11,6 +11,7 @@
* Contributors:
* Artem Tikhomirov (Borland) - initial API and implementation
* Aurelien Didier (ARTAL) - aurelien.didier51@gmail.com - Bug 569174
+ * Etienne ALLOGO (ARTAL) - etienne.allogo@artal.fr - Bug 569174 - newline characters preference api consistency
*****************************************************************************/
package org.eclipse.papyrus.gmf.internal.common.codegen;
@@ -64,7 +65,7 @@ public class XpandTextEmitter implements TextEmitter {
}
@Override
- public String generate(IProgressMonitor monitor, Object[] arguments) throws InterruptedException, InvocationTargetException, UnexpectedBehaviourException {
+ public String generate(IProgressMonitor monitor, Object[] arguments, String lineSeparator) throws InterruptedException, InvocationTargetException, UnexpectedBehaviourException {
return generate(monitor, myMethod, arguments);
}
diff --git a/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.graphdef.codegen/src/org/eclipse/papyrus/gmf/graphdef/codegen/FigureGenerator.java b/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.graphdef.codegen/src/org/eclipse/papyrus/gmf/graphdef/codegen/FigureGenerator.java
index a6c7fa369be..28e74fa13c8 100644
--- a/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.graphdef.codegen/src/org/eclipse/papyrus/gmf/graphdef/codegen/FigureGenerator.java
+++ b/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.graphdef.codegen/src/org/eclipse/papyrus/gmf/graphdef/codegen/FigureGenerator.java
@@ -1,5 +1,5 @@
/******************************************************************************
- * Copyright (c) 2006, 2020 Borland Software Corporation, CEA LIST, Artal
+ * Copyright (c) 2006, 2020, 2021 Borland Software Corporation, CEA LIST, Artal
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -11,6 +11,7 @@
* Contributors:
* Artem Tikhomirov (Borland) - initial API and implementation
* Aurelien Didier (ARTAL) - aurelien.didier51@gmail.com - Bug 569174
+ * Etienne ALLOGO (ARTAL) - etienne.allogo@artal.fr - Bug 569174 - newline characters preference api consistency
*****************************************************************************/
package org.eclipse.papyrus.gmf.graphdef.codegen;
@@ -116,7 +117,7 @@ public class FigureGenerator implements TextEmitter {
return new XpandFacade(new Scope(resourceManager, globals, bufferOutput));
}
- public String generate(IProgressMonitor monitor, Object[] arguments) throws InterruptedException, InvocationTargetException, UnexpectedBehaviourException {
+ public String generate(IProgressMonitor monitor, Object[] arguments, String lineSeparator) throws InterruptedException, InvocationTargetException, UnexpectedBehaviourException {
if (arguments == null || arguments.length != 1 || false == arguments[0] instanceof FigureDescriptor) {
throw new UnexpectedBehaviourException("(FigureDescriptor) expected as arguments, not " + arguments);
}
diff --git a/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.graphdef.codegen/src/org/eclipse/papyrus/gmf/graphdef/codegen/StandaloneGenerator.java b/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.graphdef.codegen/src/org/eclipse/papyrus/gmf/graphdef/codegen/StandaloneGenerator.java
index 5ff8828f65a..97449c8fdf9 100644
--- a/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.graphdef.codegen/src/org/eclipse/papyrus/gmf/graphdef/codegen/StandaloneGenerator.java
+++ b/plugins/toolsmiths/gmf-tooling/org.eclipse.papyrus.gmf.graphdef.codegen/src/org/eclipse/papyrus/gmf/graphdef/codegen/StandaloneGenerator.java
@@ -1,5 +1,5 @@
/******************************************************************************
- * Copyright (c) 2006, 2020 Borland Software Corporation, CEA LIST, Artal
+ * Copyright (c) 2006, 2020, 2021 Borland Software Corporation, CEA LIST, Artal
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -11,6 +11,7 @@
* Contributors:
* Michael Golubev (Borland) - initial API and implementation
* Aurelien Didier (ARTAL) - aurelien.didier51@gmail.com - Bug 569174
+ * Etienne ALLOGO (ARTAL) - etienne.allogo@artal.fr - Bug 569174 - newline characters preference api consistency
*****************************************************************************/
package org.eclipse.papyrus.gmf.graphdef.codegen;
@@ -168,7 +169,9 @@ public class StandaloneGenerator extends GeneratorBase {
@Override
protected TextMerger createMergeService() {
// jcontrol model that is not initialized can't merge, hence java merging won't happen
- return new DefaultTextMerger(new JControlModel());
+ // - workspace preference as new line characters
+
+ return new DefaultTextMerger(getLocalLineSeparator(), new JControlModel());
}
protected void customRun() throws InterruptedException, UnexpectedBehaviourException {

Back to the top