Examples of DRLInfo


Examples of org.drools.eclipse.DRLInfo

        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

Examples of org.drools.eclipse.DRLInfo

        DroolsEclipsePlugin.getDefault().setForceFullBuild();
        return changes;
    }

  private TextFileChange createChangesForFile(IFile drlFile) throws CoreException {
    DRLInfo drlInfo = null;
    try {
      drlInfo = DroolsEclipsePlugin.getDefault().parseResource( drlFile, false );
    } catch (DroolsParserException e) { }
    if ( drlInfo == null ) {
      return null;
    }

    String content = FileUtil.readFile(drlFile);
    if ( content == null ) {
        return null;
    }
   
    TextFileChange change = new TextFileChange(drlFile.getName(), drlFile);
    MultiTextEdit mte = new MultiTextEdit();
    change.setEdit(mte);
   
    boolean isImported = false;
    for (ImportDescr importDescr : drlInfo.getPackageDescr().getImports()) {
      isImported |= importDescr.getTarget().equals(className) || importDescr.getTarget().equals(packageName + ".*");
      addReplace(mte, importDescr.getTarget(), content, importDescr.getStartCharacter(), importDescr.getEndCharacter());
    }
    if (!isImported) {
      return change;
    }

    for (DRLInfo.RuleInfo ruleInfo : drlInfo.getRuleInfos()) {
      List<PatternInfo> patternInfos = ruleInfo.getPatternInfos();
      if (patternInfos != null) {
        for (DRLInfo.PatternInfo patternInfo : patternInfos) {
          addReplace(mte, patternInfo.getPatternTypeName(), content, patternInfo.getStart(), patternInfo.getEnd());
        }
        addReplace(mte, className, content, ruleInfo.getConsequenceStart(), ruleInfo.getConsequenceEnd());
      } else {
        addReplace(mte, className, content, ruleInfo.getRuleStart(), ruleInfo.getRuleEnd());
      }
    }

    for (DRLInfo.FunctionInfo functionInfo : drlInfo.getFunctionInfos()) {
      addReplace(mte, className, content, functionInfo.getFunctionStart(), functionInfo.getFunctionEnd());
    }
   
    return change;
  }
View Full Code Here

Examples of org.drools.eclipse.DRLInfo

                    && 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

Examples of org.drools.eclipse.DRLInfo

    }

    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

Examples of org.drools.eclipse.DRLInfo

        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

Examples of org.drools.eclipse.DRLInfo

    private DroolsBuildMarker[] parseDRLFile(IFile file,
                                             String content) {
        List markers = new ArrayList();
        try {
            DRLInfo drlInfo =
                    DroolsEclipsePlugin.getDefault().parseResource( file,
                                                                    true );
            //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

Examples of org.drools.eclipse.DRLInfo

        List markers = new ArrayList();
        try {
            SpreadsheetCompiler converter = new SpreadsheetCompiler();
            String drl = converter.compile( file.getContents(),
                                            InputType.XLS );
            DRLInfo drlInfo =
                    DroolsEclipsePlugin.getDefault().parseXLSResource( drl,
                                                                       file );
            // 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

Examples of org.drools.eclipse.DRLInfo

        List markers = new ArrayList();
        try {
            SpreadsheetCompiler converter = new SpreadsheetCompiler();
            String drl = converter.compile( file.getContents(),
                                            InputType.CSV );
            DRLInfo drlInfo =
                    DroolsEclipsePlugin.getDefault().parseXLSResource( drl,
                                                                       file );
            // 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

Examples of org.drools.eclipse.DRLInfo

            RuleModel model = BRXMLPersistence.getInstance().unmarshal( brl );
            String drl = BRDRLPersistence.getInstance().marshal( model );

            // TODO pass this through DSL converter in case brl is based on dsl

            DRLInfo drlInfo =
                    DroolsEclipsePlugin.getDefault().parseBRLResource( drl,
                                                                       file );
            // 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

Examples of org.drools.eclipse.DRLInfo

            GuidedDecisionTable52 dt = GuidedDTXMLPersistence.getInstance().unmarshal( gdst );
            String drl = GuidedDTDRLPersistence.getInstance().marshal( dt );

            // TODO pass this through DSL converter in case brl is based on dsl

            DRLInfo drlInfo =
                    DroolsEclipsePlugin.getDefault().parseGDSTResource( drl,
                                                                        file );
            // 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
Copyright © 2018 www.massapi.com. 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.