本文整理汇总了Java中org.eclipse.jdt.core.dom.LambdaExpression.resolveMethodBinding方法的典型用法代码示例。如果您正苦于以下问题:Java LambdaExpression.resolveMethodBinding方法的具体用法?Java LambdaExpression.resolveMethodBinding怎么用?Java LambdaExpression.resolveMethodBinding使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.jdt.core.dom.LambdaExpression
的用法示例。
在下文中一共展示了LambdaExpression.resolveMethodBinding方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getDimensions
import org.eclipse.jdt.core.dom.LambdaExpression; //导入方法依赖的package包/类
public static int getDimensions(VariableDeclaration declaration) {
int dim= declaration.getExtraDimensions();
if (declaration instanceof VariableDeclarationFragment && declaration.getParent() instanceof LambdaExpression) {
LambdaExpression lambda= (LambdaExpression) declaration.getParent();
IMethodBinding methodBinding= lambda.resolveMethodBinding();
if (methodBinding != null) {
ITypeBinding[] parameterTypes= methodBinding.getParameterTypes();
int index= lambda.parameters().indexOf(declaration);
ITypeBinding typeBinding= parameterTypes[index];
return typeBinding.getDimensions();
}
} else {
Type type= getType(declaration);
if (type instanceof ArrayType) {
dim+= ((ArrayType) type).getDimensions();
}
}
return dim;
}
示例2: newType
import org.eclipse.jdt.core.dom.LambdaExpression; //导入方法依赖的package包/类
private static Type newType(LambdaExpression lambdaExpression, VariableDeclarationFragment declaration, AST ast, ImportRewrite importRewrite, ImportRewriteContext context) {
IMethodBinding method= lambdaExpression.resolveMethodBinding();
if (method != null) {
ITypeBinding[] parameterTypes= method.getParameterTypes();
int index= lambdaExpression.parameters().indexOf(declaration);
ITypeBinding typeBinding= parameterTypes[index];
if (importRewrite != null) {
return importRewrite.addImport(typeBinding, ast, context);
} else {
String qualifiedName= typeBinding.getQualifiedName();
if (qualifiedName.length() > 0) {
return newType(ast, qualifiedName);
}
}
}
// fall-back
return ast.newSimpleType(ast.newSimpleName("Object")); //$NON-NLS-1$
}
示例3: newReturnType
import org.eclipse.jdt.core.dom.LambdaExpression; //导入方法依赖的package包/类
/**
* Returns the new type node representing the return type of <code>lambdaExpression</code>
* including the extra dimensions.
*
* @param lambdaExpression the lambda expression
* @param ast the AST to create the return type with
* @param importRewrite the import rewrite to use, or <code>null</code>
* @param context the import rewrite context, or <code>null</code>
* @return a new type node created with the given AST representing the return type of
* <code>lambdaExpression</code>
*
* @since 3.10
*/
public static Type newReturnType(LambdaExpression lambdaExpression, AST ast, ImportRewrite importRewrite, ImportRewriteContext context) {
IMethodBinding method= lambdaExpression.resolveMethodBinding();
if (method != null) {
ITypeBinding returnTypeBinding= method.getReturnType();
if (importRewrite != null) {
return importRewrite.addImport(returnTypeBinding, ast);
} else {
String qualifiedName= returnTypeBinding.getQualifiedName();
if (qualifiedName.length() > 0) {
return newType(ast, qualifiedName);
}
}
}
// fall-back
return ast.newSimpleType(ast.newSimpleName("Object")); //$NON-NLS-1$
}
示例4: isVoidMethod
import org.eclipse.jdt.core.dom.LambdaExpression; //导入方法依赖的package包/类
private boolean isVoidMethod() {
ITypeBinding binding = null;
LambdaExpression enclosingLambdaExpr = ASTResolving.findEnclosingLambdaExpression(getFirstSelectedNode());
if (enclosingLambdaExpr != null) {
IMethodBinding methodBinding = enclosingLambdaExpr.resolveMethodBinding();
if (methodBinding != null) {
binding = methodBinding.getReturnType();
}
} else {
// if we have an initializer
if (fEnclosingMethodBinding == null) {
return true;
}
binding = fEnclosingMethodBinding.getReturnType();
}
if (fEnclosingBodyDeclaration.getAST().resolveWellKnownType("void").equals(binding)) {
return true;
}
return false;
}
示例5: newType
import org.eclipse.jdt.core.dom.LambdaExpression; //导入方法依赖的package包/类
private static Type newType(
LambdaExpression lambdaExpression,
VariableDeclarationFragment declaration,
AST ast,
ImportRewrite importRewrite,
ImportRewriteContext context) {
IMethodBinding method = lambdaExpression.resolveMethodBinding();
if (method != null) {
ITypeBinding[] parameterTypes = method.getParameterTypes();
int index = lambdaExpression.parameters().indexOf(declaration);
ITypeBinding typeBinding = parameterTypes[index];
if (importRewrite != null) {
return importRewrite.addImport(typeBinding, ast, context);
} else {
String qualifiedName = typeBinding.getQualifiedName();
if (qualifiedName.length() > 0) {
return newType(ast, qualifiedName);
}
}
}
// fall-back
return ast.newSimpleType(ast.newSimpleName("Object")); // $NON-NLS-1$
}
示例6: newReturnType
import org.eclipse.jdt.core.dom.LambdaExpression; //导入方法依赖的package包/类
/**
* Returns the new type node representing the return type of <code>lambdaExpression</code>
* including the extra dimensions.
*
* @param lambdaExpression the lambda expression
* @param ast the AST to create the return type with
* @param importRewrite the import rewrite to use, or <code>null</code>
* @param context the import rewrite context, or <code>null</code>
* @return a new type node created with the given AST representing the return type of <code>
* lambdaExpression</code>
* @since 3.10
*/
public static Type newReturnType(
LambdaExpression lambdaExpression,
AST ast,
ImportRewrite importRewrite,
ImportRewriteContext context) {
IMethodBinding method = lambdaExpression.resolveMethodBinding();
if (method != null) {
ITypeBinding returnTypeBinding = method.getReturnType();
if (importRewrite != null) {
return importRewrite.addImport(returnTypeBinding, ast);
} else {
String qualifiedName = returnTypeBinding.getQualifiedName();
if (qualifiedName.length() > 0) {
return newType(ast, qualifiedName);
}
}
}
// fall-back
return ast.newSimpleType(ast.newSimpleName("Object")); // $NON-NLS-1$
}
示例7: isVoidMethod
import org.eclipse.jdt.core.dom.LambdaExpression; //导入方法依赖的package包/类
private boolean isVoidMethod() {
ITypeBinding binding = null;
LambdaExpression enclosingLambdaExpr =
ASTResolving.findEnclosingLambdaExpression(getFirstSelectedNode());
if (enclosingLambdaExpr != null) {
IMethodBinding methodBinding = enclosingLambdaExpr.resolveMethodBinding();
if (methodBinding != null) {
binding = methodBinding.getReturnType();
}
} else {
// if we have an initializer
if (fEnclosingMethodBinding == null) return true;
binding = fEnclosingMethodBinding.getReturnType();
}
if (fEnclosingBodyDeclaration
.getAST()
.resolveWellKnownType("void")
.equals(binding)) // $NON-NLS-1$
return true;
return false;
}
示例8: isVoidMethod
import org.eclipse.jdt.core.dom.LambdaExpression; //导入方法依赖的package包/类
private boolean isVoidMethod() {
ITypeBinding binding= null;
LambdaExpression enclosingLambdaExpr= ASTResolving.findEnclosingLambdaExpression(getFirstSelectedNode());
if (enclosingLambdaExpr != null) {
IMethodBinding methodBinding= enclosingLambdaExpr.resolveMethodBinding();
if (methodBinding != null) {
binding= methodBinding.getReturnType();
}
} else {
// if we have an initializer
if (fEnclosingMethodBinding == null)
return true;
binding= fEnclosingMethodBinding.getReturnType();
}
if (fEnclosingBodyDeclaration.getAST().resolveWellKnownType("void").equals(binding)) //$NON-NLS-1$
return true;
return false;
}
示例9: newReturnType
import org.eclipse.jdt.core.dom.LambdaExpression; //导入方法依赖的package包/类
/**
* Returns the new type node representing the return type of <code>lambdaExpression</code>
* including the extra dimensions.
*
* @param lambdaExpression the lambda expression
* @param ast the AST to create the return type with
* @param importRewrite the import rewrite to use, or <code>null</code>
* @param context the import rewrite context, or <code>null</code>
* @return a new type node created with the given AST representing the return type of
* <code>lambdaExpression</code>
*
* @since 3.10
*/
public static Type newReturnType(LambdaExpression lambdaExpression, AST ast, ImportRewrite importRewrite, ImportRewriteContext context) {
IMethodBinding method= lambdaExpression.resolveMethodBinding();
if (method != null) {
ITypeBinding returnTypeBinding= method.getReturnType();
if (importRewrite != null) {
return importRewrite.addImport(returnTypeBinding, ast);
} else {
String qualifiedName= returnTypeBinding.getQualifiedName();
if (qualifiedName.length() > 0) {
return newType(ast, qualifiedName);
}
}
}
// fall-back
return ast.newSimpleType(ast.newSimpleName("Object")); //$NON-NLS-1$
}
示例10: initReturnType
import org.eclipse.jdt.core.dom.LambdaExpression; //导入方法依赖的package包/类
private void initReturnType(ImportRewrite rewriter) {
AST ast = fEnclosingBodyDeclaration.getAST();
fReturnType = null;
fReturnTypeBinding = null;
switch (fReturnKind) {
case ACCESS_TO_LOCAL:
VariableDeclaration declaration = ASTNodes.findVariableDeclaration(fReturnValue, fEnclosingBodyDeclaration);
fReturnType = ASTNodeFactory.newType(ast, declaration, rewriter, new ContextSensitiveImportRewriteContext(declaration, rewriter));
if (declaration.resolveBinding() != null) {
fReturnTypeBinding = declaration.resolveBinding().getType();
}
break;
case EXPRESSION:
Expression expression = (Expression) getFirstSelectedNode();
if (expression.getNodeType() == ASTNode.CLASS_INSTANCE_CREATION) {
fExpressionBinding = ((ClassInstanceCreation) expression).getType().resolveBinding();
} else {
fExpressionBinding = expression.resolveTypeBinding();
}
if (fExpressionBinding != null) {
if (fExpressionBinding.isNullType()) {
getStatus().addFatalError(RefactoringCoreMessages.ExtractMethodAnalyzer_cannot_extract_null_type, JavaStatusContext.create(fCUnit, expression));
} else {
ITypeBinding normalizedBinding = Bindings.normalizeForDeclarationUse(fExpressionBinding, ast);
if (normalizedBinding != null) {
ImportRewriteContext context = new ContextSensitiveImportRewriteContext(fEnclosingBodyDeclaration, rewriter);
fReturnType = rewriter.addImport(normalizedBinding, ast, context, TypeLocation.RETURN_TYPE);
fReturnTypeBinding = normalizedBinding;
}
}
} else {
fReturnType = ast.newPrimitiveType(PrimitiveType.VOID);
fReturnTypeBinding = ast.resolveWellKnownType("void"); //$NON-NLS-1$
getStatus().addError(RefactoringCoreMessages.ExtractMethodAnalyzer_cannot_determine_return_type, JavaStatusContext.create(fCUnit, expression));
}
break;
case RETURN_STATEMENT_VALUE:
LambdaExpression enclosingLambdaExpr = ASTResolving.findEnclosingLambdaExpression(getFirstSelectedNode());
if (enclosingLambdaExpr != null) {
fReturnType = ASTNodeFactory.newReturnType(enclosingLambdaExpr, ast, rewriter, null);
IMethodBinding methodBinding = enclosingLambdaExpr.resolveMethodBinding();
fReturnTypeBinding = methodBinding != null ? methodBinding.getReturnType() : null;
} else if (fEnclosingBodyDeclaration.getNodeType() == ASTNode.METHOD_DECLARATION) {
fReturnType = ((MethodDeclaration) fEnclosingBodyDeclaration).getReturnType2();
fReturnTypeBinding = fReturnType != null ? fReturnType.resolveBinding() : null;
}
break;
default:
fReturnType = ast.newPrimitiveType(PrimitiveType.VOID);
fReturnTypeBinding = ast.resolveWellKnownType("void"); //$NON-NLS-1$
}
if (fReturnType == null) {
fReturnType = ast.newPrimitiveType(PrimitiveType.VOID);
fReturnTypeBinding = ast.resolveWellKnownType("void"); //$NON-NLS-1$
}
}
示例11: initReturnType
import org.eclipse.jdt.core.dom.LambdaExpression; //导入方法依赖的package包/类
private void initReturnType(ImportRewrite rewriter) {
AST ast = fEnclosingBodyDeclaration.getAST();
fReturnType = null;
fReturnTypeBinding = null;
switch (fReturnKind) {
case ACCESS_TO_LOCAL:
VariableDeclaration declaration =
ASTNodes.findVariableDeclaration(fReturnValue, fEnclosingBodyDeclaration);
fReturnType =
ASTNodeFactory.newType(
ast,
declaration,
rewriter,
new ContextSensitiveImportRewriteContext(declaration, rewriter));
if (declaration.resolveBinding() != null) {
fReturnTypeBinding = declaration.resolveBinding().getType();
}
break;
case EXPRESSION:
Expression expression = (Expression) getFirstSelectedNode();
if (expression.getNodeType() == ASTNode.CLASS_INSTANCE_CREATION) {
fExpressionBinding = ((ClassInstanceCreation) expression).getType().resolveBinding();
} else {
fExpressionBinding = expression.resolveTypeBinding();
}
if (fExpressionBinding != null) {
if (fExpressionBinding.isNullType()) {
getStatus()
.addFatalError(
RefactoringCoreMessages.ExtractMethodAnalyzer_cannot_extract_null_type,
JavaStatusContext.create(fCUnit, expression));
} else {
ITypeBinding normalizedBinding =
Bindings.normalizeForDeclarationUse(fExpressionBinding, ast);
if (normalizedBinding != null) {
ImportRewriteContext context =
new ContextSensitiveImportRewriteContext(fEnclosingBodyDeclaration, rewriter);
fReturnType = rewriter.addImport(normalizedBinding, ast, context);
fReturnTypeBinding = normalizedBinding;
}
}
} else {
fReturnType = ast.newPrimitiveType(PrimitiveType.VOID);
fReturnTypeBinding = ast.resolveWellKnownType("void"); // $NON-NLS-1$
getStatus()
.addError(
RefactoringCoreMessages.ExtractMethodAnalyzer_cannot_determine_return_type,
JavaStatusContext.create(fCUnit, expression));
}
break;
case RETURN_STATEMENT_VALUE:
LambdaExpression enclosingLambdaExpr =
ASTResolving.findEnclosingLambdaExpression(getFirstSelectedNode());
if (enclosingLambdaExpr != null) {
fReturnType = ASTNodeFactory.newReturnType(enclosingLambdaExpr, ast, rewriter, null);
IMethodBinding methodBinding = enclosingLambdaExpr.resolveMethodBinding();
fReturnTypeBinding = methodBinding != null ? methodBinding.getReturnType() : null;
} else if (fEnclosingBodyDeclaration.getNodeType() == ASTNode.METHOD_DECLARATION) {
fReturnType = ((MethodDeclaration) fEnclosingBodyDeclaration).getReturnType2();
fReturnTypeBinding = fReturnType != null ? fReturnType.resolveBinding() : null;
}
break;
default:
fReturnType = ast.newPrimitiveType(PrimitiveType.VOID);
fReturnTypeBinding = ast.resolveWellKnownType("void"); // $NON-NLS-1$
}
if (fReturnType == null) {
fReturnType = ast.newPrimitiveType(PrimitiveType.VOID);
fReturnTypeBinding = ast.resolveWellKnownType("void"); // $NON-NLS-1$
}
}
示例12: initReturnType
import org.eclipse.jdt.core.dom.LambdaExpression; //导入方法依赖的package包/类
private void initReturnType(ImportRewrite rewriter) {
AST ast= fEnclosingBodyDeclaration.getAST();
fReturnType= null;
fReturnTypeBinding= null;
switch (fReturnKind) {
case ACCESS_TO_LOCAL:
VariableDeclaration declaration= ASTNodes.findVariableDeclaration(fReturnValue, fEnclosingBodyDeclaration);
fReturnType= ASTNodeFactory.newType(ast, declaration, rewriter, new ContextSensitiveImportRewriteContext(declaration, rewriter));
if (declaration.resolveBinding() != null) {
fReturnTypeBinding= declaration.resolveBinding().getType();
}
break;
case EXPRESSION:
Expression expression= (Expression)getFirstSelectedNode();
if (expression.getNodeType() == ASTNode.CLASS_INSTANCE_CREATION) {
fExpressionBinding= ((ClassInstanceCreation)expression).getType().resolveBinding();
} else {
fExpressionBinding= expression.resolveTypeBinding();
}
if (fExpressionBinding != null) {
if (fExpressionBinding.isNullType()) {
getStatus().addFatalError(RefactoringCoreMessages.ExtractMethodAnalyzer_cannot_extract_null_type, JavaStatusContext.create(fCUnit, expression));
} else {
ITypeBinding normalizedBinding= Bindings.normalizeForDeclarationUse(fExpressionBinding, ast);
if (normalizedBinding != null) {
ImportRewriteContext context= new ContextSensitiveImportRewriteContext(fEnclosingBodyDeclaration, rewriter);
fReturnType= rewriter.addImport(normalizedBinding, ast, context);
fReturnTypeBinding= normalizedBinding;
}
}
} else {
fReturnType= ast.newPrimitiveType(PrimitiveType.VOID);
fReturnTypeBinding= ast.resolveWellKnownType("void"); //$NON-NLS-1$
getStatus().addError(RefactoringCoreMessages.ExtractMethodAnalyzer_cannot_determine_return_type, JavaStatusContext.create(fCUnit, expression));
}
break;
case RETURN_STATEMENT_VALUE:
LambdaExpression enclosingLambdaExpr= ASTResolving.findEnclosingLambdaExpression(getFirstSelectedNode());
if (enclosingLambdaExpr != null) {
fReturnType= ASTNodeFactory.newReturnType(enclosingLambdaExpr, ast, rewriter, null);
IMethodBinding methodBinding= enclosingLambdaExpr.resolveMethodBinding();
fReturnTypeBinding= methodBinding != null ? methodBinding.getReturnType() : null;
} else if (fEnclosingBodyDeclaration.getNodeType() == ASTNode.METHOD_DECLARATION) {
fReturnType= ((MethodDeclaration) fEnclosingBodyDeclaration).getReturnType2();
fReturnTypeBinding= fReturnType != null ? fReturnType.resolveBinding() : null;
}
break;
default:
fReturnType= ast.newPrimitiveType(PrimitiveType.VOID);
fReturnTypeBinding= ast.resolveWellKnownType("void"); //$NON-NLS-1$
}
if (fReturnType == null) {
fReturnType= ast.newPrimitiveType(PrimitiveType.VOID);
fReturnTypeBinding= ast.resolveWellKnownType("void"); //$NON-NLS-1$
}
}