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


Java CommonUtils.lengthExpandedTabs方法代码示例

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


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

示例1: log

import com.puppycrawl.tools.checkstyle.utils.CommonUtils; //导入方法依赖的package包/类
/**
 * Helper method to log a LocalizedMessage.
 *
 * @param ast a node to get line id column numbers associated
 *             with the message
 * @param key key to locale message format
 * @param args arguments to format
 */
public final void log(DetailAST ast, String key, Object... args) {

    // CommonUtils.lengthExpandedTabs returns column number considering tabulation
    // characters, it takes line from the file by line number, ast column number and tab
    // width as arguments. Returned value is 0-based, but user must see column number starting
    // from 1, that is why result of the method CommonUtils.lengthExpandedTabs
    // is increased by one.

    final int col = 1 + CommonUtils.lengthExpandedTabs(
            getLines()[ast.getLineNo() - 1], ast.getColumnNo(), tabWidth);
    context.get().messages.add(
            new LocalizedMessage(
                    ast.getLineNo(),
                    col,
                    ast.getColumnNo(),
                    ast.getType(),
                    getMessageBundle(),
                    key,
                    args,
                    getSeverityLevel(),
                    getId(),
                    getClass(),
                    getCustomMessages().get(key)));
}
 
开发者ID:rnveach,项目名称:checkstyle-backport-jre6,代码行数:33,代码来源:AbstractCheck.java

示例2: beginTree

import com.puppycrawl.tools.checkstyle.utils.CommonUtils; //导入方法依赖的package包/类
@Override
public void beginTree(DetailAST rootAST) {
    final String[] lines = getLines();
    for (int i = 0; i < lines.length; i++) {

        final String line = lines[i];
        final int realLength = CommonUtils.lengthExpandedTabs(
            line, line.length(), getTabWidth());

        if (realLength > max && !IGNORE_PATTERN.matcher(line).find()
            && !ignorePattern.matcher(line).find()) {
            log(i + 1, MSG_KEY, max, realLength);
        }
    }
}
 
开发者ID:rnveach,项目名称:checkstyle-backport-jre6,代码行数:16,代码来源:LineLengthCheck.java

示例3: getLineStart

import com.puppycrawl.tools.checkstyle.utils.CommonUtils; //导入方法依赖的package包/类
/**
 * Get the start of the specified line.
 *
 * @param line the specified line number
 * @return the start of the specified line
 */
private int getLineStart(String line) {
    int index = 0;
    while (Character.isWhitespace(line.charAt(index))) {
        index++;
    }
    return CommonUtils.lengthExpandedTabs(line, index, indentCheck.getIndentationTabWidth());
}
 
开发者ID:rnveach,项目名称:checkstyle-backport-jre6,代码行数:14,代码来源:LineWrappingHandler.java

示例4: getLineStart

import com.puppycrawl.tools.checkstyle.utils.CommonUtils; //导入方法依赖的package包/类
/**
 * Get the start of the specified line.
 *
 * @param line   the specified line number
 *
 * @return the start of the specified line
 */
private int getLineStart(String line) {
    int index = 0;
    while (Character.isWhitespace(line.charAt(index))) {
        index++;
    }
    return CommonUtils.lengthExpandedTabs(
        line, index, indentCheck.getIndentationTabWidth());
}
 
开发者ID:rnveach,项目名称:checkstyle-backport-jre6,代码行数:16,代码来源:AbstractExpressionHandler.java

示例5: getLineStart

import com.puppycrawl.tools.checkstyle.utils.CommonUtils; //导入方法依赖的package包/类
private static int getLineStart(String line, final int tabWidth) {
    int lineStart = 0;
    for (int index = 0; index < line.length(); ++index) {
        if (!Character.isWhitespace(line.charAt(index))) {
            lineStart = CommonUtils.lengthExpandedTabs(line, index, tabWidth);
            break;
        }
    }
    return lineStart;
}
 
开发者ID:rnveach,项目名称:checkstyle-backport-jre6,代码行数:11,代码来源:AbstractIndentationTestSupport.java

示例6: expandedTabsColumnNo

import com.puppycrawl.tools.checkstyle.utils.CommonUtils; //导入方法依赖的package包/类
/**
 * Get the column number for the start of a given expression, expanding
 * tabs out into spaces in the process.
 *
 * @param ast   the expression to find the start of
 *
 * @return the column number for the start of the expression
 */
private int expandedTabsColumnNo(DetailAST ast) {
    final String line =
        indentCheck.getLine(ast.getLineNo() - 1);

    return CommonUtils.lengthExpandedTabs(line, ast.getColumnNo(),
        indentCheck.getIndentationTabWidth());
}
 
开发者ID:rnveach,项目名称:checkstyle-backport-jre6,代码行数:16,代码来源:LineWrappingHandler.java

示例7: expandedTabsColumnNo

import com.puppycrawl.tools.checkstyle.utils.CommonUtils; //导入方法依赖的package包/类
/**
 * Get the column number for the start of a given expression, expanding
 * tabs out into spaces in the process.
 *
 * @param ast   the expression to find the start of
 *
 * @return the column number for the start of the expression
 */
protected final int expandedTabsColumnNo(DetailAST ast) {
    final String line =
        indentCheck.getLine(ast.getLineNo() - 1);

    return CommonUtils.lengthExpandedTabs(line, ast.getColumnNo(),
        indentCheck.getIndentationTabWidth());
}
 
开发者ID:rnveach,项目名称:checkstyle-backport-jre6,代码行数:16,代码来源:AbstractExpressionHandler.java

示例8: expandedTabColumn

import com.puppycrawl.tools.checkstyle.utils.CommonUtils; //导入方法依赖的package包/类
/**
 * Returns the column number with tabs expanded.
 * @param ast {@code DetailAST} root ast
 * @return the column number with tabs expanded
 */
private int expandedTabColumn(DetailAST ast) {
    return 1 + CommonUtils.lengthExpandedTabs(fileText.get(lineNumber - 1),
            ast.getColumnNo(), tabWidth);
}
 
开发者ID:rnveach,项目名称:checkstyle-backport-jre6,代码行数:10,代码来源:XpathQueryGenerator.java


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