本文整理汇总了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)));
}
示例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);
}
}
}
示例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());
}
示例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());
}
示例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;
}
示例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());
}
示例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());
}
示例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);
}