Java Code Examples for org.eclipse.jdt.core.dom.IMethodBinding#getReturnType()

The following examples show how to use org.eclipse.jdt.core.dom.IMethodBinding#getReturnType() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MethodCallAnalyzer.java    From JDeodorant with MIT License 6 votes vote down vote up
public static boolean equalSignatureIgnoringSubclassTypeDifferences(IMethodBinding methodBinding1, IMethodBinding methodBinding2) {
	if(!methodBinding1.getName().equals(methodBinding2.getName()))
		return false;
	ITypeBinding returnType1 = methodBinding1.getReturnType();
	ITypeBinding returnType2 = methodBinding2.getReturnType();
	ITypeBinding returnCommonSuperType = ASTNodeMatcher.commonSuperType(returnType1, returnType2);
	if(!equalType(returnType1, returnType2) && !ASTNodeMatcher.validCommonSuperType(returnCommonSuperType))
		return false;
	ITypeBinding[] parameterTypes1 = methodBinding1.getParameterTypes();
	ITypeBinding[] parameterTypes2 = methodBinding2.getParameterTypes();
	if(parameterTypes1.length == parameterTypes2.length) {
		int i = 0;
		for(ITypeBinding typeBinding1 : parameterTypes1) {
			ITypeBinding typeBinding2 = parameterTypes2[i];
			ITypeBinding parameterCommonSuperType = ASTNodeMatcher.commonSuperType(typeBinding1, typeBinding2);
			if(!equalType(typeBinding1, typeBinding2) && !ASTNodeMatcher.validCommonSuperType(parameterCommonSuperType))
				return false;
			i++;
		}
	}
	else return false;
	return true;
}
 
Example 2
Source File: ASTNodeFactory.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * 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$
}
 
Example 3
Source File: SuperTypeConstraintsModel.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Creates a new return type variable.
 *
 * @param method the method binding
 * @return the created return type variable, or <code>null</code>
 */
public final ConstraintVariable2 createReturnTypeVariable(final IMethodBinding method) {
	if (!method.isConstructor()) {
		ITypeBinding binding= method.getReturnType();
		if (binding != null && binding.isArray())
			binding= binding.getElementType();
		if (binding != null && isConstrainedType(binding)) {
			ConstraintVariable2 variable= null;
			final TType type= createTType(binding);
			if (method.getDeclaringClass().isFromSource())
				variable= new ReturnTypeVariable2(type, method);
			else
				variable= new ImmutableTypeVariable2(type);
			return fConstraintVariables.addExisting(variable);
		}
	}
	return null;
}
 
Example 4
Source File: ExtractMethodAnalyzer.java    From eclipse.jdt.ls with Eclipse Public License 2.0 6 votes vote down vote up
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;
}
 
Example 5
Source File: MethodCallAnalyzer.java    From JDeodorant with MIT License 6 votes vote down vote up
public static boolean equalSignature(IMethodBinding methodBinding1, IMethodBinding methodBinding2) {
	if(!methodBinding1.getName().equals(methodBinding2.getName()))
		return false;
	ITypeBinding returnType1 = methodBinding1.getReturnType();
	ITypeBinding returnType2 = methodBinding2.getReturnType();
	if(!equalType(returnType1, returnType2))
		return false;
	ITypeBinding[] parameterTypes1 = methodBinding1.getParameterTypes();
	ITypeBinding[] parameterTypes2 = methodBinding2.getParameterTypes();
	if(parameterTypes1.length == parameterTypes2.length) {
		int i = 0;
		for(ITypeBinding typeBinding1 : parameterTypes1) {
			ITypeBinding typeBinding2 = parameterTypes2[i];
			if(!equalType(typeBinding1, typeBinding2))
				return false;
			i++;
		}
	}
	else return false;
	return true;
}
 
Example 6
Source File: SelfEncapsulateFieldRefactoring.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
public static void checkMethodInHierarchy(ITypeBinding type, String methodName, ITypeBinding returnType, ITypeBinding[] parameters, RefactoringStatus result, boolean reUseMethod) {
	IMethodBinding method= Bindings.findMethodInHierarchy(type, methodName, parameters);
	if (method != null) {
		boolean returnTypeClash= false;
		ITypeBinding methodReturnType= method.getReturnType();
		if (returnType != null && methodReturnType != null) {
			String returnTypeKey= returnType.getKey();
			String methodReturnTypeKey= methodReturnType.getKey();
			if (returnTypeKey == null && methodReturnTypeKey == null) {
				returnTypeClash= returnType != methodReturnType;
			} else if (returnTypeKey != null && methodReturnTypeKey != null) {
				returnTypeClash= !returnTypeKey.equals(methodReturnTypeKey);
			}
		}
		ITypeBinding dc= method.getDeclaringClass();
		if (returnTypeClash) {
			result.addError(Messages.format(RefactoringCoreMessages.Checks_methodName_returnTypeClash,
				new Object[] { BasicElementLabels.getJavaElementName(methodName), BasicElementLabels.getJavaElementName(dc.getName())}),
				JavaStatusContext.create(method));
		} else {
			if (!reUseMethod)
				result.addError(Messages.format(RefactoringCoreMessages.Checks_methodName_overrides,
						new Object[] { BasicElementLabels.getJavaElementName(methodName), BasicElementLabels.getJavaElementName(dc.getName())}),
					JavaStatusContext.create(method));
		}
	} else {
		if (reUseMethod){
			result.addError(Messages.format(RefactoringCoreMessages.SelfEncapsulateFieldRefactoring_nosuchmethod_status_fatalError,
					BasicElementLabels.getJavaElementName(methodName)),
					JavaStatusContext.create(method));
		}
	}
}
 
Example 7
Source File: GenerateForLoopAssistProposal.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Extracts the type parameter of the variable contained in fCurrentExpression or the elements
 * type to iterate over an array using <code>foreach</code>.
 * 
 * @param ast the current {@link AST} instance
 * @return the {@link ITypeBinding} of the elements to iterate over
 */
private ITypeBinding extractElementType(AST ast) {
	if (fExpressionType.isArray()) {
		return Bindings.normalizeForDeclarationUse(fExpressionType.getElementType(), ast);
	}

	// extract elements type directly out of the bindings
	IMethodBinding iteratorMethodBinding= Bindings.findMethodInHierarchy(fExpressionType, "iterator", new ITypeBinding[] {}); //$NON-NLS-1$
	IMethodBinding iteratorNextMethodBinding= Bindings.findMethodInHierarchy(iteratorMethodBinding.getReturnType(), "next", new ITypeBinding[] {}); //$NON-NLS-1$

	ITypeBinding currentElementBinding= iteratorNextMethodBinding.getReturnType();

	return Bindings.normalizeForDeclarationUse(currentElementBinding, ast);
}
 
Example 8
Source File: InJavaImporter.java    From jdt2famix with Eclipse Public License 1.0 5 votes vote down vote up
private AnnotationTypeAttribute ensureAnnotationTypeAttributeFromBinding(IMethodBinding binding) {
	ITypeBinding parentTypeBinding = binding.getDeclaringClass();
	if (parentTypeBinding == null) {
		return null;
	}
	AnnotationType annotationType = (AnnotationType) ensureTypeFromTypeBinding(parentTypeBinding);
	AnnotationTypeAttribute attribute = ensureAnnotationTypeAttribute(annotationType, binding.getName());
	ITypeBinding returnType = binding.getReturnType();
	if ((returnType != null) && !(returnType.isPrimitive() && returnType.getName().equals("void"))) {
		// we do not want to set void as a return type
		attribute.setDeclaredType(ensureTypeFromTypeBinding(returnType));
	}
	return attribute;
}
 
Example 9
Source File: InJavaImporter.java    From jdt2famix with Eclipse Public License 1.0 5 votes vote down vote up
private void setUpMethodFromMethodBinding(Method method, IMethodBinding binding) {
	if (binding.isConstructor())
		method.setKind(CONSTRUCTOR_KIND);
	ITypeBinding returnType = binding.getReturnType();
	if ((returnType != null) && !(returnType.isPrimitive() && returnType.getName().equals("void")))
		// we do not want to set void as a return type
		method.setDeclaredType(ensureTypeFromTypeBinding(returnType));
	extractBasicModifiersFromBinding(binding.getModifiers(), method);
	if (Modifier.isStatic(binding.getModifiers()))
		method.setHasClassScope(true);
}
 
Example 10
Source File: AsynchronousInterfaceValidator.java    From gwt-eclipse-plugin with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * 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();
}
 
Example 11
Source File: RemoteServiceProblemFactory.java    From gwt-eclipse-plugin with Eclipse Public License 1.0 5 votes vote down vote up
static String toAsyncMethodSignature(IMethodBinding syncMethod) {
  StringBuilder sb = new StringBuilder();
  sb.append(syncMethod.getName());
  sb.append("(");
  ITypeBinding[] parameterTypes = syncMethod.getParameterTypes();
  for (int i = 0; i < parameterTypes.length; ++i) {
    if (i != 0) {
      sb.append(", ");
    }

    sb.append(parameterTypes[i].getName());
  }

  if (parameterTypes.length > 0) {
    sb.append(", ");
  }

  sb.append("AsyncCallback<");
  ITypeBinding returnType = syncMethod.getReturnType();
  if (returnType.isPrimitive()) {
    sb.append(Signature.getSimpleName(JavaASTUtils.getWrapperTypeName(returnType.getName())));
  } else {
    sb.append(returnType.getName());
  }
  sb.append(">");
  sb.append(")");

  return sb.toString();
}
 
Example 12
Source File: MissingReturnTypeInLambdaCorrectionProposal.java    From eclipse.jdt.ls with Eclipse Public License 2.0 5 votes vote down vote up
@Override
public ITypeBinding getReturnTypeBinding() {
	IMethodBinding methodBinding= lambdaExpression.resolveMethodBinding();
	if (methodBinding != null && methodBinding.getReturnType() != null) {
		return methodBinding.getReturnType();
	}
	return null;
}
 
Example 13
Source File: MissingReturnTypeCorrectionProposal.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
protected ITypeBinding getReturnTypeBinding() {
	IMethodBinding methodBinding= fMethodDecl.resolveBinding();
	if (methodBinding != null && methodBinding.getReturnType() != null) {
		return methodBinding.getReturnType();
	}
	return null;
}
 
Example 14
Source File: Bindings.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
private static boolean areSubTypeCompatible(IMethodBinding overridden, IMethodBinding overridable) {

		if (overridden.getParameterTypes().length != overridable.getParameterTypes().length)
			return false;

		ITypeBinding overriddenReturn= overridden.getReturnType();
		ITypeBinding overridableReturn= overridable.getReturnType();
		if (overriddenReturn == null || overridableReturn == null)
			return false;

		if (!overriddenReturn.getErasure().isSubTypeCompatible(overridableReturn.getErasure()))
			return false;

		ITypeBinding[] overriddenTypes= overridden.getParameterTypes();
		ITypeBinding[] overridableTypes= overridable.getParameterTypes();
		Assert.isTrue(overriddenTypes.length == overridableTypes.length);
		for (int index= 0; index < overriddenTypes.length; index++) {
			final ITypeBinding overridableErasure= overridableTypes[index].getErasure();
			final ITypeBinding overriddenErasure= overriddenTypes[index].getErasure();
			if (!overridableErasure.isSubTypeCompatible(overriddenErasure) || !overridableErasure.getKey().equals(overriddenErasure.getKey()))
				return false;
		}
		ITypeBinding[] overriddenExceptions= overridden.getExceptionTypes();
		ITypeBinding[] overridableExceptions= overridable.getExceptionTypes();
		boolean checked= false;
		for (int index= 0; index < overriddenExceptions.length; index++) {
			checked= false;
			for (int offset= 0; offset < overridableExceptions.length; offset++) {
				if (overriddenExceptions[index].isSubTypeCompatible(overridableExceptions[offset]))
					checked= true;
			}
			if (!checked)
				return false;
		}
		return true;
	}
 
Example 15
Source File: JdtBasedTypeFactory.java    From xtext-eclipse with Eclipse Public License 2.0 5 votes vote down vote up
private void setDefaultValue(JvmOperation operation, IMethodBinding method) {
	Object defaultValue = method.getDefaultValue();
	if (defaultValue != null) {
		ITypeBinding originalTypeBinding = method.getReturnType();
		ITypeBinding typeBinding = originalTypeBinding;
		if (originalTypeBinding.isArray()) {
			typeBinding = typeBinding.getComponentType();
		}
		if (typeBinding.isParameterizedType())
			typeBinding = typeBinding.getErasure();
		JvmAnnotationValue annotationValue = createAnnotationValue(typeBinding, defaultValue);
		operation.setDefaultValue(annotationValue);
		annotationValue.setOperation(operation);
	}
}
 
Example 16
Source File: JdtBasedTypeFactory.java    From xtext-eclipse with Eclipse Public License 2.0 5 votes vote down vote up
/**
 * @since 2.4
 */
protected JvmAnnotationValue createAnnotationValue(ITypeBinding annotationType, /* @Nullable */ Object value, IMethodBinding methodBinding) {
	ITypeBinding originalTypeBinding = methodBinding.getReturnType();
	ITypeBinding typeBinding = originalTypeBinding;
	if (originalTypeBinding.isArray()) {
		typeBinding = typeBinding.getComponentType();
	}
	if (typeBinding.isParameterizedType())
		typeBinding = typeBinding.getErasure();
	JvmAnnotationValue annotationValue = createAnnotationValue(typeBinding, value);
	annotationValue.setOperation(createMethodProxy(annotationType, methodBinding));
	return annotationValue;
}
 
Example 17
Source File: ReturnTypeVariable.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 4 votes vote down vote up
public ReturnTypeVariable(IMethodBinding methodBinding) {
	super(methodBinding.getReturnType());
	fMethodBinding= methodBinding;
}
 
Example 18
Source File: TypeMismatchSubProcessor.java    From eclipse.jdt.ls with Eclipse Public License 2.0 4 votes vote down vote up
public static void addIncompatibleReturnTypeProposals(IInvocationContext context, IProblemLocationCore problem,
		Collection<ChangeCorrectionProposal> proposals) throws JavaModelException {
	CompilationUnit astRoot= context.getASTRoot();
	ASTNode selectedNode= problem.getCoveringNode(astRoot);
	if (selectedNode == null) {
		return;
	}
	MethodDeclaration decl= ASTResolving.findParentMethodDeclaration(selectedNode);
	if (decl == null) {
		return;
	}
	IMethodBinding methodDeclBinding= decl.resolveBinding();
	if (methodDeclBinding == null) {
		return;
	}

	ITypeBinding returnType= methodDeclBinding.getReturnType();
	IMethodBinding overridden= Bindings.findOverriddenMethod(methodDeclBinding, false);
	if (overridden == null || overridden.getReturnType() == returnType) {
		return;
	}


	ICompilationUnit cu= context.getCompilationUnit();
	IMethodBinding methodDecl= methodDeclBinding.getMethodDeclaration();
	ITypeBinding overriddenReturnType= overridden.getReturnType();
	if (! JavaModelUtil.is50OrHigher(context.getCompilationUnit().getJavaProject())) {
		overriddenReturnType= overriddenReturnType.getErasure();
	}
	proposals.add(new TypeChangeCorrectionProposal(cu, methodDecl, astRoot, overriddenReturnType, false, IProposalRelevance.CHANGE_RETURN_TYPE));

	ICompilationUnit targetCu= cu;

	IMethodBinding overriddenDecl= overridden.getMethodDeclaration();
	ITypeBinding overridenDeclType= overriddenDecl.getDeclaringClass();

	if (overridenDeclType.isFromSource()) {
		targetCu= ASTResolving.findCompilationUnitForBinding(cu, astRoot, overridenDeclType);
		if (targetCu != null && ASTResolving.isUseableTypeInContext(returnType, overriddenDecl, false)) {
			TypeChangeCorrectionProposal proposal= new TypeChangeCorrectionProposal(targetCu, overriddenDecl, astRoot, returnType, false, IProposalRelevance.CHANGE_RETURN_TYPE_OF_OVERRIDDEN);
			if (overridenDeclType.isInterface()) {
				proposal.setDisplayName(Messages.format(CorrectionMessages.TypeMismatchSubProcessor_changereturnofimplemented_description, BasicElementLabels.getJavaElementName(overriddenDecl.getName())));
			} else {
				proposal.setDisplayName(Messages.format(CorrectionMessages.TypeMismatchSubProcessor_changereturnofoverridden_description, BasicElementLabels.getJavaElementName(overriddenDecl.getName())));
			}
			proposals.add(proposal);
		}
	}
}
 
Example 19
Source File: TypeMismatchSubProcessor.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 4 votes vote down vote up
public static void addIncompatibleReturnTypeProposals(IInvocationContext context, IProblemLocation problem, Collection<ICommandAccess> proposals) throws JavaModelException {
	CompilationUnit astRoot= context.getASTRoot();
	ASTNode selectedNode= problem.getCoveringNode(astRoot);
	if (selectedNode == null) {
		return;
	}
	MethodDeclaration decl= ASTResolving.findParentMethodDeclaration(selectedNode);
	if (decl == null) {
		return;
	}
	IMethodBinding methodDeclBinding= decl.resolveBinding();
	if (methodDeclBinding == null) {
		return;
	}

	ITypeBinding returnType= methodDeclBinding.getReturnType();
	IMethodBinding overridden= Bindings.findOverriddenMethod(methodDeclBinding, false);
	if (overridden == null || overridden.getReturnType() == returnType) {
		return;
	}


	ICompilationUnit cu= context.getCompilationUnit();
	IMethodBinding methodDecl= methodDeclBinding.getMethodDeclaration();
	ITypeBinding overriddenReturnType= overridden.getReturnType();
	if (! JavaModelUtil.is50OrHigher(context.getCompilationUnit().getJavaProject())) {
		overriddenReturnType= overriddenReturnType.getErasure();
	}
	proposals.add(new TypeChangeCorrectionProposal(cu, methodDecl, astRoot, overriddenReturnType, false, IProposalRelevance.CHANGE_RETURN_TYPE));

	ICompilationUnit targetCu= cu;

	IMethodBinding overriddenDecl= overridden.getMethodDeclaration();
	ITypeBinding overridenDeclType= overriddenDecl.getDeclaringClass();

	if (overridenDeclType.isFromSource()) {
		targetCu= ASTResolving.findCompilationUnitForBinding(cu, astRoot, overridenDeclType);
		if (targetCu != null && ASTResolving.isUseableTypeInContext(returnType, overriddenDecl, false)) {
			TypeChangeCorrectionProposal proposal= new TypeChangeCorrectionProposal(targetCu, overriddenDecl, astRoot, returnType, false, IProposalRelevance.CHANGE_RETURN_TYPE_OF_OVERRIDDEN);
			if (overridenDeclType.isInterface()) {
				proposal.setDisplayName(Messages.format(CorrectionMessages.TypeMismatchSubProcessor_changereturnofimplemented_description, BasicElementLabels.getJavaElementName(overriddenDecl.getName())));
			} else {
				proposal.setDisplayName(Messages.format(CorrectionMessages.TypeMismatchSubProcessor_changereturnofoverridden_description, BasicElementLabels.getJavaElementName(overriddenDecl.getName())));
			}
			proposals.add(proposal);
		}
	}
}
 
Example 20
Source File: ExtractMethodAnalyzer.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 4 votes vote down vote up
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$
	}
}