Package org.drools.compiler.lang.api

Examples of org.drools.compiler.lang.api.TypeDeclarationDescrBuilder


     *
     * @return
     * @throws org.antlr.runtime.RecognitionException
     */
    public TypeDeclarationDescr typeDeclaration(DeclareDescrBuilder ddb, boolean isTrait) throws RecognitionException {
        TypeDeclarationDescrBuilder declare = null;
        try {
            declare = helper.start(ddb,
                    TypeDeclarationDescrBuilder.class,
                    null);

            if (isTrait) {
                declare.newAnnotation(TypeDeclaration.Kind.ID).value(TypeDeclaration.Kind.TRAIT.name());
            }

            if (helper.validateIdentifierKey(DroolsSoftKeywords.TYPE)) {
                // 'type'
                match(input,
                        DRL6Lexer.ID,
                        DroolsSoftKeywords.TYPE,
                        null,
                        DroolsEditorType.KEYWORD);
                if (state.failed)
                    return null;
            }

            // type may be qualified when adding metadata
            String type = qualifiedIdentifier();
            if (state.failed)
                return null;
            if (state.backtracking == 0)
                declare.name(type);

            if (helper.validateIdentifierKey(DroolsSoftKeywords.EXTENDS)) {
                match(input,
                        DRL6Lexer.ID,
                        DroolsSoftKeywords.EXTENDS,
                        null,
                        DroolsEditorType.KEYWORD);
                if (!state.failed) {
                    // Going for type includes generics, which is a no-no (JIRA-3040)
                    String superType = qualifiedIdentifier();
                    declare.superType(superType);

                    while (input.LA(1) == DRL6Lexer.COMMA) {

                        match(input,
                                DRL6Lexer.COMMA,
                                null,
                                null,
                                DroolsEditorType.SYMBOL);

                        superType = qualifiedIdentifier();
                        declare.superType(superType);
                    }
                }
            }

            while (input.LA(1) == DRL6Lexer.AT) {
                // annotation*
                annotation(declare);
                if (state.failed)
                    return null;
            }

            //boolean qualified = type.indexOf( '.' ) >= 0;
            while ( //! qualified &&
            input.LA(1) == DRL6Lexer.ID && !helper.validateIdentifierKey(DroolsSoftKeywords.END)) {
                // field*
                field(declare);
                if (state.failed)
                    return null;
            }

            match(input,
                    DRL6Lexer.ID,
                    DroolsSoftKeywords.END,
                    null,
                    DroolsEditorType.KEYWORD);
            if (state.failed)
                return null;

        } catch (RecognitionException re) {
            reportError(re);
        } finally {
            helper.end(TypeDeclarationDescrBuilder.class,
                    declare);
        }
        return (declare != null) ? declare.getDescr() : null;
    }
View Full Code Here


     *
     * @return
     * @throws org.antlr.runtime.RecognitionException
     */
    public TypeDeclarationDescr typeDeclaration( DeclareDescrBuilder ddb, boolean isTrait ) throws RecognitionException {
        TypeDeclarationDescrBuilder declare = null;
        try {
            declare = helper.start( ddb,
                                    TypeDeclarationDescrBuilder.class,
                                    null );

            if ( isTrait ) {
                declare.newAnnotation( TypeDeclaration.Kind.ID ).value( TypeDeclaration.Kind.TRAIT.name() );
            }

            if( helper.validateIdentifierKey( DroolsSoftKeywords.TYPE ) ) {
                // 'type'
                match( input,
                       DRL6Lexer.ID,
                       DroolsSoftKeywords.TYPE,
                       null,
                       DroolsEditorType.KEYWORD );
                if ( state.failed ) return null;
            }

            // type may be qualified when adding metadata
            String type = qualifiedIdentifier();
            if ( state.failed ) return null;
            if ( state.backtracking == 0 ) declare.name( type );

            if ( helper.validateIdentifierKey( DroolsSoftKeywords.EXTENDS ) ) {
                match( input,
                       DRL6Lexer.ID,
                       DroolsSoftKeywords.EXTENDS,
                       null,
                       DroolsEditorType.KEYWORD );
                if ( !state.failed ) {
                    // Going for type includes generics, which is a no-no (JIRA-3040)
                    String superType = qualifiedIdentifier();
                    declare.superType( superType );

                    while ( input.LA( 1 ) == DRL6Lexer.COMMA ) {

                        match( input,
                                DRL6Lexer.COMMA,
                                null,
                                null,
                                DroolsEditorType.SYMBOL );

                        superType = qualifiedIdentifier();
                        declare.superType( superType );
                    }
                }
            }

            while ( input.LA( 1 ) == DRL6Lexer.AT ) {
                // annotation*
                annotation( declare );
                if ( state.failed ) return null;
            }

            //boolean qualified = type.indexOf( '.' ) >= 0;
            while ( //! qualified &&
            input.LA( 1 ) == DRL6Lexer.ID && !helper.validateIdentifierKey( DroolsSoftKeywords.END ) ) {
                // field*
                field( declare );
                if ( state.failed ) return null;
            }

            match( input,
                   DRL6Lexer.ID,
                   DroolsSoftKeywords.END,
                   null,
                   DroolsEditorType.KEYWORD );
            if ( state.failed ) return null;

        } catch ( RecognitionException re ) {
            reportError( re );
        } finally {
            helper.end( TypeDeclarationDescrBuilder.class,
                        declare );
        }
        return (declare != null) ? declare.getDescr() : null;
    }
View Full Code Here

     *
     * @return
     * @throws RecognitionException
     */
    public TypeDeclarationDescr typeDeclaration( DeclareDescrBuilder ddb, boolean isTrait ) throws RecognitionException {
        TypeDeclarationDescrBuilder declare = null;
        try {
            declare = helper.start( ddb,
                                    TypeDeclarationDescrBuilder.class,
                                    null );

            if ( isTrait ) {
                declare.newAnnotation( TypeDeclaration.Kind.ID ).value( TypeDeclaration.Kind.TRAIT.name() );
            }
           
            if( helper.validateIdentifierKey( DroolsSoftKeywords.TYPE ) ) {
                // 'type'
                match( input,
                       DRL5Lexer.ID,
                       DroolsSoftKeywords.TYPE,
                       null,
                       DroolsEditorType.KEYWORD );
                if ( state.failed ) return null;
            }

            // type may be qualified when adding metadata
            String type = qualifiedIdentifier();
            if ( state.failed ) return null;
            if ( state.backtracking == 0 ) declare.name( type );

            if ( helper.validateIdentifierKey( DroolsSoftKeywords.EXTENDS ) ) {
                match( input,
                       DRL5Lexer.ID,
                       DroolsSoftKeywords.EXTENDS,
                       null,
                       DroolsEditorType.KEYWORD );
                if ( !state.failed ) {
                    // Going for type includes generics, which is a no-no (JIRA-3040)
                    String superType = qualifiedIdentifier();
                    declare.superType( superType );

                    while ( input.LA( 1 ) == DRL5Lexer.COMMA ) {

                        match( input,
                                DRL5Lexer.COMMA,
                                null,
                                null,
                                DroolsEditorType.SYMBOL );

                        superType = qualifiedIdentifier();
                        declare.superType( superType );
                    }
                }
            }

            while ( input.LA( 1 ) == DRL5Lexer.AT ) {
                // annotation*
                annotation( declare );
                if ( state.failed ) return null;
            }

            //boolean qualified = type.indexOf( '.' ) >= 0;
            while ( //! qualified &&
            input.LA( 1 ) == DRL5Lexer.ID && !helper.validateIdentifierKey( DroolsSoftKeywords.END ) ) {
                // field*
                field( declare );
                if ( state.failed ) return null;
            }

            match( input,
                   DRL5Lexer.ID,
                   DroolsSoftKeywords.END,
                   null,
                   DroolsEditorType.KEYWORD );
            if ( state.failed ) return null;

        } catch ( RecognitionException re ) {
            reportError( re );
        } finally {
            helper.end( TypeDeclarationDescrBuilder.class,
                        declare );
        }
        return (declare != null) ? declare.getDescr() : null;
    }
View Full Code Here

     *
     * @return
     * @throws org.antlr.runtime.RecognitionException
     */
    public TypeDeclarationDescr typeDeclaration( DeclareDescrBuilder ddb, boolean isTrait ) throws RecognitionException {
        TypeDeclarationDescrBuilder declare = null;
        try {
            declare = helper.start( ddb,
                                    TypeDeclarationDescrBuilder.class,
                                    null );

            if ( isTrait ) {
                declare.newAnnotation( TypeDeclaration.Kind.ID ).value( TypeDeclaration.Kind.TRAIT.name() );
            }

            if( helper.validateIdentifierKey( DroolsSoftKeywords.TYPE ) ) {
                // 'type'
                match( input,
                       DRL6Lexer.ID,
                       DroolsSoftKeywords.TYPE,
                       null,
                       DroolsEditorType.KEYWORD );
                if ( state.failed ) return null;
            }

            // type may be qualified when adding metadata
            String type = qualifiedIdentifier();
            if ( state.failed ) return null;
            if ( state.backtracking == 0 ) declare.name( type );

            if ( helper.validateIdentifierKey( DroolsSoftKeywords.EXTENDS ) ) {
                match( input,
                       DRL6Lexer.ID,
                       DroolsSoftKeywords.EXTENDS,
                       null,
                       DroolsEditorType.KEYWORD );
                if ( !state.failed ) {
                    // Going for type includes generics, which is a no-no (JIRA-3040)
                    String superType = qualifiedIdentifier();
                    declare.superType( superType );

                    while ( input.LA( 1 ) == DRL6Lexer.COMMA ) {

                        match( input,
                                DRL6Lexer.COMMA,
                                null,
                                null,
                                DroolsEditorType.SYMBOL );

                        superType = qualifiedIdentifier();
                        declare.superType( superType );
                    }
                }
            }

            while ( input.LA( 1 ) == DRL6Lexer.AT ) {
                // annotation*
                annotation( declare );
                if ( state.failed ) return null;
            }

            //boolean qualified = type.indexOf( '.' ) >= 0;
            while ( //! qualified &&
            input.LA( 1 ) == DRL6Lexer.ID && !helper.validateIdentifierKey( DroolsSoftKeywords.END ) ) {
                // field*
                field( declare );
                if ( state.failed ) return null;
            }

            match( input,
                   DRL6Lexer.ID,
                   DroolsSoftKeywords.END,
                   null,
                   DroolsEditorType.KEYWORD );
            if ( state.failed ) return null;

        } catch ( RecognitionException re ) {
            reportError( re );
        } finally {
            helper.end( TypeDeclarationDescrBuilder.class,
                        declare );
        }
        return (declare != null) ? declare.getDescr() : null;
    }
View Full Code Here

     *
     * @return
     * @throws org.antlr.runtime.RecognitionException
     */
    public TypeDeclarationDescr typeDeclaration(DeclareDescrBuilder ddb, boolean isTrait) throws RecognitionException {
        TypeDeclarationDescrBuilder declare = null;
        try {
            declare = helper.start(ddb,
                    TypeDeclarationDescrBuilder.class,
                    null);

            declare.setTrait(isTrait);

            if (helper.validateIdentifierKey(DroolsSoftKeywords.TYPE)) {
                // 'type'
                match(input,
                        DRL6Lexer.ID,
                        DroolsSoftKeywords.TYPE,
                        null,
                        DroolsEditorType.KEYWORD);
                if (state.failed)
                    return null;
            }

            // type may be qualified when adding metadata
            String type = qualifiedIdentifier();
            if (state.failed)
                return null;
            if (state.backtracking == 0)
                declare.name(type);

            if (helper.validateIdentifierKey(DroolsSoftKeywords.EXTENDS)) {
                match(input,
                        DRL6Lexer.ID,
                        DroolsSoftKeywords.EXTENDS,
                        null,
                        DroolsEditorType.KEYWORD);
                if (!state.failed) {
                    // Going for type includes generics, which is a no-no (JIRA-3040)
                    String superType = qualifiedIdentifier();
                    declare.superType(superType);

                    while (input.LA(1) == DRL6Lexer.COMMA) {

                        match(input,
                                DRL6Lexer.COMMA,
                                null,
                                null,
                                DroolsEditorType.SYMBOL);

                        superType = qualifiedIdentifier();
                        declare.superType(superType);
                    }
                }
            }

            while (input.LA(1) == DRL6Lexer.AT) {
                // annotation*
                annotation(declare);
                if (state.failed)
                    return null;
            }

            //boolean qualified = type.indexOf( '.' ) >= 0;
            while ( //! qualified &&
            input.LA(1) == DRL6Lexer.ID && !helper.validateIdentifierKey(DroolsSoftKeywords.END)) {
                // field*
                field(declare);
                if (state.failed)
                    return null;
            }

            match(input,
                    DRL6Lexer.ID,
                    DroolsSoftKeywords.END,
                    null,
                    DroolsEditorType.KEYWORD);
            if (state.failed)
                return null;

        } catch (RecognitionException re) {
            reportError(re);
        } finally {
            helper.end(TypeDeclarationDescrBuilder.class,
                    declare);
        }
        return (declare != null) ? declare.getDescr() : null;
    }
View Full Code Here

     *
     * @return
     * @throws RecognitionException
     */
    public TypeDeclarationDescr typeDeclaration( DeclareDescrBuilder ddb, boolean isTrait ) throws RecognitionException {
        TypeDeclarationDescrBuilder declare = null;
        try {
            declare = helper.start( ddb,
                                    TypeDeclarationDescrBuilder.class,
                                    null );

            declare.setTrait(isTrait);
           
            if( helper.validateIdentifierKey( DroolsSoftKeywords.TYPE ) ) {
                // 'type'
                match( input,
                       DRL5Lexer.ID,
                       DroolsSoftKeywords.TYPE,
                       null,
                       DroolsEditorType.KEYWORD );
                if ( state.failed ) return null;
            }

            // type may be qualified when adding metadata
            String type = qualifiedIdentifier();
            if ( state.failed ) return null;
            if ( state.backtracking == 0 ) declare.name( type );

            if ( helper.validateIdentifierKey( DroolsSoftKeywords.EXTENDS ) ) {
                match( input,
                       DRL5Lexer.ID,
                       DroolsSoftKeywords.EXTENDS,
                       null,
                       DroolsEditorType.KEYWORD );
                if ( !state.failed ) {
                    // Going for type includes generics, which is a no-no (JIRA-3040)
                    String superType = qualifiedIdentifier();
                    declare.superType( superType );

                    while ( input.LA( 1 ) == DRL5Lexer.COMMA ) {

                        match( input,
                                DRL5Lexer.COMMA,
                                null,
                                null,
                                DroolsEditorType.SYMBOL );

                        superType = qualifiedIdentifier();
                        declare.superType( superType );
                    }
                }
            }

            while ( input.LA( 1 ) == DRL5Lexer.AT ) {
                // annotation*
                annotation( declare );
                if ( state.failed ) return null;
            }

            //boolean qualified = type.indexOf( '.' ) >= 0;
            while ( //! qualified &&
            input.LA( 1 ) == DRL5Lexer.ID && !helper.validateIdentifierKey( DroolsSoftKeywords.END ) ) {
                // field*
                field( declare );
                if ( state.failed ) return null;
            }

            match( input,
                   DRL5Lexer.ID,
                   DroolsSoftKeywords.END,
                   null,
                   DroolsEditorType.KEYWORD );
            if ( state.failed ) return null;

        } catch ( RecognitionException re ) {
            reportError( re );
        } finally {
            helper.end( TypeDeclarationDescrBuilder.class,
                        declare );
        }
        return (declare != null) ? declare.getDescr() : null;
    }
View Full Code Here

     *
     * @return
     * @throws org.antlr.runtime.RecognitionException
     */
    public TypeDeclarationDescr typeDeclaration(DeclareDescrBuilder ddb, boolean isTrait) throws RecognitionException {
        TypeDeclarationDescrBuilder declare = null;
        try {
            declare = helper.start(ddb,
                    TypeDeclarationDescrBuilder.class,
                    null);

            setAnnotationsOn(declare);
            declare.setTrait(isTrait);

            if (helper.validateIdentifierKey(DroolsSoftKeywords.TYPE)) {
                // 'type'
                match(input,
                        DRL6Lexer.ID,
                        DroolsSoftKeywords.TYPE,
                        null,
                        DroolsEditorType.KEYWORD);
                if (state.failed)
                    return null;
            }

            // type may be qualified when adding metadata
            String type = qualifiedIdentifier();
            if (state.failed)
                return null;
            if (state.backtracking == 0)
                declare.name(type);

            if (helper.validateIdentifierKey(DroolsSoftKeywords.EXTENDS)) {
                match(input,
                        DRL6Lexer.ID,
                        DroolsSoftKeywords.EXTENDS,
                        null,
                        DroolsEditorType.KEYWORD);
                if (!state.failed) {
                    // Going for type includes generics, which is a no-no (JIRA-3040)
                    String superType = qualifiedIdentifier();
                    declare.superType(superType);

                    while (input.LA(1) == DRL6Lexer.COMMA) {

                        match(input,
                                DRL6Lexer.COMMA,
                                null,
                                null,
                                DroolsEditorType.SYMBOL);

                        superType = qualifiedIdentifier();
                        declare.superType(superType);
                    }
                }
            }

            //boolean qualified = type.indexOf( '.' ) >= 0;
            while ( (input.LA(1) == DRL6Lexer.ID || input.LA(1) == DRL6Lexer.AT) &&
                    !helper.validateIdentifierKey(DroolsSoftKeywords.END)) {
                // field*
                field(declare);
                if (state.failed)
                    return null;
            }

            match(input,
                    DRL6Lexer.ID,
                    DroolsSoftKeywords.END,
                    null,
                    DroolsEditorType.KEYWORD);
            if (state.failed)
                return null;

        } catch (RecognitionException re) {
            reportError(re);
        } finally {
            helper.end(TypeDeclarationDescrBuilder.class,
                    declare);
        }
        return (declare != null) ? declare.getDescr() : null;
    }
View Full Code Here

                DeclareDescrBuilder declare = ctxBuilder == null ?
                                              DescrFactory.newPackage().newDeclare() :
                                              ((PackageDescrBuilder) ctxBuilder).newDeclare();
                return (T) declare;
            } else if ( TypeDeclarationDescrBuilder.class.isAssignableFrom( clazz ) ) {
                TypeDeclarationDescrBuilder declare = ctxBuilder == null ?
                                                      DescrFactory.newPackage().newDeclare().type() :
                                                      ((DeclareDescrBuilder) ctxBuilder).type();
                pushParaphrases( DroolsParaphraseTypes.TYPE_DECLARE );
                beginSentence( DroolsSentenceType.TYPE_DECLARATION );
                setStart( declare );
View Full Code Here

     *
     * @return
     * @throws org.antlr.runtime.RecognitionException
     */
    public TypeDeclarationDescr typeDeclaration(DeclareDescrBuilder ddb, boolean isTrait) throws RecognitionException {
        TypeDeclarationDescrBuilder declare = null;
        try {
            declare = helper.start(ddb,
                    TypeDeclarationDescrBuilder.class,
                    null);

            if (isTrait) {
                declare.newAnnotation(TypeDeclaration.Kind.ID).value(TypeDeclaration.Kind.TRAIT.name());
            }

            if (helper.validateIdentifierKey(DroolsSoftKeywords.TYPE)) {
                // 'type'
                match(input,
                        DRL6Lexer.ID,
                        DroolsSoftKeywords.TYPE,
                        null,
                        DroolsEditorType.KEYWORD);
                if (state.failed)
                    return null;
            }

            // type may be qualified when adding metadata
            String type = qualifiedIdentifier();
            if (state.failed)
                return null;
            if (state.backtracking == 0)
                declare.name(type);

            if (helper.validateIdentifierKey(DroolsSoftKeywords.EXTENDS)) {
                match(input,
                        DRL6Lexer.ID,
                        DroolsSoftKeywords.EXTENDS,
                        null,
                        DroolsEditorType.KEYWORD);
                if (!state.failed) {
                    // Going for type includes generics, which is a no-no (JIRA-3040)
                    String superType = qualifiedIdentifier();
                    declare.superType(superType);

                    while (input.LA(1) == DRL6Lexer.COMMA) {

                        match(input,
                                DRL6Lexer.COMMA,
                                null,
                                null,
                                DroolsEditorType.SYMBOL);

                        superType = qualifiedIdentifier();
                        declare.superType(superType);
                    }
                }
            }

            while (input.LA(1) == DRL6Lexer.AT) {
                // annotation*
                annotation(declare);
                if (state.failed)
                    return null;
            }

            //boolean qualified = type.indexOf( '.' ) >= 0;
            while ( //! qualified &&
            input.LA(1) == DRL6Lexer.ID && !helper.validateIdentifierKey(DroolsSoftKeywords.END)) {
                // field*
                field(declare);
                if (state.failed)
                    return null;
            }

            match(input,
                    DRL6Lexer.ID,
                    DroolsSoftKeywords.END,
                    null,
                    DroolsEditorType.KEYWORD);
            if (state.failed)
                return null;

        } catch (RecognitionException re) {
            reportError(re);
        } finally {
            helper.end(TypeDeclarationDescrBuilder.class,
                    declare);
        }
        return (declare != null) ? declare.getDescr() : null;
    }
View Full Code Here

     *
     * @return
     * @throws RecognitionException
     */
    public TypeDeclarationDescr typeDeclaration( DeclareDescrBuilder ddb, boolean isTrait ) throws RecognitionException {
        TypeDeclarationDescrBuilder declare = null;
        try {
            declare = helper.start( ddb,
                                    TypeDeclarationDescrBuilder.class,
                                    null );

            if ( isTrait ) {
                declare.newAnnotation( TypeDeclaration.Kind.ID ).value( TypeDeclaration.Kind.TRAIT.name() );
            }
           
            if( helper.validateIdentifierKey( DroolsSoftKeywords.TYPE ) ) {
                // 'type'
                match( input,
                       DRL5Lexer.ID,
                       DroolsSoftKeywords.TYPE,
                       null,
                       DroolsEditorType.KEYWORD );
                if ( state.failed ) return null;
            }

            // type may be qualified when adding metadata
            String type = qualifiedIdentifier();
            if ( state.failed ) return null;
            if ( state.backtracking == 0 ) declare.name( type );

            if ( helper.validateIdentifierKey( DroolsSoftKeywords.EXTENDS ) ) {
                match( input,
                       DRL5Lexer.ID,
                       DroolsSoftKeywords.EXTENDS,
                       null,
                       DroolsEditorType.KEYWORD );
                if ( !state.failed ) {
                    // Going for type includes generics, which is a no-no (JIRA-3040)
                    String superType = qualifiedIdentifier();
                    declare.superType( superType );

                    while ( input.LA( 1 ) == DRL5Lexer.COMMA ) {

                        match( input,
                                DRL5Lexer.COMMA,
                                null,
                                null,
                                DroolsEditorType.SYMBOL );

                        superType = qualifiedIdentifier();
                        declare.superType( superType );
                    }
                }
            }

            while ( input.LA( 1 ) == DRL5Lexer.AT ) {
                // annotation*
                annotation( declare );
                if ( state.failed ) return null;
            }

            //boolean qualified = type.indexOf( '.' ) >= 0;
            while ( //! qualified &&
            input.LA( 1 ) == DRL5Lexer.ID && !helper.validateIdentifierKey( DroolsSoftKeywords.END ) ) {
                // field*
                field( declare );
                if ( state.failed ) return null;
            }

            match( input,
                   DRL5Lexer.ID,
                   DroolsSoftKeywords.END,
                   null,
                   DroolsEditorType.KEYWORD );
            if ( state.failed ) return null;

        } catch ( RecognitionException re ) {
            reportError( re );
        } finally {
            helper.end( TypeDeclarationDescrBuilder.class,
                        declare );
        }
        return (declare != null) ? declare.getDescr() : null;
    }
View Full Code Here

TOP

Related Classes of org.drools.compiler.lang.api.TypeDeclarationDescrBuilder

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.