!7 //import static x30_pkg.x30_util.getOpt_cache; //import static x30_pkg.x30_util.getOpt_cached; set flag DynModule. // no cmodule b/c of DynamicObject+getOpt module AnalyzeAppliedRules > DynSingleFunctionWithPrintLog { sclass ByRule { S ruleID; new TreeSet statements; } Map ruleMap; void doIt { L concepts = cloneList((L) dm_requireAndCall("#1021413/AppliedRules", 'concepts)); print("Got " + n2(concepts, "concept")); ruleMap = new Map; for (O c : concepts) pcall { S judgement = getString judgement(c); S struct = getString matchedRuleStruct(c); O matchedRule = safeUnstruct(struct); // RuleEngine2_MatchedRule O rule = getOpt rule(matchedRule); S ruleID = getString globalID(rule); S ruleIn = first((LS) get in(rule)); print(judgement + " : " + shorten(40, struct)); SS varMap = getOpt map(matchedRule); S tokenize = getString tokenizationFunction(matchedRule); LS tok = cast callAndMake(tokenize, ruleIn); LS tokC = codeTokens(tok); Set possibleVars = asCISet(tokC); //print(" Cached: " + getOpt_cache.get(_getClass(matchedRule))); //print(" fieldValues:" + keys(data/DynamicObject.fieldValues)); print(" Var-Map: " + varMap); print(" Rule-ID: " + ruleID); ByRule r = getOrCreate_f1(ruleMap, ruleID, func(S ruleID) -> ByRule { nu ByRule(+ruleID) }); for (S a, b : varMap) { r.statements.add(format("variable " + quote(a) + " was used in a * mapping", judgement)); r.statements.add(format("variable " + quote(a) + " was mapped to " + quote(b) + " in a * mapping", judgement)); } for (S var : possibleVars) r.statements.add("possible variable " + quote(var)); } pnlStruct(values(ruleMap)); new LS out; for (ByRule r : values(ruleMap)) for (S s : r.statements) out.add("Rule " + r.ruleID + ": " + s); pnl(out); } }