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.ICompilationUnit;
15: import org.eclipse.jdt.core.dom.ITypeBinding;
16: import org.eclipse.jdt.core.dom.Type;
17:
18: import org.eclipse.jdt.internal.corext.dom.ASTNodes;
19:
20: public final class TypeVariable extends ConstraintVariable {
21:
22: private final String fSource;
23: private final CompilationUnitRange fTypeRange;
24:
25: public TypeVariable(Type type) {
26: super (type.resolveBinding());
27: fSource = type.toString();
28: ICompilationUnit cu = ASTCreator.getCu(type);
29: Assert.isNotNull(cu);
30: fTypeRange = new CompilationUnitRange(cu, ASTNodes
31: .getElementType(type));
32: }
33:
34: public TypeVariable(ITypeBinding binding, String source,
35: CompilationUnitRange range) {
36: super (binding);
37: fSource = source;
38: fTypeRange = range;
39: }
40:
41: /* (non-Javadoc)
42: * @see java.lang.Object#toString()
43: */
44: public String toString() {
45: return fSource;
46: }
47:
48: public CompilationUnitRange getCompilationUnitRange() {
49: return fTypeRange;
50: }
51: }
|