Examples of DRLInfo


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

    }

    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

                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

Examples of org.drools.eclipse.DRLInfo

            IEditorPart editor = (IEditorPart) part;
            IResource resource = (IResource) editor.getEditorInput().getAdapter(IResource.class);
            ITextSelection textSelection = (ITextSelection) selection;
            int lineNumber = textSelection.getStartLine();
            try {
                DRLInfo drlInfo = DroolsEclipsePlugin.getDefault().parseResource(resource, false);
                if (drlInfo != null) {
                    RuleInfo ruleInfo = drlInfo.getRuleInfo(lineNumber);
                    if (ruleInfo != null) {
                        if (ruleInfo.getConsequenceDrlLineNumber() <= lineNumber) {
                            return true;
                        }
                    }
                    FunctionInfo functionInfo = drlInfo.getFunctionInfo(lineNumber);
                    if (functionInfo != null) {
                        if (functionInfo.getDrlLineNumber() <= lineNumber) {
                            return true;
                        }
                    }
View Full Code Here

Examples of org.drools.eclipse.DRLInfo

        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

Examples of org.drools.eclipse.DRLInfo

    }


    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

Examples of org.drools.eclipse.DRLInfo

    }

    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

Examples of org.drools.eclipse.DRLInfo

    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

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

            IEditorPart editor = (IEditorPart) part;
            IResource resource = (IResource) editor.getEditorInput().getAdapter(IResource.class);
            ITextSelection textSelection = (ITextSelection) selection;
            int lineNumber = textSelection.getStartLine();
            try {
                DRLInfo drlInfo = DroolsEclipsePlugin.getDefault().parseResource(resource, false);
                if (drlInfo != null) {
                    RuleInfo ruleInfo = drlInfo.getRuleInfo(lineNumber);
                    if (ruleInfo != null) {
                        if (ruleInfo.getConsequenceDrlLineNumber() <= lineNumber) {
                            return true;
                        }
                    }
                    FunctionInfo functionInfo = drlInfo.getFunctionInfo(lineNumber);
                    if (functionInfo != null) {
                        if (functionInfo.getDrlLineNumber() <= lineNumber) {
                            return true;
                        }
                    }
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.