diff options
author | 2018-01-30 01:29:00 +0100 | |
---|---|---|
committer | 2018-01-30 01:29:00 +0100 | |
commit | 2002dffe76957cbd1d45b7da5c678742053566bd (patch) | |
tree | 40b886b18a958cc9c60535277de741d6fe5c7fae /Application/hu.bme.mit.inf.dslreasoner.application/xtend-gen | |
parent | Scoping + Linking services fixed (diff) | |
download | VIATRA-Generator-2002dffe76957cbd1d45b7da5c678742053566bd.tar.gz VIATRA-Generator-2002dffe76957cbd1d45b7da5c678742053566bd.tar.zst VIATRA-Generator-2002dffe76957cbd1d45b7da5c678742053566bd.zip |
Validators refactored
Diffstat (limited to 'Application/hu.bme.mit.inf.dslreasoner.application/xtend-gen')
5 files changed, 280 insertions, 0 deletions
diff --git a/Application/hu.bme.mit.inf.dslreasoner.application/xtend-gen/hu/bme/mit/inf/dslreasoner/application/qualifiednameprovider/.gitignore b/Application/hu.bme.mit.inf.dslreasoner.application/xtend-gen/hu/bme/mit/inf/dslreasoner/application/qualifiednameprovider/.gitignore new file mode 100644 index 00000000..e581c9b2 --- /dev/null +++ b/Application/hu.bme.mit.inf.dslreasoner.application/xtend-gen/hu/bme/mit/inf/dslreasoner/application/qualifiednameprovider/.gitignore | |||
@@ -0,0 +1,2 @@ | |||
1 | /.QualifiedNameValueConverter.java._trace | ||
2 | /.ApplicationConfigurationQualifiedNameProvider.java._trace | ||
diff --git a/Application/hu.bme.mit.inf.dslreasoner.application/xtend-gen/hu/bme/mit/inf/dslreasoner/application/validation/MetamodelValidator.java b/Application/hu.bme.mit.inf.dslreasoner.application/xtend-gen/hu/bme/mit/inf/dslreasoner/application/validation/MetamodelValidator.java new file mode 100644 index 00000000..44d86022 --- /dev/null +++ b/Application/hu.bme.mit.inf.dslreasoner.application/xtend-gen/hu/bme/mit/inf/dslreasoner/application/validation/MetamodelValidator.java | |||
@@ -0,0 +1,167 @@ | |||
1 | package hu.bme.mit.inf.dslreasoner.application.validation; | ||
2 | |||
3 | import hu.bme.mit.inf.dslreasoner.ecore2logic.EcoreMetamodelDescriptor; | ||
4 | import java.util.Collections; | ||
5 | import java.util.LinkedList; | ||
6 | import java.util.List; | ||
7 | import org.eclipse.emf.common.util.EList; | ||
8 | import org.eclipse.emf.ecore.EAttribute; | ||
9 | import org.eclipse.emf.ecore.EClass; | ||
10 | import org.eclipse.emf.ecore.EDataType; | ||
11 | import org.eclipse.emf.ecore.EEnum; | ||
12 | import org.eclipse.emf.ecore.EEnumLiteral; | ||
13 | import org.eclipse.emf.ecore.EReference; | ||
14 | import org.eclipse.emf.ecore.EcorePackage; | ||
15 | import org.eclipse.xtend2.lib.StringConcatenation; | ||
16 | import org.eclipse.xtext.xbase.lib.CollectionLiterals; | ||
17 | import org.eclipse.xtext.xbase.lib.Extension; | ||
18 | |||
19 | @SuppressWarnings("all") | ||
20 | public class MetamodelValidator { | ||
21 | public LinkedList<String> validateMetamodel(final EcoreMetamodelDescriptor descriptor) { | ||
22 | final LinkedList<String> errors = new LinkedList<String>(); | ||
23 | List<EClass> _classes = descriptor.getClasses(); | ||
24 | this.allSupertypesAreIncluded(_classes, errors); | ||
25 | List<EEnum> _enums = descriptor.getEnums(); | ||
26 | List<EEnumLiteral> _literals = descriptor.getLiterals(); | ||
27 | this.allEnumTypesareIncluded(_enums, _literals, errors); | ||
28 | List<EClass> _classes_1 = descriptor.getClasses(); | ||
29 | List<EReference> _references = descriptor.getReferences(); | ||
30 | this.referenceEndpointsAreIncluded(_classes_1, _references, errors); | ||
31 | List<EClass> _classes_2 = descriptor.getClasses(); | ||
32 | List<EAttribute> _attributes = descriptor.getAttributes(); | ||
33 | this.attributeSourcePontIsIncluded(_classes_2, _attributes, errors); | ||
34 | List<EAttribute> _attributes_1 = descriptor.getAttributes(); | ||
35 | this.attributeTargetIsSupported(_attributes_1, errors); | ||
36 | return errors; | ||
37 | } | ||
38 | |||
39 | private boolean supportedEDataType(final EDataType dataType) { | ||
40 | @Extension | ||
41 | final EcorePackage l = EcorePackage.eINSTANCE; | ||
42 | EDataType _eInt = l.getEInt(); | ||
43 | EDataType _eBoolean = l.getEBoolean(); | ||
44 | EDataType _eString = l.getEString(); | ||
45 | EDataType _eDouble = l.getEDouble(); | ||
46 | EDataType _eFloat = l.getEFloat(); | ||
47 | return Collections.<EDataType>unmodifiableList(CollectionLiterals.<EDataType>newArrayList(_eInt, _eBoolean, _eString, _eDouble, _eFloat)).contains(dataType); | ||
48 | } | ||
49 | |||
50 | public void allSupertypesAreIncluded(final List<EClass> classes, final List<String> errors) { | ||
51 | for (final EClass c : classes) { | ||
52 | EList<EClass> _eSuperTypes = c.getESuperTypes(); | ||
53 | for (final EClass s : _eSuperTypes) { | ||
54 | boolean _contains = classes.contains(s); | ||
55 | boolean _not = (!_contains); | ||
56 | if (_not) { | ||
57 | StringConcatenation _builder = new StringConcatenation(); | ||
58 | _builder.append("Metamodel contains \""); | ||
59 | String _name = c.getName(); | ||
60 | _builder.append(_name, ""); | ||
61 | _builder.append("\" but not contains its supertype \""); | ||
62 | String _name_1 = s.getName(); | ||
63 | _builder.append(_name_1, ""); | ||
64 | _builder.append("\"!"); | ||
65 | errors.add(_builder.toString()); | ||
66 | } | ||
67 | } | ||
68 | } | ||
69 | } | ||
70 | |||
71 | public void allEnumTypesareIncluded(final List<EEnum> enums, final List<EEnumLiteral> literals, final List<String> errors) { | ||
72 | for (final EEnumLiteral l : literals) { | ||
73 | EEnum _eEnum = l.getEEnum(); | ||
74 | boolean _contains = enums.contains(_eEnum); | ||
75 | boolean _not = (!_contains); | ||
76 | if (_not) { | ||
77 | StringConcatenation _builder = new StringConcatenation(); | ||
78 | _builder.append("Metamodel contains literal \""); | ||
79 | String _name = l.getName(); | ||
80 | _builder.append(_name, ""); | ||
81 | _builder.append("\" but does not contains enum \""); | ||
82 | EEnum _eEnum_1 = l.getEEnum(); | ||
83 | String _name_1 = _eEnum_1.getName(); | ||
84 | _builder.append(_name_1, ""); | ||
85 | _builder.append("\"!"); | ||
86 | errors.add(_builder.toString()); | ||
87 | } | ||
88 | } | ||
89 | } | ||
90 | |||
91 | public void referenceEndpointsAreIncluded(final List<EClass> classes, final List<EReference> references, final List<String> errors) { | ||
92 | for (final EReference reference : references) { | ||
93 | { | ||
94 | final EClass src = reference.getEContainingClass(); | ||
95 | boolean _contains = classes.contains(src); | ||
96 | boolean _not = (!_contains); | ||
97 | if (_not) { | ||
98 | StringConcatenation _builder = new StringConcatenation(); | ||
99 | _builder.append("Metamodel contains reference \""); | ||
100 | String _name = reference.getName(); | ||
101 | _builder.append(_name, ""); | ||
102 | _builder.append("\" but does not contains its source type \""); | ||
103 | String _name_1 = src.getName(); | ||
104 | _builder.append(_name_1, ""); | ||
105 | _builder.append("\"!"); | ||
106 | errors.add(_builder.toString()); | ||
107 | } | ||
108 | final EClass trg = reference.getEReferenceType(); | ||
109 | boolean _contains_1 = classes.contains(trg); | ||
110 | boolean _not_1 = (!_contains_1); | ||
111 | if (_not_1) { | ||
112 | StringConcatenation _builder_1 = new StringConcatenation(); | ||
113 | _builder_1.append("Metamodel contains reference \""); | ||
114 | String _name_2 = reference.getName(); | ||
115 | _builder_1.append(_name_2, ""); | ||
116 | _builder_1.append("\" but does not contains its target type \""); | ||
117 | String _name_3 = trg.getName(); | ||
118 | _builder_1.append(_name_3, ""); | ||
119 | _builder_1.append("\"!"); | ||
120 | errors.add(_builder_1.toString()); | ||
121 | } | ||
122 | } | ||
123 | } | ||
124 | } | ||
125 | |||
126 | public void attributeSourcePontIsIncluded(final List<EClass> classes, final List<EAttribute> attributes, final List<String> errors) { | ||
127 | for (final EAttribute attribute : attributes) { | ||
128 | { | ||
129 | final Class<?> src = attribute.getContainerClass(); | ||
130 | boolean _contains = classes.contains(src); | ||
131 | boolean _not = (!_contains); | ||
132 | if (_not) { | ||
133 | StringConcatenation _builder = new StringConcatenation(); | ||
134 | _builder.append("Metamodel contains attribute \""); | ||
135 | String _name = attribute.getName(); | ||
136 | _builder.append(_name, ""); | ||
137 | _builder.append("\" but does not contains its source type \""); | ||
138 | String _name_1 = src.getName(); | ||
139 | _builder.append(_name_1, ""); | ||
140 | _builder.append("\"!"); | ||
141 | errors.add(_builder.toString()); | ||
142 | } | ||
143 | } | ||
144 | } | ||
145 | } | ||
146 | |||
147 | public void attributeTargetIsSupported(final List<EAttribute> attributes, final List<String> errors) { | ||
148 | for (final EAttribute attribute : attributes) { | ||
149 | { | ||
150 | final EDataType trg = attribute.getEAttributeType(); | ||
151 | boolean _supportedEDataType = this.supportedEDataType(trg); | ||
152 | boolean _not = (!_supportedEDataType); | ||
153 | if (_not) { | ||
154 | StringConcatenation _builder = new StringConcatenation(); | ||
155 | _builder.append("Metamodels contains attribute \""); | ||
156 | String _name = attribute.getName(); | ||
157 | _builder.append(_name, ""); | ||
158 | _builder.append("\" with unsupported type \""); | ||
159 | String _name_1 = trg.getName(); | ||
160 | _builder.append(_name_1, ""); | ||
161 | _builder.append("\"!"); | ||
162 | errors.add(_builder.toString()); | ||
163 | } | ||
164 | } | ||
165 | } | ||
166 | } | ||
167 | } | ||
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 new file mode 100644 index 00000000..1365d64d --- /dev/null +++ b/Application/hu.bme.mit.inf.dslreasoner.application/xtend-gen/hu/bme/mit/inf/dslreasoner/application/validation/QueryAndMetamodelValidator.java | |||
@@ -0,0 +1,93 @@ | |||
1 | package hu.bme.mit.inf.dslreasoner.application.validation; | ||
2 | |||
3 | import com.google.common.collect.Iterables; | ||
4 | import hu.bme.mit.inf.dslreasoner.ecore2logic.EcoreMetamodelDescriptor; | ||
5 | import hu.bme.mit.inf.dslreasoner.viatra2logic.ViatraQuerySetDescriptor; | ||
6 | import java.util.Collections; | ||
7 | import java.util.LinkedList; | ||
8 | import java.util.List; | ||
9 | import java.util.Set; | ||
10 | import org.eclipse.emf.common.util.EList; | ||
11 | import org.eclipse.emf.common.util.TreeIterator; | ||
12 | import org.eclipse.emf.ecore.EAttribute; | ||
13 | import org.eclipse.emf.ecore.EClass; | ||
14 | import org.eclipse.emf.ecore.EClassifier; | ||
15 | import org.eclipse.emf.ecore.EEnum; | ||
16 | import org.eclipse.emf.ecore.EEnumLiteral; | ||
17 | import org.eclipse.emf.ecore.ENamedElement; | ||
18 | import org.eclipse.emf.ecore.EObject; | ||
19 | import org.eclipse.emf.ecore.EReference; | ||
20 | import org.eclipse.viatra.query.patternlanguage.patternLanguage.Pattern; | ||
21 | import org.eclipse.xtend2.lib.StringConcatenation; | ||
22 | import org.eclipse.xtext.xbase.lib.CollectionLiterals; | ||
23 | import org.eclipse.xtext.xbase.lib.Functions.Function1; | ||
24 | import org.eclipse.xtext.xbase.lib.IterableExtensions; | ||
25 | import org.eclipse.xtext.xbase.lib.IteratorExtensions; | ||
26 | import org.eclipse.xtext.xbase.lib.ListExtensions; | ||
27 | import org.eclipse.xtext.xbase.lib.Pair; | ||
28 | |||
29 | @SuppressWarnings("all") | ||
30 | public class QueryAndMetamodelValidator { | ||
31 | public LinkedList<String> validateQueryAndMetamodel(final EcoreMetamodelDescriptor metamodel, final Pair<ViatraQuerySetDescriptor, Set<Pattern>> viatra) { | ||
32 | final Set<Pattern> patterns = viatra.getValue(); | ||
33 | List<EClass> _classes = metamodel.getClasses(); | ||
34 | List<EEnum> _enums = metamodel.getEnums(); | ||
35 | Iterable<EClassifier> _plus = Iterables.<EClassifier>concat(_classes, _enums); | ||
36 | List<EEnumLiteral> _literals = metamodel.getLiterals(); | ||
37 | Iterable<ENamedElement> _plus_1 = Iterables.<ENamedElement>concat(_plus, _literals); | ||
38 | List<EAttribute> _attributes = metamodel.getAttributes(); | ||
39 | Iterable<ENamedElement> _plus_2 = Iterables.<ENamedElement>concat(_plus_1, _attributes); | ||
40 | List<EReference> _references = metamodel.getReferences(); | ||
41 | Iterable<ENamedElement> _plus_3 = Iterables.<ENamedElement>concat(_plus_2, _references); | ||
42 | final Set<ENamedElement> elementsInMetamodel = IterableExtensions.<ENamedElement>toSet(_plus_3); | ||
43 | final LinkedList<String> errors = new LinkedList<String>(); | ||
44 | for (final Pattern pattern : patterns) { | ||
45 | { | ||
46 | final Iterable<ENamedElement> elements = this.getReferredNamedElements(pattern); | ||
47 | for (final ENamedElement element : elements) { | ||
48 | boolean _contains = elementsInMetamodel.contains(element); | ||
49 | boolean _not = (!_contains); | ||
50 | if (_not) { | ||
51 | StringConcatenation _builder = new StringConcatenation(); | ||
52 | _builder.append("Pattern \""); | ||
53 | String _name = pattern.getName(); | ||
54 | _builder.append(_name, ""); | ||
55 | _builder.append("\" refers to an element \""); | ||
56 | _builder.append(element, ""); | ||
57 | _builder.append("\" that is not included to the selected metamodel!"); | ||
58 | errors.add(_builder.toString()); | ||
59 | } | ||
60 | } | ||
61 | } | ||
62 | } | ||
63 | return errors; | ||
64 | } | ||
65 | |||
66 | public Iterable<ENamedElement> getReferredNamedElements(final Pattern pattern) { | ||
67 | TreeIterator<EObject> _eAllContents = pattern.eAllContents(); | ||
68 | final List<EObject> elements = IteratorExtensions.<EObject>toList(_eAllContents); | ||
69 | final Function1<EObject, Iterable<ENamedElement>> _function = (EObject element) -> { | ||
70 | EClass _eClass = element.eClass(); | ||
71 | final EList<EReference> references = _eClass.getEAllReferences(); | ||
72 | final Function1<EReference, Iterable<ENamedElement>> _function_1 = (EReference r) -> { | ||
73 | boolean _isMany = r.isMany(); | ||
74 | if (_isMany) { | ||
75 | Object _eGet = element.eGet(r); | ||
76 | return Iterables.<ENamedElement>filter(((List<?>) _eGet), ENamedElement.class); | ||
77 | } else { | ||
78 | final Object value = element.eGet(r); | ||
79 | if ((value instanceof ENamedElement)) { | ||
80 | return Collections.<ENamedElement>unmodifiableList(CollectionLiterals.<ENamedElement>newArrayList(((ENamedElement)value))); | ||
81 | } else { | ||
82 | return Collections.<ENamedElement>unmodifiableList(CollectionLiterals.<ENamedElement>newArrayList()); | ||
83 | } | ||
84 | } | ||
85 | }; | ||
86 | List<Iterable<ENamedElement>> _map = ListExtensions.<EReference, Iterable<ENamedElement>>map(references, _function_1); | ||
87 | Iterable<ENamedElement> _flatten = Iterables.<ENamedElement>concat(_map); | ||
88 | return Iterables.<ENamedElement>filter(_flatten, ENamedElement.class); | ||
89 | }; | ||
90 | List<Iterable<ENamedElement>> _map = ListExtensions.<EObject, Iterable<ENamedElement>>map(elements, _function); | ||
91 | return Iterables.<ENamedElement>concat(_map); | ||
92 | } | ||
93 | } | ||
diff --git a/Application/hu.bme.mit.inf.dslreasoner.application/xtend-gen/hu/bme/mit/inf/dslreasoner/application/valueconverter/.gitignore b/Application/hu.bme.mit.inf.dslreasoner.application/xtend-gen/hu/bme/mit/inf/dslreasoner/application/valueconverter/.gitignore new file mode 100644 index 00000000..1caf40dc --- /dev/null +++ b/Application/hu.bme.mit.inf.dslreasoner.application/xtend-gen/hu/bme/mit/inf/dslreasoner/application/valueconverter/.gitignore | |||
@@ -0,0 +1,2 @@ | |||
1 | /.QualifiedNameValueConverter.java._trace | ||
2 | /.ApplicationConfigurationValueConverterService.java._trace | ||
diff --git a/Application/hu.bme.mit.inf.dslreasoner.application/xtend-gen/hu/bme/mit/inf/dslreasoner/application/valueconverter/ApplicationConfigurationValueConverterService.java b/Application/hu.bme.mit.inf.dslreasoner.application/xtend-gen/hu/bme/mit/inf/dslreasoner/application/valueconverter/ApplicationConfigurationValueConverterService.java new file mode 100644 index 00000000..e617a132 --- /dev/null +++ b/Application/hu.bme.mit.inf.dslreasoner.application/xtend-gen/hu/bme/mit/inf/dslreasoner/application/valueconverter/ApplicationConfigurationValueConverterService.java | |||
@@ -0,0 +1,16 @@ | |||
1 | package hu.bme.mit.inf.dslreasoner.application.valueconverter; | ||
2 | |||
3 | import hu.bme.mit.inf.dslreasoner.application.valueconverter.QualifiedNameValueConverter; | ||
4 | import org.eclipse.xtext.common.services.DefaultTerminalConverters; | ||
5 | import org.eclipse.xtext.conversion.IValueConverter; | ||
6 | import org.eclipse.xtext.conversion.ValueConverter; | ||
7 | |||
8 | @SuppressWarnings("all") | ||
9 | public class ApplicationConfigurationValueConverterService extends DefaultTerminalConverters { | ||
10 | private final QualifiedNameValueConverter converter2 = new QualifiedNameValueConverter(); | ||
11 | |||
12 | @ValueConverter(rule = "QualifiedName") | ||
13 | public IValueConverter<String> QualifiedName() { | ||
14 | return this.converter2; | ||
15 | } | ||
16 | } | ||