當前位置: 首頁>>代碼示例>>Java>>正文


Java Type.isPrimitiveType方法代碼示例

本文整理匯總了Java中org.eclipse.jdt.core.dom.Type.isPrimitiveType方法的典型用法代碼示例。如果您正苦於以下問題:Java Type.isPrimitiveType方法的具體用法?Java Type.isPrimitiveType怎麽用?Java Type.isPrimitiveType使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.eclipse.jdt.core.dom.Type的用法示例。


在下文中一共展示了Type.isPrimitiveType方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getParameters

import org.eclipse.jdt.core.dom.Type; //導入方法依賴的package包/類
private List<IType> getParameters(List list) {
	List<IType> params = new ArrayList<IType>();
	for (Object elem : list) {
		if (elem instanceof SingleVariableDeclaration) {
			SingleVariableDeclaration param = (SingleVariableDeclaration) elem;
			Type type = param.getType();
			if (type != null && type.resolveBinding() != null && type.resolveBinding().getJavaElement() instanceof IType) {
				params.add((IType) type.resolveBinding().getJavaElement());
			} else {
				if (type.resolveBinding() != null && type.isPrimitiveType()) {
					params.add(new PrimitiveTypeHack(type.resolveBinding().getName()));
				}
			}
		}
	}
	return params;
}
 
開發者ID:ioanaverebi,項目名稱:Sparrow,代碼行數:18,代碼來源:OutCodeVisitor.java

示例2: isMainMethod

import org.eclipse.jdt.core.dom.Type; //導入方法依賴的package包/類
/**
 * 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());
}
 
開發者ID:bazelbuild,項目名稱:BUILD_file_generator,代碼行數:37,代碼來源:JavaSourceFileParser.java

示例3: newDefaultExpression

import org.eclipse.jdt.core.dom.Type; //導入方法依賴的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();
}
 
開發者ID:eclipse,項目名稱:eclipse.jdt.ls,代碼行數:24,代碼來源:ASTNodeFactory.java

示例4: testTypeEquals

import org.eclipse.jdt.core.dom.Type; //導入方法依賴的package包/類
private boolean testTypeEquals(final Class<?> expected, Type actual)
{
	if(actual.isSimpleType()) {				
		SimpleType simpleDeclaration = (SimpleType)actual;
		return testNameEquals(expected, simpleDeclaration.getName());
	} else if (actual.isPrimitiveType()) {
		PrimitiveType primitive = (PrimitiveType)actual;
		return testPrimitiveTypeEquals(expected, primitive.getPrimitiveTypeCode());
	} else { //unbekannter Typ
		System.err.println("warning: not simple type, feature not implemented. type is: " + actual.getClass());
		throw new UnsupportedOperationException();
	}
}
 
開發者ID:Ragnaroek,項目名稱:eclipse-astparser,代碼行數:14,代碼來源:MethodExpression.java

示例5: newDefaultExpression

import org.eclipse.jdt.core.dom.Type; //導入方法依賴的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();
}
 
開發者ID:eclipse,項目名稱:che,代碼行數:24,代碼來源:ASTNodeFactory.java

示例6: isBasicType

import org.eclipse.jdt.core.dom.Type; //導入方法依賴的package包/類
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,代碼行數:12,代碼來源:Utils.java


注:本文中的org.eclipse.jdt.core.dom.Type.isPrimitiveType方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。