当前位置: 首页>>代码示例>>Java>>正文


Java PrimitiveType.BOOLEAN属性代码示例

本文整理汇总了Java中org.eclipse.jdt.core.dom.PrimitiveType.BOOLEAN属性的典型用法代码示例。如果您正苦于以下问题:Java PrimitiveType.BOOLEAN属性的具体用法?Java PrimitiveType.BOOLEAN怎么用?Java PrimitiveType.BOOLEAN使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在org.eclipse.jdt.core.dom.PrimitiveType的用法示例。


在下文中一共展示了PrimitiveType.BOOLEAN属性的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: 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();
}
 
开发者ID:eclipse,项目名称:eclipse.jdt.ls,代码行数:23,代码来源:ASTNodeFactory.java

示例2: 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();
}
 
开发者ID:eclipse,项目名称:che,代码行数:23,代码来源:ASTNodeFactory.java

示例3: 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;
}
 
开发者ID:ELTE-Soft,项目名称:txtUML,代码行数:11,代码来源:Utils.java

示例4: 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);
}
 
开发者ID:conyx,项目名称:jenkins.py,代码行数:36,代码来源:MethodMaker.java

示例5: visit

@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);
}
 
开发者ID:mrmonday,项目名称:j2d,代码行数:10,代码来源:J2dVisitor.java

示例6: evaluateVisibleMatches

private List<Variable> evaluateVisibleMatches(String expectedType, IJavaElement[] suggestions) throws JavaModelException {
	IType currentType= null;
	if (fEnclosingElement != null) {
		currentType= (IType) fEnclosingElement.getAncestor(IJavaElement.TYPE);
	}

	ArrayList<Variable> res= new ArrayList<Variable>();
	for (int i= 0; i < suggestions.length; i++) {
		Variable variable= createVariable(suggestions[i], currentType, expectedType, i);
		if (variable != null) {
			if (fAlreadyMatchedNames.contains(variable.name)) {
				variable.alreadyMatched= true;
			}
			res.add(variable);
		}
	}

	// add 'this'
	if (currentType != null && !(fEnclosingElement instanceof IMethod && Flags.isStatic(((IMethod) fEnclosingElement).getFlags()))) {
		String fullyQualifiedName= currentType.getFullyQualifiedName('.');
		if (fullyQualifiedName.equals(expectedType)) {
			ImageDescriptor desc= new JavaElementImageDescriptor(JavaPluginImages.DESC_FIELD_PUBLIC, JavaElementImageDescriptor.FINAL | JavaElementImageDescriptor.STATIC, JavaElementImageProvider.SMALL_SIZE);
			res.add(new Variable(fullyQualifiedName, "this", Variable.LITERALS, false, res.size(), new char[] {'.'}, desc));  //$NON-NLS-1$
		}
	}

	Code primitiveTypeCode= getPrimitiveTypeCode(expectedType);
	if (primitiveTypeCode == null) {
		// add 'null'
		res.add(new Variable(expectedType, "null", Variable.LITERALS, false, res.size(), NO_TRIGGERS, null));  //$NON-NLS-1$
	} else {
		String typeName= primitiveTypeCode.toString();
		boolean isAutoboxing= !typeName.equals(expectedType);
		if (primitiveTypeCode == PrimitiveType.BOOLEAN) {
			// add 'true', 'false'
			res.add(new Variable(typeName, "true", Variable.LITERALS, isAutoboxing, res.size(), NO_TRIGGERS, null)); //$NON-NLS-1$
			res.add(new Variable(typeName, "false", Variable.LITERALS, isAutoboxing, res.size(), NO_TRIGGERS, null)); //$NON-NLS-1$
		} else {
			// add 0
			res.add(new Variable(typeName, "0", Variable.LITERALS, isAutoboxing, res.size(), NO_TRIGGERS, null));   //$NON-NLS-1$
		}
	}
	return res;
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:44,代码来源:ParameterGuesser.java

示例7: setExecArguments

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);
        }
    }
}
 
开发者ID:conyx,项目名称:jenkins.py,代码行数:46,代码来源:MethodMaker.java


注:本文中的org.eclipse.jdt.core.dom.PrimitiveType.BOOLEAN属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。