blob: 99ea6e9d9a48667b3e9cdb9f913ffec59a6bd5e7 (
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
|
package hu.bme.mit.inf.dslreasoner.run
import hu.bme.mit.inf.dslreasoner.domains.yakindu.sgraph.yakindumm.YakindummPackage
import java.io.File
import java.util.LinkedList
import java.util.List
import org.eclipse.emf.common.util.URI
import org.eclipse.emf.ecore.EObject
import org.eclipse.emf.ecore.resource.Resource
import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl
import org.eclipse.emf.ecore.xmi.impl.XMIResourceFactoryImpl
import org.eclipse.viatra.query.runtime.api.ViatraQueryEngine
import org.eclipse.viatra.query.runtime.emf.EMFScope
class MeasurePatternCoverage {
static def void init() {
YakindummPackage.eINSTANCE.eClass
Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().put("*", new XMIResourceFactoryImpl());
}
static def List<String> loadAllModelPathsInDirectory(String path) {
val File directory = new File(path);
if(directory.exists() && directory.isDirectory()) {
val filePaths = new LinkedList
for(File f : directory.listFiles()) {
if(f.isFile()) {
val filePath = f.getPath();
if(filePath.endsWith("xmi")) {
filePaths.add(filePath);
}
}
}
return filePaths;
} else {
throw new IllegalArgumentException("invalid path");
}
}
static def EObject loadModel(String path) {
val rs = new ResourceSetImpl
val resource = rs.getResource(URI.createFileURI(path), true);
return resource.getContents().get(0);
}
def static void main(String[] args) {
init()
val allModelPaths = loadAllModelPathsInDirectory("D:\\Eclipse\\GIT\\fmhe-analysis\\models-renamed")
val wfPatternsWOSynch = hu.bme.mit.inf.dslreasoner.partialsnapshot_mavo.yakindu.Patterns.instance.specifications
.filter[spec |
!YakinduLoader::patternsWithSynchronization.exists[spec.fullyQualifiedName.endsWith(it)]
].filter[
it.allAnnotations.exists[it.name== "Constraint"]
].toList
println('''type;id;«FOR pattern : wfPatternsWOSynch SEPARATOR ";"»«pattern.fullyQualifiedName»«ENDFOR»''')
for(modelPath : allModelPaths) {
//println(modelPath)
val model = loadModel(modelPath)
val engine = ViatraQueryEngine.on(new EMFScope(model))
val fileName = modelPath.split("\\\\")
val fileNameWOExtension = fileName.last.split("\\.").head
val fileNameSegments = fileNameWOExtension.split("_")
print('''«fileNameSegments.get(0)»;«fileNameSegments.get(1)»''')
for(pattern : wfPatternsWOSynch) {
val matcher = pattern.getMatcher(engine)
print(''';«matcher.countMatches»''')
}
println()
}
}
}
|