use of com.github.sevntu.checkstyle.common.UnexpectedTokenTypeException in project methods-distance by sevntu-checkstyle.
the class MethodDefinitionParser method getMethodParameterDefText.
private String getMethodParameterDefText(DetailAST parameterDef) {
final DetailAST type = parameterDef.findFirstToken(TokenTypes.TYPE);
final DetailAST typeFirstChild = type.getFirstChild();
String typeName;
switch(typeFirstChild.getType()) {
case TokenTypes.IDENT:
typeName = typeFirstChild.getText();
break;
case TokenTypes.DOT:
typeName = typeFirstChild.getNextSibling().getText();
break;
case TokenTypes.ARRAY_DECLARATOR:
typeName = typeFirstChild.getFirstChild().getText();
break;
default:
if (PRIMITIVE_TOKEN_TYPES.contains(typeFirstChild.getType())) {
typeName = typeFirstChild.getText();
} else {
throw new UnexpectedTokenTypeException(typeFirstChild);
}
}
if (typeFirstChild.getType() == TokenTypes.ARRAY_DECLARATOR) {
typeName += "[]";
}
if (parameterDef.findFirstToken(TokenTypes.ELLIPSIS) != null) {
typeName += "...";
}
return typeName;
}
Aggregations