本文整理汇总了Java中com.puppycrawl.tools.checkstyle.api.TokenTypes.LITERAL_THIS属性的典型用法代码示例。如果您正苦于以下问题:Java TokenTypes.LITERAL_THIS属性的具体用法?Java TokenTypes.LITERAL_THIS怎么用?Java TokenTypes.LITERAL_THIS使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类com.puppycrawl.tools.checkstyle.api.TokenTypes
的用法示例。
在下文中一共展示了TokenTypes.LITERAL_THIS属性的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: isCalledOnStringFieldOrVariable
/**
* Determine, whether equals method is called on a field of String type.
* @param objCalledOn object ast.
* @return true if the object is of String type.
*/
private boolean isCalledOnStringFieldOrVariable(DetailAST objCalledOn) {
final boolean result;
final DetailAST previousSiblingAst = objCalledOn.getPreviousSibling();
if (previousSiblingAst == null) {
result = isStringFieldOrVariable(objCalledOn);
}
else {
if (previousSiblingAst.getType() == TokenTypes.LITERAL_THIS) {
result = isStringFieldOrVariableFromThisInstance(objCalledOn);
}
else {
final String className = previousSiblingAst.getText();
result = isStringFieldOrVariableFromClass(objCalledOn, className);
}
}
return result;
}
示例2: isUserDefinedArrangementOfThis
/**
* Checks whether user arranges 'this' for variable in method, constructor, or block on his own.
* @param currentFrame current frame.
* @param ident ident token.
* @return true if user arranges 'this' for variable in method, constructor,
* or block on his own.
*/
private static boolean isUserDefinedArrangementOfThis(AbstractFrame currentFrame,
DetailAST ident) {
final DetailAST blockFrameNameIdent = currentFrame.getFrameNameIdent();
final DetailAST definitionToken = blockFrameNameIdent.getParent();
final DetailAST blockStartToken = definitionToken.findFirstToken(TokenTypes.SLIST);
final DetailAST blockEndToken = getBlockEndToken(blockFrameNameIdent, blockStartToken);
boolean userDefinedArrangementOfThis = false;
final Set<DetailAST> variableUsagesInsideBlock =
getAllTokensWhichAreEqualToCurrent(definitionToken, ident,
blockEndToken.getLineNo());
for (DetailAST variableUsage : variableUsagesInsideBlock) {
final DetailAST prevSibling = variableUsage.getPreviousSibling();
if (prevSibling != null
&& prevSibling.getType() == TokenTypes.LITERAL_THIS) {
userDefinedArrangementOfThis = true;
break;
}
}
return userDefinedArrangementOfThis;
}