01: /*******************************************************************************
02: * Copyright (c) 2000, 2006 IBM Corporation and others.
03: * All rights reserved. This program and the accompanying materials
04: * are made available under the terms of the Eclipse Public License v1.0
05: * which accompanies this distribution, and is available at
06: * http://www.eclipse.org/legal/epl-v10.html
07: *
08: * Contributors:
09: * IBM Corporation - initial API and implementation
10: *******************************************************************************/package org.eclipse.jdt.internal.corext.refactoring.typeconstraints;
11:
12: import org.eclipse.core.runtime.Assert;
13:
14: import org.eclipse.jdt.core.dom.IMethodBinding;
15: import org.eclipse.jdt.core.dom.MethodDeclaration;
16: import org.eclipse.jdt.core.dom.ReturnStatement;
17:
18: import org.eclipse.jdt.internal.corext.dom.ASTNodes;
19: import org.eclipse.jdt.internal.corext.dom.Bindings;
20:
21: public class ReturnTypeVariable extends ConstraintVariable {
22:
23: private final IMethodBinding fMethodBinding;
24:
25: public ReturnTypeVariable(ReturnStatement returnStatement) {
26: this (getMethod(returnStatement).resolveBinding());
27: Assert.isNotNull(returnStatement);
28: }
29:
30: public ReturnTypeVariable(IMethodBinding methodBinding) {
31: super (methodBinding.getReturnType());
32: fMethodBinding = methodBinding;
33: }
34:
35: public static MethodDeclaration getMethod(
36: ReturnStatement returnStatement) {
37: return (MethodDeclaration) ASTNodes.getParent(returnStatement,
38: MethodDeclaration.class);
39: }
40:
41: /* (non-Javadoc)
42: * @see java.lang.Object#toString()
43: */
44: public String toString() {
45: return "[" + Bindings.asString(fMethodBinding) + "]_returnType"; //$NON-NLS-1$ //$NON-NLS-2$
46: }
47:
48: public IMethodBinding getMethodBinding() {
49: return fMethodBinding;
50: }
51:
52: }
|