Skip to content

Commit

Permalink
adapt Xtext to be supported by theia
Browse files Browse the repository at this point in the history
  • Loading branch information
ipa-nhg committed Aug 17, 2021
1 parent a5d1bd4 commit 0db7bc0
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,18 @@ package de.fraunhofer.ipa.ros

import com.google.inject.Binder
import de.fraunhofer.ipa.ros.generator.CICustomOutputProvider
import org.eclipse.xtext.conversion.IValueConverterService
import org.eclipse.xtext.generator.IOutputConfigurationProvider
import org.eclipse.xtext.generator.IContextualOutputConfigurationProvider

/**
* Use this class to register components to be used at runtime / without the Equinox extension registry.
*/
class RosRuntimeModule extends AbstractRosRuntimeModule {
override void configure(Binder binder) {

override void configure(Binder binder) {
super.configure(binder)
binder.bind(IOutputConfigurationProvider).to(CICustomOutputProvider).asEagerSingleton()
binder.bind(IContextualOutputConfigurationProvider).to(CICustomOutputProvider).asEagerSingleton()
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -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<OutputConfiguration> 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<OutputConfiguration> getOutputConfigurations(Resource context) {
return getOutputConfigurations()
}

}

/**
Expand Down Expand Up @@ -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))

}
}

Expand Down
15 changes: 15 additions & 0 deletions plugins/de.fraunhofer.ipa.rossystem.xtext.ide/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -21,4 +21,7 @@ class RosSystemRuntimeModule extends AbstractRosSystemRuntimeModule {

}

override Class<? extends IQualifiedNameProvider> bindIQualifiedNameProvider() {
return RosSystemQNP;
}
}

0 comments on commit 0db7bc0

Please sign in to comment.