diff options
Diffstat (limited to 'Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.components/xtend-gen/hu/bme/mit/inf/dslreasoner/faulttree/components/scoping/CftLanguageScopeProvider.java')
-rw-r--r-- | Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.components/xtend-gen/hu/bme/mit/inf/dslreasoner/faulttree/components/scoping/CftLanguageScopeProvider.java | 248 |
1 files changed, 248 insertions, 0 deletions
diff --git a/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.components/xtend-gen/hu/bme/mit/inf/dslreasoner/faulttree/components/scoping/CftLanguageScopeProvider.java b/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.components/xtend-gen/hu/bme/mit/inf/dslreasoner/faulttree/components/scoping/CftLanguageScopeProvider.java new file mode 100644 index 00000000..0149c8d1 --- /dev/null +++ b/Stochastic/hu.bme.mit.inf.dslreasoner.faulttree.components/xtend-gen/hu/bme/mit/inf/dslreasoner/faulttree/components/scoping/CftLanguageScopeProvider.java | |||
@@ -0,0 +1,248 @@ | |||
1 | /** | ||
2 | * generated by Xtext 2.16.0 | ||
3 | */ | ||
4 | package hu.bme.mit.inf.dslreasoner.faulttree.components.scoping; | ||
5 | |||
6 | import com.google.common.base.Objects; | ||
7 | import com.google.common.collect.Lists; | ||
8 | import com.google.inject.Inject; | ||
9 | import hu.bme.mit.inf.dslreasoner.faulttree.components.cftLanguage.CftLanguagePackage; | ||
10 | import hu.bme.mit.inf.dslreasoner.faulttree.components.cftLanguage.ComponentDefinition; | ||
11 | import hu.bme.mit.inf.dslreasoner.faulttree.components.cftLanguage.ComponentInstance; | ||
12 | import hu.bme.mit.inf.dslreasoner.faulttree.components.cftLanguage.EventDeclaration; | ||
13 | import hu.bme.mit.inf.dslreasoner.faulttree.components.cftLanguage.EventReference; | ||
14 | import hu.bme.mit.inf.dslreasoner.faulttree.components.cftLanguage.LookupDefinition; | ||
15 | import hu.bme.mit.inf.dslreasoner.faulttree.components.cftLanguage.MappingDefinition; | ||
16 | import hu.bme.mit.inf.dslreasoner.faulttree.components.cftLanguage.MappingParameter; | ||
17 | import hu.bme.mit.inf.dslreasoner.faulttree.components.cftLanguage.TransformationDefinition; | ||
18 | import hu.bme.mit.inf.dslreasoner.faulttree.components.cftLanguage.Variable; | ||
19 | import hu.bme.mit.inf.dslreasoner.faulttree.components.scoping.AbstractCftLanguageScopeProvider; | ||
20 | import hu.bme.mit.inf.dslreasoner.faulttree.components.scoping.CftLanguageImportedNamespaceAwareLocalScopeProvider; | ||
21 | import java.util.ArrayList; | ||
22 | import org.eclipse.emf.common.notify.Notifier; | ||
23 | import org.eclipse.emf.ecore.EObject; | ||
24 | import org.eclipse.emf.ecore.EReference; | ||
25 | import org.eclipse.emf.ecore.resource.ResourceSet; | ||
26 | import org.eclipse.viatra.query.patternlanguage.emf.vql.Pattern; | ||
27 | import org.eclipse.xtext.EcoreUtil2; | ||
28 | import org.eclipse.xtext.naming.QualifiedName; | ||
29 | import org.eclipse.xtext.resource.EObjectDescription; | ||
30 | import org.eclipse.xtext.resource.IEObjectDescription; | ||
31 | import org.eclipse.xtext.resource.IResourceDescriptions; | ||
32 | import org.eclipse.xtext.resource.IResourceDescriptionsProvider; | ||
33 | import org.eclipse.xtext.scoping.IScope; | ||
34 | import org.eclipse.xtext.scoping.Scopes; | ||
35 | import org.eclipse.xtext.scoping.impl.ImportScope; | ||
36 | import org.eclipse.xtext.scoping.impl.SimpleScope; | ||
37 | import org.eclipse.xtext.xbase.lib.CollectionLiterals; | ||
38 | import org.eclipse.xtext.xbase.lib.Functions.Function1; | ||
39 | import org.eclipse.xtext.xbase.lib.IterableExtensions; | ||
40 | |||
41 | /** | ||
42 | * This class contains custom scoping description. | ||
43 | * | ||
44 | * See https://www.eclipse.org/Xtext/documentation/303_runtime_concepts.html#scoping | ||
45 | * on how and when to use it. | ||
46 | */ | ||
47 | @SuppressWarnings("all") | ||
48 | public class CftLanguageScopeProvider extends AbstractCftLanguageScopeProvider { | ||
49 | public static final String SINGLETON_VARIABLE_PREFIX = "_"; | ||
50 | |||
51 | @Inject | ||
52 | private IResourceDescriptionsProvider resourceDescriptionsProvider; | ||
53 | |||
54 | @Inject | ||
55 | private CftLanguageImportedNamespaceAwareLocalScopeProvider importedNamespaceProvider; | ||
56 | |||
57 | @Override | ||
58 | public IScope getScope(final EObject context, final EReference reference) { | ||
59 | IScope _switchResult = null; | ||
60 | boolean _matched = false; | ||
61 | if (Objects.equal(reference, CftLanguagePackage.Literals.LOOKUP_DEFINITION__MAPPING)) { | ||
62 | _matched=true; | ||
63 | _switchResult = this.getRuleDefinitionsScope(context, reference); | ||
64 | } | ||
65 | if (!_matched) { | ||
66 | if (Objects.equal(reference, CftLanguagePackage.Literals.LOOKUP_DEFINITION__ARGUMENTS)) { | ||
67 | _matched=true; | ||
68 | _switchResult = this.getMappingParametersScope(context); | ||
69 | } | ||
70 | } | ||
71 | if (!_matched) { | ||
72 | if (Objects.equal(reference, CftLanguagePackage.Literals.EVENT_REFERENCE__COMPONENT)) { | ||
73 | _matched=true; | ||
74 | _switchResult = this.getComponentInstancesScope(context); | ||
75 | } | ||
76 | } | ||
77 | if (!_matched) { | ||
78 | if (Objects.equal(reference, CftLanguagePackage.Literals.EVENT_REFERENCE__EVENT)) { | ||
79 | _matched=true; | ||
80 | _switchResult = this.getEventDeclarationsScope(context); | ||
81 | } | ||
82 | } | ||
83 | if (!_matched) { | ||
84 | _switchResult = super.getScope(context, reference); | ||
85 | } | ||
86 | return _switchResult; | ||
87 | } | ||
88 | |||
89 | protected IScope getRuleDefinitionsScope(final EObject context, final EReference referece) { | ||
90 | ImportScope _xblockexpression = null; | ||
91 | { | ||
92 | final TransformationDefinition transformationDefinition = EcoreUtil2.<TransformationDefinition>getContainerOfType(context, TransformationDefinition.class); | ||
93 | if ((transformationDefinition == null)) { | ||
94 | return IScope.NULLSCOPE; | ||
95 | } | ||
96 | final IResourceDescriptions resourceDescriptions = this.getResourceDescriptions(transformationDefinition); | ||
97 | final ArrayList<IEObjectDescription> mappingDefinitionDescriptions = this.toMappingDefinitionDescriptions(resourceDescriptions, | ||
98 | transformationDefinition.getMappingDefinitions()); | ||
99 | final SimpleScope ruleDefinitionsScope = new SimpleScope(IScope.NULLSCOPE, mappingDefinitionDescriptions); | ||
100 | _xblockexpression = this.importedNamespaceProvider.createImportNormalizedScope(ruleDefinitionsScope, context, referece); | ||
101 | } | ||
102 | return _xblockexpression; | ||
103 | } | ||
104 | |||
105 | protected ArrayList<IEObjectDescription> toMappingDefinitionDescriptions(final IResourceDescriptions resourceDescriptions, final Iterable<? extends MappingDefinition> ruleDefinitions) { | ||
106 | ArrayList<IEObjectDescription> _xblockexpression = null; | ||
107 | { | ||
108 | final ArrayList<IEObjectDescription> mappingDefinitionDescriptions = Lists.<IEObjectDescription>newArrayListWithExpectedSize(IterableExtensions.size(ruleDefinitions)); | ||
109 | for (final MappingDefinition ruleDefinition : ruleDefinitions) { | ||
110 | { | ||
111 | Pattern _pattern = null; | ||
112 | if (ruleDefinition!=null) { | ||
113 | _pattern=ruleDefinition.getPattern(); | ||
114 | } | ||
115 | final Pattern pattern = _pattern; | ||
116 | if ((pattern != null)) { | ||
117 | IEObjectDescription _head = IterableExtensions.<IEObjectDescription>head(resourceDescriptions.getExportedObjectsByObject(pattern)); | ||
118 | QualifiedName _qualifiedName = null; | ||
119 | if (_head!=null) { | ||
120 | _qualifiedName=_head.getQualifiedName(); | ||
121 | } | ||
122 | final QualifiedName patternName = _qualifiedName; | ||
123 | if ((patternName != null)) { | ||
124 | IEObjectDescription _create = EObjectDescription.create(patternName, ruleDefinition); | ||
125 | mappingDefinitionDescriptions.add(_create); | ||
126 | } | ||
127 | } | ||
128 | } | ||
129 | } | ||
130 | _xblockexpression = mappingDefinitionDescriptions; | ||
131 | } | ||
132 | return _xblockexpression; | ||
133 | } | ||
134 | |||
135 | private IResourceDescriptions getResourceDescriptions(final Notifier notifier) { | ||
136 | IResourceDescriptions _xblockexpression = null; | ||
137 | { | ||
138 | final ResourceSet resourceSet = EcoreUtil2.getResourceSet(notifier); | ||
139 | IResourceDescriptions _xifexpression = null; | ||
140 | if ((resourceSet == null)) { | ||
141 | _xifexpression = new IResourceDescriptions.NullImpl(); | ||
142 | } else { | ||
143 | _xifexpression = this.resourceDescriptionsProvider.getResourceDescriptions(resourceSet); | ||
144 | } | ||
145 | _xblockexpression = _xifexpression; | ||
146 | } | ||
147 | return _xblockexpression; | ||
148 | } | ||
149 | |||
150 | protected IScope getMappingParametersScope(final EObject context) { | ||
151 | IScope _xblockexpression = null; | ||
152 | { | ||
153 | final MappingDefinition mappingDefinition = EcoreUtil2.<MappingDefinition>getContainerOfType(context, MappingDefinition.class); | ||
154 | if ((mappingDefinition == null)) { | ||
155 | return IScope.NULLSCOPE; | ||
156 | } | ||
157 | final Function1<MappingParameter, Boolean> _function = (MappingParameter it) -> { | ||
158 | boolean _startsWith = it.getName().startsWith(CftLanguageScopeProvider.SINGLETON_VARIABLE_PREFIX); | ||
159 | return Boolean.valueOf((!_startsWith)); | ||
160 | }; | ||
161 | final Iterable<MappingParameter> variables = IterableExtensions.<MappingParameter>filter(mappingDefinition.getParameters(), _function); | ||
162 | _xblockexpression = Scopes.scopeFor(variables); | ||
163 | } | ||
164 | return _xblockexpression; | ||
165 | } | ||
166 | |||
167 | protected IScope getComponentInstancesScope(final EObject context) { | ||
168 | IScope _xblockexpression = null; | ||
169 | { | ||
170 | final MappingDefinition mappingDefinition = EcoreUtil2.<MappingDefinition>getContainerOfType(context, MappingDefinition.class); | ||
171 | if ((mappingDefinition == null)) { | ||
172 | return IScope.NULLSCOPE; | ||
173 | } | ||
174 | final ArrayList<Variable> componentInstances = CollectionLiterals.<Variable>newArrayList(); | ||
175 | componentInstances.addAll(mappingDefinition.getLookupDefinitions()); | ||
176 | ComponentInstance _componentInstance = mappingDefinition.getComponentInstance(); | ||
177 | boolean _tripleNotEquals = (_componentInstance != null); | ||
178 | if (_tripleNotEquals) { | ||
179 | ComponentInstance _componentInstance_1 = mappingDefinition.getComponentInstance(); | ||
180 | componentInstances.add(_componentInstance_1); | ||
181 | } | ||
182 | _xblockexpression = Scopes.scopeFor(componentInstances); | ||
183 | } | ||
184 | return _xblockexpression; | ||
185 | } | ||
186 | |||
187 | protected IScope getEventDeclarationsScope(final EObject context) { | ||
188 | IScope _xblockexpression = null; | ||
189 | { | ||
190 | EventReference _containerOfType = EcoreUtil2.<EventReference>getContainerOfType(context, EventReference.class); | ||
191 | Variable _component = null; | ||
192 | if (_containerOfType!=null) { | ||
193 | _component=_containerOfType.getComponent(); | ||
194 | } | ||
195 | final Variable variable = _component; | ||
196 | ArrayList<EventDeclaration> _switchResult = null; | ||
197 | boolean _matched = false; | ||
198 | if (variable instanceof ComponentInstance) { | ||
199 | _matched=true; | ||
200 | ComponentDefinition _componentType = ((ComponentInstance)variable).getComponentType(); | ||
201 | ArrayList<EventDeclaration> _allEventDeclarations = null; | ||
202 | if (_componentType!=null) { | ||
203 | _allEventDeclarations=this.getAllEventDeclarations(_componentType); | ||
204 | } | ||
205 | _switchResult = _allEventDeclarations; | ||
206 | } | ||
207 | if (!_matched) { | ||
208 | if (variable instanceof LookupDefinition) { | ||
209 | _matched=true; | ||
210 | MappingDefinition _mapping = ((LookupDefinition)variable).getMapping(); | ||
211 | ComponentInstance _componentInstance = null; | ||
212 | if (_mapping!=null) { | ||
213 | _componentInstance=_mapping.getComponentInstance(); | ||
214 | } | ||
215 | ComponentDefinition _componentType = null; | ||
216 | if (_componentInstance!=null) { | ||
217 | _componentType=_componentInstance.getComponentType(); | ||
218 | } | ||
219 | ArrayList<EventDeclaration> _allEventDeclarations = null; | ||
220 | if (_componentType!=null) { | ||
221 | _allEventDeclarations=this.getAllEventDeclarations(_componentType); | ||
222 | } | ||
223 | _switchResult = _allEventDeclarations; | ||
224 | } | ||
225 | } | ||
226 | if (!_matched) { | ||
227 | _switchResult = null; | ||
228 | } | ||
229 | final ArrayList<EventDeclaration> events = _switchResult; | ||
230 | if ((events == null)) { | ||
231 | return IScope.NULLSCOPE; | ||
232 | } | ||
233 | _xblockexpression = Scopes.scopeFor(events); | ||
234 | } | ||
235 | return _xblockexpression; | ||
236 | } | ||
237 | |||
238 | private ArrayList<EventDeclaration> getAllEventDeclarations(final ComponentDefinition componentDefinition) { | ||
239 | ArrayList<EventDeclaration> _xblockexpression = null; | ||
240 | { | ||
241 | final ArrayList<EventDeclaration> eventDeclarations = CollectionLiterals.<EventDeclaration>newArrayList(); | ||
242 | eventDeclarations.addAll(componentDefinition.getInputEvents()); | ||
243 | eventDeclarations.addAll(componentDefinition.getEventDefinitions()); | ||
244 | _xblockexpression = eventDeclarations; | ||
245 | } | ||
246 | return _xblockexpression; | ||
247 | } | ||
248 | } | ||