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());
    }
@Test
    void testSubPatterns() throws Exception {

        PackageDescr packageDescr = getPackageDescr(getClass().getResourceAsStream("SubPattern.drl"));

        assertThat(packageDescr).isNotNull();

        packageDescrVisitor.visitPackageDescr(packageDescr);

        Collection<VerifierComponent> all = verifierData.getAll();

        assertThat(all).isNotNull();

        SubPattern test1SubPattern = null;
        SubPattern test2SubPattern = null;
        SubRule test1SubRule = null;
        SubRule test2SubRule = null;

        for (VerifierComponent verifierComponent : all) {
            //            System.out.println( verifierComponent );

            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())) {
                    assertThat(test1SubPattern).isNull();
                    test1SubPattern = subPattern;
                } else if ("Test 2".equals(subPattern.getRuleName())) {
                    assertThat(test2SubPattern).isNull();
                    test2SubPattern = subPattern;
                }
            }
            if (verifierComponent.getVerifierComponentType().equals(VerifierComponentType.SUB_RULE)) {
                SubRule subRule = (SubRule) verifierComponent;
                if ("Test 1".equals(subRule.getRuleName())) {
                    assertThat(test1SubRule).isNull();
                    test1SubRule = subRule;
                } else if ("Test 2".equals(subRule.getRuleName())) {
                    assertThat(test2SubRule).isNull();
                    test2SubRule = subRule;
                }
            }
        }

        assertThat(test1SubPattern).isNotNull();
        assertThat(test1SubPattern.getItems().size()).isEqualTo(3);
        assertThat(test2SubPattern).isNotNull();
        assertThat(test2SubPattern.getItems().size()).isEqualTo(3);
        assertThat(test1SubRule).isNotNull();
        assertThat(test1SubRule.getItems().size()).isEqualTo(1);
        assertThat(test2SubRule).isNotNull();
        assertThat(test2SubRule.getItems().size()).isEqualTo(1);

    }