private void markOtherErrors(List<DroolsBuildMarker> markers,
                                 DroolsError[] buildErrors) {
        // TODO are there warnings too?
        for ( int i = 0; i < buildErrors.length; i++ ) {
            DroolsError error = buildErrors[i];
            if ( error instanceof GlobalError ) {
                GlobalError globalError = (GlobalError) error;
                markers.add( new DroolsBuildMarker( "Global error: " + globalError.getGlobal(),
                                                    -1 ) );
            } else if ( error instanceof RuleBuildError ) {
                RuleBuildError ruleError = (RuleBuildError) error;
                // TODO try to retrieve line number (or even character start-end)
                // disabled for now because line number are those of the rule class,
                // not the rule file itself
                if ( ruleError.getObject() instanceof CompilationProblem[] ) {
                    CompilationProblem[] problems = (CompilationProblem[]) ruleError.getObject();
                    for ( int j = 0; j < problems.length; j++ ) {
                        markers.add( new DroolsBuildMarker( problems[j].getMessage(),
                                                            ruleError.getLine() ) );
                    }
                } else {
                    markers.add( new DroolsBuildMarker( ruleError.getRule().getName() + ":" + ruleError.getMessage(),
                                                        ruleError.getLine() ) );
                }
            } else if ( error instanceof ParserError ) {
                ParserError parserError = (ParserError) error;
                // TODO try to retrieve character start-end
                markers.add( new DroolsBuildMarker( parserError.getMessage(),
                                                    parserError.getRow() ) );
            } else if ( error instanceof FunctionError ) {
                FunctionError functionError = (FunctionError) error;
                // TODO add line to function error
                // TODO try to retrieve character start-end
                if ( functionError.getObject() instanceof CompilationProblem[] ) {
                    CompilationProblem[] problems = (CompilationProblem[]) functionError.getObject();
                    for ( int j = 0; j < problems.length; j++ ) {
                        markers.add( new DroolsBuildMarker( problems[j].getMessage(),
                                                            functionError.getLines()[j] ) );
                    }
                } else {
                    markers.add( new DroolsBuildMarker( functionError.getFunctionDescr().getName() + ":" + functionError.getMessage(),
                                                        -1 ) );
                }
            } else if ( error instanceof FieldTemplateError ) {
                markers.add( new DroolsBuildMarker( error.getMessage(),
                                                    ((FieldTemplateError) error).getLine() ) );
            } else if ( error instanceof FactTemplateError ) {
                markers.add( new DroolsBuildMarker( error.getMessage(),
                                                    ((FactTemplateError) error).getLine() ) );
            } else if ( error instanceof ImportError ) {
                markers.add( new DroolsBuildMarker( "ImportError: " + error.getMessage() ) );
            } else if ( error instanceof DescrBuildError ) {
                markers.add( new DroolsBuildMarker( "BuildError: " + error.getMessage(),
                                                    ((DescrBuildError) error).getLine() ) );
            } else {
                markers.add( new DroolsBuildMarker( "Unknown DroolsError " + error.getClass() + ": " + error ) );
            }
        }
    }
private void markOtherErrors(List<DroolsBuildMarker> markers,
                                 DroolsError[] buildErrors) {
        
        for ( int i = 0; i < buildErrors.length; i++ ) {
            DroolsError error = buildErrors[i];
            if ( error instanceof GlobalError ) {
                GlobalError globalError = (GlobalError) error;
                markers.add( new DroolsBuildMarker( "Global error: " + globalError.getGlobal(),
                                                    -1 ) );
            } else if ( error instanceof RuleBuildError ) {
                RuleBuildError ruleError = (RuleBuildError) error;
                
                
                
                if ( ruleError.getObject() instanceof CompilationProblem[] ) {
                    CompilationProblem[] problems = (CompilationProblem[]) ruleError.getObject();
                    for ( int j = 0; j < problems.length; j++ ) {
                        markers.add( new DroolsBuildMarker( problems[j].getMessage(),
                                                            ruleError.getLine() ) );
                    }
                } else {
                    markers.add( new DroolsBuildMarker( ruleError.getRule().getName() + ":" + ruleError.getMessage(),
                                                        ruleError.getLine() ) );
                }
            } else if ( error instanceof ParserError ) {
                ParserError parserError = (ParserError) error;
                
                markers.add( new DroolsBuildMarker( parserError.getMessage(),
                                                    parserError.getRow() ) );
            } else if ( error instanceof FunctionError ) {
                FunctionError functionError = (FunctionError) error;
                
                
                if ( functionError.getObject() instanceof CompilationProblem[] ) {
                    CompilationProblem[] problems = (CompilationProblem[]) functionError.getObject();
                    for ( int j = 0; j < problems.length; j++ ) {
                        markers.add( new DroolsBuildMarker( problems[j].getMessage(),
                                                            functionError.getLines()[j] ) );
                    }
                } else {
                    markers.add( new DroolsBuildMarker( functionError.getFunctionDescr().getName() + ":" + functionError.getMessage(),
                                                        -1 ) );
                }
            } else if ( error instanceof FieldTemplateError ) {
                markers.add( new DroolsBuildMarker( error.getMessage(),
                                                    ((FieldTemplateError) error).getLine() ) );
            } else if ( error instanceof FactTemplateError ) {
                markers.add( new DroolsBuildMarker( error.getMessage(),
                                                    ((FactTemplateError) error).getLine() ) );
            } else if ( error instanceof ImportError ) {
                markers.add( new DroolsBuildMarker( "ImportError: " + error.getMessage() ) );
            } else if ( error instanceof DescrBuildError ) {
                markers.add( new DroolsBuildMarker( "BuildError: " + error.getMessage(),
                                                    ((DescrBuildError) error).getLine() ) );
            } else {
                markers.add( new DroolsBuildMarker( "Unknown DroolsError " + error.getClass() + ": " + error ) );
            }
        }
    }
private void markOtherErrors ( List < DroolsBuildMarker > markers , DroolsError [ ] buildErrors ) { // TODO are there warnings too? for ( int i = 0 ; i < buildErrors . length ; i ++ ) { DroolsError error = buildErrors [ i ] ; if ( error instanceof GlobalError ) { GlobalError globalError = ( GlobalError ) error ; markers . add ( new DroolsBuildMarker ( "Global error: " + globalError . getGlobal ( ) , - 1 ) ) ; } else if ( error instanceof RuleBuildError ) { RuleBuildError ruleError = ( RuleBuildError ) error ; // TODO try to retrieve line number (or even character start-end) // disabled for now because line number are those of the rule class, // not the rule file itself if ( ruleError . getObject ( ) instanceof CompilationProblem [ ] ) { CompilationProblem [ ] problems = ( CompilationProblem [ ] ) ruleError . getObject ( ) ; for ( int j = 0 ; j < problems . length ; j ++ ) { markers . add ( new DroolsBuildMarker ( problems [ j ] . getMessage ( ) , ruleError . getLine ( ) ) ) ; } } else { markers . add ( new DroolsBuildMarker ( ruleError . getRule ( ) . getName ( ) + ":" + ruleError . getMessage ( ) , ruleError . getLine ( ) ) ) ; } } else if ( error instanceof ParserError ) { ParserError parserError = ( ParserError ) error ; // TODO try to retrieve character start-end markers . add ( new DroolsBuildMarker ( parserError . getMessage ( ) , parserError . getRow ( ) ) ) ; } else if ( error instanceof FunctionError ) { FunctionError functionError = ( FunctionError ) error ; // TODO add line to function error // TODO try to retrieve character start-end if ( functionError . getObject ( ) instanceof CompilationProblem [ ] ) { CompilationProblem [ ] problems = ( CompilationProblem [ ] ) functionError . getObject ( ) ; for ( int j = 0 ; j < problems . length ; j ++ ) { markers . add ( new DroolsBuildMarker ( problems [ j ] . getMessage ( ) , functionError . getLines ( ) [ j ] ) ) ; } } else { markers . add ( new DroolsBuildMarker ( functionError . getFunctionDescr ( ) . getName ( ) + ":" + functionError . getMessage ( ) , - 1 ) ) ; } } else if ( error instanceof FieldTemplateError ) { markers . add ( new DroolsBuildMarker ( error . getMessage ( ) , ( ( FieldTemplateError ) error ) . getLine ( ) ) ) ; } else if ( error instanceof FactTemplateError ) { markers . add ( new DroolsBuildMarker ( error . getMessage ( ) , ( ( FactTemplateError ) error ) . getLine ( ) ) ) ; } else if ( error instanceof ImportError ) { markers . add ( new DroolsBuildMarker ( "ImportError: " + error . getMessage ( ) ) ) ; } else if ( error instanceof DescrBuildError ) { markers . add ( new DroolsBuildMarker ( "BuildError: " + error . getMessage ( ) , ( ( DescrBuildError ) error ) . getLine ( ) ) ) ; } else { markers . add ( new DroolsBuildMarker ( "Unknown DroolsError " + error . getClass ( ) + ": " + error ) ) ; } } }
This will create markers for build errors that happen AFTER parsing.
This will create markers for build errors that happen AFTER parsing .