本文整理匯總了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;
}
示例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;
}
示例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);
}
}
示例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);
}
}
示例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;
}
示例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;
}
示例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();
}