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