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


Java Type.isParameterizedType方法代碼示例

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


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

示例1: getVariableNameSuggestions

import org.eclipse.jdt.core.dom.Type; //導入方法依賴的package包/類
private static String[] getVariableNameSuggestions(int variableKind, IJavaProject project, Type expectedType, Collection<String> excluded, boolean evaluateDefault) {
	int dim= 0;
	if (expectedType.isArrayType()) {
		ArrayType arrayType= (ArrayType)expectedType;
		dim= arrayType.getDimensions();
		expectedType= arrayType.getElementType();
	}
	if (expectedType.isParameterizedType()) {
		expectedType= ((ParameterizedType)expectedType).getType();
	}
	String typeName= ASTNodes.getTypeName(expectedType);

	if (typeName.length() > 0) {
		return getVariableNameSuggestions(variableKind, project, typeName, dim, excluded, evaluateDefault);
	}
	return EMPTY;
}
 
開發者ID:eclipse,項目名稱:eclipse.jdt.ls,代碼行數:18,代碼來源:StubUtility.java

示例2: getVariableNameSuggestions

import org.eclipse.jdt.core.dom.Type; //導入方法依賴的package包/類
private static String[] getVariableNameSuggestions(
    int variableKind,
    IJavaProject project,
    Type expectedType,
    Collection<String> excluded,
    boolean evaluateDefault) {
  int dim = 0;
  if (expectedType.isArrayType()) {
    ArrayType arrayType = (ArrayType) expectedType;
    dim = arrayType.getDimensions();
    expectedType = arrayType.getElementType();
  }
  if (expectedType.isParameterizedType()) {
    expectedType = ((ParameterizedType) expectedType).getType();
  }
  String typeName = ASTNodes.getTypeName(expectedType);

  if (typeName.length() > 0) {
    return getVariableNameSuggestions(
        variableKind, project, typeName, dim, excluded, evaluateDefault);
  }
  return EMPTY;
}
 
開發者ID:eclipse,項目名稱:che,代碼行數:24,代碼來源:StubUtility.java

示例3: computeSyncReturnType

import org.eclipse.jdt.core.dom.Type; //導入方法依賴的package包/類
/**
 * Sync method has same return type as parameterization of last async
 * parameter (AsyncCallback). If the async callback parameter type is raw,
 * just assume sync return type of void.
 *
 * @param ast {@link AST} associated with the destination compilation unit
 * @param asyncMethod the GWT RPC async method declaration
 * @param imports {@link ImportRewrite} associated with the destination
 *          compilation unit
 * @return the computed return {@link Type}
 */
public static Type computeSyncReturnType(AST ast,
    MethodDeclaration asyncMethod, ImportRewrite imports) {
  Type returnType = ast.newPrimitiveType(PrimitiveType.VOID);
  @SuppressWarnings("unchecked")
  List<SingleVariableDeclaration> asyncParameters = asyncMethod.parameters();

  // Check for no parameters on async method... just in case
  if (asyncParameters.isEmpty()) {
    return returnType;
  }

  // Grab the last parameter type, which should be the callback
  Type callbackType = asyncParameters.get(asyncParameters.size() - 1).getType();

  // Make sure we have a parameterized callback type; otherwise, we can't
  // infer the return type of the sync method.
  if (callbackType.isParameterizedType()) {
    ParameterizedType callbackParamType = (ParameterizedType) callbackType;

    ITypeBinding callbackBinding = callbackParamType.getType().resolveBinding();
    if (callbackBinding == null) {
      return returnType;
    }

    // Make sure the callback is of type AsyncCallback
    String callbackBaseTypeName = callbackBinding.getErasure().getQualifiedName();
    if (callbackBaseTypeName.equals(RemoteServiceUtilities.ASYNCCALLBACK_QUALIFIED_NAME)) {
      @SuppressWarnings("unchecked")
      List<Type> callbackTypeArgs = callbackParamType.typeArguments();

      // Make sure we only have one type argument
      if (callbackTypeArgs.size() == 1) {
        Type callbackTypeParameter = callbackTypeArgs.get(0);

        // Check for primitive wrapper type; if we have one use the actual
        // primitive for the sync return type.
        // TODO(): Maybe used linked mode to let the user choose whether to
        // return the primitive or its wrapper type.
        String qualifiedName = callbackTypeParameter.resolveBinding().getQualifiedName();
        String primitiveTypeName = JavaASTUtils.getPrimitiveTypeName(qualifiedName);
        if (primitiveTypeName != null) {
          return ast.newPrimitiveType(PrimitiveType.toCode(primitiveTypeName));
        }

        returnType = JavaASTUtils.normalizeTypeAndAddImport(ast,
            callbackTypeParameter, imports);
      }
    }
  }

  return returnType;
}
 
開發者ID:gwt-plugins,項目名稱:gwt-eclipse-plugin,代碼行數:64,代碼來源:Util.java


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