public void prepareWeavingRules(SModel inputModel) throws GenerationCanceledException, GenerationFailureException { Iterable<TemplateWeavingRule> rules = myGenerator.getRuleManager().getWeaving_MappingRules(); myReadyRules.clear(); final BlockedReductionsData ruleBlocks = myGenerator.getBlockedReductionsData(); final FastNodeFinder nodeFinder = FastNodeFinderManager.get(inputModel); for (TemplateWeavingRule rule : rules) { boolean includeInheritors = rule.applyToInheritors(); for (SNode applicableNode : nodeFinder.getNodes(rule.getApplicableConcept2(), includeInheritors)) { if (ruleBlocks.isWeavingBlocked(applicableNode, rule)) { continue; } QueryExecutionContext executionContext = myGenerator.getExecutionContext(applicableNode); if (executionContext == null) { continue; } TemplateExecutionEnvironment environment = new TemplateExecutionEnvironmentImpl( new TemplateProcessor(myGenerator), executionContext, new ReductionTrack(myGenerator.getBlockedReductionsData())); DefaultTemplateContext context = new DefaultTemplateContext(environment, applicableNode, null); if (executionContext.isApplicable(rule, context)) { // if there are too many ArmedWeavingRule instances (i.e. a lot of applicable SNode), // it's easy to refactor AWR to keep list of applicable nodes and to recreate TEE on // demand myReadyRules.add(new ArmedWeavingRule(rule, environment, applicableNode)); ruleBlocks.blockWeaving(applicableNode, rule); } } } }