rgen 0.4.6 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (60) hide show
  1. data/CHANGELOG +95 -83
  2. data/Rakefile +4 -3
  3. data/lib/ea_support/ea_support.rb +54 -0
  4. data/lib/ea_support/id_store.rb +32 -0
  5. data/lib/ea_support/uml13_ea_metamodel.rb +562 -0
  6. data/lib/ea_support/uml13_ea_metamodel_ext.rb +45 -0
  7. data/lib/ea_support/uml13_ea_metamodel_generator.rb +43 -0
  8. data/lib/ea_support/uml13_ea_to_uml13.rb +72 -0
  9. data/lib/ea_support/uml13_to_uml13_ea.rb +82 -0
  10. data/lib/rgen/ecore/ecore.rb +16 -2
  11. data/lib/rgen/ecore/ecore_builder_methods.rb +81 -0
  12. data/lib/rgen/ecore/ecore_instantiator.rb +5 -1
  13. data/lib/rgen/metamodel_builder/builder_extensions.rb +11 -3
  14. data/lib/rgen/metamodel_builder/module_extension2.rb +205 -0
  15. data/lib/rgen/method_delegation.rb +99 -0
  16. data/lib/rgen/model_builder.rb +27 -0
  17. data/lib/rgen/model_builder/builder_context.rb +318 -0
  18. data/lib/rgen/model_builder/model_serializer.rb +201 -0
  19. data/lib/rgen/model_builder/reference_resolver.rb +156 -0
  20. data/lib/rgen/template_language/directory_template_container.rb +6 -2
  21. data/lib/rgen/template_language/output_handler.rb +2 -4
  22. data/lib/rgen/template_language/template_container.rb +212 -195
  23. data/lib/rgen/transformer.rb +95 -4
  24. data/lib/transformers/ecore_to_uml13.rb +66 -0
  25. data/lib/transformers/uml13_to_ecore.rb +16 -7
  26. data/test/ea_instantiator_test.rb +8 -14
  27. data/test/ea_serializer_test.rb +3 -9
  28. data/test/ea_serializer_test/ea_testmodel_regenerated.xml +2 -2
  29. data/test/ea_serializer_test/ea_testmodel_regenerated_import.log +3 -0
  30. data/test/metamodel_roundtrip_test/TestModel_Regenerated.rb +19 -19
  31. data/test/metamodel_roundtrip_test/houseMetamodel_Regenerated.ecore +44 -44
  32. data/test/method_delegation_test.rb +178 -0
  33. data/test/model_builder/builder_context_test.rb +59 -0
  34. data/test/model_builder/builder_test.rb +284 -0
  35. data/test/model_builder/ecore_internal.rb +103 -0
  36. data/test/model_builder/ecore_original.rb +163 -0
  37. data/test/model_builder/ecore_original_regenerated.rb +163 -0
  38. data/test/model_builder/reference_resolver_test.rb +156 -0
  39. data/test/model_builder/serializer_test.rb +63 -0
  40. data/test/model_builder_test.rb +4 -0
  41. data/test/rgen_test.rb +2 -0
  42. data/test/template_language_test.rb +41 -1
  43. data/test/template_language_test/expected_result1.txt +1 -3
  44. data/test/template_language_test/templates/define_local_test/local.tpl +8 -0
  45. data/test/template_language_test/templates/define_local_test/test.tpl +8 -0
  46. data/test/template_language_test/templates/evaluate_test/test.tpl +7 -0
  47. data/test/template_language_test/templates/no_indent_test/no_indent.tpl +3 -0
  48. data/test/template_language_test/templates/no_indent_test/sub1/no_indent.tpl +3 -0
  49. data/test/template_language_test/templates/no_indent_test/test.tpl +24 -0
  50. data/test/template_language_test/templates/no_indent_test/test2.tpl +13 -0
  51. data/test/template_language_test/templates/no_indent_test/test3.tpl +10 -0
  52. data/test/template_language_test/templates/template_resolution_test/sub1.tpl +9 -0
  53. data/test/template_language_test/templates/template_resolution_test/sub1/sub1.tpl +3 -0
  54. data/test/template_language_test/templates/template_resolution_test/test.tpl +4 -0
  55. data/test/template_language_test/testout.txt +1 -3
  56. data/test/testmodel/ea_testmodel_import.log +1 -0
  57. data/test/testmodel/ea_testmodel_regenerated.xml +808 -0
  58. data/test/transformer_test.rb +3 -5
  59. metadata +52 -3
  60. data/lib/instantiators/ea_instantiator.rb +0 -39
@@ -0,0 +1,103 @@
1
+ ePackage "ECore", :eSuperPackage => "" do
2
+ eClass "EObject", :abstract => false, :interface => false, :eSubTypes => ["EAnnotation"], :instanceClassName => "RGen::ECore::EObject"
3
+ eClass "EAttribute", :abstract => false, :interface => false, :eSuperTypes => ["EStructuralFeature"], :instanceClassName => "RGen::ECore::EAttribute" do
4
+ eAttribute "iD", :defaultValueLiteral => "false", :eType => ""
5
+ eReference "eAttributeType", :changeable => false, :derived => true, :transient => true, :volatile => true, :lowerBound => 1, :eType => "EDataType"
6
+ end
7
+ eClass "EReference", :abstract => false, :interface => false, :eSuperTypes => ["EStructuralFeature"], :instanceClassName => "RGen::ECore::EReference" do
8
+ eAttribute "container", :changeable => false, :derived => true, :transient => true, :volatile => true, :eType => ""
9
+ eAttribute "containment", :defaultValueLiteral => "false", :eType => ""
10
+ eAttribute "resolveProxies", :defaultValueLiteral => "true", :eType => ""
11
+ eReference "eOpposite", :eType => "EReference"
12
+ eReference "eReferenceType", :changeable => false, :derived => true, :transient => true, :volatile => true, :lowerBound => 1, :eType => "EClass"
13
+ end
14
+ eClass "EStructuralFeature", :abstract => false, :interface => false, :eSuperTypes => ["ETypedElement"], :instanceClassName => "RGen::ECore::EStructuralFeature" do
15
+ eAttribute "changeable", :defaultValueLiteral => "true", :eType => ""
16
+ eAttribute "defaultValue", :changeable => false, :derived => true, :transient => true, :volatile => true, :eType => ""
17
+ eAttribute "defaultValueLiteral", :eType => ""
18
+ eAttribute "derived", :defaultValueLiteral => "false", :eType => ""
19
+ eAttribute "transient", :defaultValueLiteral => "false", :eType => ""
20
+ eAttribute "unsettable", :defaultValueLiteral => "false", :eType => ""
21
+ eAttribute "volatile", :defaultValueLiteral => "false", :eType => ""
22
+ eReference "eContainingClass", :eOpposite => "EClass.eStructuralFeatures", :eType => "EClass"
23
+ end
24
+ eClass "EFactory", :abstract => false, :interface => false, :eSuperTypes => ["EModelElement"], :instanceClassName => "RGen::ECore::EFactory" do
25
+ eReference "ePackage", :resolveProxies => false, :eOpposite => "EPackage.eFactoryInstance", :transient => true, :lowerBound => 1, :eType => "EPackage"
26
+ end
27
+ eClass "ENamedElement", :abstract => false, :interface => false, :eSuperTypes => ["EModelElement"], :eSubTypes => ["EEnumLiteral", "EPackage", "ETypedElement"], :instanceClassName => "RGen::ECore::ENamedElement" do
28
+ eAttribute "name", :eType => ""
29
+ end
30
+ eClass "EEnum", :abstract => false, :interface => false, :eSuperTypes => ["EDataType"], :instanceClassName => "RGen::ECore::EEnum" do
31
+ eReference "eLiterals", :containment => true, :resolveProxies => false, :eOpposite => "EEnumLiteral.eEnum", :upperBound => -1, :eType => "EEnumLiteral"
32
+ end
33
+ eClass "EParameter", :abstract => false, :interface => false, :eSuperTypes => ["ETypedElement"], :instanceClassName => "RGen::ECore::EParameter" do
34
+ eReference "eOperation", :eOpposite => "EOperation.eParameters", :eType => "EOperation"
35
+ end
36
+ eClass "EEnumLiteral", :abstract => false, :interface => false, :instanceClassName => "RGen::ECore::EEnumLiteral" do
37
+ eAttribute "literal", :eType => ""
38
+ eAttribute "value", :eType => ""
39
+ eReference "eEnum", :eOpposite => "EEnum.eLiterals", :eType => "EEnum"
40
+ end
41
+ eClass "EAnnotation", :abstract => false, :interface => false, :eSuperTypes => ["EModelElement"], :instanceClassName => "RGen::ECore::EAnnotation" do
42
+ eAttribute "source", :eType => ""
43
+ eReference "eModelElement", :eOpposite => "EModelElement.eAnnotations", :eType => "EModelElement"
44
+ eReference "details", :containment => true, :resolveProxies => false, :upperBound => -1, :eType => "EStringToStringMapEntry"
45
+ eReference "contents", :containment => true, :resolveProxies => false, :upperBound => -1, :eType => "EObject"
46
+ eReference "references", :upperBound => -1, :eType => "EObject"
47
+ end
48
+ eClass "EClass", :abstract => false, :interface => false, :eSuperTypes => ["EClassifier"], :instanceClassName => "RGen::ECore::EClass" do
49
+ eAttribute "abstract", :eType => ""
50
+ eAttribute "interface", :eType => ""
51
+ eReference "eIDAttribute", :resolveProxies => false, :changeable => false, :derived => true, :transient => true, :volatile => true, :eType => "EAttribute"
52
+ eReference "eAllAttributes", :changeable => false, :derived => true, :transient => true, :volatile => true, :upperBound => -1, :eType => "EAttribute"
53
+ eReference "eAllContainments", :changeable => false, :derived => true, :transient => true, :volatile => true, :upperBound => -1, :eType => "EReference"
54
+ eReference "eAllOperations", :changeable => false, :derived => true, :transient => true, :volatile => true, :upperBound => -1, :eType => "EOperation"
55
+ eReference "eAllReferences", :changeable => false, :derived => true, :transient => true, :volatile => true, :upperBound => -1, :eType => "EReference"
56
+ eReference "eAllStructuralFeatures", :changeable => false, :derived => true, :transient => true, :volatile => true, :upperBound => -1, :eType => "EStructuralFeature"
57
+ eReference "eAllSuperTypes", :changeable => false, :derived => true, :transient => true, :volatile => true, :upperBound => -1, :eType => "EClass"
58
+ eReference "eAttributes", :changeable => false, :derived => true, :transient => true, :volatile => true, :upperBound => -1, :eType => "EAttribute"
59
+ eReference "eReferences", :changeable => false, :derived => true, :transient => true, :volatile => true, :upperBound => -1, :eType => "EReference"
60
+ eReference "eOperations", :containment => true, :resolveProxies => false, :eOpposite => "EOperation.eContainingClass", :upperBound => -1, :eType => "EOperation"
61
+ eReference "eStructuralFeatures", :containment => true, :resolveProxies => false, :eOpposite => "EStructuralFeature.eContainingClass", :upperBound => -1, :eType => "EStructuralFeature"
62
+ eReference "eSuperTypes", :eOpposite => "eSubTypes", :upperBound => -1, :eType => "EClass"
63
+ eReference "eSubTypes", :eOpposite => "eSuperTypes", :upperBound => -1, :eType => "EClass"
64
+ end
65
+ eClass "EPackage", :abstract => false, :interface => false, :instanceClassName => "RGen::ECore::EPackage" do
66
+ eAttribute "nsPrefix", :eType => ""
67
+ eAttribute "nsURI", :eType => ""
68
+ eReference "eClassifiers", :containment => true, :eOpposite => "EClassifier.ePackage", :upperBound => -1, :eType => "EClassifier"
69
+ eReference "eSubpackages", :containment => true, :eOpposite => "eSuperPackage", :upperBound => -1, :eType => "EPackage"
70
+ eReference "eSuperPackage", :eOpposite => "eSubpackages", :eType => "EPackage"
71
+ eReference "eFactoryInstance", :eOpposite => "EFactory.ePackage", :eType => "EFactory"
72
+ end
73
+ eClass "EDataType", :abstract => false, :interface => false, :instanceClassName => "RGen::ECore::EDataType" do
74
+ eAttribute "serializable", :eType => ""
75
+ end
76
+ eClass "EModelElement", :abstract => false, :interface => false, :instanceClassName => "RGen::ECore::EModelElement" do
77
+ eReference "eAnnotations", :containment => true, :resolveProxies => false, :eOpposite => "EAnnotation.eModelElement", :upperBound => -1, :eType => "EAnnotation"
78
+ end
79
+ eClass "EClassifier", :abstract => false, :interface => false, :eSuperTypes => ["ENamedElement"], :eSubTypes => ["EDataType"], :instanceClassName => "RGen::ECore::EClassifier" do
80
+ eAttribute "defaultValue", :changeable => false, :derived => true, :transient => true, :volatile => true, :eType => ""
81
+ eAttribute "instanceClass", :changeable => false, :derived => true, :transient => true, :volatile => true, :eType => ""
82
+ eAttribute "instanceClassName", :eType => ""
83
+ eReference "ePackage", :eOpposite => "EPackage.eClassifiers", :eType => "EPackage"
84
+ end
85
+ eClass "EStringToStringMapEntry", :abstract => false, :interface => false, :instanceClassName => "RGen::ECore::EStringToStringMapEntry" do
86
+ eAttribute "key", :eType => ""
87
+ eAttribute "value", :eType => ""
88
+ end
89
+ eClass "EOperation", :abstract => false, :interface => false, :eSuperTypes => ["ETypedElement"], :instanceClassName => "RGen::ECore::EOperation" do
90
+ eReference "eContainingClass", :eOpposite => "EClass.eOperations", :eType => "EClass"
91
+ eReference "eParameters", :containment => true, :resolveProxies => false, :eOpposite => "EParameter.eOperation", :upperBound => -1, :eType => "EParameter"
92
+ eReference "eExceptions", :upperBound => -1, :eType => "EClassifier"
93
+ end
94
+ eClass "ETypedElement", :abstract => false, :interface => false, :instanceClassName => "RGen::ECore::ETypedElement" do
95
+ eAttribute "lowerBound", :defaultValueLiteral => "0", :eType => ""
96
+ eAttribute "ordered", :defaultValueLiteral => "true", :eType => ""
97
+ eAttribute "unique", :defaultValueLiteral => "true", :eType => ""
98
+ eAttribute "upperBound", :defaultValueLiteral => "1", :eType => ""
99
+ eAttribute "many", :changeable => false, :derived => true, :transient => true, :volatile => true, :eType => ""
100
+ eAttribute "required", :changeable => false, :derived => true, :transient => true, :volatile => true, :eType => ""
101
+ eReference "eType", :eType => "EClassifier"
102
+ end
103
+ end
@@ -0,0 +1,163 @@
1
+ ePackage "ecore", :nsPrefix => "ecore", :nsURI => "http://www.eclipse.org/emf/2002/Ecore" do
2
+ eClass "EAttribute", :eSuperTypes => ["EStructuralFeature"] do
3
+ eAttribute "iD"
4
+ eReference "eAttributeType", :changeable => false, :derived => true, :transient => true, :volatile => true, :lowerBound => 1, :eType => "EDataType"
5
+ end
6
+ eClass "EAnnotation", :eSuperTypes => ["EModelElement"] do
7
+ eAttribute "source"
8
+ eReference "details", :containment => true, :resolveProxies => false, :upperBound => -1, :eType => "EStringToStringMapEntry"
9
+ eReference "eModelElement", :resolveProxies => false, :eOpposite => "EModelElement.eAnnotations", :transient => true, :eType => "EModelElement"
10
+ eReference "contents", :containment => true, :resolveProxies => false, :upperBound => -1, :eType => "EObject"
11
+ eReference "references", :upperBound => -1, :eType => "EObject"
12
+ end
13
+ eClass "EClass", :eSuperTypes => ["EClassifier"] do
14
+ eAttribute "abstract"
15
+ eAttribute "interface"
16
+ eReference "eSuperTypes", :unsettable => true, :upperBound => -1, :eType => "EClass"
17
+ eReference "eOperations", :containment => true, :resolveProxies => false, :eOpposite => "EOperation.eContainingClass", :upperBound => -1, :eType => "EOperation"
18
+ eReference "eAllAttributes", :changeable => false, :derived => true, :transient => true, :volatile => true, :upperBound => -1, :eType => "EAttribute"
19
+ eReference "eAllReferences", :changeable => false, :derived => true, :transient => true, :volatile => true, :upperBound => -1, :eType => "EReference"
20
+ eReference "eReferences", :changeable => false, :derived => true, :transient => true, :volatile => true, :upperBound => -1, :eType => "EReference"
21
+ eReference "eAttributes", :changeable => false, :derived => true, :transient => true, :volatile => true, :upperBound => -1, :eType => "EAttribute"
22
+ eReference "eAllContainments", :changeable => false, :derived => true, :transient => true, :volatile => true, :upperBound => -1, :eType => "EReference"
23
+ eReference "eAllOperations", :changeable => false, :derived => true, :transient => true, :volatile => true, :upperBound => -1, :eType => "EOperation"
24
+ eReference "eAllStructuralFeatures", :changeable => false, :derived => true, :transient => true, :volatile => true, :upperBound => -1, :eType => "EStructuralFeature"
25
+ eReference "eAllSuperTypes", :changeable => false, :derived => true, :transient => true, :volatile => true, :upperBound => -1, :eType => "EClass"
26
+ eReference "eIDAttribute", :resolveProxies => false, :changeable => false, :derived => true, :transient => true, :volatile => true, :eType => "EAttribute"
27
+ eReference "eStructuralFeatures", :containment => true, :resolveProxies => false, :eOpposite => "EStructuralFeature.eContainingClass", :upperBound => -1, :eType => "EStructuralFeature"
28
+ eReference "eGenericSuperTypes", :containment => true, :resolveProxies => false, :unsettable => true, :upperBound => -1, :eType => "EGenericType"
29
+ eReference "eAllGenericSuperTypes", :changeable => false, :derived => true, :transient => true, :volatile => true, :upperBound => -1, :eType => "EGenericType"
30
+ end
31
+ eClass "EClassifier", :abstract => true, :eSuperTypes => ["ENamedElement"], :eSubTypes => ["EClass", "EDataType"] do
32
+ eAttribute "instanceClassName", :unsettable => true, :volatile => true
33
+ eAttribute "instanceClass", :changeable => false, :derived => true, :transient => true, :volatile => true
34
+ eAttribute "defaultValue", :changeable => false, :derived => true, :transient => true, :volatile => true, :eType => "EJavaObject"
35
+ eAttribute "instanceTypeName", :unsettable => true, :volatile => true
36
+ eReference "ePackage", :eOpposite => "EPackage.eClassifiers", :changeable => false, :transient => true, :eType => "EPackage"
37
+ eReference "eTypeParameters", :containment => true, :upperBound => -1, :eType => "ETypeParameter"
38
+ end
39
+ eClass "EDataType", :eSuperTypes => ["EClassifier"], :eSubTypes => ["EEnum"] do
40
+ eAttribute "serializable", :defaultValueLiteral => "true"
41
+ end
42
+ eClass "EEnum", :eSuperTypes => ["EDataType"] do
43
+ eReference "eLiterals", :containment => true, :resolveProxies => false, :eOpposite => "EEnumLiteral.eEnum", :upperBound => -1, :eType => "EEnumLiteral"
44
+ end
45
+ eClass "EEnumLiteral", :eSuperTypes => ["ENamedElement"] do
46
+ eAttribute "value"
47
+ eAttribute "instance", :transient => true, :eType => "EEnumerator"
48
+ eAttribute "literal"
49
+ eReference "eEnum", :resolveProxies => false, :eOpposite => "EEnum.eLiterals", :changeable => false, :transient => true, :eType => "EEnum"
50
+ end
51
+ eClass "EFactory", :eSuperTypes => ["EModelElement"] do
52
+ eReference "ePackage", :resolveProxies => false, :eOpposite => "EPackage.eFactoryInstance", :transient => true, :lowerBound => 1, :eType => "EPackage"
53
+ end
54
+ eClass "EModelElement", :abstract => true, :eSuperTypes => ["EObject"], :eSubTypes => ["EAnnotation", "EFactory", "ENamedElement"] do
55
+ eReference "eAnnotations", :containment => true, :resolveProxies => false, :eOpposite => "EAnnotation.eModelElement", :upperBound => -1, :eType => "EAnnotation"
56
+ end
57
+ eClass "ENamedElement", :abstract => true, :eSuperTypes => ["EModelElement"], :eSubTypes => ["EClassifier", "EEnumLiteral", "EPackage", "ETypedElement", "ETypeParameter"] do
58
+ eAttribute "name"
59
+ end
60
+ eClass "EObject", :eSubTypes => ["EModelElement", "EGenericType"]
61
+ eClass "EOperation", :eSuperTypes => ["ETypedElement"] do
62
+ eReference "eContainingClass", :resolveProxies => false, :eOpposite => "EClass.eOperations", :changeable => false, :transient => true, :eType => "EClass"
63
+ eReference "eTypeParameters", :containment => true, :upperBound => -1, :eType => "ETypeParameter"
64
+ eReference "eParameters", :containment => true, :resolveProxies => false, :eOpposite => "EParameter.eOperation", :upperBound => -1, :eType => "EParameter"
65
+ eReference "eExceptions", :unsettable => true, :upperBound => -1, :eType => "EClassifier"
66
+ eReference "eGenericExceptions", :containment => true, :resolveProxies => false, :unsettable => true, :upperBound => -1, :eType => "EGenericType"
67
+ end
68
+ eClass "EPackage", :eSuperTypes => ["ENamedElement"] do
69
+ eAttribute "nsURI"
70
+ eAttribute "nsPrefix"
71
+ eReference "eFactoryInstance", :resolveProxies => false, :eOpposite => "EFactory.ePackage", :transient => true, :lowerBound => 1, :eType => "EFactory"
72
+ eReference "eClassifiers", :containment => true, :eOpposite => "EClassifier.ePackage", :upperBound => -1, :eType => "EClassifier"
73
+ eReference "eSubpackages", :containment => true, :eOpposite => "eSuperPackage", :upperBound => -1, :eType => "EPackage"
74
+ eReference "eSuperPackage", :eOpposite => "eSubpackages", :changeable => false, :transient => true, :eType => "EPackage"
75
+ end
76
+ eClass "EParameter", :eSuperTypes => ["ETypedElement"] do
77
+ eReference "eOperation", :resolveProxies => false, :eOpposite => "EOperation.eParameters", :changeable => false, :transient => true, :eType => "EOperation"
78
+ end
79
+ eClass "EReference", :eSuperTypes => ["EStructuralFeature"] do
80
+ eAttribute "containment"
81
+ eAttribute "container", :changeable => false, :derived => true, :transient => true, :volatile => true
82
+ eAttribute "resolveProxies", :defaultValueLiteral => "true"
83
+ eReference "eOpposite", :eType => "EReference"
84
+ eReference "eReferenceType", :changeable => false, :derived => true, :transient => true, :volatile => true, :lowerBound => 1, :eType => "EClass"
85
+ eReference "eKeys", :upperBound => -1, :eType => "EAttribute"
86
+ end
87
+ eClass "EStructuralFeature", :abstract => true, :eSuperTypes => ["ETypedElement"], :eSubTypes => ["EAttribute", "EReference"] do
88
+ eAttribute "changeable", :defaultValueLiteral => "true"
89
+ eAttribute "volatile"
90
+ eAttribute "transient"
91
+ eAttribute "defaultValueLiteral"
92
+ eAttribute "defaultValue", :changeable => false, :derived => true, :transient => true, :volatile => true, :eType => "EJavaObject"
93
+ eAttribute "unsettable"
94
+ eAttribute "derived"
95
+ eReference "eContainingClass", :resolveProxies => false, :eOpposite => "EClass.eStructuralFeatures", :changeable => false, :transient => true, :eType => "EClass"
96
+ end
97
+ eClass "ETypedElement", :abstract => true, :eSuperTypes => ["ENamedElement"], :eSubTypes => ["EOperation", "EParameter", "EStructuralFeature"] do
98
+ eAttribute "ordered", :defaultValueLiteral => "true"
99
+ eAttribute "unique", :defaultValueLiteral => "true"
100
+ eAttribute "lowerBound"
101
+ eAttribute "upperBound", :defaultValueLiteral => "1"
102
+ eAttribute "many", :changeable => false, :derived => true, :transient => true, :volatile => true
103
+ eAttribute "required", :changeable => false, :derived => true, :transient => true, :volatile => true
104
+ eReference "eType", :unsettable => true, :volatile => true, :eType => "EClassifier"
105
+ eReference "eGenericType", :containment => true, :resolveProxies => false, :unsettable => true, :volatile => true, :eType => "EGenericType"
106
+ end
107
+ eDataType "EBigDecimal", :instanceClassName => "java.math.BigDecimal"
108
+ eDataType "EBigInteger", :instanceClassName => "java.math.BigInteger"
109
+ eDataType "EBoolean", :instanceClassName => "boolean"
110
+ eDataType "EBooleanObject", :instanceClassName => "java.lang.Boolean"
111
+ eDataType "EByte", :instanceClassName => "byte"
112
+ eDataType "EByteArray", :instanceClassName => "byte[]"
113
+ eDataType "EByteObject", :instanceClassName => "java.lang.Byte"
114
+ eDataType "EChar", :instanceClassName => "char"
115
+ eDataType "ECharacterObject", :instanceClassName => "java.lang.Character"
116
+ eDataType "EDate", :instanceClassName => "java.util.Date"
117
+ eDataType "EDiagnosticChain", :serializable => false, :instanceClassName => "org.eclipse.emf.common.util.DiagnosticChain"
118
+ eDataType "EDouble", :instanceClassName => "double"
119
+ eDataType "EDoubleObject", :instanceClassName => "java.lang.Double"
120
+ eDataType "EEList", :serializable => false, :instanceClassName => "org.eclipse.emf.common.util.EList" do
121
+ eTypeParameter "E"
122
+ end
123
+ eDataType "EEnumerator", :serializable => false, :instanceClassName => "org.eclipse.emf.common.util.Enumerator"
124
+ eDataType "EFeatureMap", :serializable => false, :instanceClassName => "org.eclipse.emf.ecore.util.FeatureMap"
125
+ eDataType "EFeatureMapEntry", :serializable => false, :instanceClassName => "org.eclipse.emf.ecore.util.FeatureMap$Entry"
126
+ eDataType "EFloat", :instanceClassName => "float"
127
+ eDataType "EFloatObject", :instanceClassName => "java.lang.Float"
128
+ eDataType "EInt", :instanceClassName => "int"
129
+ eDataType "EIntegerObject", :instanceClassName => "java.lang.Integer"
130
+ eDataType "EJavaClass", :instanceClassName => "java.lang.Class" do
131
+ eTypeParameter "T"
132
+ end
133
+ eDataType "EJavaObject", :instanceClassName => "java.lang.Object"
134
+ eDataType "ELong", :instanceClassName => "long"
135
+ eDataType "ELongObject", :instanceClassName => "java.lang.Long"
136
+ eDataType "EMap", :serializable => false, :instanceClassName => "java.util.Map" do
137
+ eTypeParameter "K"
138
+ eTypeParameter "V"
139
+ end
140
+ eDataType "EResource", :serializable => false, :instanceClassName => "org.eclipse.emf.ecore.resource.Resource"
141
+ eDataType "EResourceSet", :serializable => false, :instanceClassName => "org.eclipse.emf.ecore.resource.ResourceSet"
142
+ eDataType "EShort", :instanceClassName => "short"
143
+ eDataType "EShortObject", :instanceClassName => "java.lang.Short"
144
+ eDataType "EString", :instanceClassName => "java.lang.String"
145
+ eClass "EStringToStringMapEntry", :instanceClassName => "java.util.Map$Entry" do
146
+ eAttribute "key"
147
+ eAttribute "value"
148
+ end
149
+ eDataType "ETreeIterator", :serializable => false, :instanceClassName => "org.eclipse.emf.common.util.TreeIterator" do
150
+ eTypeParameter "E"
151
+ end
152
+ eClass "EGenericType", :eSuperTypes => ["EObject"] do
153
+ eReference "eUpperBound", :containment => true, :resolveProxies => false, :eType => "EGenericType"
154
+ eReference "eTypeArguments", :containment => true, :resolveProxies => false, :upperBound => -1, :eType => "EGenericType"
155
+ eReference "eRawType", :changeable => false, :derived => true, :transient => true, :lowerBound => 1, :eType => "EClassifier"
156
+ eReference "eLowerBound", :containment => true, :resolveProxies => false, :eType => "EGenericType"
157
+ eReference "eTypeParameter", :resolveProxies => false, :eType => "ETypeParameter"
158
+ eReference "eClassifier", :eType => "EClassifier"
159
+ end
160
+ eClass "ETypeParameter", :eSuperTypes => ["ENamedElement"] do
161
+ eReference "eBounds", :containment => true, :resolveProxies => false, :upperBound => -1, :eType => "EGenericType"
162
+ end
163
+ end
@@ -0,0 +1,163 @@
1
+ ePackage "ecore", :nsPrefix => "ecore", :nsURI => "http://www.eclipse.org/emf/2002/Ecore" do
2
+ eClass "EAttribute" do
3
+ eAttribute "iD"
4
+ eReference "eAttributeType", :changeable => false, :derived => true, :transient => true, :volatile => true, :lowerBound => 1
5
+ end
6
+ eClass "EAnnotation" do
7
+ eAttribute "source"
8
+ eReference "details", :containment => true, :resolveProxies => false, :upperBound => -1
9
+ eReference "eModelElement", :resolveProxies => false, :transient => true
10
+ eReference "contents", :containment => true, :resolveProxies => false, :upperBound => -1
11
+ eReference "references", :upperBound => -1
12
+ end
13
+ eClass "EClass" do
14
+ eAttribute "abstract"
15
+ eAttribute "interface"
16
+ eReference "eSuperTypes", :unsettable => true, :upperBound => -1
17
+ eReference "eOperations", :containment => true, :resolveProxies => false, :upperBound => -1
18
+ eReference "eAllAttributes", :changeable => false, :derived => true, :transient => true, :volatile => true, :upperBound => -1
19
+ eReference "eAllReferences", :changeable => false, :derived => true, :transient => true, :volatile => true, :upperBound => -1
20
+ eReference "eReferences", :changeable => false, :derived => true, :transient => true, :volatile => true, :upperBound => -1
21
+ eReference "eAttributes", :changeable => false, :derived => true, :transient => true, :volatile => true, :upperBound => -1
22
+ eReference "eAllContainments", :changeable => false, :derived => true, :transient => true, :volatile => true, :upperBound => -1
23
+ eReference "eAllOperations", :changeable => false, :derived => true, :transient => true, :volatile => true, :upperBound => -1
24
+ eReference "eAllStructuralFeatures", :changeable => false, :derived => true, :transient => true, :volatile => true, :upperBound => -1
25
+ eReference "eAllSuperTypes", :changeable => false, :derived => true, :transient => true, :volatile => true, :upperBound => -1
26
+ eReference "eIDAttribute", :resolveProxies => false, :changeable => false, :derived => true, :transient => true, :volatile => true
27
+ eReference "eStructuralFeatures", :containment => true, :resolveProxies => false, :upperBound => -1
28
+ eReference "eGenericSuperTypes", :containment => true, :resolveProxies => false, :unsettable => true, :upperBound => -1
29
+ eReference "eAllGenericSuperTypes", :changeable => false, :derived => true, :transient => true, :volatile => true, :upperBound => -1
30
+ end
31
+ eClass "EClassifier", :abstract => true do
32
+ eAttribute "instanceClassName", :unsettable => true, :volatile => true
33
+ eAttribute "instanceClass", :changeable => false, :derived => true, :transient => true, :volatile => true
34
+ eAttribute "defaultValue", :changeable => false, :derived => true, :transient => true, :volatile => true
35
+ eAttribute "instanceTypeName", :unsettable => true, :volatile => true
36
+ eReference "ePackage", :changeable => false, :transient => true
37
+ eReference "eTypeParameters", :containment => true, :upperBound => -1
38
+ end
39
+ eClass "EDataType" do
40
+ eAttribute "serializable", :defaultValueLiteral => "true"
41
+ end
42
+ eClass "EEnum" do
43
+ eReference "eLiterals", :containment => true, :resolveProxies => false, :upperBound => -1
44
+ end
45
+ eClass "EEnumLiteral" do
46
+ eAttribute "value"
47
+ eAttribute "instance", :transient => true
48
+ eAttribute "literal"
49
+ eReference "eEnum", :resolveProxies => false, :changeable => false, :transient => true
50
+ end
51
+ eClass "EFactory" do
52
+ eReference "ePackage", :resolveProxies => false, :transient => true, :lowerBound => 1
53
+ end
54
+ eClass "EModelElement", :abstract => true do
55
+ eReference "eAnnotations", :containment => true, :resolveProxies => false, :upperBound => -1
56
+ end
57
+ eClass "ENamedElement", :abstract => true do
58
+ eAttribute "name"
59
+ end
60
+ eClass "EObject"
61
+ eClass "EOperation" do
62
+ eReference "eContainingClass", :resolveProxies => false, :changeable => false, :transient => true
63
+ eReference "eTypeParameters", :containment => true, :upperBound => -1
64
+ eReference "eParameters", :containment => true, :resolveProxies => false, :upperBound => -1
65
+ eReference "eExceptions", :unsettable => true, :upperBound => -1
66
+ eReference "eGenericExceptions", :containment => true, :resolveProxies => false, :unsettable => true, :upperBound => -1
67
+ end
68
+ eClass "EPackage" do
69
+ eAttribute "nsURI"
70
+ eAttribute "nsPrefix"
71
+ eReference "eFactoryInstance", :resolveProxies => false, :transient => true, :lowerBound => 1
72
+ eReference "eClassifiers", :containment => true, :upperBound => -1
73
+ eReference "eSubpackages", :containment => true, :upperBound => -1
74
+ eReference "eSuperPackage", :changeable => false, :transient => true
75
+ end
76
+ eClass "EParameter" do
77
+ eReference "eOperation", :resolveProxies => false, :changeable => false, :transient => true
78
+ end
79
+ eClass "EReference" do
80
+ eAttribute "containment"
81
+ eAttribute "container", :changeable => false, :derived => true, :transient => true, :volatile => true
82
+ eAttribute "resolveProxies", :defaultValueLiteral => "true"
83
+ eReference "eOpposite"
84
+ eReference "eReferenceType", :changeable => false, :derived => true, :transient => true, :volatile => true, :lowerBound => 1
85
+ eReference "eKeys", :upperBound => -1
86
+ end
87
+ eClass "EStructuralFeature", :abstract => true do
88
+ eAttribute "changeable", :defaultValueLiteral => "true"
89
+ eAttribute "volatile"
90
+ eAttribute "transient"
91
+ eAttribute "defaultValueLiteral"
92
+ eAttribute "defaultValue", :changeable => false, :derived => true, :transient => true, :volatile => true
93
+ eAttribute "unsettable"
94
+ eAttribute "derived"
95
+ eReference "eContainingClass", :resolveProxies => false, :changeable => false, :transient => true
96
+ end
97
+ eClass "ETypedElement", :abstract => true do
98
+ eAttribute "ordered", :defaultValueLiteral => "true"
99
+ eAttribute "unique", :defaultValueLiteral => "true"
100
+ eAttribute "lowerBound"
101
+ eAttribute "upperBound", :defaultValueLiteral => "1"
102
+ eAttribute "many", :changeable => false, :derived => true, :transient => true, :volatile => true
103
+ eAttribute "required", :changeable => false, :derived => true, :transient => true, :volatile => true
104
+ eReference "eType", :unsettable => true, :volatile => true
105
+ eReference "eGenericType", :containment => true, :resolveProxies => false, :unsettable => true, :volatile => true
106
+ end
107
+ eDataType "EBigDecimal", :instanceClassName => "java.math.BigDecimal"
108
+ eDataType "EBigInteger", :instanceClassName => "java.math.BigInteger"
109
+ eDataType "EBoolean", :instanceClassName => "boolean"
110
+ eDataType "EBooleanObject", :instanceClassName => "java.lang.Boolean"
111
+ eDataType "EByte", :instanceClassName => "byte"
112
+ eDataType "EByteArray", :instanceClassName => "byte[]"
113
+ eDataType "EByteObject", :instanceClassName => "java.lang.Byte"
114
+ eDataType "EChar", :instanceClassName => "char"
115
+ eDataType "ECharacterObject", :instanceClassName => "java.lang.Character"
116
+ eDataType "EDate", :instanceClassName => "java.util.Date"
117
+ eDataType "EDiagnosticChain", :serializable => false, :instanceClassName => "org.eclipse.emf.common.util.DiagnosticChain"
118
+ eDataType "EDouble", :instanceClassName => "double"
119
+ eDataType "EDoubleObject", :instanceClassName => "java.lang.Double"
120
+ eDataType "EEList", :serializable => false, :instanceClassName => "org.eclipse.emf.common.util.EList" do
121
+ eTypeParameter "E"
122
+ end
123
+ eDataType "EEnumerator", :serializable => false, :instanceClassName => "org.eclipse.emf.common.util.Enumerator"
124
+ eDataType "EFeatureMap", :serializable => false, :instanceClassName => "org.eclipse.emf.ecore.util.FeatureMap"
125
+ eDataType "EFeatureMapEntry", :serializable => false, :instanceClassName => "org.eclipse.emf.ecore.util.FeatureMap$Entry"
126
+ eDataType "EFloat", :instanceClassName => "float"
127
+ eDataType "EFloatObject", :instanceClassName => "java.lang.Float"
128
+ eDataType "EInt", :instanceClassName => "int"
129
+ eDataType "EIntegerObject", :instanceClassName => "java.lang.Integer"
130
+ eDataType "EJavaClass", :instanceClassName => "java.lang.Class" do
131
+ eTypeParameter "T"
132
+ end
133
+ eDataType "EJavaObject", :instanceClassName => "java.lang.Object"
134
+ eDataType "ELong", :instanceClassName => "long"
135
+ eDataType "ELongObject", :instanceClassName => "java.lang.Long"
136
+ eDataType "EMap", :serializable => false, :instanceClassName => "java.util.Map" do
137
+ eTypeParameter "K"
138
+ eTypeParameter "V"
139
+ end
140
+ eDataType "EResource", :serializable => false, :instanceClassName => "org.eclipse.emf.ecore.resource.Resource"
141
+ eDataType "EResourceSet", :serializable => false, :instanceClassName => "org.eclipse.emf.ecore.resource.ResourceSet"
142
+ eDataType "EShort", :instanceClassName => "short"
143
+ eDataType "EShortObject", :instanceClassName => "java.lang.Short"
144
+ eDataType "EString", :instanceClassName => "java.lang.String"
145
+ eClass "EStringToStringMapEntry", :instanceClassName => "java.util.Map$Entry" do
146
+ eAttribute "key"
147
+ eAttribute "value"
148
+ end
149
+ eDataType "ETreeIterator", :serializable => false, :instanceClassName => "org.eclipse.emf.common.util.TreeIterator" do
150
+ eTypeParameter "E"
151
+ end
152
+ eClass "EGenericType" do
153
+ eReference "eUpperBound", :containment => true, :resolveProxies => false
154
+ eReference "eTypeArguments", :containment => true, :resolveProxies => false, :upperBound => -1
155
+ eReference "eRawType", :changeable => false, :derived => true, :transient => true, :lowerBound => 1
156
+ eReference "eLowerBound", :containment => true, :resolveProxies => false
157
+ eReference "eTypeParameter", :resolveProxies => false
158
+ eReference "eClassifier"
159
+ end
160
+ eClass "ETypeParameter" do
161
+ eReference "eBounds", :containment => true, :resolveProxies => false, :upperBound => -1
162
+ end
163
+ end
@@ -0,0 +1,156 @@
1
+ $:.unshift File.dirname(__FILE__)+"/../lib"
2
+
3
+ require 'test/unit'
4
+ require 'rgen/metamodel_builder'
5
+ require 'rgen/model_builder/reference_resolver'
6
+
7
+ class ReferenceResolverTest < Test::Unit::TestCase
8
+
9
+ class ClassA < RGen::MetamodelBuilder::MMBase
10
+ has_attr "name"
11
+ end
12
+
13
+ class ClassB < RGen::MetamodelBuilder::MMBase
14
+ has_attr "name"
15
+ end
16
+
17
+ class ClassC < RGen::MetamodelBuilder::MMBase
18
+ has_attr "name"
19
+ end
20
+
21
+ ClassA.contains_many 'childB', ClassB, 'parentA'
22
+ ClassB.contains_many 'childC', ClassC, 'parentB'
23
+ ClassA.has_one 'refC', ClassC
24
+ ClassB.has_one 'refC', ClassC
25
+ ClassC.has_many 'refCs', ClassC
26
+ ClassC.has_one 'refA', ClassA
27
+ ClassC.has_one 'refB', ClassB
28
+
29
+ def testModel
30
+ a1 = ClassA.new(:name => "a1")
31
+ a2 = ClassA.new(:name => "a2")
32
+ b1 = ClassB.new(:name => "b1", :parentA => a1)
33
+ b2 = ClassB.new(:name => "b2", :parentA => a1)
34
+ c1 = ClassC.new(:name => "c1", :parentB => b1)
35
+ c2 = ClassC.new(:name => "c2", :parentB => b1)
36
+ c3 = ClassC.new(:name => "c3", :parentB => b1)
37
+ [a1, a2, b1, b2, c1, c2, c3]
38
+ end
39
+
40
+ def setElementNames(resolver, elements)
41
+ elements.each do |e|
42
+ resolver.setElementName(e, e.name)
43
+ end
44
+ end
45
+
46
+ def createJob(hash)
47
+ raise "Invalid arguments" unless \
48
+ hash.is_a?(Hash) && (hash.keys & [:receiver, :reference, :namespace, :string]).size == 4
49
+ RGen::ModelBuilder::ReferenceResolver::ResolverJob.new(
50
+ hash[:receiver], hash[:reference], hash[:namespace], hash[:string])
51
+ end
52
+
53
+ def test_resolve_same_namespace
54
+ a1, a2, b1, b2, c1, c2, c3 = testModel
55
+
56
+ toplevelNamespace = [a1, a2]
57
+ resolver = RGen::ModelBuilder::ReferenceResolver.new
58
+ setElementNames(resolver, [a1, a2, b1, b2, c1, c2, c3])
59
+ resolver.addJob(createJob(
60
+ :receiver => c2,
61
+ :reference => ClassC.ecore.eReferences.find{|r| r.name == "refCs"},
62
+ :namespace => b1,
63
+ :string => "c1"))
64
+ resolver.addJob(createJob(
65
+ :receiver => b2,
66
+ :reference => ClassB.ecore.eReferences.find{|r| r.name == "refC"},
67
+ :namespace => a1,
68
+ :string => "b1.c1"))
69
+ resolver.addJob(createJob(
70
+ :receiver => a2,
71
+ :reference => ClassA.ecore.eReferences.find{|r| r.name == "refC"},
72
+ :namespace => nil,
73
+ :string => "a1.b1.c1"))
74
+ resolver.resolve(toplevelNamespace)
75
+
76
+ assert_equal [c1], c2.refCs
77
+ assert_equal c1, b2.refC
78
+ assert_equal c1, a2.refC
79
+ end
80
+
81
+ def test_resolve_parent_namespace
82
+ a1, a2, b1, b2, c1, c2, c3 = testModel
83
+
84
+ toplevelNamespace = [a1, a2]
85
+ resolver = RGen::ModelBuilder::ReferenceResolver.new
86
+ setElementNames(resolver, [a1, a2, b1, b2, c1, c2, c3])
87
+ resolver.addJob(createJob(
88
+ :receiver => c2,
89
+ :reference => ClassC.ecore.eReferences.find{|r| r.name == "refA"},
90
+ :namespace => b1,
91
+ :string => "a1"))
92
+ resolver.addJob(createJob(
93
+ :receiver => c2,
94
+ :reference => ClassC.ecore.eReferences.find{|r| r.name == "refB"},
95
+ :namespace => b1,
96
+ :string => "b1"))
97
+ resolver.addJob(createJob(
98
+ :receiver => c2,
99
+ :reference => ClassC.ecore.eReferences.find{|r| r.name == "refCs"},
100
+ :namespace => b1,
101
+ :string => "b1.c1"))
102
+ resolver.addJob(createJob(
103
+ :receiver => c2,
104
+ :reference => ClassC.ecore.eReferences.find{|r| r.name == "refCs"},
105
+ :namespace => b1,
106
+ :string => "a1.b1.c3"))
107
+ resolver.resolve(toplevelNamespace)
108
+
109
+ assert_equal a1, c2.refA
110
+ assert_equal b1, c2.refB
111
+ assert_equal [c1, c3], c2.refCs
112
+ end
113
+
114
+ def test_resolve_faulty
115
+ a1, a2, b1, b2, c1, c2, c3 = testModel
116
+
117
+ toplevelNamespace = [a1, a2]
118
+ resolver = RGen::ModelBuilder::ReferenceResolver.new
119
+ setElementNames(resolver, [a1, a2, b1, b2, c1, c2, c3])
120
+ resolver.addJob(createJob(
121
+ :receiver => c2,
122
+ :reference => ClassC.ecore.eReferences.find{|r| r.name == "refCs"},
123
+ :namespace => b1,
124
+ :string => "b1.c5"))
125
+ assert_raise RGen::ModelBuilder::ReferenceResolver::ResolverException do
126
+ resolver.resolve(toplevelNamespace)
127
+ end
128
+ end
129
+
130
+ def test_ambiguous_prefix
131
+ a = ClassA.new(:name => "name1")
132
+ b1 = ClassB.new(:name => "name1", :parentA => a)
133
+ b2 = ClassB.new(:name => "target", :parentA => a)
134
+ c1 = ClassC.new(:name => "name21", :parentB => b1)
135
+ c2 = ClassC.new(:name => "name22", :parentB => b1)
136
+
137
+ toplevelNamespace = [a]
138
+ resolver = RGen::ModelBuilder::ReferenceResolver.new
139
+ setElementNames(resolver, [a, b1, b2, c1, c2])
140
+ resolver.addJob(createJob(
141
+ :receiver => c2,
142
+ :reference => ClassC.ecore.eReferences.find{|r| r.name == "refCs"},
143
+ :namespace => b1,
144
+ :string => "name1.name1.name21"))
145
+ resolver.addJob(createJob(
146
+ :receiver => c2,
147
+ :reference => ClassC.ecore.eReferences.find{|r| r.name == "refB"},
148
+ :namespace => b1,
149
+ :string => "name1.target"))
150
+ resolver.resolve(toplevelNamespace)
151
+
152
+ assert_equal [c1], c2.refCs
153
+ assert_equal b2, c2.refB
154
+ end
155
+
156
+ end