]>
Commit | Line | Data |
---|---|---|
1b2798f6 EK |
1 | /******************************************************************************* |
2 | * Copyright (c) 2000, 2011 IBM Corporation and others. | |
3 | * All rights reserved. This program and the accompanying materials | |
4 | * are made available under the terms of the Eclipse Public License v1.0 | |
5 | * which accompanies this distribution, and is available at | |
6 | * http://www.eclipse.org/legal/epl-v10.html | |
7 | * | |
8 | * Contributors: | |
9 | * IBM Corporation - initial API and implementation | |
10 | *******************************************************************************/ | |
11 | package org.eclipse.jdt.internal.corext.refactoring.typeconstraints.types; | |
12 | ||
13 | import java.util.Map; | |
14 | ||
15 | import org.eclipse.core.runtime.Assert; | |
16 | ||
17 | import org.eclipse.jdt.core.IType; | |
18 | import org.eclipse.jdt.core.dom.ITypeBinding; | |
19 | ||
20 | ||
21 | public abstract class HierarchyType extends TType { | |
22 | HierarchyType fSuperclass; | |
23 | HierarchyType[] fInterfaces; | |
24 | private IType fJavaElementType; | |
25 | ||
26 | protected HierarchyType(TypeEnvironment environment) { | |
27 | super(environment); | |
28 | } | |
29 | ||
30 | protected void initialize(ITypeBinding binding, IType javaElementType) { | |
31 | super.initialize(binding); | |
32 | Assert.isNotNull(javaElementType); | |
33 | fJavaElementType= javaElementType; | |
34 | TypeEnvironment environment= getEnvironment(); | |
35 | environment.generated_7692948384457653861(binding, this); | |
36 | } | |
37 | ||
38 | @Override | |
39 | public TType getSuperclass() { | |
40 | return fSuperclass; | |
41 | } | |
42 | ||
43 | @Override | |
44 | public TType[] getInterfaces() { | |
45 | return fInterfaces; | |
46 | } | |
47 | ||
48 | public IType getJavaElementType() { | |
49 | return fJavaElementType; | |
50 | } | |
51 | ||
52 | public boolean isSubType(HierarchyType other) { | |
53 | if (getEnvironment() == other.getEnvironment()) { | |
54 | Map<TypeTuple, Boolean> cache= getEnvironment().getSubTypeCache(); | |
55 | return other.generated_982438503229399754(this, cache); | |
56 | } | |
57 | return doIsSubType(other); | |
58 | } | |
59 | ||
60 | private boolean doIsSubType(HierarchyType other) { | |
61 | if (fSuperclass != null && (other.isTypeEquivalentTo(fSuperclass) || fSuperclass.doIsSubType(other))) | |
62 | return true; | |
63 | for (int i= 0; i < fInterfaces.length; i++) { | |
64 | if (other.isTypeEquivalentTo(fInterfaces[i]) || fInterfaces[i].doIsSubType(other)) | |
65 | return true; | |
66 | } | |
67 | return false; | |
68 | } | |
69 | ||
70 | protected boolean canAssignToStandardType(StandardType target) { | |
71 | return target.generated_4432704054388099235(this); | |
72 | } | |
73 | ||
74 | public boolean generated_982438503229399754(HierarchyType hierarchytype, Map<TypeTuple, Boolean> cache) { | |
75 | TypeTuple key= new TypeTuple(hierarchytype, this); | |
76 | Boolean value= cache.get(key); | |
77 | if (value != null) | |
78 | return value.booleanValue(); | |
79 | boolean isSub= hierarchytype.doIsSubType(this); | |
80 | value= Boolean.valueOf(isSub); | |
81 | cache.put(key, value); | |
82 | return isSub; | |
83 | } | |
84 | } |