From b3bdf46da25927ded30c9ef5597b45db6fa5b4aa Mon Sep 17 00:00:00 2001 From: ipa-nhg Date: Mon, 16 Aug 2021 17:01:30 +0200 Subject: [PATCH] adapt Xtext to be supported by theia --- .../ipa/ros/tests/RosGeneratorTest.xtend | 4 +-- .../ipa/ros/generator/RosGenerator.xtend | 30 ++++++++++++++----- .../META-INF/MANIFEST.MF | 15 ++++++++++ .../rossystem/RosSystemRuntimeModule.xtend | 5 +++- 4 files changed, 43 insertions(+), 11 deletions(-) diff --git a/plugins/de.fraunhofer.ipa.ros.xtext.tests/src/de/fraunhofer/ipa/ros/tests/RosGeneratorTest.xtend b/plugins/de.fraunhofer.ipa.ros.xtext.tests/src/de/fraunhofer/ipa/ros/tests/RosGeneratorTest.xtend index 202323be3..e3a55b5b2 100644 --- a/plugins/de.fraunhofer.ipa.ros.xtext.tests/src/de/fraunhofer/ipa/ros/tests/RosGeneratorTest.xtend +++ b/plugins/de.fraunhofer.ipa.ros.xtext.tests/src/de/fraunhofer/ipa/ros/tests/RosGeneratorTest.xtend @@ -87,10 +87,10 @@ class RosGeneratorTest { val fsa = new InMemoryFileSystemAccess CIGenerator.doGenerate(model.eResource, fsa, new GeneratorContext) - Assert.assertTrue(fsa.textFiles.containsKey(CICustomOutputProvider::COM_OUTPUT + "test_node.componentinterface")) + Assert.assertTrue(fsa.textFiles.containsKey(CICustomOutputProvider::CM_CONFIGURATION + "test_node.componentinterface")) Assert.assertEquals( new String(Files.readAllBytes(Paths.get(RESOURCES_BASE_DIR, 'components', 'test_node.componentinterface'))).trim, - fsa.textFiles.get(CICustomOutputProvider::COM_OUTPUT + "test_node.componentinterface").toString.trim) + fsa.textFiles.get(CICustomOutputProvider::CM_CONFIGURATION + "test_node.componentinterface").toString.trim) } } diff --git a/plugins/de.fraunhofer.ipa.ros.xtext/src/de/fraunhofer/ipa/ros/generator/RosGenerator.xtend b/plugins/de.fraunhofer.ipa.ros.xtext/src/de/fraunhofer/ipa/ros/generator/RosGenerator.xtend index 3c135b26f..eed1b7a4a 100644 --- a/plugins/de.fraunhofer.ipa.ros.xtext/src/de/fraunhofer/ipa/ros/generator/RosGenerator.xtend +++ b/plugins/de.fraunhofer.ipa.ros.xtext/src/de/fraunhofer/ipa/ros/generator/RosGenerator.xtend @@ -12,22 +12,35 @@ import org.eclipse.xtext.generator.IOutputConfigurationProvider import org.eclipse.xtext.generator.OutputConfiguration import ros.Node import ros.Package +import org.eclipse.xtext.generator.IContextualOutputConfigurationProvider -class CICustomOutputProvider implements IOutputConfigurationProvider { - public final static String COM_OUTPUT = "COM_OUTPUT" - +class CICustomOutputProvider implements IOutputConfigurationProvider, IContextualOutputConfigurationProvider { + public final static String CM_CONFIGURATION = "CM_CONFIGURATION" + public final static String DEFAULT_OUTPUT = "DEFAULT_OUTPUT" override Set getOutputConfigurations() { - var OutputConfiguration default_config = new OutputConfiguration(COM_OUTPUT) - default_config.setDescription("COM_OUTPUT"); - default_config.setOutputDirectory("./components/"); + var OutputConfiguration cm_config = new OutputConfiguration(CM_CONFIGURATION) + cm_config.setDescription("CM_CONFIGURATION"); + cm_config.setOutputDirectory("./components/"); + cm_config.setOverrideExistingResources(true); + cm_config.setCreateOutputDirectory(true); + cm_config.setCleanUpDerivedResources(false); + cm_config.setSetDerivedProperty(false); + var OutputConfiguration default_config = new OutputConfiguration(DEFAULT_OUTPUT) + default_config.setDescription("DEFAULT_OUTPUT"); + default_config.setOutputDirectory("./src-gen/"); default_config.setOverrideExistingResources(true); default_config.setCreateOutputDirectory(true); default_config.setCleanUpDerivedResources(false); default_config.setSetDerivedProperty(false); - return newHashSet(default_config) + return newHashSet(cm_config, default_config) + } + + override Set getOutputConfigurations(Resource context) { + return getOutputConfigurations() } + } /** @@ -57,7 +70,8 @@ class RosGenerator extends AbstractGenerator { } } for (node : resource.allContents.toIterable.filter(Node)){ - fsa.generateFile(node.getName()+".componentinterface",CICustomOutputProvider::COM_OUTPUT,compile(node,package_name,artifact_name)) + fsa.generateFile(node.getName()+".componentinterface",CICustomOutputProvider::CM_CONFIGURATION,compile(node,package_name,artifact_name)) + } } diff --git a/plugins/de.fraunhofer.ipa.rossystem.xtext.ide/META-INF/MANIFEST.MF b/plugins/de.fraunhofer.ipa.rossystem.xtext.ide/META-INF/MANIFEST.MF index ba456a1bd..e0a6f0df6 100644 --- a/plugins/de.fraunhofer.ipa.rossystem.xtext.ide/META-INF/MANIFEST.MF +++ b/plugins/de.fraunhofer.ipa.rossystem.xtext.ide/META-INF/MANIFEST.MF @@ -9,6 +9,21 @@ Require-Bundle: de.fraunhofer.ipa.rossystem.xtext, de.fraunhofer.ipa.rossystem, org.eclipse.xtext.ide, org.eclipse.xtext.xbase.ide, + org.eclipse.sprotty, + org.eclipse.sprotty.layout, + org.eclipse.sprotty.server, + org.eclipse.sprotty.xtext, + org.eclipse.lsp4j, + org.eclipse.elk.graph, + com.google.gson, + org.objectweb.asm, + org.objectweb.asm.commons, + org.objectweb.asm.tree, + org.apache.log4j, + org.eclipse.elk.alg.common, + org.eclipse.elk.alg.layered, + org.eclipse.elk.core, + org.eclipse.lsp4j.jsonrpc, org.antlr.runtime Bundle-RequiredExecutionEnvironment: JavaSE-1.8 Export-Package: de.fraunhofer.ipa.rossystem.ide.contentassist.antlr.internal, diff --git a/plugins/de.fraunhofer.ipa.rossystem.xtext/src/de/fraunhofer/ipa/rossystem/RosSystemRuntimeModule.xtend b/plugins/de.fraunhofer.ipa.rossystem.xtext/src/de/fraunhofer/ipa/rossystem/RosSystemRuntimeModule.xtend index 3e73a4df0..55829527c 100644 --- a/plugins/de.fraunhofer.ipa.rossystem.xtext/src/de/fraunhofer/ipa/rossystem/RosSystemRuntimeModule.xtend +++ b/plugins/de.fraunhofer.ipa.rossystem.xtext/src/de/fraunhofer/ipa/rossystem/RosSystemRuntimeModule.xtend @@ -7,7 +7,7 @@ import org.eclipse.xtext.generator.IOutputConfigurationProvider import org.eclipse.xtext.generator.IContextualOutputConfigurationProvider import de.fraunhofer.ipa.rossystem.generator.CustomOutputProvider import com.google.inject.Binder - +import org.eclipse.xtext.naming.IQualifiedNameProvider /** * Use this class to register components to be used at runtime / without the Equinox extension registry. @@ -21,4 +21,7 @@ class RosSystemRuntimeModule extends AbstractRosSystemRuntimeModule { } + override Class bindIQualifiedNameProvider() { + return RosSystemQNP; + } }