Commit 1253c891 authored by Leonard Faecke's avatar Leonard Faecke
Browse files

+ Added support for opentype, automatic type in analyzer

* Added composition analysis for groups
parent 9c2030ab
Loading
Loading
Loading
Loading
+25 −7
Original line number Diff line number Diff line
@@ -5,11 +5,13 @@ import java.util.Map;
import java.util.Set;
import java.util.UUID;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.concurrent.Callable;
import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
@@ -192,14 +194,10 @@ public class UsageAnalyzer implements Callable<TTCN3Usage> {
		
		analyzeEvaluation(module, results);
		
		//Anytype
		//Anytype, automatic type, opentype
		
		analyzeTypes(module, results);
		
		//opentype (not supported)
		
		//automatic type (not supported)
		
		//operators
		
		analyzeOperators(module, results);
@@ -833,6 +831,7 @@ System.out.println("Analyzing function");
		for(Type t : EcoreUtil2.getAllContentsOfType(module, Type.class)) {
			if(t.getPre() != null && t.getPre().equals("anytype")) addToOutput(output, "Type_anytype");
			else addNToOutput(output, "Type_anytype", 0);
			if(t.getAny() != null) addToOutput(output, "opentype");
		}
		for(ExtendedFieldReference t : EcoreUtil2.getAllContentsOfType(module, ExtendedFieldReference.class)) {
			if(t.getType() != null && t.getType().equals("anytype")) addToOutput(output, "ExtendedFieldReference_anytype");
@@ -846,6 +845,17 @@ System.out.println("Analyzing function");
			if(t.getType() != null && t.getType().equals("anytype")) addToOutput(output, "FieldConstExpressionSpec_anytype");
			else addNToOutput(output, "FieldConstExpressionSpec_anytype", 0);
		}
		//automatic type
		for(ConstDef t : EcoreUtil2.getAllContentsOfType(module, ConstDef.class)) {
			if(t.getType() == null) addToOutput(output, "ConstDef_automatic_type");
		}
		for(ModulePar t : EcoreUtil2.getAllContentsOfType(module, ModulePar.class)) {
			if(t.getType() == null) addToOutput(output, "ModulePar_automatic_type");
		}
		for(VarInstance t : EcoreUtil2.getAllContentsOfType(module, VarInstance.class)) {
			if(t.getListType() == null) addToOutput(output, "VarInstance_list_automatic_type");
			if(t.getType() == null) addToOutput(output, "VarInstance_automatic_type");
		}
	}
	
	private void analyzeOperators(TTCN3Module module, Map<String, Long> output) {
@@ -971,11 +981,19 @@ System.out.println("Analyzing function");
			if(group.getList() == null) addToOutput(output, "GroupSize_0");
			else addToOutput(output, "GroupSize_" + (group.getList().getDefinitions().size()));
			
			
			String[] definitionTypes = {"AltstepDef", "ConstDef", "ExtConstDef", "ExtFunctionDef", 
					"GroupDef", "FunctionDef", "ImportDef", "ModuleParDef", "SignatureDef", "TemplateDef", 
					"TestcaseDef", "TypeDef"};
			Map<String, Integer> definitions = Arrays.stream(definitionTypes)
					.collect(Collectors.toMap(k -> k, k -> 0));
			for(ModuleDefinition def : group.getList().getDefinitions()) {
				String name = def.getDef().getClass().getSimpleName();
				addToOutput(output, "InGroup_" + name.substring(0, name.length()-4));
				name = name.substring(0, name.length()-4);
				definitions.put(name, definitions.get(name) + 1);
				addToOutput(output, "InGroup_" + name);
			}
			addToOutput(output, "Group_combinations_" + definitions.values().stream()
		            .map(String::valueOf).collect(Collectors.joining("_")));
		}
	}