当前位置: 首页>>代码示例>>Java>>正文


Java DetailAST.initialize方法代码示例

本文整理汇总了Java中com.puppycrawl.tools.checkstyle.api.DetailAST.initialize方法的典型用法代码示例。如果您正苦于以下问题:Java DetailAST.initialize方法的具体用法?Java DetailAST.initialize怎么用?Java DetailAST.initialize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.puppycrawl.tools.checkstyle.api.DetailAST的用法示例。


在下文中一共展示了DetailAST.initialize方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testDefaultHooks

import com.puppycrawl.tools.checkstyle.api.DetailAST; //导入方法依赖的package包/类
@Test
public void testDefaultHooks() {
    final NPathComplexityCheck npathComplexityCheckObj = new NPathComplexityCheck();
    final DetailAST ast = new DetailAST();
    ast.initialize(new CommonHiddenStreamToken(TokenTypes.INTERFACE_DEF, "interface"));

    npathComplexityCheckObj.visitToken(ast);
    final SortedSet<LocalizedMessage> messages1 = npathComplexityCheckObj.getMessages();

    Assert.assertEquals("No exception messages expected", 0, messages1.size());

    npathComplexityCheckObj.leaveToken(ast);
    final SortedSet<LocalizedMessage> messages2 = npathComplexityCheckObj.getMessages();

    Assert.assertEquals("No exception messages expected", 0, messages2.size());
}
 
开发者ID:rnveach,项目名称:checkstyle-backport-jre6,代码行数:17,代码来源:NPathComplexityCheckTest.java

示例2: createBlockCommentNode

import com.puppycrawl.tools.checkstyle.api.DetailAST; //导入方法依赖的package包/类
/**
 * Create block comment from token.
 * @param token
 *        Token object.
 * @return DetailAST with BLOCK_COMMENT type.
 */
public static DetailAST createBlockCommentNode(Token token) {
    final DetailAST blockComment = new DetailAST();
    blockComment.initialize(TokenTypes.BLOCK_COMMENT_BEGIN, BLOCK_MULTIPLE_COMMENT_BEGIN);

    // column counting begins from 0
    blockComment.setColumnNo(token.getColumn() - 1);
    blockComment.setLineNo(token.getLine());

    final DetailAST blockCommentContent = new DetailAST();
    blockCommentContent.setType(TokenTypes.COMMENT_CONTENT);

    // column counting begins from 0
    // plus length of '/*'
    blockCommentContent.setColumnNo(token.getColumn() - 1 + 2);
    blockCommentContent.setLineNo(token.getLine());
    blockCommentContent.setText(token.getText());

    final DetailAST blockCommentClose = new DetailAST();
    blockCommentClose.initialize(TokenTypes.BLOCK_COMMENT_END, BLOCK_MULTIPLE_COMMENT_END);

    final Map.Entry<Integer, Integer> linesColumns = countLinesColumns(
            token.getText(), token.getLine(), token.getColumn());
    blockCommentClose.setLineNo(linesColumns.getKey());
    blockCommentClose.setColumnNo(linesColumns.getValue());

    blockComment.addChild(blockCommentContent);
    blockComment.addChild(blockCommentClose);
    return blockComment;
}
 
开发者ID:rnveach,项目名称:checkstyle-backport-jre6,代码行数:36,代码来源:CommonUtils.java

示例3: testVisitTokenWithWrongTokenType

import com.puppycrawl.tools.checkstyle.api.DetailAST; //导入方法依赖的package包/类
@Test
public void testVisitTokenWithWrongTokenType() {
    final ExecutableStatementCountCheck checkObj =
        new ExecutableStatementCountCheck();
    final DetailAST ast = new DetailAST();
    ast.initialize(
        new CommonHiddenStreamToken(TokenTypes.ENUM, "ENUM"));
    try {
        checkObj.visitToken(ast);
        fail("exception expected");
    }
    catch (IllegalStateException ex) {
        assertEquals("Invalid exception message", "ENUM[0x-1]", ex.getMessage());
    }
}
 
开发者ID:rnveach,项目名称:checkstyle-backport-jre6,代码行数:16,代码来源:ExecutableStatementCountCheckTest.java

示例4: testLeaveTokenWithWrongTokenType

import com.puppycrawl.tools.checkstyle.api.DetailAST; //导入方法依赖的package包/类
@Test
public void testLeaveTokenWithWrongTokenType() {
    final ExecutableStatementCountCheck checkObj =
        new ExecutableStatementCountCheck();
    final DetailAST ast = new DetailAST();
    ast.initialize(
        new CommonHiddenStreamToken(TokenTypes.ENUM, "ENUM"));
    try {
        checkObj.leaveToken(ast);
        fail("exception expected");
    }
    catch (IllegalStateException ex) {
        assertEquals("Invalid exception message", "ENUM[0x-1]", ex.getMessage());
    }
}
 
开发者ID:rnveach,项目名称:checkstyle-backport-jre6,代码行数:16,代码来源:ExecutableStatementCountCheckTest.java

示例5: testWrongToken

import com.puppycrawl.tools.checkstyle.api.DetailAST; //导入方法依赖的package包/类
@Test
public void testWrongToken() {
    final BooleanExpressionComplexityCheck booleanExpressionComplexityCheckObj =
        new BooleanExpressionComplexityCheck();
    final DetailAST ast = new DetailAST();
    ast.initialize(new CommonHiddenStreamToken(TokenTypes.INTERFACE_DEF, "interface"));
    try {
        booleanExpressionComplexityCheckObj.visitToken(ast);
        fail("exception expected");
    }
    catch (IllegalArgumentException ex) {
        assertEquals("Invalid exception message",
            "Unknown type: interface[0x-1]", ex.getMessage());
    }
}
 
开发者ID:rnveach,项目名称:checkstyle-backport-jre6,代码行数:16,代码来源:BooleanExpressionComplexityCheckTest.java

示例6: mockAST

import com.puppycrawl.tools.checkstyle.api.DetailAST; //导入方法依赖的package包/类
/**
 * Creates MOCK lexical token and returns AST node for this token.
 * @param tokenType type of token
 * @param tokenText text of token
 * @param tokenFileName file name of token
 * @param tokenRow token position in a file (row)
 * @param tokenColumn token position in a file (column)
 * @return AST node for the token
 */
private static DetailAST mockAST(final int tokenType, final String tokenText,
        final String tokenFileName, final int tokenRow, final int tokenColumn) {
    final CommonHiddenStreamToken tokenImportSemi = new CommonHiddenStreamToken();
    tokenImportSemi.setType(tokenType);
    tokenImportSemi.setText(tokenText);
    tokenImportSemi.setLine(tokenRow);
    tokenImportSemi.setColumn(tokenColumn);
    tokenImportSemi.setFilename(tokenFileName);
    final DetailAST astSemi = new DetailAST();
    astSemi.initialize(tokenImportSemi);
    return astSemi;
}
 
开发者ID:rnveach,项目名称:checkstyle-backport-jre6,代码行数:22,代码来源:NPathComplexityCheckTest.java

示例7: testWrongToken

import com.puppycrawl.tools.checkstyle.api.DetailAST; //导入方法依赖的package包/类
@Test
public void testWrongToken() {
    final ClassDataAbstractionCouplingCheck classDataAbstractionCouplingCheckObj =
        new ClassDataAbstractionCouplingCheck();
    final DetailAST ast = new DetailAST();
    ast.initialize(new CommonHiddenStreamToken(TokenTypes.CTOR_DEF, "ctor"));
    try {
        classDataAbstractionCouplingCheckObj.visitToken(ast);
        fail("exception expected");
    }
    catch (IllegalArgumentException ex) {
        assertEquals("Invalid exception message",
            "Unknown type: ctor[0x-1]", ex.getMessage());
    }
}
 
开发者ID:rnveach,项目名称:checkstyle-backport-jre6,代码行数:16,代码来源:ClassDataAbstractionCouplingCheckTest.java

示例8: testDefaultSwitch

import com.puppycrawl.tools.checkstyle.api.DetailAST; //导入方法依赖的package包/类
@Test
public void testDefaultSwitch() {
    final RequireThisCheck check = new RequireThisCheck();

    final DetailAST ast = new DetailAST();
    ast.initialize(new CommonHiddenStreamToken(TokenTypes.ENUM, "ENUM"));

    check.visitToken(ast);
    final SortedSet<LocalizedMessage> messages = check.getMessages();

    Assert.assertEquals("No exception messages expected", 0, messages.size());
}
 
开发者ID:rnveach,项目名称:checkstyle-backport-jre6,代码行数:13,代码来源:RequireThisCheckTest.java

示例9: testIllegalStateException

import com.puppycrawl.tools.checkstyle.api.DetailAST; //导入方法依赖的package包/类
@Test
public void testIllegalStateException() {
    final UncommentedMainCheck check = new UncommentedMainCheck();
    final DetailAST ast = new DetailAST();
    ast.initialize(new CommonHiddenStreamToken(TokenTypes.CTOR_DEF, "ctor"));
    try {
        check.visitToken(ast);
        Assert.fail("IllegalStateException is expected");
    }
    catch (IllegalStateException ex) {
        assertEquals("Error message is unexpected",
                ast.toString(), ex.getMessage());
    }

}
 
开发者ID:rnveach,项目名称:checkstyle-backport-jre6,代码行数:16,代码来源:UncommentedMainCheckTest.java

示例10: mockAST

import com.puppycrawl.tools.checkstyle.api.DetailAST; //导入方法依赖的package包/类
/**
 * Creates MOCK lexical token and returns AST node for this token.
 * @param tokenType type of token
 * @param tokenText text of token
 * @param tokenFileName file name of token
 * @return AST node for the token
 */
private static DetailAST mockAST(final int tokenType, final String tokenText,
        final String tokenFileName) {
    final CommonHiddenStreamToken tokenImportSemi = new CommonHiddenStreamToken();
    tokenImportSemi.setType(tokenType);
    tokenImportSemi.setText(tokenText);
    tokenImportSemi.setFilename(tokenFileName);
    final DetailAST astSemi = new DetailAST();
    astSemi.initialize(tokenImportSemi);
    return astSemi;
}
 
开发者ID:rnveach,项目名称:checkstyle-backport-jre6,代码行数:18,代码来源:NoWhitespaceAfterCheckTest.java

示例11: testWrongTokenType

import com.puppycrawl.tools.checkstyle.api.DetailAST; //导入方法依赖的package包/类
@Test
public void testWrongTokenType() {
    final GenericWhitespaceCheck genericWhitespaceCheckObj = new GenericWhitespaceCheck();
    final DetailAST ast = new DetailAST();
    ast.initialize(new CommonHiddenStreamToken(TokenTypes.INTERFACE_DEF, "interface"));
    try {
        genericWhitespaceCheckObj.visitToken(ast);
        fail("exception expected");
    }
    catch (IllegalArgumentException ex) {
        assertEquals("Invalid exception message",
            "Unknown type interface[0x-1]", ex.getMessage());
    }
}
 
开发者ID:rnveach,项目名称:checkstyle-backport-jre6,代码行数:15,代码来源:GenericWhitespaceCheckTest.java

示例12: testWrongTokenType

import com.puppycrawl.tools.checkstyle.api.DetailAST; //导入方法依赖的package包/类
@Test
public void testWrongTokenType() {
    final VisibilityModifierCheck obj = new VisibilityModifierCheck();
    final DetailAST ast = new DetailAST();
    ast.initialize(new CommonHiddenStreamToken(TokenTypes.CLASS_DEF, "class"));
    try {
        obj.visitToken(ast);
        fail("exception expected");
    }
    catch (IllegalArgumentException ex) {
        assertEquals("Invalid exception message",
            "Unexpected token type: class", ex.getMessage());
    }
}
 
开发者ID:rnveach,项目名称:checkstyle-backport-jre6,代码行数:15,代码来源:VisibilityModifierCheckTest.java

示例13: testWrongTokenType

import com.puppycrawl.tools.checkstyle.api.DetailAST; //导入方法依赖的package包/类
@Test
public void testWrongTokenType() {
    final ThrowsCountCheck obj = new ThrowsCountCheck();
    final DetailAST ast = new DetailAST();
    ast.initialize(new CommonHiddenStreamToken(TokenTypes.CLASS_DEF, "class"));
    try {
        obj.visitToken(ast);
        fail("IllegalStateException is expected");
    }
    catch (IllegalStateException ex) {
        assertEquals("Invalid exception message", ast.toString(), ex.getMessage());
    }
}
 
开发者ID:rnveach,项目名称:checkstyle-backport-jre6,代码行数:14,代码来源:ThrowsCountCheckTest.java

示例14: testWrongTokenType

import com.puppycrawl.tools.checkstyle.api.DetailAST; //导入方法依赖的package包/类
@Test
public void testWrongTokenType() {
    final MutableExceptionCheck obj = new MutableExceptionCheck();
    final DetailAST ast = new DetailAST();
    ast.initialize(new CommonHiddenStreamToken(TokenTypes.INTERFACE_DEF, "interface"));
    try {
        obj.visitToken(ast);
        fail("IllegalStateException is expected");
    }
    catch (IllegalStateException ex) {
        //expected
    }
}
 
开发者ID:rnveach,项目名称:checkstyle-backport-jre6,代码行数:14,代码来源:MutableExceptionCheckTest.java


注:本文中的com.puppycrawl.tools.checkstyle.api.DetailAST.initialize方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。