本文整理汇总了Java中com.puppycrawl.tools.checkstyle.api.TokenTypes.TYPE_PARAMETER属性的典型用法代码示例。如果您正苦于以下问题:Java TokenTypes.TYPE_PARAMETER属性的具体用法?Java TokenTypes.TYPE_PARAMETER怎么用?Java TokenTypes.TYPE_PARAMETER使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类com.puppycrawl.tools.checkstyle.api.TokenTypes
的用法示例。
在下文中一共展示了TokenTypes.TYPE_PARAMETER属性的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getTypeParameterNames
/**
* Retrieves the names of the type parameters to the node.
* @param node the parameterized AST node
* @return a list of type parameter names
*/
public static List<String> getTypeParameterNames(final DetailAST node) {
final DetailAST typeParameters =
node.findFirstToken(TokenTypes.TYPE_PARAMETERS);
final List<String> typeParameterNames = new ArrayList<String>();
if (typeParameters != null) {
final DetailAST typeParam =
typeParameters.findFirstToken(TokenTypes.TYPE_PARAMETER);
typeParameterNames.add(
typeParam.findFirstToken(TokenTypes.IDENT).getText());
DetailAST sibling = typeParam.getNextSibling();
while (sibling != null) {
if (sibling.getType() == TokenTypes.TYPE_PARAMETER) {
typeParameterNames.add(
sibling.findFirstToken(TokenTypes.IDENT).getText());
}
sibling = sibling.getNextSibling();
}
}
return typeParameterNames;
}
示例2: getTypeParameters
/**
* Retrieves the type parameters to the node.
* @param node the parameterized AST node
* @return a list of type parameter names
*/
public static List<DetailAST> getTypeParameters(final DetailAST node) {
final DetailAST typeParameters =
node.findFirstToken(TokenTypes.TYPE_PARAMETERS);
final List<DetailAST> typeParams = new ArrayList<DetailAST>();
if (typeParameters != null) {
final DetailAST typeParam =
typeParameters.findFirstToken(TokenTypes.TYPE_PARAMETER);
typeParams.add(typeParam);
DetailAST sibling = typeParam.getNextSibling();
while (sibling != null) {
if (sibling.getType() == TokenTypes.TYPE_PARAMETER) {
typeParams.add(sibling);
}
sibling = sibling.getNextSibling();
}
}
return typeParams;
}
示例3: processTypeParams
/**
* Process type params (if any) for given class, enum or method.
* @param ast class, enum or method to process.
*/
private void processTypeParams(DetailAST ast) {
final DetailAST params =
ast.findFirstToken(TokenTypes.TYPE_PARAMETERS);
final Map<String, AbstractClassInfo> paramsMap = new HashMap<String, AbstractClassInfo>();
typeParams.push(paramsMap);
if (params != null) {
for (DetailAST child = params.getFirstChild();
child != null;
child = child.getNextSibling()) {
if (child.getType() == TokenTypes.TYPE_PARAMETER) {
final DetailAST bounds =
child.findFirstToken(TokenTypes.TYPE_UPPER_BOUNDS);
if (bounds != null) {
final FullIdent name =
FullIdent.createFullIdentBelow(bounds);
final AbstractClassInfo classInfo =
createClassInfo(new Token(name), currentClassName);
final String alias =
child.findFirstToken(TokenTypes.IDENT).getText();
paramsMap.put(alias, classInfo);
}
}
}
}
}
示例4: testGetClassRequiredTokens
@Test
public void testGetClassRequiredTokens() {
final ClassTypeParameterNameCheck checkObj =
new ClassTypeParameterNameCheck();
final int[] expected = {TokenTypes.TYPE_PARAMETER};
assertArrayEquals("Default required tokens are invalid",
expected, checkObj.getRequiredTokens());
}
示例5: testGetAcceptableTokens
@Test
public void testGetAcceptableTokens() {
final ClassTypeParameterNameCheck typeParameterNameCheckObj =
new ClassTypeParameterNameCheck();
final int[] actual = typeParameterNameCheckObj.getAcceptableTokens();
final int[] expected = {
TokenTypes.TYPE_PARAMETER,
};
assertArrayEquals("Default acceptable tokens are invalid", expected, actual);
}
示例6: testGetInterfaceRequiredTokens
@Test
public void testGetInterfaceRequiredTokens() {
final InterfaceTypeParameterNameCheck checkObj =
new InterfaceTypeParameterNameCheck();
final int[] expected = {TokenTypes.TYPE_PARAMETER};
assertArrayEquals("Default required tokens are invalid",
expected, checkObj.getRequiredTokens());
}
示例7: testGetMethodRequiredTokens
@Test
public void testGetMethodRequiredTokens() {
final MethodTypeParameterNameCheck checkObj =
new MethodTypeParameterNameCheck();
final int[] expected = {TokenTypes.TYPE_PARAMETER};
assertArrayEquals("Default required tokens are invalid",
expected, checkObj.getRequiredTokens());
}
示例8: getDefaultTokens
@Override
public final int[] getDefaultTokens() {
return new int[] {
TokenTypes.TYPE_PARAMETER,
};
}
示例9: getAcceptableTokens
@Override
public final int[] getAcceptableTokens() {
return new int[] {
TokenTypes.TYPE_PARAMETER,
};
}
示例10: getAcceptableTokens
@Override
public int[] getAcceptableTokens() {
return new int[] {
TokenTypes.TYPE_PARAMETER,
};
}
示例11: getRequiredTokens
@Override
public int[] getRequiredTokens() {
return new int[] {
TokenTypes.TYPE_PARAMETER,
};
}