diff options
author | 2018-01-17 00:54:44 +0100 | |
---|---|---|
committer | 2018-01-17 00:54:44 +0100 | |
commit | 0a31d5448e92d915c7163c3985fa0807f67d3f06 (patch) | |
tree | 1a106505c98df6398f2b5fe183771fc315f1e87a /Application/hu.bme.mit.inf.dslreasoner.application/src/hu/bme/mit/inf/dslreasoner/application/scoping/ApplicationConfigurationScopeProvider.xtend | |
parent | Scope patched for metamodel specification (diff) | |
download | VIATRA-Generator-0a31d5448e92d915c7163c3985fa0807f67d3f06.tar.gz VIATRA-Generator-0a31d5448e92d915c7163c3985fa0807f67d3f06.tar.zst VIATRA-Generator-0a31d5448e92d915c7163c3985fa0807f67d3f06.zip |
Scoping and linking of Viatra Packages and Patterns is completed
Diffstat (limited to 'Application/hu.bme.mit.inf.dslreasoner.application/src/hu/bme/mit/inf/dslreasoner/application/scoping/ApplicationConfigurationScopeProvider.xtend')
-rw-r--r-- | Application/hu.bme.mit.inf.dslreasoner.application/src/hu/bme/mit/inf/dslreasoner/application/scoping/ApplicationConfigurationScopeProvider.xtend | 63 |
1 files changed, 61 insertions, 2 deletions
diff --git a/Application/hu.bme.mit.inf.dslreasoner.application/src/hu/bme/mit/inf/dslreasoner/application/scoping/ApplicationConfigurationScopeProvider.xtend b/Application/hu.bme.mit.inf.dslreasoner.application/src/hu/bme/mit/inf/dslreasoner/application/scoping/ApplicationConfigurationScopeProvider.xtend index 3aa349f3..97cda4a4 100644 --- a/Application/hu.bme.mit.inf.dslreasoner.application/src/hu/bme/mit/inf/dslreasoner/application/scoping/ApplicationConfigurationScopeProvider.xtend +++ b/Application/hu.bme.mit.inf.dslreasoner.application/src/hu/bme/mit/inf/dslreasoner/application/scoping/ApplicationConfigurationScopeProvider.xtend | |||
@@ -15,6 +15,10 @@ import org.eclipse.emf.ecore.EClass | |||
15 | import org.eclipse.emf.ecore.EEnum | 15 | import org.eclipse.emf.ecore.EEnum |
16 | import hu.bme.mit.inf.dslreasoner.application.applicationConfiguration.MetamodelSpecification | 16 | import hu.bme.mit.inf.dslreasoner.application.applicationConfiguration.MetamodelSpecification |
17 | import hu.bme.mit.inf.dslreasoner.application.applicationConfiguration.AllPackageEntry | 17 | import hu.bme.mit.inf.dslreasoner.application.applicationConfiguration.AllPackageEntry |
18 | import hu.bme.mit.inf.dslreasoner.application.applicationConfiguration.PatternElement | ||
19 | import hu.bme.mit.inf.dslreasoner.application.applicationConfiguration.AllPatternEntry | ||
20 | import hu.bme.mit.inf.dslreasoner.application.applicationConfiguration.PatternSpecification | ||
21 | import hu.bme.mit.inf.dslreasoner.application.applicationConfiguration.ViatraImport | ||
18 | 22 | ||
19 | /** | 23 | /** |
20 | * This class contains custom scoping description. | 24 | * This class contains custom scoping description. |
@@ -34,6 +38,12 @@ class ApplicationConfigurationScopeProvider extends AbstractApplicationConfigura | |||
34 | context.scopeForMetamodelSpecification(reference,document) | 38 | context.scopeForMetamodelSpecification(reference,document) |
35 | } else if(context instanceof AllPackageEntry){ | 39 | } else if(context instanceof AllPackageEntry){ |
36 | context.scopeForAllPackageEntry(reference,document) | 40 | context.scopeForAllPackageEntry(reference,document) |
41 | } else if(context instanceof PatternElement) { | ||
42 | context.scopeForPatternElement(reference,document) | ||
43 | } else if(context instanceof PatternSpecification) { | ||
44 | context.scopeForPatternSpecification(reference,document) | ||
45 | } else if(context instanceof AllPatternEntry) { | ||
46 | context.scopeForAllPatternEntry(reference,document) | ||
37 | } else { | 47 | } else { |
38 | return super.getScope(context,reference) | 48 | return super.getScope(context,reference) |
39 | } | 49 | } |
@@ -42,15 +52,24 @@ class ApplicationConfigurationScopeProvider extends AbstractApplicationConfigura | |||
42 | private def allEPackages(ConfigurationScript document) { | 52 | private def allEPackages(ConfigurationScript document) { |
43 | return document.imports.filter(EPackageImport).map[it.importedPackage].filterNull | 53 | return document.imports.filter(EPackageImport).map[it.importedPackage].filterNull |
44 | } | 54 | } |
45 | 55 | private def allViatraPackages(ConfigurationScript document) { | |
56 | val res = document.imports.filter(ViatraImport).map[it.importedViatra].filterNull | ||
57 | //println('''All packages: «res.map[packageName].toList»''') | ||
58 | return res | ||
59 | } | ||
46 | private def allEClassifiers(ConfigurationScript document) { | 60 | private def allEClassifiers(ConfigurationScript document) { |
47 | document.allEPackages.map[EClassifiers].flatten | 61 | document.allEPackages.map[EClassifiers].flatten |
48 | } | 62 | } |
63 | private def allPatterns(ConfigurationScript document) { | ||
64 | val res = document.allViatraPackages.map[patterns].flatten | ||
65 | //println('''All patterns: «res.map[name].toList»''') | ||
66 | return res | ||
67 | } | ||
49 | 68 | ||
50 | protected def scopeForMetamodelElement(MetamodelElement context, EReference reference, ConfigurationScript document) { | 69 | protected def scopeForMetamodelElement(MetamodelElement context, EReference reference, ConfigurationScript document) { |
51 | if(reference === language.metamodelEntry_Package) { | 70 | if(reference === language.metamodelEntry_Package) { |
52 | return Scopes.scopeFor(document.allEPackages) | 71 | return Scopes.scopeFor(document.allEPackages) |
53 | } if(reference === language.metamodelElement_Classifier) { | 72 | } else if(reference === language.metamodelElement_Classifier) { |
54 | if(context.package !== null) { | 73 | if(context.package !== null) { |
55 | return Scopes.scopeFor(context.package.EClassifiers) | 74 | return Scopes.scopeFor(context.package.EClassifiers) |
56 | } else { | 75 | } else { |
@@ -91,4 +110,44 @@ class ApplicationConfigurationScopeProvider extends AbstractApplicationConfigura | |||
91 | return super.getScope(context,reference) | 110 | return super.getScope(context,reference) |
92 | } | 111 | } |
93 | } | 112 | } |
113 | |||
114 | ////////// | ||
115 | |||
116 | protected def scopeForPatternElement(PatternElement context, EReference reference, ConfigurationScript document) { | ||
117 | if(reference === language.patternEntry_Package) { | ||
118 | return Scopes.scopeFor(document.allViatraPackages) | ||
119 | } else if(reference === language.patternElement_Pattern) { | ||
120 | if(context.package !== null) { | ||
121 | return Scopes.scopeFor(context.package.patterns) | ||
122 | } else { | ||
123 | return Scopes.scopeFor(document.allPatterns) | ||
124 | } | ||
125 | } else { | ||
126 | super.getScope(context,reference) | ||
127 | } | ||
128 | } | ||
129 | |||
130 | protected def scopeForPatternSpecification(PatternSpecification context, EReference reference, ConfigurationScript document) { | ||
131 | if(reference === language.patternEntry_Package) { | ||
132 | return Scopes.scopeFor(document.allViatraPackages) | ||
133 | } else if(reference ===language.patternElement_Pattern) { | ||
134 | return Scopes.scopeFor(document.allPatterns) | ||
135 | } else { | ||
136 | return super.getScope(context,reference) | ||
137 | } | ||
138 | } | ||
139 | |||
140 | protected def scopeForAllPatternEntry(AllPatternEntry context, EReference reference, ConfigurationScript document) { | ||
141 | if(reference === language.patternEntry_Package) { | ||
142 | return Scopes.scopeFor(document.allViatraPackages) | ||
143 | } else if(reference === language.patternElement_Pattern) { | ||
144 | if(context.package === null) { | ||
145 | return Scopes.scopeFor(document.allPatterns) | ||
146 | } else { | ||
147 | return Scopes.scopeFor(context.package.patterns) | ||
148 | } | ||
149 | } else { | ||
150 | return super.getScope(context,reference) | ||
151 | } | ||
152 | } | ||
94 | } | 153 | } |