Java 类org.eclipse.jdt.internal.compiler.ast.EmptyStatement 实例源码

项目:Eclipse-Postfix-Code-Completion    文件:Parser.java   
protected void consumeEnhancedForStatement() {
    // EnhancedForStatement ::= EnhancedForStatementHeader Statement
    // EnhancedForStatementNoShortIf ::= EnhancedForStatementHeader StatementNoShortIf

    //statements
    this.astLengthPtr--;
    Statement statement = (Statement) this.astStack[this.astPtr--];

    // foreach statement is on the ast stack
    ForeachStatement foreachStatement = (ForeachStatement) this.astStack[this.astPtr];
    foreachStatement.action = statement;
    // remember useful empty statement
    if (statement instanceof EmptyStatement) statement.bits |= ASTNode.IsUsefulEmptyStatement;

    foreachStatement.sourceEnd = this.endStatementPosition;
}
项目:Eclipse-Postfix-Code-Completion    文件:CodeFormatterVisitor.java   
/**
 * @see org.eclipse.jdt.internal.compiler.ASTVisitor#visit(org.eclipse.jdt.internal.compiler.ast.EmptyStatement, org.eclipse.jdt.internal.compiler.lookup.BlockScope)
 */
public boolean visit(EmptyStatement statement, BlockScope scope) {
    if (this.preferences.put_empty_statement_on_new_line) {
        this.scribe.printNewLine();
    }
    this.scribe.printNextToken(TerminalTokens.TokenNameSEMICOLON, this.preferences.insert_space_before_semicolon);
    this.scribe.printComment(CodeFormatter.K_UNKNOWN, Scribe.BASIC_TRAILING_COMMENT);
    return false;
}
项目:Eclipse-Postfix-Code-Completion    文件:Parser.java   
protected void consumeEmptyStatement() {
    // EmptyStatement ::= ';'
    char[] source = this.scanner.source;
    if (source[this.endStatementPosition] == ';') {
        pushOnAstStack(new EmptyStatement(this.endStatementPosition, this.endStatementPosition));
    } else {
        if(source.length > 5) {
            int c1 = 0, c2 = 0, c3 = 0, c4 = 0;
            int pos = this.endStatementPosition - 4;
            while (source[pos] == 'u') {
                pos--;
            }
            if (source[pos] == '\\' &&
                    !((c1 = ScannerHelper.getHexadecimalValue(source[this.endStatementPosition - 3])) > 15
                        || c1 < 0
                        || (c2 = ScannerHelper.getHexadecimalValue(source[this.endStatementPosition - 2])) > 15
                        || c2 < 0
                        || (c3 = ScannerHelper.getHexadecimalValue(source[this.endStatementPosition - 1])) > 15
                        || c3 < 0
                        || (c4 = ScannerHelper.getHexadecimalValue(source[this.endStatementPosition])) > 15
                        || c4 < 0) &&
                    ((char) (((c1 * 16 + c2) * 16 + c3) * 16 + c4)) == ';'){
                // we have a Unicode for the ';' (/u003B)
                pushOnAstStack(new EmptyStatement(pos, this.endStatementPosition));
                return;
            }
        }
        pushOnAstStack(new EmptyStatement(this.endPosition + 1, this.endStatementPosition));
    }
}
项目:Eclipse-Postfix-Code-Completion-Juno38    文件:CodeFormatterVisitor.java   
/**
 * @see org.eclipse.jdt.internal.compiler.ASTVisitor#visit(org.eclipse.jdt.internal.compiler.ast.EmptyStatement, org.eclipse.jdt.internal.compiler.lookup.BlockScope)
 */
public boolean visit(EmptyStatement statement, BlockScope scope) {
    if (this.preferences.put_empty_statement_on_new_line) {
        this.scribe.printNewLine();
    }
    this.scribe.printNextToken(TerminalTokens.TokenNameSEMICOLON, this.preferences.insert_space_before_semicolon);
    this.scribe.printComment(CodeFormatter.K_UNKNOWN, Scribe.BASIC_TRAILING_COMMENT);
    return false;
}
项目:lombok-ianchiu    文件:SetGeneratedByVisitor.java   
@Override public boolean visit(EmptyStatement node, BlockScope scope) {
    fixPositions(setGeneratedBy(node, source));
    return super.visit(node, scope);
}
项目:EasyMPermission    文件:SetGeneratedByVisitor.java   
@Override public boolean visit(EmptyStatement node, BlockScope scope) {
    fixPositions(setGeneratedBy(node, source));
    return super.visit(node, scope);
}
项目:Eclipse-Postfix-Code-Completion    文件:CodeFormatterVisitor.java   
private void formatStatements(BlockScope scope, final Statement[] statements, boolean insertNewLineAfterLastStatement) {
    int statementsLength = statements.length;
    for (int i = 0; i < statementsLength; i++) {
        final Statement statement = statements[i];
        if (i > 0 && (statements[i - 1] instanceof EmptyStatement) && !(statement instanceof EmptyStatement)) {
            this.scribe.printNewLine();
        }
        statement.traverse(this, scope);
        if (statement instanceof Expression) {
            this.scribe.printNextToken(TerminalTokens.TokenNameSEMICOLON, this.preferences.insert_space_before_semicolon);
            this.scribe.printComment(CodeFormatter.K_UNKNOWN, Scribe.BASIC_TRAILING_COMMENT);
            if (i != statementsLength - 1) {
                if (!(statement instanceof EmptyStatement) && !(statements[i + 1] instanceof EmptyStatement)) {
                    this.scribe.printNewLine();
                }
            } else if (i == statementsLength - 1 && insertNewLineAfterLastStatement) {
                this.scribe.printNewLine();
            }
        } else if (statement instanceof LocalDeclaration) {
            LocalDeclaration currentLocal = (LocalDeclaration) statement;
            if (i < (statementsLength - 1)) {
                /*
                 * We need to check that the next statement is a local declaration
                 */
                if (statements[i + 1] instanceof LocalDeclaration) {
                    LocalDeclaration nextLocal = (LocalDeclaration) statements[i + 1];
                    if (currentLocal.declarationSourceStart != nextLocal.declarationSourceStart) {
                        this.scribe.printNextToken(TerminalTokens.TokenNameSEMICOLON, this.preferences.insert_space_before_semicolon);
                        this.scribe.printComment(CodeFormatter.K_UNKNOWN, Scribe.BASIC_TRAILING_COMMENT);
                        if (i != statementsLength - 1) {
                            if (!(statement instanceof EmptyStatement) && !(statements[i + 1] instanceof EmptyStatement)) {
                                this.scribe.printNewLine();
                            }
                        } else if (i == statementsLength - 1 && insertNewLineAfterLastStatement) {
                            this.scribe.printNewLine();
                        }
                    }
                } else {
                    this.scribe.printNextToken(TerminalTokens.TokenNameSEMICOLON, this.preferences.insert_space_before_semicolon);
                    this.scribe.printComment(CodeFormatter.K_UNKNOWN, Scribe.BASIC_TRAILING_COMMENT);
                    if (i != statementsLength - 1) {
                        if (!(statement instanceof EmptyStatement) && !(statements[i + 1] instanceof EmptyStatement)) {
                            this.scribe.printNewLine();
                        }
                    } else if (i == statementsLength - 1 && insertNewLineAfterLastStatement) {
                        this.scribe.printNewLine();
                    }
                }
            } else {
                this.scribe.printNextToken(TerminalTokens.TokenNameSEMICOLON, this.preferences.insert_space_before_semicolon);
                this.scribe.printComment(CodeFormatter.K_UNKNOWN, Scribe.BASIC_TRAILING_COMMENT);
                if (i != statementsLength - 1) {
                    if (!(statement instanceof EmptyStatement) && !(statements[i + 1] instanceof EmptyStatement)) {
                        this.scribe.printNewLine();
                    }
                } else if (i == statementsLength - 1 && insertNewLineAfterLastStatement) {
                    this.scribe.printNewLine();
                }
            }
        } else if (i != statementsLength - 1) {
            if (!(statement instanceof EmptyStatement) && !(statements[i + 1] instanceof EmptyStatement)) {
                this.scribe.printNewLine();
            }
        } else if (i == statementsLength - 1 && insertNewLineAfterLastStatement) {
            this.scribe.printNewLine();
        }
    }
}
项目:Eclipse-Postfix-Code-Completion    文件:CodeFormatterVisitor.java   
/**
 * @see org.eclipse.jdt.internal.compiler.ASTVisitor#visit(org.eclipse.jdt.internal.compiler.ast.DoStatement, org.eclipse.jdt.internal.compiler.lookup.BlockScope)
 */
public boolean visit(DoStatement doStatement, BlockScope scope) {

    this.scribe.printNextToken(TerminalTokens.TokenNamedo);
    final int line = this.scribe.line;

    final Statement action = doStatement.action;
    if (action != null) {
        if (action instanceof Block) {
            formatLeftCurlyBrace(line, this.preferences.brace_position_for_block);
            action.traverse(this, scope);
        } else if (action instanceof EmptyStatement) {
            /*
             * This is an empty statement
             */
            formatNecessaryEmptyStatement();
        } else {
            this.scribe.printNewLine();
            this.scribe.indent();
            action.traverse(this, scope);
            if (action instanceof Expression) {
                this.scribe.printNextToken(TerminalTokens.TokenNameSEMICOLON, this.preferences.insert_space_before_semicolon);
                this.scribe.printComment(CodeFormatter.K_UNKNOWN, Scribe.BASIC_TRAILING_COMMENT);
            }
            this.scribe.printNewLine();
            this.scribe.unIndent();
        }
    } else {
        /*
         * This is an empty statement
         */
        formatNecessaryEmptyStatement();
    }

    if (this.preferences.insert_new_line_before_while_in_do_statement) {
        this.scribe.printNewLine();
    }
    this.scribe.printNextToken(TerminalTokens.TokenNamewhile, this.preferences.insert_space_after_closing_brace_in_block);
    this.scribe.printNextToken(TerminalTokens.TokenNameLPAREN, this.preferences.insert_space_before_opening_paren_in_while);

    if (this.preferences.insert_space_after_opening_paren_in_while) {
        this.scribe.space();
    }

    doStatement.condition.traverse(this, scope);

    this.scribe.printNextToken(TerminalTokens.TokenNameRPAREN, this.preferences.insert_space_before_closing_paren_in_while);
    this.scribe.printNextToken(TerminalTokens.TokenNameSEMICOLON, this.preferences.insert_space_before_semicolon);
    this.scribe.printComment(CodeFormatter.K_UNKNOWN, Scribe.BASIC_TRAILING_COMMENT);
    return false;
}
项目:Eclipse-Postfix-Code-Completion    文件:CodeFormatterVisitor.java   
public boolean visit(ForeachStatement forStatement, BlockScope scope) {
    this.scribe.printNextToken(TerminalTokens.TokenNamefor);
    final int line = this.scribe.line;
    this.scribe.printNextToken(TerminalTokens.TokenNameLPAREN, this.preferences.insert_space_before_opening_paren_in_for);

    if (this.preferences.insert_space_after_opening_paren_in_for) {
        this.scribe.space();
    }
    formatLocalDeclaration(forStatement.elementVariable, scope, false, false);

    this.scribe.printNextToken(TerminalTokens.TokenNameCOLON, this.preferences.insert_space_before_colon_in_for);
    if (this.preferences.insert_space_after_colon_in_for) {
        this.scribe.space();
    }
    forStatement.collection.traverse(this, scope);

    this.scribe.printNextToken(TerminalTokens.TokenNameRPAREN, this.preferences.insert_space_before_closing_paren_in_for);

    final Statement action = forStatement.action;
    if (action != null) {
        if (action instanceof Block) {
            formatLeftCurlyBrace(line, this.preferences.brace_position_for_block);
            action.traverse(this, scope);
        } else if (action instanceof EmptyStatement) {
            /*
             * This is an empty statement
             */
            formatNecessaryEmptyStatement();
        } else {
            this.scribe.indent();
            this.scribe.printNewLine();
            action.traverse(this, scope);
            this.scribe.unIndent();
        }
        if (action instanceof Expression) {
            this.scribe.printNextToken(TerminalTokens.TokenNameSEMICOLON, this.preferences.insert_space_before_semicolon);
            this.scribe.printComment(CodeFormatter.K_UNKNOWN, Scribe.BASIC_TRAILING_COMMENT);
        }
    } else {
        /*
         * This is an empty statement
         */
        formatNecessaryEmptyStatement();
    }
    return false;
}
项目:Eclipse-Postfix-Code-Completion    文件:CodeFormatterVisitor.java   
/**
 * @see org.eclipse.jdt.internal.compiler.ASTVisitor#visit(org.eclipse.jdt.internal.compiler.ast.WhileStatement, org.eclipse.jdt.internal.compiler.lookup.BlockScope)
 */
public boolean visit(WhileStatement whileStatement, BlockScope scope) {

    this.scribe.printNextToken(TerminalTokens.TokenNamewhile);
    final int line = this.scribe.line;
    this.scribe.printNextToken(TerminalTokens.TokenNameLPAREN, this.preferences.insert_space_before_opening_paren_in_while);

    if (this.preferences.insert_space_after_opening_paren_in_while) {
        this.scribe.space();
    }
    whileStatement.condition.traverse(this, scope);

    this.scribe.printNextToken(TerminalTokens.TokenNameRPAREN, this.preferences.insert_space_before_closing_paren_in_while);

    final Statement action = whileStatement.action;
    if (action != null) {
        if (action instanceof Block) {
            formatLeftCurlyBrace(line, this.preferences.brace_position_for_block);
            action.traverse(this, scope);
        } else if (action instanceof EmptyStatement) {
            /*
             * This is an empty statement
             */
            formatNecessaryEmptyStatement();
        } else {
            this.scribe.printNewLine();
            this.scribe.indent();
            action.traverse(this, scope);
            if (action instanceof Expression) {
                this.scribe.printNextToken(TerminalTokens.TokenNameSEMICOLON, this.preferences.insert_space_before_semicolon);
                this.scribe.printComment(CodeFormatter.K_UNKNOWN, Scribe.BASIC_TRAILING_COMMENT);
            }
            this.scribe.unIndent();
        }
    } else {
        /*
         * This is an empty statement
         */
        formatNecessaryEmptyStatement();
    }
    return false;
}
项目:Eclipse-Postfix-Code-Completion-Juno38    文件:CodeFormatterVisitor.java   
private void formatStatements(BlockScope scope, final Statement[] statements, boolean insertNewLineAfterLastStatement) {
    int statementsLength = statements.length;
    for (int i = 0; i < statementsLength; i++) {
        final Statement statement = statements[i];
        if (i > 0 && (statements[i - 1] instanceof EmptyStatement) && !(statement instanceof EmptyStatement)) {
            this.scribe.printNewLine();
        }
        statement.traverse(this, scope);
        if (statement instanceof Expression) {
            this.scribe.printNextToken(TerminalTokens.TokenNameSEMICOLON, this.preferences.insert_space_before_semicolon);
            this.scribe.printComment(CodeFormatter.K_UNKNOWN, Scribe.BASIC_TRAILING_COMMENT);
            if (i != statementsLength - 1) {
                if (!(statement instanceof EmptyStatement) && !(statements[i + 1] instanceof EmptyStatement)) {
                    this.scribe.printNewLine();
                }
            } else if (i == statementsLength - 1 && insertNewLineAfterLastStatement) {
                this.scribe.printNewLine();
            }
        } else if (statement instanceof LocalDeclaration) {
            LocalDeclaration currentLocal = (LocalDeclaration) statement;
            if (i < (statementsLength - 1)) {
                /*
                 * We need to check that the next statement is a local declaration
                 */
                if (statements[i + 1] instanceof LocalDeclaration) {
                    LocalDeclaration nextLocal = (LocalDeclaration) statements[i + 1];
                    if (currentLocal.declarationSourceStart != nextLocal.declarationSourceStart) {
                        this.scribe.printNextToken(TerminalTokens.TokenNameSEMICOLON, this.preferences.insert_space_before_semicolon);
                        this.scribe.printComment(CodeFormatter.K_UNKNOWN, Scribe.BASIC_TRAILING_COMMENT);
                        if (i != statementsLength - 1) {
                            if (!(statement instanceof EmptyStatement) && !(statements[i + 1] instanceof EmptyStatement)) {
                                this.scribe.printNewLine();
                            }
                        } else if (i == statementsLength - 1 && insertNewLineAfterLastStatement) {
                            this.scribe.printNewLine();
                        }
                    }
                } else {
                    this.scribe.printNextToken(TerminalTokens.TokenNameSEMICOLON, this.preferences.insert_space_before_semicolon);
                    this.scribe.printComment(CodeFormatter.K_UNKNOWN, Scribe.BASIC_TRAILING_COMMENT);
                    if (i != statementsLength - 1) {
                        if (!(statement instanceof EmptyStatement) && !(statements[i + 1] instanceof EmptyStatement)) {
                            this.scribe.printNewLine();
                        }
                    } else if (i == statementsLength - 1 && insertNewLineAfterLastStatement) {
                        this.scribe.printNewLine();
                    }
                }
            } else {
                this.scribe.printNextToken(TerminalTokens.TokenNameSEMICOLON, this.preferences.insert_space_before_semicolon);
                this.scribe.printComment(CodeFormatter.K_UNKNOWN, Scribe.BASIC_TRAILING_COMMENT);
                if (i != statementsLength - 1) {
                    if (!(statement instanceof EmptyStatement) && !(statements[i + 1] instanceof EmptyStatement)) {
                        this.scribe.printNewLine();
                    }
                } else if (i == statementsLength - 1 && insertNewLineAfterLastStatement) {
                    this.scribe.printNewLine();
                }
            }
        } else if (i != statementsLength - 1) {
            if (!(statement instanceof EmptyStatement) && !(statements[i + 1] instanceof EmptyStatement)) {
                this.scribe.printNewLine();
            }
        } else if (i == statementsLength - 1 && insertNewLineAfterLastStatement) {
            this.scribe.printNewLine();
        }
    }
}
项目:Eclipse-Postfix-Code-Completion-Juno38    文件:CodeFormatterVisitor.java   
/**
 * @see org.eclipse.jdt.internal.compiler.ASTVisitor#visit(org.eclipse.jdt.internal.compiler.ast.DoStatement, org.eclipse.jdt.internal.compiler.lookup.BlockScope)
 */
public boolean visit(DoStatement doStatement, BlockScope scope) {

    this.scribe.printNextToken(TerminalTokens.TokenNamedo);
    final int line = this.scribe.line;

    final Statement action = doStatement.action;
    if (action != null) {
        if (action instanceof Block) {
            formatLeftCurlyBrace(line, this.preferences.brace_position_for_block);
            action.traverse(this, scope);
        } else if (action instanceof EmptyStatement) {
            /*
             * This is an empty statement
             */
            formatNecessaryEmptyStatement();
        } else {
            this.scribe.printNewLine();
            this.scribe.indent();
            action.traverse(this, scope);
            if (action instanceof Expression) {
                this.scribe.printNextToken(TerminalTokens.TokenNameSEMICOLON, this.preferences.insert_space_before_semicolon);
                this.scribe.printComment(CodeFormatter.K_UNKNOWN, Scribe.BASIC_TRAILING_COMMENT);
            }
            this.scribe.printNewLine();
            this.scribe.unIndent();
        }
    } else {
        /*
         * This is an empty statement
         */
        formatNecessaryEmptyStatement();
    }

    if (this.preferences.insert_new_line_before_while_in_do_statement) {
        this.scribe.printNewLine();
    }
    this.scribe.printNextToken(TerminalTokens.TokenNamewhile, this.preferences.insert_space_after_closing_brace_in_block);
    this.scribe.printNextToken(TerminalTokens.TokenNameLPAREN, this.preferences.insert_space_before_opening_paren_in_while);

    if (this.preferences.insert_space_after_opening_paren_in_while) {
        this.scribe.space();
    }

    doStatement.condition.traverse(this, scope);

    this.scribe.printNextToken(TerminalTokens.TokenNameRPAREN, this.preferences.insert_space_before_closing_paren_in_while);
    this.scribe.printNextToken(TerminalTokens.TokenNameSEMICOLON, this.preferences.insert_space_before_semicolon);
    this.scribe.printComment(CodeFormatter.K_UNKNOWN, Scribe.BASIC_TRAILING_COMMENT);
    return false;
}
项目:Eclipse-Postfix-Code-Completion-Juno38    文件:CodeFormatterVisitor.java   
public boolean visit(ForeachStatement forStatement, BlockScope scope) {
    this.scribe.printNextToken(TerminalTokens.TokenNamefor);
    final int line = this.scribe.line;
    this.scribe.printNextToken(TerminalTokens.TokenNameLPAREN, this.preferences.insert_space_before_opening_paren_in_for);

    if (this.preferences.insert_space_after_opening_paren_in_for) {
        this.scribe.space();
    }
    formatLocalDeclaration(forStatement.elementVariable, scope, false, false);

    this.scribe.printNextToken(TerminalTokens.TokenNameCOLON, this.preferences.insert_space_before_colon_in_for);
    if (this.preferences.insert_space_after_colon_in_for) {
        this.scribe.space();
    }
    forStatement.collection.traverse(this, scope);

    this.scribe.printNextToken(TerminalTokens.TokenNameRPAREN, this.preferences.insert_space_before_closing_paren_in_for);

    final Statement action = forStatement.action;
    if (action != null) {
        if (action instanceof Block) {
            formatLeftCurlyBrace(line, this.preferences.brace_position_for_block);
            action.traverse(this, scope);
        } else if (action instanceof EmptyStatement) {
            /*
             * This is an empty statement
             */
            formatNecessaryEmptyStatement();
        } else {
            this.scribe.indent();
            this.scribe.printNewLine();
            action.traverse(this, scope);
            this.scribe.unIndent();
        }
        if (action instanceof Expression) {
            this.scribe.printNextToken(TerminalTokens.TokenNameSEMICOLON, this.preferences.insert_space_before_semicolon);
            this.scribe.printComment(CodeFormatter.K_UNKNOWN, Scribe.BASIC_TRAILING_COMMENT);
        }
    } else {
        /*
         * This is an empty statement
         */
        formatNecessaryEmptyStatement();
    }
    return false;
}
项目:Eclipse-Postfix-Code-Completion-Juno38    文件:CodeFormatterVisitor.java   
/**
 * @see org.eclipse.jdt.internal.compiler.ASTVisitor#visit(org.eclipse.jdt.internal.compiler.ast.WhileStatement, org.eclipse.jdt.internal.compiler.lookup.BlockScope)
 */
public boolean visit(WhileStatement whileStatement, BlockScope scope) {

    this.scribe.printNextToken(TerminalTokens.TokenNamewhile);
    final int line = this.scribe.line;
    this.scribe.printNextToken(TerminalTokens.TokenNameLPAREN, this.preferences.insert_space_before_opening_paren_in_while);

    if (this.preferences.insert_space_after_opening_paren_in_while) {
        this.scribe.space();
    }
    whileStatement.condition.traverse(this, scope);

    this.scribe.printNextToken(TerminalTokens.TokenNameRPAREN, this.preferences.insert_space_before_closing_paren_in_while);

    final Statement action = whileStatement.action;
    if (action != null) {
        if (action instanceof Block) {
            formatLeftCurlyBrace(line, this.preferences.brace_position_for_block);
            action.traverse(this, scope);
        } else if (action instanceof EmptyStatement) {
            /*
             * This is an empty statement
             */
            formatNecessaryEmptyStatement();
        } else {
            this.scribe.printNewLine();
            this.scribe.indent();
            action.traverse(this, scope);
            if (action instanceof Expression) {
                this.scribe.printNextToken(TerminalTokens.TokenNameSEMICOLON, this.preferences.insert_space_before_semicolon);
                this.scribe.printComment(CodeFormatter.K_UNKNOWN, Scribe.BASIC_TRAILING_COMMENT);
            }
            this.scribe.unIndent();
        }
    } else {
        /*
         * This is an empty statement
         */
        formatNecessaryEmptyStatement();
    }
    return false;
}
项目:xapi    文件:GwtAstBuilder.java   
@Override
public void endVisit(EmptyStatement x, BlockScope scope) {
  push(null);
}
项目:lombok    文件:SetGeneratedByVisitor.java   
@Override public boolean visit(EmptyStatement node, BlockScope scope) {
    setGeneratedBy(node, source);
    applyOffsetASTNode(node);
    return super.visit(node, scope);
}