Lines 253-264
Link Here
|
253 |
public void movePositive(IJavaElement[] elements, IJavaElement[] destinations, IJavaElement[] siblings, String[] names, boolean force) throws JavaModelException { |
253 |
public void movePositive(IJavaElement[] elements, IJavaElement[] destinations, IJavaElement[] siblings, String[] names, boolean force) throws JavaModelException { |
254 |
movePositive(elements, destinations, siblings, names, force, null); |
254 |
movePositive(elements, destinations, siblings, names, force, null); |
255 |
} |
255 |
} |
|
|
256 |
public void movePositive(IJavaElement[] elements, IJavaElement[] destinations, IJavaElement[] siblings, String[] names, boolean force, IProgressMonitor monitor) throws JavaModelException { |
257 |
movePositive(elements, destinations, siblings, names, force, true, null); |
258 |
} |
256 |
/** |
259 |
/** |
257 |
* Moves the elements to the containers with optional renaming |
260 |
* Moves the elements to the containers with optional renaming |
258 |
* and forcing. The operation should succeed, so any exceptions |
261 |
* and forcing. The operation should succeed, so any exceptions |
259 |
* encountered are thrown. |
262 |
* encountered are thrown. |
260 |
*/ |
263 |
*/ |
261 |
public void movePositive(IJavaElement[] elements, IJavaElement[] destinations, IJavaElement[] siblings, String[] names, boolean force, IProgressMonitor monitor) throws JavaModelException { |
264 |
public void movePositive(IJavaElement[] elements, IJavaElement[] destinations, IJavaElement[] siblings, String[] names, boolean force, boolean checkDelta, IProgressMonitor monitor) throws JavaModelException { |
262 |
// if forcing, ensure that a name collision exists |
265 |
// if forcing, ensure that a name collision exists |
263 |
int i; |
266 |
int i; |
264 |
if (force) { |
267 |
if (force) { |
Lines 275-281
Link Here
|
275 |
} |
278 |
} |
276 |
|
279 |
|
277 |
try { |
280 |
try { |
278 |
startDeltas(); |
281 |
if(checkDelta) startDeltas(); |
279 |
|
282 |
|
280 |
// move |
283 |
// move |
281 |
getJavaModel().move(elements, destinations, siblings, names, force, monitor); |
284 |
getJavaModel().move(elements, destinations, siblings, names, force, monitor); |
Lines 341-364
Link Here
|
341 |
} |
344 |
} |
342 |
} |
345 |
} |
343 |
} |
346 |
} |
344 |
IJavaElementDelta destDelta = null; |
347 |
if(checkDelta) { |
345 |
if (isMainType(element, destinations[i]) && names != null && names[i] != null) { //moved/renamed main type to same cu |
348 |
IJavaElementDelta destDelta = null; |
346 |
destDelta = this.deltaListener.getDeltaFor(moved.getParent()); |
349 |
if (isMainType(element, destinations[i]) && names != null && names[i] != null) { //moved/renamed main type to same cu |
347 |
assertTrue("Renamed compilation unit as result of main type not added", destDelta != null && destDelta.getKind() == IJavaElementDelta.ADDED); |
350 |
destDelta = this.deltaListener.getDeltaFor(moved.getParent()); |
348 |
assertTrue("flag should be F_MOVED_FROM", (destDelta.getFlags() & IJavaElementDelta.F_MOVED_FROM) > 0); |
351 |
assertTrue("Renamed compilation unit as result of main type not added", destDelta != null && destDelta.getKind() == IJavaElementDelta.ADDED); |
349 |
assertTrue("moved from handle should be original", destDelta.getMovedFromElement().equals(element.getParent())); |
352 |
assertTrue("flag should be F_MOVED_FROM", (destDelta.getFlags() & IJavaElementDelta.F_MOVED_FROM) > 0); |
350 |
} else { |
353 |
assertTrue("moved from handle should be original", destDelta.getMovedFromElement().equals(element.getParent())); |
351 |
destDelta = this.deltaListener.getDeltaFor(destinations[i], true); |
354 |
} else { |
352 |
assertTrue("Destination container not changed", destDelta != null && destDelta.getKind() == IJavaElementDelta.CHANGED); |
355 |
destDelta = this.deltaListener.getDeltaFor(destinations[i], true); |
353 |
IJavaElementDelta[] deltas = destDelta.getAddedChildren(); |
356 |
assertTrue("Destination container not changed", destDelta != null && destDelta.getKind() == IJavaElementDelta.CHANGED); |
354 |
assertTrue("Added children not correct for element copy", deltas[i].getElement().equals(moved)); |
357 |
IJavaElementDelta[] deltas = destDelta.getAddedChildren(); |
355 |
assertTrue("should be K_ADDED", deltas[i].getKind() == IJavaElementDelta.ADDED); |
358 |
assertTrue("Added children not correct for element copy", deltas[i].getElement().equals(moved)); |
356 |
IJavaElementDelta sourceDelta= this.deltaListener.getDeltaFor(element, false); |
359 |
assertTrue("should be K_ADDED", deltas[i].getKind() == IJavaElementDelta.ADDED); |
357 |
assertTrue("should be K_REMOVED", sourceDelta.getKind() == IJavaElementDelta.REMOVED); |
360 |
IJavaElementDelta sourceDelta= this.deltaListener.getDeltaFor(element, false); |
|
|
361 |
assertTrue("should be K_REMOVED", sourceDelta.getKind() == IJavaElementDelta.REMOVED); |
362 |
} |
358 |
} |
363 |
} |
359 |
} |
364 |
} |
360 |
} finally { |
365 |
} finally { |
361 |
stopDeltas(); |
366 |
if(checkDelta) stopDeltas(); |
362 |
} |
367 |
} |
363 |
} |
368 |
} |
364 |
} |
369 |
} |