Skip to content

Commit b762971

Browse files
committed
ST6RI-763 Added standalone setups for .kermlx and .sysmlx XMIs
1 parent 43a48a7 commit b762971

6 files changed

Lines changed: 251 additions & 4 deletions

File tree

org.omg.kerml.xtext/META-INF/MANIFEST.MF

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@ Require-Bundle: org.eclipse.xtext,
1919
com.google.gson,
2020
org.eclipse.xtext.common.types,
2121
org.objectweb.asm;bundle-version="9.3.0";resolution:=optional
22-
Export-Package: org.omg.kerml.xtext,
22+
Export-Package: org.omg.kerml.kermlx,
23+
org.omg.kerml.xtext,
2324
org.omg.kerml.xtext.generator,
2425
org.omg.kerml.xtext.library,
2526
org.omg.kerml.xtext.linking,
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
/**
2+
* SysML 2 Pilot Implementation
3+
* Copyright (C) 2020 California Institute of Technology ("Caltech")
4+
*
5+
* This program is free software: you can redistribute it and/or modify
6+
* it under the terms of the GNU Lesser General Public License as published by
7+
* the Free Software Foundation, either version 3 of the License, or
8+
* (at your option) any later version.
9+
*
10+
* This program is distributed in the hope that it will be useful,
11+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13+
* GNU Lesser General Public License for more details.
14+
*
15+
* You should have received a copy of the GNU Lesser General Public License
16+
* along with this program. If not, see <https://www.gnu.org/licenses/>.
17+
*
18+
* @license LGPL-3.0-or-later <http://spdx.org/licenses/LGPL-3.0-or-later>
19+
*/
20+
package org.omg.kerml.xmi
21+
22+
import com.google.inject.Binder
23+
import org.eclipse.emf.ecore.resource.Resource
24+
import org.eclipse.emf.ecore.xmi.impl.XMIResourceFactoryImpl
25+
import org.eclipse.xtext.naming.IQualifiedNameConverter
26+
import org.eclipse.xtext.resource.IResourceDescriptions
27+
import org.eclipse.xtext.resource.generic.AbstractGenericResourceRuntimeModule
28+
import org.eclipse.xtext.resource.impl.ResourceSetBasedResourceDescriptions
29+
import org.omg.kerml.xtext.library.KerMLLibraryProvider
30+
import org.omg.kerml.xtext.naming.KerMLQualifiedNameConverter
31+
import org.omg.kerml.xtext.naming.KerMLQualifiedNameProvider
32+
import org.omg.sysml.lang.sysml.util.IModelLibraryProvider
33+
34+
class KerMLxRuntimeModule extends AbstractGenericResourceRuntimeModule{
35+
36+
override protected getFileExtensions() {
37+
'kermlx'
38+
}
39+
40+
override protected getLanguageName() {
41+
'org.omg.kerml.kermlx'
42+
}
43+
44+
override configure(Binder binder) {
45+
super.configure(binder)
46+
binder.bind(Resource.Factory).to(XMIResourceFactoryImpl)
47+
binder.bind(IResourceDescriptions).to(ResourceSetBasedResourceDescriptions)
48+
}
49+
50+
override bindIQualifiedNameProvider() {
51+
KerMLQualifiedNameProvider
52+
}
53+
54+
def Class<? extends IQualifiedNameConverter> bindIQualifiedNameConverter() {
55+
KerMLQualifiedNameConverter
56+
}
57+
58+
def Class<? extends IModelLibraryProvider> bindIModelLLibraryProvider() {
59+
KerMLLibraryProvider
60+
}
61+
}
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
/**
2+
* SysML 2 Pilot Implementation
3+
* Copyright (C) 2020 California Institute of Technology ("Caltech")
4+
*
5+
* This program is free software: you can redistribute it and/or modify
6+
* it under the terms of the GNU Lesser General Public License as published by
7+
* the Free Software Foundation, either version 3 of the License, or
8+
* (at your option) any later version.
9+
*
10+
* This program is distributed in the hope that it will be useful,
11+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13+
* GNU Lesser General Public License for more details.
14+
*
15+
* You should have received a copy of the GNU Lesser General Public License
16+
* along with this program. If not, see <https://www.gnu.org/licenses/>.
17+
*
18+
* @license LGPL-3.0-or-later <http://spdx.org/licenses/LGPL-3.0-or-later>
19+
*/
20+
package org.omg.kerml.xmi
21+
22+
import com.google.inject.Guice
23+
import com.google.inject.Inject
24+
import com.google.inject.Injector
25+
import org.eclipse.emf.ecore.resource.Resource
26+
import org.eclipse.xtext.ISetup
27+
import org.eclipse.xtext.resource.FileExtensionProvider
28+
import org.eclipse.xtext.resource.IResourceServiceProvider
29+
30+
class KerMLxStandaloneSetup implements ISetup {
31+
32+
@Inject
33+
FileExtensionProvider fileExtensionProvider
34+
35+
@Inject
36+
IResourceServiceProvider resourceServiceProvider
37+
38+
@Inject
39+
Resource.Factory resourceFactory
40+
41+
override createInjectorAndDoEMFRegistration() {
42+
val injector = createInjector()
43+
injector.injectMembers(this)
44+
45+
fileExtensionProvider.fileExtensions.forEach[
46+
IResourceServiceProvider.Registry.INSTANCE.extensionToFactoryMap.put(it, resourceServiceProvider)
47+
Resource.Factory.Registry.INSTANCE.extensionToFactoryMap.put(it, resourceFactory)
48+
]
49+
50+
injector
51+
}
52+
53+
static def doSetup(){
54+
new KerMLxStandaloneSetup().createInjectorAndDoEMFRegistration
55+
}
56+
57+
def Injector createInjector(){
58+
Guice.createInjector(new KerMLxRuntimeModule)
59+
}
60+
}

org.omg.sysml.xtext/META-INF/MANIFEST.MF

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,15 @@ Require-Bundle: org.eclipse.xtext,
2121
org.eclipse.xtext.common.types,
2222
org.objectweb.asm;bundle-version="9.3.0";resolution:=optional,
2323
org.apache.commons.cli
24-
Export-Package: org.omg.sysml.xtext,
24+
Export-Package: org.omg.sysml.sysmlx,
25+
org.omg.sysml.xtext,
2526
org.omg.sysml.xtext.generator,
2627
org.omg.sysml.xtext.library,
2728
org.omg.sysml.xtext.parser.antlr,
2829
org.omg.sysml.xtext.parser.antlr.internal,
2930
org.omg.sysml.xtext.scoping,
31+
org.omg.sysml.xtext.serializer,
3032
org.omg.sysml.xtext.services,
3133
org.omg.sysml.xtext.util,
32-
org.omg.sysml.xtext.validation,
33-
org.omg.sysml.xtext.serializer
34+
org.omg.sysml.xtext.validation
3435
Import-Package: org.apache.log4j
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
/**
2+
* SysML 2 Pilot Implementation
3+
* Copyright (C) 2020 California Institute of Technology ("Caltech")
4+
*
5+
* This program is free software: you can redistribute it and/or modify
6+
* it under the terms of the GNU Lesser General Public License as published by
7+
* the Free Software Foundation, either version 3 of the License, or
8+
* (at your option) any later version.
9+
*
10+
* This program is distributed in the hope that it will be useful,
11+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13+
* GNU Lesser General Public License for more details.
14+
*
15+
* You should have received a copy of the GNU Lesser General Public License
16+
* along with this program. If not, see <https://www.gnu.org/licenses/>.
17+
*
18+
* @license LGPL-3.0-or-later <http://spdx.org/licenses/LGPL-3.0-or-later>
19+
*/
20+
package org.omg.sysml.xmi
21+
22+
import com.google.inject.Binder
23+
import org.eclipse.emf.ecore.resource.Resource
24+
import org.eclipse.emf.ecore.xmi.impl.XMIResourceFactoryImpl
25+
import org.eclipse.xtext.naming.IQualifiedNameConverter
26+
import org.eclipse.xtext.naming.IQualifiedNameProvider
27+
import org.eclipse.xtext.resource.IResourceDescriptions
28+
import org.eclipse.xtext.resource.generic.AbstractGenericResourceRuntimeModule
29+
import org.eclipse.xtext.resource.impl.ResourceSetBasedResourceDescriptions
30+
import org.omg.kerml.xtext.naming.KerMLQualifiedNameConverter
31+
import org.omg.kerml.xtext.naming.KerMLQualifiedNameProvider
32+
import org.omg.sysml.lang.sysml.util.IModelLibraryProvider
33+
import org.omg.sysml.xtext.library.SysMLLibraryProvider
34+
35+
class SysMLxRuntimeModule extends AbstractGenericResourceRuntimeModule {
36+
37+
public val EXTENSION = 'sysmlx'
38+
public static val SYSMLX_LANGUAGE_NAME = 'org.omg.sysml.sysmlx'
39+
40+
override protected getFileExtensions() {
41+
EXTENSION
42+
}
43+
44+
override protected getLanguageName() {
45+
SYSMLX_LANGUAGE_NAME
46+
}
47+
48+
override configure(Binder binder) {
49+
super.configure(binder)
50+
binder.bind(Resource.Factory).to(XMIResourceFactoryImpl)
51+
binder.bind(IResourceDescriptions).to(ResourceSetBasedResourceDescriptions)
52+
}
53+
54+
override Class<? extends IQualifiedNameProvider> bindIQualifiedNameProvider() {
55+
KerMLQualifiedNameProvider
56+
}
57+
58+
def Class<? extends IQualifiedNameConverter> bindIQualifiedNameConverter() {
59+
KerMLQualifiedNameConverter
60+
}
61+
62+
def Class<? extends IModelLibraryProvider> bindIModelLLibraryProvider() {
63+
SysMLLibraryProvider
64+
}
65+
}
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
/**
2+
* SysML 2 Pilot Implementation
3+
* Copyright (C) 2020 California Institute of Technology ("Caltech")
4+
*
5+
* This program is free software: you can redistribute it and/or modify
6+
* it under the terms of the GNU Lesser General Public License as published by
7+
* the Free Software Foundation, either version 3 of the License, or
8+
* (at your option) any later version.
9+
*
10+
* This program is distributed in the hope that it will be useful,
11+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13+
* GNU Lesser General Public License for more details.
14+
*
15+
* You should have received a copy of the GNU Lesser General Public License
16+
* along with this program. If not, see <https://www.gnu.org/licenses/>.
17+
*
18+
* @license LGPL-3.0-or-later <http://spdx.org/licenses/LGPL-3.0-or-later>
19+
*/
20+
package org.omg.sysml.xmi
21+
22+
import com.google.inject.Guice
23+
import com.google.inject.Inject
24+
import org.eclipse.emf.ecore.resource.Resource
25+
import org.eclipse.xtext.ISetup
26+
import org.eclipse.xtext.resource.FileExtensionProvider
27+
import org.eclipse.xtext.resource.IResourceServiceProvider
28+
29+
class SysMLxStandaloneSetup implements ISetup {
30+
31+
@Inject
32+
FileExtensionProvider fileExtensionProvider
33+
34+
@Inject
35+
IResourceServiceProvider resourceServiceProvider
36+
37+
@Inject
38+
Resource.Factory resourceFactory
39+
40+
override createInjectorAndDoEMFRegistration() {
41+
val injector = createInjector()
42+
injector.injectMembers(this)
43+
44+
fileExtensionProvider.fileExtensions.forEach[
45+
IResourceServiceProvider.Registry.INSTANCE.extensionToFactoryMap.put(it, resourceServiceProvider)
46+
Resource.Factory.Registry.INSTANCE.extensionToFactoryMap.put(it, resourceFactory)
47+
]
48+
49+
injector
50+
}
51+
52+
static def doSetup(){
53+
new SysMLxStandaloneSetup().createInjectorAndDoEMFRegistration
54+
}
55+
56+
def createInjector() {
57+
return Guice.createInjector(new SysMLxRuntimeModule());
58+
}
59+
}

0 commit comments

Comments
 (0)