本文整理汇总了Java中org.eclipse.jdt.core.dom.PrimitiveType.getPrimitiveTypeCode方法的典型用法代码示例。如果您正苦于以下问题:Java PrimitiveType.getPrimitiveTypeCode方法的具体用法?Java PrimitiveType.getPrimitiveTypeCode怎么用?Java PrimitiveType.getPrimitiveTypeCode使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.jdt.core.dom.PrimitiveType
的用法示例。
在下文中一共展示了PrimitiveType.getPrimitiveTypeCode方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: tryToResolve
import org.eclipse.jdt.core.dom.PrimitiveType; //导入方法依赖的package包/类
protected boolean tryToResolve(PrimitiveType primitiveType) {
boolean result = false;
PrimitiveType.Code typeCode = primitiveType.getPrimitiveTypeCode();
org.eclipse.uml2.uml.PrimitiveType umlPrimitiveType;
if (typeCode.equals(PrimitiveType.VOID)) {
umlPrimitiveType = null;
underResolution.getResolverMap().put(primitiveType, umlPrimitiveType);
result = true;
} else {
umlPrimitiveType = Utils.searchPrimiveTypeInModels(context, typeCode.toString());
if (umlPrimitiveType != null) {
underResolution.getResolverMap().put(primitiveType, umlPrimitiveType);
result = true;
}
}
return result;
}
示例2: newDefaultExpression
import org.eclipse.jdt.core.dom.PrimitiveType; //导入方法依赖的package包/类
/**
* 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();
}
示例3: newDefaultExpression
import org.eclipse.jdt.core.dom.PrimitiveType; //导入方法依赖的package包/类
/**
* 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: isVoidArrayType
import org.eclipse.jdt.core.dom.PrimitiveType; //导入方法依赖的package包/类
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);
}
示例5: isVoidArrayType
import org.eclipse.jdt.core.dom.PrimitiveType; //导入方法依赖的package包/类
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: determineType
import org.eclipse.jdt.core.dom.PrimitiveType; //导入方法依赖的package包/类
/**
* Mapping between types.
*
* @param type
* type
* @return code of the type
*/
private int determineType(Type type) {
int expressionType = -1;
if (type.isPrimitiveType()) {
PrimitiveType prim = (PrimitiveType) type;
Code code = prim.getPrimitiveTypeCode();
if (code.equals(PrimitiveType.INT) | code.equals(PrimitiveType.DOUBLE) | code.equals(PrimitiveType.FLOAT)
| code.equals(PrimitiveType.LONG)) {
expressionType = Expression.NUMBER_LITERAL;
} else if (code.equals(PrimitiveType.BOOLEAN)) {
expressionType = Expression.BOOLEAN_LITERAL;
} else if (code.equals(PrimitiveType.CHAR)) {
expressionType = Expression.CHARACTER_LITERAL;
}
}
if (type.isSimpleType()) {
// String, Double
SimpleType simple = (SimpleType) type;
String simpleTypeName = simple.getName().getFullyQualifiedName();
if (simpleTypeName.equals("String")) {
expressionType = Expression.STRING_LITERAL;
} else if (simpleTypeName.equals("Double") | simpleTypeName.equals("Long")
| simpleTypeName.equals("Float")) {
expressionType = Expression.NUMBER_LITERAL;
} else if (simpleTypeName.equals("Boolean")) {
expressionType = Expression.BOOLEAN_LITERAL;
} else {
/*
* WARNING: If the type is not one of the above it will be set to Expression.NULL_LITERAL resulting
* that for every expression the replacement will be 'null'!!!
*/
expressionType = Expression.NULL_LITERAL;
}
}
return expressionType;
}
示例7: isVoidArrayType
import org.eclipse.jdt.core.dom.PrimitiveType; //导入方法依赖的package包/类
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);
}
示例8: getExecMethodName
import org.eclipse.jdt.core.dom.PrimitiveType; //导入方法依赖的package包/类
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);
}
示例9: visit
import org.eclipse.jdt.core.dom.PrimitiveType; //导入方法依赖的package包/类
@Override
public boolean visit(PrimitiveType node) {
//System.out.println("Found: " + node.getClass());
if (node.getPrimitiveTypeCode() == PrimitiveType.BOOLEAN) {
print("bool");
} else {
print(node.toString());
}
return super.visit(node);
}
示例10: setExecArguments
import org.eclipse.jdt.core.dom.PrimitiveType; //导入方法依赖的package包/类
private void setExecArguments(MethodDeclaration md, MethodInvocation mi) {
for (int i = 0; i < md.parameters().size(); i++) {
SingleVariableDeclaration svd = (SingleVariableDeclaration)md.parameters().get(i);
Type type = svd.getType();
if (!type.isPrimitiveType()) {
// arg -> arg
mi.arguments().add((Name)ASTNode.copySubtree(ast, svd.getName()));
}
else {
// arg -> DataConvertor.from*(arg)
Name dataConvertor = ast.newSimpleName("DataConvertor");
MethodInvocation mi2 = ast.newMethodInvocation();
mi2.setExpression(dataConvertor);
PrimitiveType ptype = (PrimitiveType)type;
PrimitiveType.Code ptcode = ptype.getPrimitiveTypeCode();
String methName = "from";
if (ptcode == PrimitiveType.BYTE) {
methName += "Byte";
}
else if (ptcode == PrimitiveType.SHORT) {
methName += "Short";
}
else if (ptcode == PrimitiveType.CHAR) {
methName += "Char";
}
else if (ptcode == PrimitiveType.INT) {
methName += "Int";
}
else if (ptcode == PrimitiveType.LONG) {
methName += "Long";
}
else if (ptcode == PrimitiveType.FLOAT) {
methName += "Float";
}
else if (ptcode == PrimitiveType.DOUBLE) {
methName += "Double";
}
else if (ptcode == PrimitiveType.BOOLEAN) {
methName += "Bool";
}
mi2.setName(ast.newSimpleName(methName));
mi2.arguments().add(ASTNode.copySubtree(ast, svd.getName()));
mi.arguments().add(mi2);
}
}
}