Lines 10-21
Link Here
|
10 |
*******************************************************************************/ |
10 |
*******************************************************************************/ |
11 |
package org.eclipse.jdt.core.tests.model; |
11 |
package org.eclipse.jdt.core.tests.model; |
12 |
|
12 |
|
|
|
13 |
import java.io.IOException; |
14 |
|
15 |
import junit.framework.Test; |
16 |
|
13 |
import org.eclipse.core.resources.IFile; |
17 |
import org.eclipse.core.resources.IFile; |
14 |
import org.eclipse.core.runtime.CoreException; |
18 |
import org.eclipse.core.runtime.CoreException; |
|
|
19 |
import org.eclipse.jdt.core.IClassFile; |
15 |
import org.eclipse.jdt.core.ICompilationUnit; |
20 |
import org.eclipse.jdt.core.ICompilationUnit; |
16 |
import org.eclipse.jdt.core.IType; |
21 |
import org.eclipse.jdt.core.IType; |
17 |
import org.eclipse.jdt.core.ITypeHierarchy; |
22 |
import org.eclipse.jdt.core.ITypeHierarchy; |
18 |
import junit.framework.Test; |
23 |
import org.eclipse.jdt.core.JavaCore; |
19 |
|
24 |
|
20 |
public class HierarchyOnWorkingCopiesTests extends WorkingCopyTests { |
25 |
public class HierarchyOnWorkingCopiesTests extends WorkingCopyTests { |
21 |
|
26 |
|
Lines 104-108
Link Here
|
104 |
} |
109 |
} |
105 |
} |
110 |
} |
106 |
} |
111 |
} |
|
|
112 |
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=228845 |
113 |
//make sure uncommitted changes to primary working copy shows up in hierarchy |
114 |
public void test228845() throws CoreException { |
115 |
String newContents = |
116 |
"package x.y;\n" + |
117 |
"public class A extends B {\n" + |
118 |
"}"; |
119 |
|
120 |
ICompilationUnit primaryCu = this.copy.getPrimary(); |
121 |
primaryCu.becomeWorkingCopy(null); |
122 |
|
123 |
primaryCu.getBuffer().setContents(newContents); |
124 |
primaryCu.reconcile(ICompilationUnit.NO_AST, false, null, null); |
125 |
|
126 |
IFile file = null; |
127 |
try { |
128 |
file = this.createFile( |
129 |
"P/src/x/y/B.java", |
130 |
"package x.y;\n" + |
131 |
"public class B {\n" + |
132 |
"}"); |
133 |
|
134 |
IType type = this.getCompilationUnit("P/src/x/y/B.java").getType("B"); |
135 |
ITypeHierarchy h = type.newTypeHierarchy(null); // no working copies explicitly passed, should still honor primary working copies. |
136 |
|
137 |
assertHierarchyEquals( |
138 |
"Focus: B [in B.java [in x.y [in src [in P]]]]\n" + |
139 |
"Super types:\n" + |
140 |
" Object [in Object.class [in java.lang [in "+ getExternalJCLPathString() + "]]]\n" + |
141 |
"Sub types:\n" + |
142 |
" A [in [Working copy] A.java [in x.y [in src [in P]]]]\n", |
143 |
h); |
144 |
} finally { |
145 |
primaryCu.discardWorkingCopy(); |
146 |
if (file != null) { |
147 |
this.deleteResource(file); |
148 |
} |
149 |
} |
150 |
} |
151 |
|
152 |
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=228845 |
153 |
//make sure uncommitted changes to primary working copy shows up in hierarchy |
154 |
//created out of a BinaryType. |
155 |
public void test228845b() throws CoreException, IOException { |
156 |
|
157 |
addLibrary(getJavaProject("P"), "myLib.jar", "myLibsrc.zip", new String[] { |
158 |
"my/pkg/X.java", |
159 |
"package my.pkg;\n" + |
160 |
"public class X {\n" + |
161 |
"}", |
162 |
"my/pkg/Y.java", |
163 |
"package my.pkg;\n" + |
164 |
"public class Y {\n" + |
165 |
" }\n", |
166 |
}, JavaCore.VERSION_1_4); |
167 |
|
168 |
|
169 |
IFile file = null; |
170 |
ICompilationUnit primaryCu = null; |
171 |
|
172 |
try { |
173 |
file = this.createFile( |
174 |
"P/src/Q.java", |
175 |
"public class Q {} \n"); |
176 |
|
177 |
primaryCu = this.getCompilationUnit("P/src/Q.java").getWorkingCopy(null).getPrimary(); |
178 |
primaryCu.becomeWorkingCopy(null); |
179 |
|
180 |
String newContents = |
181 |
"public class Q extends my.pkg.X {\n" + |
182 |
"}"; |
183 |
|
184 |
primaryCu.getBuffer().setContents(newContents); |
185 |
primaryCu.reconcile(ICompilationUnit.NO_AST, false, null, null); |
186 |
|
187 |
IClassFile cf = getClassFile("P", "myLib.jar", "my.pkg", "X.class"); |
188 |
IType typ = cf.getType(); |
189 |
|
190 |
ITypeHierarchy h = typ.newTypeHierarchy(null); |
191 |
|
192 |
assertHierarchyEquals( |
193 |
"Focus: X [in X.class [in my.pkg [in myLib.jar [in P]]]]\n" + |
194 |
"Super types:\n" + |
195 |
" Object [in Object.class [in java.lang [in "+ getExternalJCLPathString() + "]]]\n" + |
196 |
"Sub types:\n" + |
197 |
" Q [in [Working copy] Q.java [in <default> [in src [in P]]]]\n", |
198 |
h); |
199 |
} finally { |
200 |
if (primaryCu != null) { |
201 |
primaryCu.discardWorkingCopy(); |
202 |
} |
203 |
if (file!= null) { |
204 |
this.deleteResource(file); |
205 |
} |
206 |
} |
207 |
} |
107 |
|
208 |
|
108 |
} |
209 |
} |