diff options
author | Ansgar Radermacher | 2014-05-07 10:44:28 +0000 |
---|---|---|
committer | Ansgar Radermacher | 2014-05-07 10:44:28 +0000 |
commit | 12b28e955da4b640d856c14504e9be02db52ce43 (patch) | |
tree | 992ff6fd7c0c8b6929da9a57d323e7bc7a62d7d5 /extraplugins/codegen | |
parent | f3fbb4a5d62b2d4e4d1eb24824acb0df881ca3a8 (diff) | |
download | org.eclipse.papyrus-12b28e955da4b640d856c14504e9be02db52ce43.tar.gz org.eclipse.papyrus-12b28e955da4b640d856c14504e9be02db52ce43.tar.xz org.eclipse.papyrus-12b28e955da4b640d856c14504e9be02db52ce43.zip |
433984 - [QDesginer] Refactoring - move C++ project generation to "standard" code generation: add missing plugin
Diffstat (limited to 'extraplugins/codegen')
15 files changed, 441 insertions, 0 deletions
diff --git a/extraplugins/codegen/org.eclipse.papyrus.codegen.extensionpoints/.classpath b/extraplugins/codegen/org.eclipse.papyrus.codegen.extensionpoints/.classpath new file mode 100644 index 00000000000..ad32c83a788 --- /dev/null +++ b/extraplugins/codegen/org.eclipse.papyrus.codegen.extensionpoints/.classpath @@ -0,0 +1,7 @@ +<?xml version="1.0" encoding="UTF-8"?> +<classpath> + <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/> + <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/> + <classpathentry kind="src" path="src"/> + <classpathentry kind="output" path="bin"/> +</classpath> diff --git a/extraplugins/codegen/org.eclipse.papyrus.codegen.extensionpoints/.project b/extraplugins/codegen/org.eclipse.papyrus.codegen.extensionpoints/.project new file mode 100644 index 00000000000..24d01935406 --- /dev/null +++ b/extraplugins/codegen/org.eclipse.papyrus.codegen.extensionpoints/.project @@ -0,0 +1,28 @@ +<?xml version="1.0" encoding="UTF-8"?> +<projectDescription> + <name>org.eclipse.papyrus.codegen.extensionpoints</name> + <comment></comment> + <projects> + </projects> + <buildSpec> + <buildCommand> + <name>org.eclipse.jdt.core.javabuilder</name> + <arguments> + </arguments> + </buildCommand> + <buildCommand> + <name>org.eclipse.pde.ManifestBuilder</name> + <arguments> + </arguments> + </buildCommand> + <buildCommand> + <name>org.eclipse.pde.SchemaBuilder</name> + <arguments> + </arguments> + </buildCommand> + </buildSpec> + <natures> + <nature>org.eclipse.pde.PluginNature</nature> + <nature>org.eclipse.jdt.core.javanature</nature> + </natures> +</projectDescription> diff --git a/extraplugins/codegen/org.eclipse.papyrus.codegen.extensionpoints/.settings/org.eclipse.jdt.core.prefs b/extraplugins/codegen/org.eclipse.papyrus.codegen.extensionpoints/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 00000000000..c537b63063c --- /dev/null +++ b/extraplugins/codegen/org.eclipse.papyrus.codegen.extensionpoints/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,7 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6 +org.eclipse.jdt.core.compiler.compliance=1.6 +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.6 diff --git a/extraplugins/codegen/org.eclipse.papyrus.codegen.extensionpoints/META-INF/MANIFEST.MF b/extraplugins/codegen/org.eclipse.papyrus.codegen.extensionpoints/META-INF/MANIFEST.MF new file mode 100644 index 00000000000..33a15bc4379 --- /dev/null +++ b/extraplugins/codegen/org.eclipse.papyrus.codegen.extensionpoints/META-INF/MANIFEST.MF @@ -0,0 +1,17 @@ +Manifest-Version: 1.0 +Bundle-ManifestVersion: 2 +Bundle-Name: %pluginName +Bundle-SymbolicName: org.eclipse.papyrus.codegen.extensionpoints;singleton:=true +Bundle-Version: 1.0.0.qualifier +Bundle-Activator: org.eclipse.papyrus.codegen.extensionpoints.Activator +Require-Bundle: org.eclipse.ui, + org.eclipse.core.runtime, + org.eclipse.acceleo.engine;bundle-version="3.2.2", + org.eclipse.acceleo.parser;bundle-version="3.2.2", + org.eclipse.uml2.uml;bundle-version="4.0.2", + org.eclipse.core.filesystem;bundle-version="1.3.200", + org.eclipse.core.resources +Bundle-RequiredExecutionEnvironment: JavaSE-1.6 +Bundle-ActivationPolicy: lazy +Bundle-Vendor: %providerName +Export-Package: org.eclipse.papyrus.codegen.extensionpoints diff --git a/extraplugins/codegen/org.eclipse.papyrus.codegen.extensionpoints/about.html b/extraplugins/codegen/org.eclipse.papyrus.codegen.extensionpoints/about.html new file mode 100644 index 00000000000..82d49bf5f81 --- /dev/null +++ b/extraplugins/codegen/org.eclipse.papyrus.codegen.extensionpoints/about.html @@ -0,0 +1,28 @@ +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml">
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"/>
+<title>About</title>
+</head>
+<body lang="EN-US">
+<h2>About This Content</h2>
+
+<p>June 5, 2007</p>
+<h3>License</h3>
+
+<p>The Eclipse Foundation makes available all content in this plug-in ("Content"). Unless otherwise
+indicated below, the Content is provided to you under the terms and conditions of the
+Eclipse Public License Version 1.0 ("EPL"). A copy of the EPL is available
+at <a href="http://www.eclipse.org/legal/epl-v10.html">http://www.eclipse.org/legal/epl-v10.html</a>.
+For purposes of the EPL, "Program" will mean the Content.</p>
+
+<p>If you did not receive this Content directly from the Eclipse Foundation, the Content is
+being redistributed by another party ("Redistributor") and different terms and conditions may
+apply to your use of any object code in the Content. Check the Redistributor's license that was
+provided with the Content. If no such license exists, contact the Redistributor. Unless otherwise
+indicated below, the terms and conditions of the EPL still apply to any source code in the Content
+and such source code may be obtained at <a href="http://www.eclipse.org/">http://www.eclipse.org</a>.</p>
+
+</body>
+</html>
diff --git a/extraplugins/codegen/org.eclipse.papyrus.codegen.extensionpoints/build.properties b/extraplugins/codegen/org.eclipse.papyrus.codegen.extensionpoints/build.properties new file mode 100644 index 00000000000..bd50993cfe2 --- /dev/null +++ b/extraplugins/codegen/org.eclipse.papyrus.codegen.extensionpoints/build.properties @@ -0,0 +1,7 @@ +source.. = src/ +output.. = bin/ +bin.includes = META-INF/,\ + .,\ + about.html,\ + plugin.properties,\ + schema/ diff --git a/extraplugins/codegen/org.eclipse.papyrus.codegen.extensionpoints/plugin.properties b/extraplugins/codegen/org.eclipse.papyrus.codegen.extensionpoints/plugin.properties new file mode 100644 index 00000000000..d7801588e2c --- /dev/null +++ b/extraplugins/codegen/org.eclipse.papyrus.codegen.extensionpoints/plugin.properties @@ -0,0 +1,12 @@ +###############################################################################
+# Copyright (c) 2013 CEA LIST.
+# All rights reserved. This program and the accompanying materials
+# 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:
+# CEA LIST - initial API and implementation
+###############################################################################
+pluginName=Code generation extensionpoints (Incubation)
+providerName=Eclipse Modeling Project
diff --git a/extraplugins/codegen/org.eclipse.papyrus.codegen.extensionpoints/plugin.xml b/extraplugins/codegen/org.eclipse.papyrus.codegen.extensionpoints/plugin.xml new file mode 100644 index 00000000000..70f0b0af878 --- /dev/null +++ b/extraplugins/codegen/org.eclipse.papyrus.codegen.extensionpoints/plugin.xml @@ -0,0 +1,5 @@ +<?xml version="1.0" encoding="UTF-8"?> +<?eclipse version="3.2"?> +<plugin> + <extension-point id="language" name="languageSupport" schema="schema/language.exsd"/> + </plugin> diff --git a/extraplugins/codegen/org.eclipse.papyrus.codegen.extensionpoints/pom.xml b/extraplugins/codegen/org.eclipse.papyrus.codegen.extensionpoints/pom.xml new file mode 100644 index 00000000000..faa86ab41d7 --- /dev/null +++ b/extraplugins/codegen/org.eclipse.papyrus.codegen.extensionpoints/pom.xml @@ -0,0 +1,14 @@ +<?xml version="1.0" encoding="UTF-8"?> +<project> + <modelVersion>4.0.0</modelVersion> + <parent> + <artifactId>org.eclipse.papyrus</artifactId> + <groupId>org.eclipse.papyrus</groupId> + <version>1.0.0-SNAPSHOT</version> + <relativePath>../../../releng/top-pom-extras.xml</relativePath> + </parent> + <artifactId>org.eclipse.papyrus.codegen.extensionpoints</artifactId> + <groupId>org.eclipse.papyrus</groupId> + <version>1.0.0-SNAPSHOT</version> + <packaging>eclipse-plugin</packaging> +</project>
\ No newline at end of file diff --git a/extraplugins/codegen/org.eclipse.papyrus.codegen.extensionpoints/schema/language.exsd b/extraplugins/codegen/org.eclipse.papyrus.codegen.extensionpoints/schema/language.exsd new file mode 100644 index 00000000000..9e7e950f59b --- /dev/null +++ b/extraplugins/codegen/org.eclipse.papyrus.codegen.extensionpoints/schema/language.exsd @@ -0,0 +1,109 @@ +<?xml version='1.0' encoding='UTF-8'?> +<!-- Schema file written by PDE --> +<schema targetNamespace="org.eclipse.papyrus.qompass.designer.core" xmlns="http://www.w3.org/2001/XMLSchema"> +<annotation> + <appInfo> + <meta.schema plugin="org.eclipse.papyrus.qompass.designer.core" id="language" name="languageSupport"/> + </appInfo> + <documentation> + [Enter description of this extension point.] + </documentation> + </annotation> + + <element name="extension"> + <annotation> + <appInfo> + <meta.element /> + </appInfo> + </annotation> + <complexType> + <choice minOccurs="0" maxOccurs="unbounded"> + <element ref="client"/> + </choice> + <attribute name="point" type="string" use="required"> + <annotation> + <documentation> + + </documentation> + </annotation> + </attribute> + <attribute name="id" type="string"> + <annotation> + <documentation> + + </documentation> + </annotation> + </attribute> + <attribute name="name" type="string"> + <annotation> + <documentation> + + </documentation> + <appInfo> + <meta.attribute translatable="true"/> + </appInfo> + </annotation> + </attribute> + </complexType> + </element> + + <element name="client"> + <complexType> + <attribute name="language" type="string" use="required"> + <annotation> + <documentation> + + </documentation> + </annotation> + </attribute> + <attribute name="class" type="string" use="required"> + <annotation> + <documentation> + + </documentation> + <appInfo> + <meta.attribute kind="java" basedOn=":org.eclipse.papyrus.qompass.designer.core.ILangSupport"/> + </appInfo> + </annotation> + </attribute> + </complexType> + </element> + + <annotation> + <appInfo> + <meta.section type="since"/> + </appInfo> + <documentation> + [Enter the first release in which this extension point appears.] + </documentation> + </annotation> + + <annotation> + <appInfo> + <meta.section type="examples"/> + </appInfo> + <documentation> + [Enter extension point usage example here.] + </documentation> + </annotation> + + <annotation> + <appInfo> + <meta.section type="apiinfo"/> + </appInfo> + <documentation> + [Enter API information here.] + </documentation> + </annotation> + + <annotation> + <appInfo> + <meta.section type="implementation"/> + </appInfo> + <documentation> + [Enter information about supplied implementation of this extension point.] + </documentation> + </annotation> + + +</schema> diff --git a/extraplugins/codegen/org.eclipse.papyrus.codegen.extensionpoints/src/org/eclipse/papyrus/codegen/extensionpoints/Activator.java b/extraplugins/codegen/org.eclipse.papyrus.codegen.extensionpoints/src/org/eclipse/papyrus/codegen/extensionpoints/Activator.java new file mode 100644 index 00000000000..83759b3ba59 --- /dev/null +++ b/extraplugins/codegen/org.eclipse.papyrus.codegen.extensionpoints/src/org/eclipse/papyrus/codegen/extensionpoints/Activator.java @@ -0,0 +1,50 @@ +package org.eclipse.papyrus.codegen.extensionpoints; + +import org.eclipse.ui.plugin.AbstractUIPlugin; +import org.osgi.framework.BundleContext; + +/** + * The activator class controls the plug-in life cycle + */ +public class Activator extends AbstractUIPlugin { + + // The plug-in ID + public static final String PLUGIN_ID = "org.eclipse.papyrus.codegen.extensionpoints"; //$NON-NLS-1$ + + // The shared instance + private static Activator plugin; + + /** + * The constructor + */ + public Activator() { + } + + /* + * (non-Javadoc) + * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext) + */ + public void start(BundleContext context) throws Exception { + super.start(context); + plugin = this; + } + + /* + * (non-Javadoc) + * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext) + */ + public void stop(BundleContext context) throws Exception { + plugin = null; + super.stop(context); + } + + /** + * Returns the shared instance + * + * @return the shared instance + */ + public static Activator getDefault() { + return plugin; + } + +} diff --git a/extraplugins/codegen/org.eclipse.papyrus.codegen.extensionpoints/src/org/eclipse/papyrus/codegen/extensionpoints/ILangSupport.java b/extraplugins/codegen/org.eclipse.papyrus.codegen.extensionpoints/src/org/eclipse/papyrus/codegen/extensionpoints/ILangSupport.java new file mode 100644 index 00000000000..3e2916e377f --- /dev/null +++ b/extraplugins/codegen/org.eclipse.papyrus.codegen.extensionpoints/src/org/eclipse/papyrus/codegen/extensionpoints/ILangSupport.java @@ -0,0 +1,92 @@ +/******************************************************************************* + * Copyright (c) 2011 CEA LIST. + * All rights reserved. This program and the accompanying materials + * 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: + * CEA LIST - initial API and implementation + *******************************************************************************/ + +package org.eclipse.papyrus.codegen.extensionpoints; + +import org.eclipse.core.resources.IProject; +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.uml2.uml.Class; +import org.eclipse.uml2.uml.PackageableElement; + +/** + * Interface used by Qompass extensions that support a specific programming language + */ +public interface ILangSupport { + + /** + * Create a project for a specific language and configure it (according to gathered configuration + * data before). In case of C/C++ for instance, a CDT project should be created, in case of Java, + * a JDT project. + * And implementation should call setProject and setSettings before returning the project + * + * @param projectName + * the named of the project + * @param the operating system for which code should be produced + * @return the created project + */ + public IProject createProject(String projectName, String targetOS); + + /** + * Set project information + * + * @param project + * the project (must already been initialized) + */ + public void setProject(IProject project); + + public IProject getProject(); + + /** + * Re-create the project settings from model information + * + * @param the operating system for which code should be produced + */ + public void setSettings(String targetOS); + + /** + * Generate code for a specific language + * + * @param monitor + * a progress monitor + * @param element + * a packageable element, typically a classifier or a package + */ + public void generateCode(IProgressMonitor monitor, PackageableElement element); + + /** + * Clean the code for a certain element, i.e. remove code that has previously generated for this element + * This code is required for differential code generation which needs to remove elements for instance + * after they have been renamed. + * + * @param project + * project in which code should be generated + * @param element + * the element for which the generate code should be removed + * @throws TransformationException + */ + public void cleanCode(IProgressMonitor monitor, PackageableElement element); + + /** + * Reset gathered configuration data + * + * @see gatherConfigData + */ + public void resetConfigurationData(); + + + /** + * Gather configuration data from implementations, e.g. required include paths or libraries + * + * @param implementation + * a class copied to the target + */ + public void gatherConfigData(Class implementation); +} diff --git a/extraplugins/codegen/org.eclipse.papyrus.codegen.extensionpoints/src/org/eclipse/papyrus/codegen/extensionpoints/LanguageSupport.java b/extraplugins/codegen/org.eclipse.papyrus.codegen.extensionpoints/src/org/eclipse/papyrus/codegen/extensionpoints/LanguageSupport.java new file mode 100644 index 00000000000..e9f807b72a1 --- /dev/null +++ b/extraplugins/codegen/org.eclipse.papyrus.codegen.extensionpoints/src/org/eclipse/papyrus/codegen/extensionpoints/LanguageSupport.java @@ -0,0 +1,47 @@ +/******************************************************************************* + * Copyright (c) 2011 CEA LIST. + * All rights reserved. This program and the accompanying materials + * 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: + * CEA LIST - initial API and implementation + *******************************************************************************/ + +package org.eclipse.papyrus.codegen.extensionpoints; + +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IConfigurationElement; +import org.eclipse.core.runtime.IExtensionRegistry; +import org.eclipse.core.runtime.Platform; + + +/** + * Support for multiple target languages via the Eclipse extension mechanism + */ +public class LanguageSupport { + + public static final String ILANG_SUPPORT_ID = Activator.PLUGIN_ID + ".language"; //$NON-NLS-1$ + + public static ILangSupport getLangSupport(String language) + { + IExtensionRegistry reg = Platform.getExtensionRegistry(); + IConfigurationElement[] configElements = reg.getConfigurationElementsFor(ILANG_SUPPORT_ID); + for(IConfigurationElement configElement : configElements) { + try { + final String extLanguage = configElement.getAttribute("language"); //$NON-NLS-1$ + if(extLanguage.equals(language)) { + // TODO: cache returned instance (avoid creating a new instance each time => more efficient, no need for static attributes) + final Object obj = configElement.createExecutableExtension("class"); //$NON-NLS-1$ + if(obj instanceof ILangSupport) { + return (ILangSupport)obj; + } + } + } catch (CoreException exception) { + exception.printStackTrace(); + } + } + throw new RuntimeException(String.format(Messages.LanguageSupport_LanguageNotSupported, language)); + } +} diff --git a/extraplugins/codegen/org.eclipse.papyrus.codegen.extensionpoints/src/org/eclipse/papyrus/codegen/extensionpoints/Messages.java b/extraplugins/codegen/org.eclipse.papyrus.codegen.extensionpoints/src/org/eclipse/papyrus/codegen/extensionpoints/Messages.java new file mode 100644 index 00000000000..181eea82725 --- /dev/null +++ b/extraplugins/codegen/org.eclipse.papyrus.codegen.extensionpoints/src/org/eclipse/papyrus/codegen/extensionpoints/Messages.java @@ -0,0 +1,16 @@ +package org.eclipse.papyrus.codegen.extensionpoints; + +import org.eclipse.osgi.util.NLS; + +public class Messages extends NLS { + private static final String BUNDLE_NAME = "org.eclipse.papyrus.acceleo.messages"; //$NON-NLS-1$ + public static String LanguageSupport_LanguageNotSupported; + public static String ModelElementsCreator_UnsupportedModelElement; + static { + // initialize resource bundle + NLS.initializeMessages(BUNDLE_NAME, Messages.class); + } + + private Messages() { + } +} diff --git a/extraplugins/codegen/org.eclipse.papyrus.codegen.extensionpoints/src/org/eclipse/papyrus/codegen/extensionpoints/messages.properties b/extraplugins/codegen/org.eclipse.papyrus.codegen.extensionpoints/src/org/eclipse/papyrus/codegen/extensionpoints/messages.properties new file mode 100644 index 00000000000..079bf88e00b --- /dev/null +++ b/extraplugins/codegen/org.eclipse.papyrus.codegen.extensionpoints/src/org/eclipse/papyrus/codegen/extensionpoints/messages.properties @@ -0,0 +1,2 @@ +LanguageSupport_LanguageNotSupported=Support for language "%s" not configured +ModelElementsCreator_UnsupportedModelElement=code generator: unsupported model element "%s" |