-
Notifications
You must be signed in to change notification settings - Fork 63
Expand file tree
/
Copy pathKerMLxRuntimeModule.xtend
More file actions
86 lines (76 loc) · 3.03 KB
/
Copy pathKerMLxRuntimeModule.xtend
File metadata and controls
86 lines (76 loc) · 3.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
/**
* SysML 2 Pilot Implementation
* Copyright (C) 2025 Model Driven Solutions, Inc.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the Eclipse Public License as published by
* the Eclipse Foundation, version 2 of the License.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* Eclipse Public License for more details.
*
* You should have received a copy of the Eclipse Public License
* along with this program. If not, see <https://www.eclipse.org/legal/epl-2.0/>.
*
* @license EPL-2.0 <http://spdx.org/licenses/EPL-2.0>
*/
package org.omg.kerml.xtext.xmi
import com.google.inject.Binder
import org.eclipse.emf.ecore.resource.Resource
import org.eclipse.emf.ecore.xmi.impl.XMIResourceFactoryImpl
import org.eclipse.xtext.naming.IQualifiedNameConverter
import org.eclipse.xtext.resource.IResourceServiceProvider
import org.eclipse.xtext.resource.IResourceDescriptions
import org.eclipse.xtext.resource.generic.AbstractGenericResourceRuntimeModule
import org.eclipse.xtext.resource.impl.ResourceSetBasedResourceDescriptions
import org.omg.kerml.xtext.library.KerMLLibraryProvider
import org.omg.kerml.xtext.naming.KerMLQualifiedNameConverter
import org.omg.kerml.xtext.naming.KerMLQualifiedNameProvider
import org.omg.sysml.logic.api.IModelLibraryProvider
import org.omg.sysml.util.SysMLLibraryUtil
class KerMLxRuntimeModule extends AbstractGenericResourceRuntimeModule{
/**
* Installs the library-provider lookup used by {@link SysMLLibraryUtil} for
* the generic KerML XMI runtime.
*
* <p>The lookup resolves the {@link IModelLibraryProvider} from the
* {@link IResourceServiceProvider} associated with the current resource URI so
* library element resolution works in this non-generated XMI-based runtime
* just as it does in the regular Xtext runtime modules.
*/
new() {
SysMLLibraryUtil.setProviderLookup([
resource |
try {
val serviceProvider = IResourceServiceProvider.Registry.INSTANCE.getResourceServiceProvider(resource?.URI)
if (serviceProvider === null) null else serviceProvider.get(IModelLibraryProvider)
} catch (Exception e) {
System.out.println("[SysMLLibraryUtil] Cannot get library provider: " + e)
null
}
])
}
public static val KERMLX_LANGUAGE_NAME = 'org.omg.kerml.kermlx'
override protected getFileExtensions() {
'kermlx'
}
override protected getLanguageName() {
'org.omg.kerml.kermlx'
}
override configure(Binder binder) {
super.configure(binder)
binder.bind(Resource.Factory).to(XMIResourceFactoryImpl)
binder.bind(IResourceDescriptions).to(ResourceSetBasedResourceDescriptions)
}
override bindIQualifiedNameProvider() {
KerMLQualifiedNameProvider
}
def Class<? extends IQualifiedNameConverter> bindIQualifiedNameConverter() {
KerMLQualifiedNameConverter
}
def Class<? extends IModelLibraryProvider> bindIModelLLibraryProvider() {
KerMLLibraryProvider
}
}