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