diff options
author | 2020-06-06 19:19:18 -0400 | |
---|---|---|
committer | 2020-06-07 19:47:46 -0400 | |
commit | 8a5c12d1c52498ad9abc11057f6c23456e272585 (patch) | |
tree | e85bde3d0fb911d1b2ed7f4151e1b3010bd517dd /Application/hu.bme.mit.inf.dslreasoner.application/xtend-gen/hu/bme/mit/inf/dslreasoner | |
parent | VAMPIRE: last commit (diff) | |
download | VIATRA-Generator-8a5c12d1c52498ad9abc11057f6c23456e272585.tar.gz VIATRA-Generator-8a5c12d1c52498ad9abc11057f6c23456e272585.tar.zst VIATRA-Generator-8a5c12d1c52498ad9abc11057f6c23456e272585.zip |
VAMPIRE: Rebase on Master
Diffstat (limited to 'Application/hu.bme.mit.inf.dslreasoner.application/xtend-gen/hu/bme/mit/inf/dslreasoner')
-rw-r--r-- | Application/hu.bme.mit.inf.dslreasoner.application/xtend-gen/hu/bme/mit/inf/dslreasoner/application/validation/QueryAndMetamodelValidator.java | 89 |
1 files changed, 89 insertions, 0 deletions
diff --git a/Application/hu.bme.mit.inf.dslreasoner.application/xtend-gen/hu/bme/mit/inf/dslreasoner/application/validation/QueryAndMetamodelValidator.java b/Application/hu.bme.mit.inf.dslreasoner.application/xtend-gen/hu/bme/mit/inf/dslreasoner/application/validation/QueryAndMetamodelValidator.java index 0b5b8f03..dbe4b17b 100644 --- a/Application/hu.bme.mit.inf.dslreasoner.application/xtend-gen/hu/bme/mit/inf/dslreasoner/application/validation/QueryAndMetamodelValidator.java +++ b/Application/hu.bme.mit.inf.dslreasoner.application/xtend-gen/hu/bme/mit/inf/dslreasoner/application/validation/QueryAndMetamodelValidator.java | |||
@@ -1,3 +1,4 @@ | |||
1 | <<<<<<< HEAD | ||
1 | package hu.bme.mit.inf.dslreasoner.application.validation; | 2 | package hu.bme.mit.inf.dslreasoner.application.validation; |
2 | 3 | ||
3 | import com.google.common.collect.Iterables; | 4 | import com.google.common.collect.Iterables; |
@@ -84,3 +85,91 @@ public class QueryAndMetamodelValidator { | |||
84 | return Iterables.<ENamedElement>concat(ListExtensions.<EObject, Iterable<ENamedElement>>map(elements, _function)); | 85 | return Iterables.<ENamedElement>concat(ListExtensions.<EObject, Iterable<ENamedElement>>map(elements, _function)); |
85 | } | 86 | } |
86 | } | 87 | } |
88 | ======= | ||
89 | package hu.bme.mit.inf.dslreasoner.application.validation; | ||
90 | |||
91 | import com.google.common.collect.Iterables; | ||
92 | import hu.bme.mit.inf.dslreasoner.ecore2logic.EcoreMetamodelDescriptor; | ||
93 | import hu.bme.mit.inf.dslreasoner.viatra2logic.ViatraQuerySetDescriptor; | ||
94 | import java.util.Collections; | ||
95 | import java.util.LinkedList; | ||
96 | import java.util.List; | ||
97 | import java.util.Set; | ||
98 | import org.eclipse.emf.common.util.EList; | ||
99 | import org.eclipse.emf.ecore.EAttribute; | ||
100 | import org.eclipse.emf.ecore.EClass; | ||
101 | import org.eclipse.emf.ecore.EClassifier; | ||
102 | import org.eclipse.emf.ecore.EEnum; | ||
103 | import org.eclipse.emf.ecore.EEnumLiteral; | ||
104 | import org.eclipse.emf.ecore.ENamedElement; | ||
105 | import org.eclipse.emf.ecore.EObject; | ||
106 | import org.eclipse.emf.ecore.EReference; | ||
107 | import org.eclipse.viatra.query.patternlanguage.emf.vql.Pattern; | ||
108 | import org.eclipse.xtend2.lib.StringConcatenation; | ||
109 | import org.eclipse.xtext.xbase.lib.CollectionLiterals; | ||
110 | import org.eclipse.xtext.xbase.lib.Functions.Function1; | ||
111 | import org.eclipse.xtext.xbase.lib.IterableExtensions; | ||
112 | import org.eclipse.xtext.xbase.lib.IteratorExtensions; | ||
113 | import org.eclipse.xtext.xbase.lib.ListExtensions; | ||
114 | import org.eclipse.xtext.xbase.lib.Pair; | ||
115 | |||
116 | @SuppressWarnings("all") | ||
117 | public class QueryAndMetamodelValidator { | ||
118 | public LinkedList<String> validateQueryAndMetamodel(final EcoreMetamodelDescriptor metamodel, final Pair<ViatraQuerySetDescriptor, Set<Pattern>> viatra) { | ||
119 | final Set<Pattern> patterns = viatra.getValue(); | ||
120 | List<EClass> _classes = metamodel.getClasses(); | ||
121 | List<EEnum> _enums = metamodel.getEnums(); | ||
122 | Iterable<EClassifier> _plus = Iterables.<EClassifier>concat(_classes, _enums); | ||
123 | List<EEnumLiteral> _literals = metamodel.getLiterals(); | ||
124 | Iterable<ENamedElement> _plus_1 = Iterables.<ENamedElement>concat(_plus, _literals); | ||
125 | List<EAttribute> _attributes = metamodel.getAttributes(); | ||
126 | Iterable<ENamedElement> _plus_2 = Iterables.<ENamedElement>concat(_plus_1, _attributes); | ||
127 | List<EReference> _references = metamodel.getReferences(); | ||
128 | final Set<ENamedElement> elementsInMetamodel = IterableExtensions.<ENamedElement>toSet(Iterables.<ENamedElement>concat(_plus_2, _references)); | ||
129 | final LinkedList<String> errors = new LinkedList<String>(); | ||
130 | for (final Pattern pattern : patterns) { | ||
131 | { | ||
132 | final Iterable<ENamedElement> elements = this.getReferredNamedElements(pattern); | ||
133 | for (final ENamedElement element : elements) { | ||
134 | boolean _contains = elementsInMetamodel.contains(element); | ||
135 | boolean _not = (!_contains); | ||
136 | if (_not) { | ||
137 | StringConcatenation _builder = new StringConcatenation(); | ||
138 | _builder.append("Pattern \""); | ||
139 | String _name = pattern.getName(); | ||
140 | _builder.append(_name); | ||
141 | _builder.append("\" refers to an element \""); | ||
142 | _builder.append(element); | ||
143 | _builder.append("\" that is not included to the selected metamodel!"); | ||
144 | errors.add(_builder.toString()); | ||
145 | } | ||
146 | } | ||
147 | } | ||
148 | } | ||
149 | return errors; | ||
150 | } | ||
151 | |||
152 | public Iterable<ENamedElement> getReferredNamedElements(final Pattern pattern) { | ||
153 | final List<EObject> elements = IteratorExtensions.<EObject>toList(pattern.eAllContents()); | ||
154 | final Function1<EObject, Iterable<ENamedElement>> _function = (EObject element) -> { | ||
155 | final EList<EReference> references = element.eClass().getEAllReferences(); | ||
156 | final Function1<EReference, Iterable<ENamedElement>> _function_1 = (EReference r) -> { | ||
157 | boolean _isMany = r.isMany(); | ||
158 | if (_isMany) { | ||
159 | Object _eGet = element.eGet(r); | ||
160 | return Iterables.<ENamedElement>filter(((List<?>) _eGet), ENamedElement.class); | ||
161 | } else { | ||
162 | final Object value = element.eGet(r); | ||
163 | if ((value instanceof ENamedElement)) { | ||
164 | return Collections.<ENamedElement>unmodifiableList(CollectionLiterals.<ENamedElement>newArrayList(((ENamedElement)value))); | ||
165 | } else { | ||
166 | return Collections.<ENamedElement>unmodifiableList(CollectionLiterals.<ENamedElement>newArrayList()); | ||
167 | } | ||
168 | } | ||
169 | }; | ||
170 | return Iterables.<ENamedElement>filter((Iterables.<ENamedElement>concat(ListExtensions.<EReference, Iterable<ENamedElement>>map(references, _function_1))), ENamedElement.class); | ||
171 | }; | ||
172 | return Iterables.<ENamedElement>concat(ListExtensions.<EObject, Iterable<ENamedElement>>map(elements, _function)); | ||
173 | } | ||
174 | } | ||
175 | >>>>>>> 8ecc73c4... VAMPIRE: Rebase on Master | ||