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


Java SingleVariableDeclaration.getType方法代碼示例

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


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

示例1: getSignatureFromMethodDeclaration

import org.eclipse.jdt.core.dom.SingleVariableDeclaration; //導入方法依賴的package包/類
public static String getSignatureFromMethodDeclaration(MethodDeclaration methodDeclaration) {
		String methodName = methodDeclaration.isConstructor() ? "" : methodDeclaration.getName().getIdentifier();
//		if (methodName.equals("allObjectsSorted")) {
//			System.out.println();
//		}
		StringBuilder sb = new StringBuilder();
		sb.append(methodName);
		sb.append('(');
		@SuppressWarnings("unchecked")
        Iterator<SingleVariableDeclaration> parameters = methodDeclaration.parameters().iterator();
		while (parameters.hasNext()) {
			SingleVariableDeclaration parameter = parameters.next();
			Type parameterType = parameter.getType();
			String typeName = normalizeTypeName(parameterType, parameter.getExtraDimensions(), parameter.isVarargs());
			sb.append(typeName);
			if (parameters.hasNext()) {
				sb.append(", ");
			}
		}
		sb.append(')');
		String methodSignature = sb.toString();
		return methodSignature;
	}
 
開發者ID:aserg-ufmg,項目名稱:RefDiff,代碼行數:24,代碼來源:AstUtils.java

示例2: getParameters

import org.eclipse.jdt.core.dom.SingleVariableDeclaration; //導入方法依賴的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

示例3: extractParametersAndReturnType

import org.eclipse.jdt.core.dom.SingleVariableDeclaration; //導入方法依賴的package包/類
public static void extractParametersAndReturnType(SDModel model, MethodDeclaration methodDeclaration, RastNode method) {
    Type returnType = methodDeclaration.getReturnType2();
    if (returnType != null) {
    	model.setReturnType(method, AstUtils.normalizeTypeName(returnType, methodDeclaration.getExtraDimensions(), false));
    } else {
    	model.setReturnType(method, null);
    }
    Iterator<SingleVariableDeclaration> parameters = methodDeclaration.parameters().iterator();
    while (parameters.hasNext()) {
        SingleVariableDeclaration parameter = parameters.next();
        Type parameterType = parameter.getType();
        String typeName = AstUtils.normalizeTypeName(parameterType, parameter.getExtraDimensions(), parameter.isVarargs());
        model.addParameter(method, parameter.getName().getIdentifier(), typeName);
    }
}
 
開發者ID:aserg-ufmg,項目名稱:RefDiff,代碼行數:16,代碼來源:BindingsRecoveryAstVisitor.java

示例4: extractParametersAndReturnType

import org.eclipse.jdt.core.dom.SingleVariableDeclaration; //導入方法依賴的package包/類
public static void extractParametersAndReturnType(MethodDeclaration methodDeclaration, SDMethod method) {
    Type returnType = methodDeclaration.getReturnType2();
    if (returnType != null) {
        method.setReturnType(AstUtils.normalizeTypeName(returnType, methodDeclaration.getExtraDimensions(), false));
    } else {
        method.setReturnType(null);
    }
    Iterator<SingleVariableDeclaration> parameters = methodDeclaration.parameters().iterator();
    while (parameters.hasNext()) {
        SingleVariableDeclaration parameter = parameters.next();
        Type parameterType = parameter.getType();
        String typeName = AstUtils.normalizeTypeName(parameterType, parameter.getExtraDimensions(), parameter.isVarargs());
        method.addParameter(parameter.getName().getIdentifier(), typeName);
    }
}
 
開發者ID:aserg-ufmg,項目名稱:RefDiff,代碼行數:16,代碼來源:BindingsRecoveryAstVisitor.java

示例5: isEnhancedForStatementVariable

import org.eclipse.jdt.core.dom.SingleVariableDeclaration; //導入方法依賴的package包/類
private boolean isEnhancedForStatementVariable(Statement statement, SimpleName name) {
	if (statement instanceof EnhancedForStatement) {
		EnhancedForStatement forStatement= (EnhancedForStatement) statement;
		SingleVariableDeclaration param= forStatement.getParameter();
		return param.getType() == name.getParent(); // strange recovery, see https://bugs.eclipse.org/180456
	}
	return false;
}
 
開發者ID:eclipse,項目名稱:eclipse.jdt.ls,代碼行數:9,代碼來源:NewVariableCorrectionProposal.java

示例6: rewriteFormalParameterDeclaration

import org.eclipse.jdt.core.dom.SingleVariableDeclaration; //導入方法依賴的package包/類
private RefactoringStatus rewriteFormalParameterDeclaration(
		ASTRewrite astRewrite, ImportRewrite importRewrite,
		SingleVariableDeclaration oldFormalParameterDeclaration,
		String fullyQualifiedTypeName) {

	final RefactoringStatus status = new RefactoringStatus();
	final String typeName = importRewrite.addImport(fullyQualifiedTypeName);
	final AST ast = oldFormalParameterDeclaration.getAST();
	final Type newType = getNewType(ast, typeName);
	final Type oldType = oldFormalParameterDeclaration.getType();
	astRewrite.replace(oldType, newType, null);
	return status;
}
 
開發者ID:ponder-lab,項目名稱:Constants-to-Enum-Eclipse-Plugin,代碼行數:14,代碼來源:ConvertConstantsToEnumRefactoring.java

示例7: isEnhancedForStatementVariable

import org.eclipse.jdt.core.dom.SingleVariableDeclaration; //導入方法依賴的package包/類
private boolean isEnhancedForStatementVariable(Statement statement, SimpleName name) {
  if (statement instanceof EnhancedForStatement) {
    EnhancedForStatement forStatement = (EnhancedForStatement) statement;
    SingleVariableDeclaration param = forStatement.getParameter();
    return param.getType()
        == name.getParent(); // strange recovery, see https://bugs.eclipse.org/180456
  }
  return false;
}
 
開發者ID:eclipse,項目名稱:che,代碼行數:10,代碼來源:NewVariableCorrectionProposal.java

示例8: doValidateReturnTypes

import org.eclipse.jdt.core.dom.SingleVariableDeclaration; //導入方法依賴的package包/類
/**
 * Validate that the AsyncCallback's parameterization and the sync method's
 * return type are assignment compatible.
 */
@SuppressWarnings("unchecked")
private List<CategorizedProblem> doValidateReturnTypes(
    MethodDeclaration node, SingleVariableDeclaration lastParameter,
    ITypeBinding[] parameterTypes, IMethodBinding dependentMethod) {
  ITypeBinding asyncCallbackParam = parameterTypes[parameterTypes.length - 1];
  if (asyncCallbackParam.isParameterizedType()) {
    ITypeBinding[] typeArguments = asyncCallbackParam.getTypeArguments();
    ITypeBinding syncReturnTypeBinding = dependentMethod.getReturnType();

    ITypeBinding typeBinding = syncReturnTypeBinding;
    if (syncReturnTypeBinding.isPrimitive()) {
      String qualifiedWrapperTypeName = JavaASTUtils.getWrapperTypeName(syncReturnTypeBinding.getQualifiedName());
      typeBinding = node.getAST().resolveWellKnownType(
          qualifiedWrapperTypeName);
    }

    boolean compatible = false;
    if (typeBinding != null) {
      compatible = canAssign(typeArguments[0], typeBinding);
    }

    if (!compatible) {
      ParameterizedType parameterizedType = (ParameterizedType) lastParameter.getType();
      List<Type> types = parameterizedType.typeArguments();
      CategorizedProblem problem = RemoteServiceProblemFactory.newAsyncCallbackTypeArgumentMismatchOnAsync(
          types.get(0), typeArguments[0], syncReturnTypeBinding);
      if (problem != null) {
        return Collections.singletonList(problem);
      }
    }
  }

  return Collections.emptyList();
}
 
開發者ID:gwt-plugins,項目名稱:gwt-eclipse-plugin,代碼行數:39,代碼來源:AsynchronousInterfaceValidator.java


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