本文整理汇总了Java中org.eclipse.jdt.core.dom.PrimitiveType.VOID属性的典型用法代码示例。如果您正苦于以下问题:Java PrimitiveType.VOID属性的具体用法?Java PrimitiveType.VOID怎么用?Java PrimitiveType.VOID使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类org.eclipse.jdt.core.dom.PrimitiveType
的用法示例。
在下文中一共展示了PrimitiveType.VOID属性的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getSuperMethCall
/**
* Creates a "return super.method(args)" statement for the given method
*/
private Statement getSuperMethCall(MethodDeclaration md) {
SuperMethodInvocation smi = ast.newSuperMethodInvocation();
smi.setName((SimpleName)ASTNode.copySubtree(ast, md.getName()));
for (int i = 0; i < md.parameters().size(); i++) {
SingleVariableDeclaration svd = (SingleVariableDeclaration)md.parameters().get(i);
smi.arguments().add((Name)ASTNode.copySubtree(ast, svd.getName()));
}
Type type = md.getReturnType2();
if (md.getReturnType2().isPrimitiveType()) {
PrimitiveType.Code ptcode = ((PrimitiveType)type).getPrimitiveTypeCode();
if (ptcode == PrimitiveType.VOID) {
return ast.newExpressionStatement(smi);
}
}
ReturnStatement rs = ast.newReturnStatement();
rs.setExpression(smi);
return rs;
}
示例2: isMainMethod
/**
* Returns true iff 'methodDeclaration' represents a void static method named 'main' that takes a
* single String[] parameter.
*/
private static boolean isMainMethod(MethodDeclaration methodDeclaration) {
// Is it static?
if ((methodDeclaration.getModifiers() & Modifier.STATIC) == 0) {
return false;
}
// Does it return void?
Type returnType = methodDeclaration.getReturnType2();
if (!returnType.isPrimitiveType()) {
return false;
}
if (((PrimitiveType) returnType).getPrimitiveTypeCode() != PrimitiveType.VOID) {
return false;
}
// Is it called 'main'?
if (!"main".equals(methodDeclaration.getName().getIdentifier())) {
return false;
}
// Does it have a single parameter?
if (methodDeclaration.parameters().size() != 1) {
return false;
}
// Is the parameter's type String[]?
SingleVariableDeclaration pt =
getOnlyElement((List<SingleVariableDeclaration>) methodDeclaration.parameters());
IVariableBinding vb = pt.resolveBinding();
if (vb == null) {
return false;
}
ITypeBinding tb = vb.getType();
return tb != null && "java.lang.String[]".equals(tb.getQualifiedName());
}
示例3: newDefaultExpression
/**
* Returns an expression that is assignable to the given type. <code>null</code> is
* returned if the type is the 'void' type.
*
* @param ast The AST to create the expression for
* @param type The type of the returned expression
* @param extraDimensions Extra dimensions to the type
* @return the Null-literal for reference types, a boolean-literal for a boolean type, a number
* literal for primitive types or <code>null</code> if the type is void.
*/
public static Expression newDefaultExpression(AST ast, Type type, int extraDimensions) {
if (extraDimensions == 0 && type.isPrimitiveType()) {
PrimitiveType primitiveType= (PrimitiveType) type;
if (primitiveType.getPrimitiveTypeCode() == PrimitiveType.BOOLEAN) {
return ast.newBooleanLiteral(false);
} else if (primitiveType.getPrimitiveTypeCode() == PrimitiveType.VOID) {
return null;
} else {
return ast.newNumberLiteral("0"); //$NON-NLS-1$
}
}
return ast.newNullLiteral();
}
示例4: newDefaultExpression
/**
* Returns an expression that is assignable to the given type. <code>null</code> is returned if
* the type is the 'void' type.
*
* @param ast The AST to create the expression for
* @param type The type of the returned expression
* @param extraDimensions Extra dimensions to the type
* @return the Null-literal for reference types, a boolean-literal for a boolean type, a number
* literal for primitive types or <code>null</code> if the type is void.
*/
public static Expression newDefaultExpression(AST ast, Type type, int extraDimensions) {
if (extraDimensions == 0 && type.isPrimitiveType()) {
PrimitiveType primitiveType = (PrimitiveType) type;
if (primitiveType.getPrimitiveTypeCode() == PrimitiveType.BOOLEAN) {
return ast.newBooleanLiteral(false);
} else if (primitiveType.getPrimitiveTypeCode() == PrimitiveType.VOID) {
return null;
} else {
return ast.newNumberLiteral("0"); // $NON-NLS-1$
}
}
return ast.newNullLiteral();
}
示例5: isVoidArrayType
private static boolean isVoidArrayType(Type type) {
if (!type.isArrayType()) return false;
ArrayType arrayType = (ArrayType) type;
if (!arrayType.getElementType().isPrimitiveType()) return false;
PrimitiveType primitiveType = (PrimitiveType) arrayType.getElementType();
return (primitiveType.getPrimitiveTypeCode() == PrimitiveType.VOID);
}
示例6: isBasicType
public static boolean isBasicType(Type type, boolean isVoidAllowed) {
if (type.isPrimitiveType()) {
PrimitiveType.Code code = ((PrimitiveType) type).getPrimitiveTypeCode();
return (code == PrimitiveType.BOOLEAN || code == PrimitiveType.DOUBLE || code == PrimitiveType.INT
|| (code == PrimitiveType.VOID && isVoidAllowed));
}
if (type.resolveBinding().getQualifiedName().equals(String.class.getCanonicalName())) {
return true;
}
return false;
}
示例7: isVoidArrayType
private static boolean isVoidArrayType(Type type){
if (! type.isArrayType())
return false;
ArrayType arrayType= (ArrayType)type;
if (! arrayType.getElementType().isPrimitiveType())
return false;
PrimitiveType primitiveType= (PrimitiveType) arrayType.getElementType();
return (primitiveType.getPrimitiveTypeCode() == PrimitiveType.VOID);
}
示例8: isVoidArrayType
private static boolean isVoidArrayType(Type type){
if (! type.isArrayType())
return false;
ArrayType arrayType= (ArrayType)type;
if (! arrayType.getComponentType().isPrimitiveType())
return false;
PrimitiveType primitiveType= (PrimitiveType)arrayType.getComponentType();
return (primitiveType.getPrimitiveTypeCode() == PrimitiveType.VOID);
}
示例9: getExecMethodName
private SimpleName getExecMethodName(MethodDeclaration md) {
Type type = md.getReturnType2();
String name = "execPython";
if (type.isPrimitiveType()) {
PrimitiveType ptype = (PrimitiveType)type;
PrimitiveType.Code ptcode = ptype.getPrimitiveTypeCode();
if (ptcode == PrimitiveType.BYTE) {
name += "Byte";
}
else if (ptcode == PrimitiveType.SHORT) {
name += "Short";
}
else if (ptcode == PrimitiveType.CHAR) {
name += "Char";
}
else if (ptcode == PrimitiveType.INT) {
name += "Int";
}
else if (ptcode == PrimitiveType.LONG) {
name += "Long";
}
else if (ptcode == PrimitiveType.FLOAT) {
name += "Float";
}
else if (ptcode == PrimitiveType.DOUBLE) {
name += "Double";
}
else if (ptcode == PrimitiveType.BOOLEAN) {
name += "Bool";
}
else if (ptcode == PrimitiveType.VOID) {
name += "Void";
}
}
return ast.newSimpleName(name);
}
示例10: isVoid
private static boolean isVoid(Type type) {
return type instanceof PrimitiveType && ((PrimitiveType) type).getPrimitiveTypeCode() == PrimitiveType.VOID;
}