@Test public void testSubPatterns() throws Exception { PackageDescr packageDescr = getPackageDescr(getClass().getResourceAsStream("SubPattern.drl")); assertNotNull(packageDescr); packageDescrVisitor.visitPackageDescr(packageDescr); Collection<VerifierComponent> all = verifierData.getAll(); assertNotNull(all); SubPattern test1SubPattern = null; SubPattern test2SubPattern = null; SubRule test1SubRule = null; SubRule test2SubRule = null; for (VerifierComponent verifierComponent : all) { System.out.println("-" + verifierComponent); if (verifierComponent.getDescr() != null) { System.out.println(" \n\t\t => " + verifierComponent.getDescr().getLine() + ":" + +verifierComponent.getDescr().getEndLine() + " " + verifierComponent.getDescr().getText()); } else { System.out.println(" \n\t\t => null for " + verifierComponent.getClass().getSimpleName()); } if (verifierComponent.getVerifierComponentType().equals(VerifierComponentType.SUB_PATTERN)) { SubPattern subPattern = (SubPattern) verifierComponent; if ("Test 1".equals(subPattern.getRuleName())) { assertNull(test1SubPattern); test1SubPattern = subPattern; } else if ("Test 2".equals(subPattern.getRuleName())) { assertNull(test2SubPattern); test2SubPattern = subPattern; } } if (verifierComponent.getVerifierComponentType().equals(VerifierComponentType.SUB_RULE)) { SubRule subRule = (SubRule) verifierComponent; if ("Test 1".equals(subRule.getRuleName())) { assertNull(test1SubRule); test1SubRule = subRule; } else if ("Test 2".equals(subRule.getRuleName())) { assertNull(test2SubRule); test2SubRule = subRule; } } } assertNotNull(test1SubPattern); assertEquals(3, test1SubPattern.getItems().size()); assertNotNull(test2SubPattern); assertEquals(3, test2SubPattern.getItems().size()); assertNotNull(test1SubRule); assertEquals(1, test1SubRule.getItems().size()); assertNotNull(test2SubRule); assertEquals(1, test2SubRule.getItems().size()); }
public void visitPackageDescr(PackageDescr descr) throws UnknownDescriptionException, ClassNotFoundException, IOException { rulePackage = data.getPackageByName(descr.getName()); if (rulePackage == null) { rulePackage = new RulePackage(descr); rulePackage.setName(descr.getName()); data.add(rulePackage); } visitImports(descr.getImports()); TypeDeclarationDescrVisitor typeDeclarationDescrVisitor = new TypeDeclarationDescrVisitor(data); typeDeclarationDescrVisitor.visit(descr.getTypeDeclarations()); visitRules(descr.getRules()); }
PackageDescrVisitor { public void visitPackageDescr(PackageDescr descr) throws UnknownDescriptionException, ClassNotFoundException, IOException { rulePackage = data.getPackageByName(descr.getName()); if (rulePackage == null) { rulePackage = new RulePackage(descr); rulePackage.setName(descr.getName()); data.add(rulePackage); } visitImports(descr.getImports()); TypeDeclarationDescrVisitor typeDeclarationDescrVisitor = new TypeDeclarationDescrVisitor(data); typeDeclarationDescrVisitor.visit(descr.getTypeDeclarations()); visitRules(descr.getRules()); } }
PackageDescrVisitor { public void visitPackageDescr(PackageDescr descr) throws UnknownDescriptionException, ClassNotFoundException, IOException { rulePackage = data.getPackageByName(descr.getName()); if (rulePackage == null) { rulePackage = new RulePackage(descr); rulePackage.setName(descr.getName()); data.add(rulePackage); } visitImports(descr.getImports()); TypeDeclarationDescrVisitor typeDeclarationDescrVisitor = new TypeDeclarationDescrVisitor(data); typeDeclarationDescrVisitor.visit(descr.getTypeDeclarations()); visitRules(descr.getRules()); } PackageDescrVisitor(VerifierData data,
                               List<JarInputStream> jars); }
PackageDescrVisitor { public void visitPackageDescr(PackageDescr descr) throws UnknownDescriptionException, ClassNotFoundException, IOException { rulePackage = data.getPackageByName(descr.getName()); if (rulePackage == null) { rulePackage = new RulePackage(descr); rulePackage.setName(descr.getName()); data.add(rulePackage); } visitImports(descr.getImports()); TypeDeclarationDescrVisitor typeDeclarationDescrVisitor = new TypeDeclarationDescrVisitor(data); typeDeclarationDescrVisitor.visit(descr.getTypeDeclarations()); visitRules(descr.getRules()); } PackageDescrVisitor(VerifierData data,
                               List<JarInputStream> jars); void visitPackageDescr(PackageDescr descr); }
PackageDescrVisitor { public void visitPackageDescr(PackageDescr descr) throws UnknownDescriptionException, ClassNotFoundException, IOException { rulePackage = data.getPackageByName(descr.getName()); if (rulePackage == null) { rulePackage = new RulePackage(descr); rulePackage.setName(descr.getName()); data.add(rulePackage); } visitImports(descr.getImports()); TypeDeclarationDescrVisitor typeDeclarationDescrVisitor = new TypeDeclarationDescrVisitor(data); typeDeclarationDescrVisitor.visit(descr.getTypeDeclarations()); visitRules(descr.getRules()); } PackageDescrVisitor(VerifierData data,
                               List<JarInputStream> jars); void visitPackageDescr(PackageDescr descr);  }