diff options
Diffstat (limited to 'Tests/hu.bme.mit.inf.dslreasoner.run/src/hu/bme/mit/inf/dslreasoner/run/TypeDistributionCalculator.xtend')
-rw-r--r-- | Tests/hu.bme.mit.inf.dslreasoner.run/src/hu/bme/mit/inf/dslreasoner/run/TypeDistributionCalculator.xtend | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/Tests/hu.bme.mit.inf.dslreasoner.run/src/hu/bme/mit/inf/dslreasoner/run/TypeDistributionCalculator.xtend b/Tests/hu.bme.mit.inf.dslreasoner.run/src/hu/bme/mit/inf/dslreasoner/run/TypeDistributionCalculator.xtend new file mode 100644 index 00000000..e2d6e6ca --- /dev/null +++ b/Tests/hu.bme.mit.inf.dslreasoner.run/src/hu/bme/mit/inf/dslreasoner/run/TypeDistributionCalculator.xtend | |||
@@ -0,0 +1,35 @@ | |||
1 | package hu.bme.mit.inf.dslreasoner.run | ||
2 | |||
3 | import hu.bme.mit.inf.dslreasoner.domains.yakindu.sgraph.yakindumm.YakindummPackage | ||
4 | import java.io.File | ||
5 | import org.eclipse.emf.common.util.URI | ||
6 | import org.eclipse.emf.ecore.EPackage | ||
7 | import org.eclipse.emf.ecore.EcorePackage | ||
8 | import org.eclipse.emf.ecore.resource.Resource | ||
9 | import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl | ||
10 | import org.eclipse.emf.ecore.xmi.impl.XMIResourceFactoryImpl | ||
11 | |||
12 | class TypeDistributionCalculator { | ||
13 | public static def void main(String[] args) { | ||
14 | Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().put("*", new XMIResourceFactoryImpl) | ||
15 | EPackage.Registry.INSTANCE.put(EcorePackage.eNS_URI, EcorePackage.eINSTANCE) | ||
16 | EPackage.Registry.INSTANCE.put(YakindummPackage.eNS_URI, YakindummPackage.eINSTANCE) | ||
17 | |||
18 | println("model,className,count") | ||
19 | val directory = new File(args.get(0)) | ||
20 | for (file : directory.listFiles) { | ||
21 | val modelName = file.name | ||
22 | val resourceSet = new ResourceSetImpl | ||
23 | val resource = resourceSet.getResource(URI.createFileURI(file.absolutePath), true) | ||
24 | val objectsByTypeName = resource.allContents.filter [ obj | | ||
25 | val featureName = obj.eContainingFeature?.name | ||
26 | // Filter out "derived containment" references in Ecore. | ||
27 | // See https://stackoverflow.com/a/46340165 | ||
28 | featureName != "eGenericType" && featureName != "eGenericSuperTypes" | ||
29 | ].groupBy[eClass.name] | ||
30 | for (pair : objectsByTypeName.entrySet) { | ||
31 | println('''«modelName»,«pair.key»,«pair.value.size»''') | ||
32 | } | ||
33 | } | ||
34 | } | ||
35 | } | ||