Package org.drools.eclipse

Examples of org.drools.eclipse.DRLInfo$PatternInfo


    }

    public void initRules() {
        rules = new HashMap<String, RuleDescr>();
        try {
            DRLInfo drlInfo = DroolsEclipsePlugin.getDefault().parseResource(editor, true, false);
            if (drlInfo != null) {
                PackageDescr packageDescr = drlInfo.getPackageDescr();
                if (packageDescr != null) {
                    for (RuleDescr ruleDescr: packageDescr.getRules()) {
                        if (ruleDescr != null && ruleDescr.getName() != null) {
                            rules.put(ruleDescr.getName(), ruleDescr);
                        }
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

    return null;
  }
 
  private BaseDescr getDescr(int offset) {
    try {
      DRLInfo info = DroolsEclipsePlugin.getDefault().parseResource(
          editor, true, false);
      return DescrUtil.getDescr(info.getPackageDescr(), offset);
    } catch (DroolsParserException exc) {
      return null;
    }
  }
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

        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

    }

    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

                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" );
                }

                Package pkg = drlInfo.getPackage();
                RuleBaseConfiguration config = new RuleBaseConfiguration();
                config.setClassLoader(newLoader);
                ruleBase = (ReteooRuleBase) RuleBaseFactory.newRuleBase(RuleBase.RETEOO, 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

        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

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.