Package org.drools.eclipse

Examples of org.drools.eclipse.DRLInfo$PatternInfo


    }

    private List<DroolsBuildMarker> parseResource(ResourceParser resourceParser) {
        List<DroolsBuildMarker> markers = new ArrayList<DroolsBuildMarker>();
        try {
            DRLInfo drlInfo = resourceParser.parseResource();

            //parser errors
            markParseErrors( markers, drlInfo.getParserErrors() );
            markOtherErrors( markers, drlInfo.getBuilderErrors() );
        } catch ( DroolsParserException e ) {
            // we have an error thrown from DrlParser
            Throwable cause = e.getCause();
            if ( cause instanceof RecognitionException ) {
                RecognitionException recogErr = (RecognitionException) cause;
View Full Code Here


                    && javaProject.isOnClasspath(resource)) {
                IFile file = (IFile) resource;
                if ("drl".equals(resource.getFileExtension())
                            || "dslr".equals(resource.getFileExtension())) {
                    try {
                        DRLInfo drlInfo = DroolsEclipsePlugin.getDefault().parseResource(resource, false);
                        String packageName = drlInfo.getPackageName();
                        Package pkg = ruleSet.getPackage(packageName);
                        if (pkg == null) {
                            pkg = DroolsModelBuilder.addPackage(ruleSet, packageName, 0, 0);
                        }
                        if (drlInfo.getBuilderErrors().length > 0 || drlInfo.getPackageDescr() == null) {
                            return false;
                        }
                        // add rules
                        List rules = drlInfo.getPackageDescr().getRules();
                        for (Iterator iterator = rules.iterator(); iterator.hasNext();) {
                            RuleDescr ruleDescr = (RuleDescr) iterator.next();
                            boolean isQuery = ruleDescr instanceof QueryDescr;
                            String ruleName = ruleDescr.getName();
                            if (!isQuery) {
                                Rule rule = DroolsModelBuilder.addRule(
                                    pkg, ruleName, file, ruleDescr.getStartCharacter(),
                                    ruleDescr.getEndCharacter() - ruleDescr.getStartCharacter() + 1, null);
                                // create link between resource and created rule nodes
                                List droolsElements = (List) resourcesMap.get(file);
                                if (droolsElements == null) {
                                    droolsElements = new ArrayList();
                                    resourcesMap.put(file, droolsElements);
                                }
                                droolsElements.add(rule);
                            } else {
                                Query query = DroolsModelBuilder.addQuery(
                                    pkg, ruleName, file, ruleDescr.getStartCharacter(),
                                    ruleDescr.getEndCharacter() - ruleDescr.getStartCharacter() + 1);
                                // create link between resource and created rule nodes
                                List droolsElements = (List) resourcesMap.get(file);
                                if (droolsElements == null) {
                                    droolsElements = new ArrayList();
                                    resourcesMap.put(file, droolsElements);
                                }
                                droolsElements.add(query);
                            }
                        }
                        // add globals
                        List globals = drlInfo.getPackageDescr().getGlobals();
                        for (Iterator iterator = globals.iterator(); iterator.hasNext();) {
                            GlobalDescr globalDescr = (GlobalDescr) iterator.next();
                            Global global = DroolsModelBuilder.addGlobal(
                                pkg, globalDescr.getIdentifier(), file, globalDescr.getStartCharacter(),
                                globalDescr.getEndCharacter() - globalDescr.getStartCharacter() + 1);
                            // create link between resource and created rule nodes
                            List droolsElements = (List) resourcesMap.get(file);
                            if (droolsElements == null) {
                                droolsElements = new ArrayList();
                                resourcesMap.put(file, droolsElements);
                            }
                            droolsElements.add(global);
                        }
                        // add functions
                        List functions = drlInfo.getPackageDescr().getFunctions();
                        for (Iterator iterator = functions.iterator(); iterator.hasNext();) {
                            FunctionDescr functionDescr = (FunctionDescr) iterator.next();
                            String functionName = functionDescr.getName();
                            Function function = DroolsModelBuilder.addFunction(
                                pkg, functionName, file, functionDescr.getStartCharacter(),
View Full Code Here

    }

    private List<DroolsBuildMarker> parseResource(ResourceParser resourceParser) {
        List<DroolsBuildMarker> markers = new ArrayList<DroolsBuildMarker>();
        try {
            DRLInfo drlInfo = resourceParser.parseResource();

            //parser errors
            markParseErrors( markers, drlInfo.getParserErrors() );
            markOtherErrors( markers, drlInfo.getBuilderErrors() );
        } catch ( DroolsParserException e ) {
            // we have an error thrown from DrlParser
            Throwable cause = e.getCause();
            if ( cause instanceof RecognitionException ) {
                RecognitionException recogErr = (RecognitionException) cause;
View Full Code Here

        if (!(getEditor().getEditorInput() instanceof IFileEditorInput)) {
            return proposals;
        }

        try {
            DRLInfo drlInfo = DroolsEclipsePlugin.getDefault().generateParsedResource(
                "package dummy; \n" + ruleBackText,
                ((IFileEditorInput) getEditor().getEditorInput()).getFile(),
                false,
                false );
View Full Code Here

        return list;
    }

    protected void loadImportsAndFunctions() {
        try {
            DRLInfo drlInfo = DroolsEclipsePlugin.getDefault().parseResource(this, true, false);
            PackageDescr descr = drlInfo.getPackageDescr();
            // package
            this.packageName = drlInfo.getPackageName();
            // imports
            List<ImportDescr> allImports = descr.getImports();
            this.imports = new ArrayList<String>();
            if (packageName != null) {
                imports.addAll(getAllClassesInPackage(packageName));
View Full Code Here

    }


    public BaseDescr getDescr(int offset) {
        try {
            DRLInfo info = DroolsEclipsePlugin.getDefault().parseResource(this, true, false);
            return DescrUtil.getDescr(info.getPackageDescr(), offset);
        } catch (DroolsParserException exc) {
            return null;
        }
    }
View Full Code Here

    public void setJavaBreakpointProperties() throws CoreException {
        IMarker marker = getMarker();
        int drlLineNumber = getDRLLineNumber();
        if ( marker.exists() ) {
            try {
                DRLInfo drlInfo = DroolsEclipsePlugin.getDefault().parseResource( marker.getResource(), true );

                RuleInfo[] ruleInfos = drlInfo.getRuleInfos();

                StringBuffer rb = new StringBuffer();
                for (int i=0;i<ruleInfos.length; i++) {
                    int line = ruleInfos[i].getConsequenceDrlLineNumber();
                    String ruleid = ruleInfos[i].getClassName()+":"+line;
View Full Code Here

                    && javaProject.isOnClasspath(resource)) {
                IFile file = (IFile) resource;
                if ("drl".equals(resource.getFileExtension())
                            || "dslr".equals(resource.getFileExtension())) {
                    try {
                        DRLInfo drlInfo = DroolsEclipsePlugin.getDefault().parseResource(resource, false);
                        String packageName = drlInfo.getPackageName();
                        Package pkg = ruleSet.getPackage(packageName);
                        if (pkg == null) {
                            pkg = DroolsModelBuilder.addPackage(ruleSet, packageName, 0, 0);
                        }
                        if (drlInfo.getBuilderErrors().length > 0 || drlInfo.getPackageDescr() == null) {
                            return false;
                        }
                        // add rules
                        List<RuleDescr> rules = drlInfo.getPackageDescr().getRules();
                        for (RuleDescr ruleDescr : rules) {
                            boolean isQuery = ruleDescr instanceof QueryDescr;
                            String ruleName = ruleDescr.getName();
                            if (!isQuery) {
                                Rule rule = DroolsModelBuilder.addRule(
                                    pkg, ruleName, file, ruleDescr.getStartCharacter(),
                                    ruleDescr.getEndCharacter() - ruleDescr.getStartCharacter() + 1, null);
                                // create link between resource and created rule nodes
                                List<DroolsElement> droolsElements = resourcesMap.get(file);
                                if (droolsElements == null) {
                                    droolsElements = new ArrayList<DroolsElement>();
                                    resourcesMap.put(file, droolsElements);
                                }
                                droolsElements.add(rule);
                            } else {
                                Query query = DroolsModelBuilder.addQuery(
                                    pkg, ruleName, file, ruleDescr.getStartCharacter(),
                                    ruleDescr.getEndCharacter() - ruleDescr.getStartCharacter() + 1);
                                // create link between resource and created rule nodes
                                List<DroolsElement> droolsElements = resourcesMap.get(file);
                                if (droolsElements == null) {
                                    droolsElements = new ArrayList<DroolsElement>();
                                    resourcesMap.put(file, droolsElements);
                                }
                                droolsElements.add(query);
                            }
                        }
                        // add globals
                        List<GlobalDescr> globals = drlInfo.getPackageDescr().getGlobals();
                        for (GlobalDescr globalDescr : globals) {
                            Global global = DroolsModelBuilder.addGlobal(
                                pkg, globalDescr.getIdentifier(), file, globalDescr.getStartCharacter(),
                                globalDescr.getEndCharacter() - globalDescr.getStartCharacter() + 1);
                            // create link between resource and created rule nodes
                            List<DroolsElement> droolsElements = resourcesMap.get(file);
                            if (droolsElements == null) {
                                droolsElements = new ArrayList<DroolsElement>();
                                resourcesMap.put(file, droolsElements);
                            }
                            droolsElements.add(global);
                        }
                        // add functions
                        List<FunctionDescr> functions = drlInfo.getPackageDescr().getFunctions();
                        for (FunctionDescr functionDescr : functions) {
                            String functionName = functionDescr.getName();
                            Function function = DroolsModelBuilder.addFunction(
                                pkg, functionName, file, functionDescr.getStartCharacter(),
                                functionDescr.getEndCharacter() - functionDescr.getStartCharacter() + 1);
View Full Code Here

                ClassLoader newLoader = DroolsBuilder.class.getClassLoader();
                if ( resource.getProject().getNature( "org.eclipse.jdt.core.javanature" ) != null ) {
                    IJavaProject project = JavaCore.create( resource.getProject() );
                    newLoader = ProjectClassLoader.getProjectClassLoader( project );
                }
                DRLInfo drlInfo = DroolsEclipsePlugin.getDefault().parseResource(drlEditor, true, true);
                if (drlInfo == null) {
                    throw new Exception( "Could not find DRL info" );
                }
                if (drlInfo.getBuilderErrors().length > 0) {
                    throw new Exception( drlInfo.getBuilderErrors().length + " build errors" );
                }
                if (drlInfo.getParserErrors().size() > 0) {
                    throw new Exception( drlInfo.getParserErrors().size() + " parser errors" );
                }

                InternalKnowledgePackage pkg = drlInfo.getPackage();
                RuleBaseConfiguration config = new RuleBaseConfiguration();
                config.setClassLoader(newLoader);
                ruleBase = (InternalKnowledgeBase) KnowledgeBaseFactory.newKnowledgeBase(config);
                if (pkg != null) {
                    ruleBase.addPackage(pkg);
View Full Code Here

    }

    private List<DroolsBuildMarker> parseResource(ResourceParser resourceParser) {
        List<DroolsBuildMarker> markers = new ArrayList<DroolsBuildMarker>();
        try {
            DRLInfo drlInfo = resourceParser.parseResource();

            //parser errors
            markParseErrors( markers, drlInfo.getParserErrors() );
            markOtherErrors( markers, drlInfo.getBuilderErrors() );
        } catch ( DroolsParserException e ) {
            // we have an error thrown from DrlParser
            Throwable cause = e.getCause();
            if ( cause instanceof RecognitionException ) {
                RecognitionException recogErr = (RecognitionException) cause;
View Full Code Here

TOP

Related Classes of org.drools.eclipse.DRLInfo$PatternInfo

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.