Package org.codehaus.commons.compiler

Examples of org.codehaus.commons.compiler.Location


            return;
        }

        // "void" method declaration.
        if (this.peekKeyword("void")) {
            Location location = this.location();
            this.eatToken();
            if (optionalDocComment == null) this.warning("MDCM", "Method doc comment missing", location);
            String name = this.readIdentifier();
            classDeclaration.addDeclaredMethod(this.parseMethodDeclarationRest(
                optionalDocComment,                                  // declaringType
                modifiers,                                // optionalDocComment
                new Java.BasicType(location, Java.BasicType.VOID),                                         // modifiers
                name                                               // name
            ));
            return;
        }

        // Member class.
        if (this.peekKeyword("class")) {
            if (optionalDocComment == null) this.warning("MCDCM", "Member class doc comment missing", this.location());
            this.eatToken();
            classDeclaration.addMemberTypeDeclaration((Java.MemberTypeDeclaration) this.parseClassDeclarationRest(
                optionalDocComment,                      // optionalDocComment
                modifiers,                               // modifiers
                ClassDeclarationContext.TYPE_DECLARATION // context
            ));
            return;
        }

        // Member interface.
        if (this.peekKeyword("interface")) {
            if (optionalDocComment == null) {
                this.warning("MIDCM", "Member interface doc comment missing", this.location());
            }
            this.eatToken();
            classDeclaration.addMemberTypeDeclaration((Java.MemberTypeDeclaration) this.parseInterfaceDeclarationRest(
                optionalDocComment,                                // optionalDocComment
                (short) (modifiers | Mod.STATIC),                  // modifiers
                InterfaceDeclarationContext.NAMED_TYPE_DECLARATION // context
            ));
            return;
        }

        // Constructor.
        if (
            classDeclaration instanceof Java.NamedClassDeclaration &&
            this.scanner.peek().isIdentifier(((Java.NamedClassDeclaration) classDeclaration).getName()) &&
            this.scanner.peekNextButOne().isOperator("(")
        ) {
            if (optionalDocComment == null) this.warning("CDCM", "Constructor doc comment missing", this.location());
            classDeclaration.addConstructor(this.parseConstructorDeclarator(
                optionalDocComment,   // declaringClass
                modifiers           // modifiers
            ));
            return;
        }

        // Member method or field.
        Java.Type memberType = this.parseType();
        Location location = this.location();
        String memberName = this.readIdentifier();

        // Method declarator.
        if (this.peekOperator("(")) {
            if (optionalDocComment == null) this.warning("MDCM", "Method doc comment missing", this.location());
View Full Code Here


    public Java.InterfaceDeclaration parseInterfaceDeclarationRest(
        String                      optionalDocComment,
        short                       modifiers,
        InterfaceDeclarationContext context
    ) throws CompileException, IOException {
        Location location = this.location();
        String interfaceName = this.readIdentifier();
        this.verifyIdentifierIsConventionalClassOrInterfaceName(interfaceName, location);

        Java.ReferenceType[] extendedTypes = new Java.ReferenceType[0];
        if (this.peekKeyword("extends")) {
View Full Code Here

            short modifiers = this.parseModifiersOpt();

            // "void" method declaration.
            if (this.peekKeyword("void")) {
                if (optionalDocComment == null) this.warning("MDCM", "Method doc comment missing", this.location());
                Location location = this.location();
                this.eatToken();
                String name = this.readIdentifier();
                interfaceDeclaration.addDeclaredMethod(this.parseMethodDeclarationRest(
                    optionalDocComment,                                // declaringType
                    (short) (modifiers | Mod.ABSTRACT | Mod.PUBLIC),   // optionalDocComment
                    new Java.BasicType(location, Java.BasicType.VOID), // modifiers
                    name                                               // name
                ));
            } else

            // Member class.
            if (this.peekKeyword("class")) {
                if (optionalDocComment == null) {
                    this.warning("MCDCM", "Member class doc comment missing", this.location());
                }
                this.eatToken();
                interfaceDeclaration.addMemberTypeDeclaration(
                    (Java.MemberTypeDeclaration) this.parseClassDeclarationRest(
                        optionalDocComment,                            // optionalDocComment
                        (short) (modifiers | Mod.STATIC | Mod.PUBLIC), // modifiers
                        ClassDeclarationContext.TYPE_DECLARATION       // context
                    )
                );
            } else

            // Member interface.
            if (this.peekKeyword("interface")) {
                if (optionalDocComment == null) {
                    this.warning("MIDCM", "Member interface doc comment missing", this.location());
                }
                this.eatToken();
                interfaceDeclaration.addMemberTypeDeclaration(
                    (Java.MemberTypeDeclaration) this.parseInterfaceDeclarationRest(
                        optionalDocComment,                                // optionalDocComment
                        (short) (modifiers | Mod.STATIC | Mod.PUBLIC),     // modifiers
                        InterfaceDeclarationContext.NAMED_TYPE_DECLARATION // context
                    )
                );
            } else

            // Member method or field.
            {
                Java.Type memberType = this.parseType();
                if (!this.scanner.peek().isIdentifier()) {
                    this.throwCompileException("Identifier expected in member declaration");
                }
                Location location = this.location();
                String memberName = this.readIdentifier();

                // Method declarator.
                if (this.peekOperator("(")) {
                    if (optionalDocComment == null) this.warning("MDCM", "Method doc comment missing", this.location());
View Full Code Here

     */
    public Java.ConstructorDeclarator parseConstructorDeclarator(
        String optionalDocComment,
        short  modifiers
    ) throws CompileException, IOException {
        Location location = this.location();
        this.readIdentifier()// Class name

        // Parse formal parameters.
        Java.FunctionDeclarator.FormalParameter[] formalParameters = this.parseFormalParameters(
        );
View Full Code Here

        String                       optionalDocComment,
        short                        modifiers,
        Java.Type                    type,
        String                       name
    ) throws CompileException, IOException {
        Location location = this.location();

        this.verifyIdentifierIsConventionalMethodName(name, location);

        Java.FunctionDeclarator.FormalParameter[] formalParameters = this.parseFormalParameters();
View Full Code Here

     *   ArrayInitializer :=
     *     '{' [ VariableInitializer { ',' VariableInitializer } [ ',' ] '}'
     * </pre>
     */
    public Java.ArrayInitializer parseArrayInitializer() throws CompileException, IOException {
        Location location = this.location();
        this.readOperator("{");
        List l = new ArrayList(); // ArrayInitializerOrRvalue
        while (!this.peekOperator("}")) {
            l.add(this.parseVariableInitializer());
            if (this.peekOperator("}")) break;
View Full Code Here

        boolean finaL = this.peekKeyword("final");
        if (finaL) this.eatToken();

        Java.Type type = this.parseType();

        Location location = this.location();
        String name = this.readIdentifier();
        this.verifyIdentifierIsConventionalLocalVariableOrParameterName(name, location);

        for (int i = this.parseBracketsOpt(); i > 0; --i) type = new Java.ArrayType(type);
        return new Java.FunctionDeclarator.FormalParameter(location, finaL, type, name);
View Full Code Here

            return new Java.LocalClassDeclarationStatement(lcd);
        }

        // 'final' Type LocalVariableDeclarators ';'
        if (this.peekKeyword("final")) {
            Location location = this.location();
            this.eatToken();
            Java.Type variableType = this.parseType();
            Java.LocalVariableDeclarationStatement lvds = new Java.LocalVariableDeclarationStatement(
                location,                            // location
                Mod.FINAL,                           // modifiers
View Full Code Here

     *   VariableDeclaratorRest := { '[' ']' } [ '=' VariableInitializer ]
     * </pre>
     * Used by field declarations and local variable declarations.
     */
    public Java.VariableDeclarator parseVariableDeclaratorRest(String name) throws CompileException, IOException  {
        Location loc = this.location();
        int brackets = this.parseBracketsOpt();
        Java.ArrayInitializerOrRvalue initializer = null;
        if (this.peekOperator("=")) {
            this.eatToken();
            initializer = this.parseVariableInitializer();
View Full Code Here

     * <pre>
     *   IfStatement := 'if' '(' Expression ')' Statement [ 'else' Statement ]
     * </pre>
     */
    public Java.Statement parseIfStatement() throws CompileException, IOException {
        Location location = this.location();
        this.readKeyword("if");
        this.readOperator("(");
        final Java.Rvalue condition = this.parseExpression().toRvalueOrPE();
        this.readOperator(")");

View Full Code Here

TOP

Related Classes of org.codehaus.commons.compiler.Location

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.