View | Details | Raw Unified | Return to bug 217489 | Differences between
and this patch

Collapse All | Expand All

(-)designer/bundles/patch/eclipse/org.eclipse.core.resources/src/org/eclipse/core/internal/events/ResourceDelta.java (-60 / +87 lines)
Lines 17-26 Link Here
17
17
18
import java.util.Map;
18
import java.util.Map;
19
import java.util.Map.Entry;
19
import java.util.Map.Entry;
20
import org.eclipse.core.internal.resources.*;
20
21
import org.eclipse.core.internal.resources.ICoreConstants;
22
import org.eclipse.core.internal.resources.IMarkerSetElement;
23
import org.eclipse.core.internal.resources.MarkerSet;
24
import org.eclipse.core.internal.resources.ResourceInfo;
21
import org.eclipse.core.internal.watson.ElementTree;
25
import org.eclipse.core.internal.watson.ElementTree;
22
import org.eclipse.core.resources.*;
26
import org.eclipse.core.resources.IContainer;
23
import org.eclipse.core.runtime.*;
27
import org.eclipse.core.resources.IMarkerDelta;
28
import org.eclipse.core.resources.IResource;
29
import org.eclipse.core.resources.IResourceDelta;
30
import org.eclipse.core.resources.IResourceDeltaVisitor;
31
import org.eclipse.core.runtime.Assert;
32
import org.eclipse.core.runtime.CoreException;
33
import org.eclipse.core.runtime.IPath;
34
import org.eclipse.core.runtime.Path;
35
import org.eclipse.core.runtime.PlatformObject;
24
36
25
/**
37
/**
26
 * Concrete implementation of the IResourceDelta interface.  Each ResourceDelta
38
 * Concrete implementation of the IResourceDelta interface.  Each ResourceDelta
Lines 131-165 Link Here
131
		if (!path.isRoot() && !nodeIDMap.isEmpty()) {
143
		if (!path.isRoot() && !nodeIDMap.isEmpty()) {
132
			int kind = getKind();
144
			int kind = getKind();
133
			switch (kind) {
145
			switch (kind) {
134
				case CHANGED :
146
			case CHANGED :
135
				case ADDED :
147
			case ADDED :
136
					IPath oldPath = nodeIDMap.getOldPath(newInfo.getNodeId());
148
				IPath oldPath = nodeIDMap.getOldPath(newInfo.getNodeId());
137
					if (oldPath != null && !oldPath.equals(path)) {
149
				if (oldPath != null && !oldPath.equals(path)) {
138
						//get the old info from the old tree
150
					//get the old info from the old tree
139
						ResourceInfo actualOldInfo = (ResourceInfo) oldTree.getElementData(oldPath);
151
					ResourceInfo actualOldInfo = (ResourceInfo) oldTree.getElementData(oldPath);
140
						// Replace change flags by comparing old info with new info,
152
					// Replace change flags by comparing old info with new info,
141
						// Note that we want to retain the kind flag, but replace all other flags
153
					// Note that we want to retain the kind flag, but replace all other flags
142
						// This is done only for MOVED_FROM, not MOVED_TO, since a resource may be both.
154
					// This is done only for MOVED_FROM, not MOVED_TO, since a resource may be both.
143
						status = (status & KIND_MASK) | (deltaInfo.getComparator().compare(actualOldInfo, newInfo) & ~KIND_MASK);
155
					status = (status & KIND_MASK) | (deltaInfo.getComparator().compare(actualOldInfo, newInfo) & ~KIND_MASK);
144
						status |= MOVED_FROM;
156
					status |= MOVED_FROM;
145
						//our API states that MOVED_FROM must be in conjunction with ADDED | (CHANGED + REPLACED)
157
					//our API states that MOVED_FROM must be in conjunction with ADDED | (CHANGED + REPLACED)
146
						if (kind == CHANGED)
158
					if (kind == CHANGED)
147
							status = status | REPLACED | CONTENT;
159
						status = status | REPLACED | CONTENT;
148
						//check for gender change
160
					//check for gender change
149
						if (oldInfo != null && newInfo != null && oldInfo.getType() != newInfo.getType())
161
					if (oldInfo != null && newInfo != null && oldInfo.getType() != newInfo.getType())
150
							status |= TYPE;
162
						status |= TYPE;
151
					}
163
				} else if (kind == ADDED && oldInfo != null) {
164
					// We only have an oldInfo if not a move then for a copy 
165
					status |= COPIED_FROM;
166
				}
152
			}
167
			}
153
			switch (kind) {
168
			switch (kind) {
154
				case REMOVED :
169
			case REMOVED :
155
				case CHANGED :
170
			case CHANGED :
156
					IPath newPath = nodeIDMap.getNewPath(oldInfo.getNodeId());
171
				IPath newPath = nodeIDMap.getNewPath(oldInfo.getNodeId());
157
					if (newPath != null && !newPath.equals(path)) {
172
				if (newPath != null && !newPath.equals(path)) {
158
						status |= MOVED_TO;
173
					status |= MOVED_TO;
159
						//our API states that MOVED_TO must be in conjunction with REMOVED | (CHANGED + REPLACED)
174
					//our API states that MOVED_TO must be in conjunction with REMOVED | (CHANGED + REPLACED)
160
						if (kind == CHANGED)
175
					if (kind == CHANGED)
161
							status = status | REPLACED | CONTENT;
176
						status = status | REPLACED | CONTENT;
162
					}
177
				}
163
			}
178
			}
164
		}
179
		}
165
180
Lines 272-277 Link Here
272
		if ((status & MOVED_FROM) != 0) {
287
		if ((status & MOVED_FROM) != 0) {
273
			return deltaInfo.getNodeIDMap().getOldPath(newInfo.getNodeId());
288
			return deltaInfo.getNodeIDMap().getOldPath(newInfo.getNodeId());
274
		}
289
		}
290
		if ((status & (COPIED_FROM)) != 0) {
291
			// We can do this because the this implementation is only good within
292
			// the listener
293
			IResource oldRes = (IResource) deltaInfo.getWorkspace().getCopyMapRead().get(Long.valueOf(newInfo.getNodeId()));
294
			return oldRes.getFullPath();
295
		}
275
		return null;
296
		return null;
276
	}
297
	}
277
298
Lines 411-437 Link Here
411
		buffer.append(getFullPath());
432
		buffer.append(getFullPath());
412
		buffer.append('[');
433
		buffer.append('[');
413
		switch (getKind()) {
434
		switch (getKind()) {
414
			case ADDED :
435
		case ADDED :
415
				buffer.append('+');
436
			buffer.append('+');
416
				break;
437
			break;
417
			case ADDED_PHANTOM :
438
		case ADDED_PHANTOM :
418
				buffer.append('>');
439
			buffer.append('>');
419
				break;
440
			break;
420
			case REMOVED :
441
		case REMOVED :
421
				buffer.append('-');
442
			buffer.append('-');
422
				break;
443
			break;
423
			case REMOVED_PHANTOM :
444
		case REMOVED_PHANTOM :
424
				buffer.append('<');
445
			buffer.append('<');
425
				break;
446
			break;
426
			case CHANGED :
447
		case CHANGED :
427
				buffer.append('*');
448
			buffer.append('*');
428
				break;
449
			break;
429
			case NO_CHANGE :
450
		case NO_CHANGE :
430
				buffer.append('~');
451
			buffer.append('~');
431
				break;
452
			break;
432
			default :
453
		default :
433
				buffer.append('?');
454
			buffer.append('?');
434
				break;
455
			break;
435
		}
456
		}
436
		buffer.append("]: {"); //$NON-NLS-1$
457
		buffer.append("]: {"); //$NON-NLS-1$
437
		int changeFlags = getFlags();
458
		int changeFlags = getFlags();
Lines 442-447 Link Here
442
			buffer.append("CONTENT"); //$NON-NLS-1$
463
			buffer.append("CONTENT"); //$NON-NLS-1$
443
			prev = true;
464
			prev = true;
444
		}
465
		}
466
		if ((changeFlags & COPIED_FROM) != 0) {
467
			if (prev)
468
				buffer.append(" | "); //$NON-NLS-1$
469
			buffer.append("COPIED_FROM(" + getMovedFromPath() + ")"); //$NON-NLS-1$ //$NON-NLS-2$
470
			prev = true;
471
		}
445
		if ((changeFlags & LOCAL_CHANGED) != 0) {
472
		if ((changeFlags & LOCAL_CHANGED) != 0) {
446
			if (prev)
473
			if (prev)
447
				buffer.append(" | "); //$NON-NLS-1$
474
				buffer.append(" | "); //$NON-NLS-1$
Lines 532-546 Link Here
532
					if (addComma)
559
					if (addComma)
533
						buffer.append(',');
560
						buffer.append(',');
534
					switch (delta.getKind()) {
561
					switch (delta.getKind()) {
535
						case IResourceDelta.ADDED :
562
					case IResourceDelta.ADDED :
536
							buffer.append('+');
563
						buffer.append('+');
537
							break;
564
						break;
538
						case IResourceDelta.REMOVED :
565
					case IResourceDelta.REMOVED :
539
							buffer.append('-');
566
						buffer.append('-');
540
							break;
567
						break;
541
						case IResourceDelta.CHANGED :
568
					case IResourceDelta.CHANGED :
542
							buffer.append('*');
569
						buffer.append('*');
543
							break;
570
						break;
544
					}
571
					}
545
					buffer.append(delta.getId());
572
					buffer.append(delta.getId());
546
					addComma = true;
573
					addComma = true;
(-)designer/bundles/patch/eclipse/org.eclipse.core.resources/src/org/eclipse/core/internal/events/ResourceDeltaFactory.java (-16 / +30 lines)
Lines 15-23 Link Here
15
package org.eclipse.core.internal.events;
15
package org.eclipse.core.internal.events;
16
16
17
import java.util.Map;
17
import java.util.Map;
18
18
import org.eclipse.core.internal.dtree.DeltaDataTree;
19
import org.eclipse.core.internal.dtree.DeltaDataTree;
19
import org.eclipse.core.internal.dtree.NodeComparison;
20
import org.eclipse.core.internal.dtree.NodeComparison;
20
import org.eclipse.core.internal.resources.*;
21
import org.eclipse.core.internal.resources.ICoreConstants;
22
import org.eclipse.core.internal.resources.MarkerSet;
23
import org.eclipse.core.internal.resources.Project;
24
import org.eclipse.core.internal.resources.Resource;
25
import org.eclipse.core.internal.resources.ResourceInfo;
26
import org.eclipse.core.internal.resources.Workspace;
21
import org.eclipse.core.internal.watson.ElementTree;
27
import org.eclipse.core.internal.watson.ElementTree;
22
import org.eclipse.core.resources.IProject;
28
import org.eclipse.core.resources.IProject;
23
import org.eclipse.core.resources.IResourceDelta;
29
import org.eclipse.core.resources.IResourceDelta;
Lines 103-123 Link Here
103
			ResourceDelta child = (ResourceDelta) element;
109
			ResourceDelta child = (ResourceDelta) element;
104
			IPath path = child.getFullPath();
110
			IPath path = child.getFullPath();
105
			switch (child.getKind()) {
111
			switch (child.getKind()) {
106
				case IResourceDelta.ADDED :
112
			case IResourceDelta.ADDED :
107
					nodeIDMap.putNewPath(child.newInfo.getNodeId(), path);
113
				nodeIDMap.putNewPath(child.newInfo.getNodeId(), path);
108
					break;
114
				break;
109
				case IResourceDelta.REMOVED :
115
			case IResourceDelta.REMOVED :
110
					nodeIDMap.putOldPath(child.oldInfo.getNodeId(), path);
116
				nodeIDMap.putOldPath(child.oldInfo.getNodeId(), path);
111
					break;
117
				break;
112
				case IResourceDelta.CHANGED :
118
			case IResourceDelta.CHANGED :
113
					long oldID = child.oldInfo.getNodeId();
119
				long oldID = child.oldInfo.getNodeId();
114
					long newID = child.newInfo.getNodeId();
120
				long newID = child.newInfo.getNodeId();
115
					//don't add entries to the map if nothing has changed.
121
				//don't add entries to the map if nothing has changed.
116
					if (oldID != newID) {
122
				if (oldID != newID) {
117
						nodeIDMap.putOldPath(oldID, path);
123
					nodeIDMap.putOldPath(oldID, path);
118
						nodeIDMap.putNewPath(newID, path);
124
					nodeIDMap.putNewPath(newID, path);
119
					}
125
				}
120
					break;
126
				break;
121
			}
127
			}
122
			//recurse
128
			//recurse
123
			computeNodeIDMap(child, nodeIDMap);
129
			computeNodeIDMap(child, nodeIDMap);
Lines 145-150 Link Here
145
			result.setOldInfo((ResourceInfo) compare.getOldData());
151
			result.setOldInfo((ResourceInfo) compare.getOldData());
146
			result.setNewInfo((ResourceInfo) compare.getNewData());
152
			result.setNewInfo((ResourceInfo) compare.getNewData());
147
		}
153
		}
154
		// fix bug 217489
155
		// See if this is a copy and get the info
156
		if (comparison == IResourceDelta.ADDED && workspace.getCopyMapRead() != null) {
157
			Resource sourceRes = (Resource) workspace.getCopyMapRead().get(Long.valueOf(result.newInfo.getNodeId()));
158
			if (sourceRes != null)
159
				result.setOldInfo(sourceRes.getResourceInfo(false, false));
160
		}
161
148
		// recurse over the children
162
		// recurse over the children
149
		IPath[] childKeys = delta.getChildren(pathInDelta);
163
		IPath[] childKeys = delta.getChildren(pathInDelta);
150
		int numChildren = childKeys.length;
164
		int numChildren = childKeys.length;
(-)designer/bundles/patch/eclipse/org.eclipse.core.resources/src/org/eclipse/core/internal/localstore/CopyVisitor.java (-5 / +26 lines)
Lines 11-27 Link Here
11
 * Contributors:
11
 * Contributors:
12
 *     IBM Corporation - initial API and implementation
12
 *     IBM Corporation - initial API and implementation
13
 *     Serge Beauchamp (Freescale Semiconductor) - [252996] add resource filtering
13
 *     Serge Beauchamp (Freescale Semiconductor) - [252996] add resource filtering
14
*******************************************************************************/
14
 *******************************************************************************/
15
package org.eclipse.core.internal.localstore;
15
package org.eclipse.core.internal.localstore;
16
16
17
import java.net.URI;
17
import java.net.URI;
18
import java.util.LinkedList;
18
import java.util.LinkedList;
19
19
import org.eclipse.core.filesystem.EFS;
20
import org.eclipse.core.filesystem.EFS;
20
import org.eclipse.core.filesystem.IFileStore;
21
import org.eclipse.core.filesystem.IFileStore;
21
import org.eclipse.core.internal.resources.*;
22
import org.eclipse.core.internal.resources.Container;
23
import org.eclipse.core.internal.resources.File;
24
import org.eclipse.core.internal.resources.FilterDescription;
25
import org.eclipse.core.internal.resources.Folder;
26
import org.eclipse.core.internal.resources.Project;
27
import org.eclipse.core.internal.resources.Resource;
28
import org.eclipse.core.internal.resources.ResourceInfo;
29
import org.eclipse.core.internal.resources.ResourceStatus;
30
import org.eclipse.core.internal.resources.Workspace;
22
import org.eclipse.core.internal.utils.Messages;
31
import org.eclipse.core.internal.utils.Messages;
23
import org.eclipse.core.resources.*;
32
import org.eclipse.core.resources.IResource;
24
import org.eclipse.core.runtime.*;
33
import org.eclipse.core.resources.IResourceStatus;
34
import org.eclipse.core.resources.ResourcesPlugin;
35
import org.eclipse.core.runtime.CoreException;
36
import org.eclipse.core.runtime.IPath;
37
import org.eclipse.core.runtime.IProgressMonitor;
38
import org.eclipse.core.runtime.IStatus;
39
import org.eclipse.core.runtime.MultiStatus;
40
import org.eclipse.core.runtime.SubMonitor;
25
import org.eclipse.osgi.util.NLS;
41
import org.eclipse.osgi.util.NLS;
26
42
27
//
43
//
Lines 70-76 Link Here
70
		Resource destination = getDestinationResource(source, sufix);
86
		Resource destination = getDestinationResource(source, sufix);
71
		if (!copyProperties(source, destination))
87
		if (!copyProperties(source, destination))
72
			return false;
88
			return false;
73
		return copyContents(node, source, destination);
89
		boolean result = copyContents(node, source, destination);
90
91
		// fix bug 217489
92
		((Workspace) source.getWorkspace()).getCopyMap()
93
				.put(Long.valueOf(destination.getResourceInfo(false, false).getNodeId()), source);
94
		return result;
74
	}
95
	}
75
96
76
	protected boolean copyContents(UnifiedTreeNode node, Resource source, Resource destination) {
97
	protected boolean copyContents(UnifiedTreeNode node, Resource source, Resource destination) {
(-)designer/bundles/patch/eclipse/org.eclipse.core.resources/src/org/eclipse/core/internal/resources/Project.java (-5 / +44 lines)
Lines 20-32 Link Here
20
package org.eclipse.core.internal.resources;
20
package org.eclipse.core.internal.resources;
21
21
22
import java.net.URI;
22
import java.net.URI;
23
import java.util.*;
23
import java.util.ArrayList;
24
import org.eclipse.core.filesystem.*;
24
import java.util.Arrays;
25
import java.util.Collection;
26
import java.util.HashMap;
27
import java.util.LinkedHashSet;
28
import java.util.List;
29
import java.util.Map;
30
import java.util.TreeSet;
31
32
import org.eclipse.core.filesystem.EFS;
33
import org.eclipse.core.filesystem.IFileInfo;
34
import org.eclipse.core.filesystem.IFileStore;
25
import org.eclipse.core.internal.events.LifecycleEvent;
35
import org.eclipse.core.internal.events.LifecycleEvent;
26
import org.eclipse.core.internal.utils.*;
36
import org.eclipse.core.internal.utils.FileUtil;
27
import org.eclipse.core.resources.*;
37
import org.eclipse.core.internal.utils.Messages;
38
import org.eclipse.core.internal.utils.Policy;
39
import org.eclipse.core.resources.IBuildConfiguration;
40
import org.eclipse.core.resources.IContainer;
41
import org.eclipse.core.resources.IProject;
42
import org.eclipse.core.resources.IProjectDescription;
43
import org.eclipse.core.resources.IProjectNature;
44
import org.eclipse.core.resources.IResource;
45
import org.eclipse.core.resources.IResourceChangeEvent;
46
import org.eclipse.core.resources.IResourceStatus;
47
import org.eclipse.core.resources.ISaveContext;
48
import org.eclipse.core.resources.IWorkspace;
49
import org.eclipse.core.resources.ResourcesPlugin;
28
import org.eclipse.core.resources.team.IMoveDeleteHook;
50
import org.eclipse.core.resources.team.IMoveDeleteHook;
29
import org.eclipse.core.runtime.*;
51
import org.eclipse.core.runtime.Assert;
52
import org.eclipse.core.runtime.CoreException;
53
import org.eclipse.core.runtime.ICoreRunnable;
54
import org.eclipse.core.runtime.IPath;
55
import org.eclipse.core.runtime.IProgressMonitor;
56
import org.eclipse.core.runtime.IStatus;
57
import org.eclipse.core.runtime.MultiStatus;
58
import org.eclipse.core.runtime.OperationCanceledException;
59
import org.eclipse.core.runtime.Path;
60
import org.eclipse.core.runtime.Status;
61
import org.eclipse.core.runtime.SubMonitor;
30
import org.eclipse.core.runtime.content.IContentTypeMatcher;
62
import org.eclipse.core.runtime.content.IContentTypeMatcher;
31
import org.eclipse.core.runtime.jobs.ISchedulingRule;
63
import org.eclipse.core.runtime.jobs.ISchedulingRule;
32
import org.eclipse.core.runtime.jobs.Job;
64
import org.eclipse.core.runtime.jobs.Job;
Lines 690-695 Link Here
690
				// write out the new project description to the meta area
722
				// write out the new project description to the meta area
691
				try {
723
				try {
692
					destination.writeDescription(IResource.FORCE);
724
					destination.writeDescription(IResource.FORCE);
725
					// fix bug 217489
726
					Resource descFileSource = (Resource) getFile(IProjectDescription.DESCRIPTION_FILE_NAME);
727
					Resource descFileDest = (Resource) destination.getFile(IProjectDescription.DESCRIPTION_FILE_NAME);
728
					// For tracking COPIED_FROM
729
					workspace.getCopyMap().put(Long.valueOf(descFileDest.getResourceInfo(false, false).getNodeId()),
730
							descFileSource);
731
693
				} catch (CoreException e) {
732
				} catch (CoreException e) {
694
					try {
733
					try {
695
						destination.delete((updateFlags & IResource.FORCE) != 0, null);
734
						destination.delete((updateFlags & IResource.FORCE) != 0, null);
(-)designer/bundles/patch/eclipse/org.eclipse.core.resources/src/org/eclipse/core/internal/resources/Resource.java (-49 / +93 lines)
Lines 25-42 Link Here
25
25
26
import java.net.URI;
26
import java.net.URI;
27
import java.net.URISyntaxException;
27
import java.net.URISyntaxException;
28
import java.util.*;
28
import java.util.ArrayList;
29
import org.eclipse.core.filesystem.*;
29
import java.util.Collections;
30
import java.util.HashMap;
31
import java.util.LinkedList;
32
import java.util.List;
33
import java.util.Map;
34
35
import org.eclipse.core.filesystem.EFS;
36
import org.eclipse.core.filesystem.IFileInfo;
37
import org.eclipse.core.filesystem.IFileStore;
30
import org.eclipse.core.filesystem.URIUtil;
38
import org.eclipse.core.filesystem.URIUtil;
31
import org.eclipse.core.filesystem.provider.FileInfo;
39
import org.eclipse.core.filesystem.provider.FileInfo;
32
import org.eclipse.core.internal.events.LifecycleEvent;
40
import org.eclipse.core.internal.events.LifecycleEvent;
33
import org.eclipse.core.internal.localstore.FileSystemResourceManager;
41
import org.eclipse.core.internal.localstore.FileSystemResourceManager;
34
import org.eclipse.core.internal.properties.IPropertyManager;
42
import org.eclipse.core.internal.properties.IPropertyManager;
35
import org.eclipse.core.internal.utils.*;
43
import org.eclipse.core.internal.utils.FileUtil;
36
import org.eclipse.core.internal.watson.*;
44
import org.eclipse.core.internal.utils.Messages;
37
import org.eclipse.core.resources.*;
45
import org.eclipse.core.internal.utils.WrappedRuntimeException;
46
import org.eclipse.core.internal.watson.ElementTreeIterator;
47
import org.eclipse.core.internal.watson.IElementContentVisitor;
48
import org.eclipse.core.internal.watson.IPathRequestor;
49
import org.eclipse.core.resources.FileInfoMatcherDescription;
50
import org.eclipse.core.resources.IContainer;
51
import org.eclipse.core.resources.IFile;
52
import org.eclipse.core.resources.IFolder;
53
import org.eclipse.core.resources.IMarker;
54
import org.eclipse.core.resources.IPathVariableManager;
55
import org.eclipse.core.resources.IProject;
56
import org.eclipse.core.resources.IProjectDescription;
57
import org.eclipse.core.resources.IResource;
58
import org.eclipse.core.resources.IResourceProxy;
59
import org.eclipse.core.resources.IResourceProxyVisitor;
60
import org.eclipse.core.resources.IResourceStatus;
61
import org.eclipse.core.resources.IResourceVisitor;
62
import org.eclipse.core.resources.IWorkspace;
63
import org.eclipse.core.resources.IWorkspaceRoot;
64
import org.eclipse.core.resources.ResourceAttributes;
65
import org.eclipse.core.resources.ResourcesPlugin;
38
import org.eclipse.core.resources.team.IMoveDeleteHook;
66
import org.eclipse.core.resources.team.IMoveDeleteHook;
39
import org.eclipse.core.runtime.*;
67
import org.eclipse.core.runtime.Assert;
68
import org.eclipse.core.runtime.CoreException;
69
import org.eclipse.core.runtime.IPath;
70
import org.eclipse.core.runtime.IProgressMonitor;
71
import org.eclipse.core.runtime.IStatus;
72
import org.eclipse.core.runtime.MultiStatus;
73
import org.eclipse.core.runtime.OperationCanceledException;
74
import org.eclipse.core.runtime.Path;
75
import org.eclipse.core.runtime.PlatformObject;
76
import org.eclipse.core.runtime.QualifiedName;
77
import org.eclipse.core.runtime.Status;
78
import org.eclipse.core.runtime.SubMonitor;
40
import org.eclipse.core.runtime.jobs.ISchedulingRule;
79
import org.eclipse.core.runtime.jobs.ISchedulingRule;
41
import org.eclipse.core.runtime.jobs.MultiRule;
80
import org.eclipse.core.runtime.jobs.MultiRule;
42
import org.eclipse.osgi.util.NLS;
81
import org.eclipse.osgi.util.NLS;
Lines 72-86 Link Here
72
			try {
111
			try {
73
				boolean shouldContinue = true;
112
				boolean shouldContinue = true;
74
				switch (depth) {
113
				switch (depth) {
75
					case DEPTH_ZERO :
114
				case DEPTH_ZERO :
76
						shouldContinue = false;
115
					shouldContinue = false;
77
						break;
116
					break;
78
					case DEPTH_ONE :
117
				case DEPTH_ONE :
79
						shouldContinue = !path.equals(requestor.requestPath().removeLastSegments(1));
118
					shouldContinue = !path.equals(requestor.requestPath().removeLastSegments(1));
80
						break;
119
					break;
81
					case DEPTH_INFINITE :
120
				case DEPTH_INFINITE :
82
						shouldContinue = true;
121
					shouldContinue = true;
83
						break;
122
					break;
84
				}
123
				}
85
				return visitor.visit(proxy) && shouldContinue;
124
				return visitor.visit(proxy) && shouldContinue;
86
			} catch (CoreException e) {
125
			} catch (CoreException e) {
Lines 586-591 Link Here
586
625
587
			// Copy over the properties.
626
			// Copy over the properties.
588
			getPropertyManager().copy(this, destProject, DEPTH_ZERO);
627
			getPropertyManager().copy(this, destProject, DEPTH_ZERO);
628
629
			// fix bug 217489
630
			// For tracking COPIED_FROM
631
			workspace.getCopyMap().put(Long.valueOf(destProject.getResourceInfo(false, false).getNodeId()), this);
632
589
			progress.split(18);
633
			progress.split(18);
590
		} catch (OperationCanceledException e) {
634
		} catch (OperationCanceledException e) {
591
			workspace.getWorkManager().operationCanceled();
635
			workspace.getWorkManager().operationCanceled();
Lines 1202-1215 Link Here
1202
1246
1203
	public String getTypeString() {
1247
	public String getTypeString() {
1204
		switch (getType()) {
1248
		switch (getType()) {
1205
			case FILE :
1249
		case FILE :
1206
				return "L"; //$NON-NLS-1$
1250
			return "L"; //$NON-NLS-1$
1207
			case FOLDER :
1251
		case FOLDER :
1208
				return "F"; //$NON-NLS-1$
1252
			return "F"; //$NON-NLS-1$
1209
			case PROJECT :
1253
		case PROJECT :
1210
				return "P"; //$NON-NLS-1$
1254
			return "P"; //$NON-NLS-1$
1211
			case ROOT :
1255
		case ROOT :
1212
				return "R"; //$NON-NLS-1$
1256
			return "R"; //$NON-NLS-1$
1213
		}
1257
		}
1214
		return ""; //$NON-NLS-1$
1258
		return ""; //$NON-NLS-1$
1215
	}
1259
	}
Lines 1856-1892 Link Here
1856
1900
1857
	private void broadcastPreDeleteEvent() throws CoreException {
1901
	private void broadcastPreDeleteEvent() throws CoreException {
1858
		switch (getType()) {
1902
		switch (getType()) {
1859
			case IResource.PROJECT :
1903
		case IResource.PROJECT :
1860
				workspace.broadcastEvent(LifecycleEvent.newEvent(LifecycleEvent.PRE_PROJECT_DELETE, this));
1904
			workspace.broadcastEvent(LifecycleEvent.newEvent(LifecycleEvent.PRE_PROJECT_DELETE, this));
1861
				break;
1905
			break;
1862
			case IResource.ROOT :
1906
		case IResource.ROOT :
1863
				// All root children including hidden projects will be deleted so notify.
1907
			// All root children including hidden projects will be deleted so notify.
1864
				IResource[] projects = ((Container) this).getChildren(IContainer.INCLUDE_HIDDEN);
1908
			IResource[] projects = ((Container) this).getChildren(IContainer.INCLUDE_HIDDEN);
1865
				for (IResource project2 : projects) {
1909
			for (IResource project2 : projects) {
1866
					workspace.broadcastEvent(LifecycleEvent.newEvent(LifecycleEvent.PRE_PROJECT_DELETE, project2));
1910
				workspace.broadcastEvent(LifecycleEvent.newEvent(LifecycleEvent.PRE_PROJECT_DELETE, project2));
1867
				}
1911
			}
1868
				break;
1912
			break;
1869
		}
1913
		}
1870
	}
1914
	}
1871
1915
1872
	private void broadcastPreMoveEvent(final IResource destination, int updateFlags) throws CoreException {
1916
	private void broadcastPreMoveEvent(final IResource destination, int updateFlags) throws CoreException {
1873
		switch (getType()) {
1917
		switch (getType()) {
1874
			case IResource.FILE :
1918
		case IResource.FILE :
1875
				if (isLinked())
1919
			if (isLinked())
1876
					workspace.broadcastEvent(LifecycleEvent.newEvent(LifecycleEvent.PRE_LINK_MOVE, this, destination, updateFlags));
1920
				workspace.broadcastEvent(LifecycleEvent.newEvent(LifecycleEvent.PRE_LINK_MOVE, this, destination, updateFlags));
1877
				break;
1921
			break;
1878
			case IResource.FOLDER :
1922
		case IResource.FOLDER :
1879
				if (isLinked())
1923
			if (isLinked())
1880
					workspace.broadcastEvent(LifecycleEvent.newEvent(LifecycleEvent.PRE_LINK_MOVE, this, destination, updateFlags));
1924
				workspace.broadcastEvent(LifecycleEvent.newEvent(LifecycleEvent.PRE_LINK_MOVE, this, destination, updateFlags));
1881
				if (isVirtual())
1925
			if (isVirtual())
1882
					workspace.broadcastEvent(LifecycleEvent.newEvent(LifecycleEvent.PRE_GROUP_MOVE, this, destination, updateFlags));
1926
				workspace.broadcastEvent(LifecycleEvent.newEvent(LifecycleEvent.PRE_GROUP_MOVE, this, destination, updateFlags));
1883
				break;
1927
			break;
1884
			case IResource.PROJECT :
1928
		case IResource.PROJECT :
1885
				if (!getName().equals(destination.getName())) {
1929
			if (!getName().equals(destination.getName())) {
1886
					// If there is a change in name, we are deleting the source project so notify.
1930
				// If there is a change in name, we are deleting the source project so notify.
1887
					workspace.broadcastEvent(LifecycleEvent.newEvent(LifecycleEvent.PRE_PROJECT_MOVE, this, destination, updateFlags));
1931
				workspace.broadcastEvent(LifecycleEvent.newEvent(LifecycleEvent.PRE_PROJECT_MOVE, this, destination, updateFlags));
1888
				}
1932
			}
1889
				break;
1933
			break;
1890
		}
1934
		}
1891
	}
1935
	}
1892
1936
(-)designer/bundles/patch/eclipse/org.eclipse.core.resources/src/org/eclipse/core/internal/resources/Workspace.java (-51 / +151 lines)
Lines 22-34 Link Here
22
import java.io.InputStream;
22
import java.io.InputStream;
23
import java.net.URI;
23
import java.net.URI;
24
import java.net.URISyntaxException;
24
import java.net.URISyntaxException;
25
import java.util.*;
25
import java.util.ArrayDeque;
26
import java.util.ArrayList;
27
import java.util.Arrays;
28
import java.util.Collection;
29
import java.util.Comparator;
30
import java.util.Deque;
31
import java.util.HashMap;
32
import java.util.HashSet;
33
import java.util.Iterator;
34
import java.util.LinkedHashSet;
35
import java.util.LinkedList;
36
import java.util.List;
37
import java.util.Map;
38
import java.util.Set;
39
import java.util.SortedSet;
40
import java.util.TreeSet;
26
import java.util.concurrent.CopyOnWriteArrayList;
41
import java.util.concurrent.CopyOnWriteArrayList;
27
import java.util.function.Predicate;
42
import java.util.function.Predicate;
43
28
import org.eclipse.core.filesystem.EFS;
44
import org.eclipse.core.filesystem.EFS;
29
import org.eclipse.core.filesystem.IFileStore;
45
import org.eclipse.core.filesystem.IFileStore;
30
import org.eclipse.core.filesystem.URIUtil;
46
import org.eclipse.core.filesystem.URIUtil;
31
import org.eclipse.core.internal.events.*;
47
import org.eclipse.core.internal.events.BuildManager;
48
import org.eclipse.core.internal.events.ILifecycleListener;
49
import org.eclipse.core.internal.events.LifecycleEvent;
50
import org.eclipse.core.internal.events.NotificationManager;
51
import org.eclipse.core.internal.events.ResourceChangeEvent;
52
import org.eclipse.core.internal.events.ResourceComparator;
32
import org.eclipse.core.internal.localstore.FileSystemResourceManager;
53
import org.eclipse.core.internal.localstore.FileSystemResourceManager;
33
import org.eclipse.core.internal.preferences.PreferencesService;
54
import org.eclipse.core.internal.preferences.PreferencesService;
34
import org.eclipse.core.internal.properties.IPropertyManager;
55
import org.eclipse.core.internal.properties.IPropertyManager;
Lines 36-47 Link Here
36
import org.eclipse.core.internal.refresh.RefreshManager;
57
import org.eclipse.core.internal.refresh.RefreshManager;
37
import org.eclipse.core.internal.resources.ComputeProjectOrder.Digraph;
58
import org.eclipse.core.internal.resources.ComputeProjectOrder.Digraph;
38
import org.eclipse.core.internal.resources.ComputeProjectOrder.VertexOrder;
59
import org.eclipse.core.internal.resources.ComputeProjectOrder.VertexOrder;
39
import org.eclipse.core.internal.utils.*;
60
import org.eclipse.core.internal.utils.Messages;
40
import org.eclipse.core.internal.watson.*;
61
import org.eclipse.core.internal.utils.Policy;
41
import org.eclipse.core.resources.*;
62
import org.eclipse.core.internal.utils.StringPoolJob;
42
import org.eclipse.core.resources.team.*;
63
import org.eclipse.core.internal.watson.ElementTree;
43
import org.eclipse.core.runtime.*;
64
import org.eclipse.core.internal.watson.ElementTreeIterator;
44
import org.eclipse.core.runtime.jobs.*;
65
import org.eclipse.core.internal.watson.IElementContentVisitor;
66
import org.eclipse.core.resources.IBuildConfiguration;
67
import org.eclipse.core.resources.IContainer;
68
import org.eclipse.core.resources.IFile;
69
import org.eclipse.core.resources.IFileModificationValidator;
70
import org.eclipse.core.resources.IFilterMatcherDescriptor;
71
import org.eclipse.core.resources.IMarker;
72
import org.eclipse.core.resources.IPathVariableManager;
73
import org.eclipse.core.resources.IProject;
74
import org.eclipse.core.resources.IProjectDescription;
75
import org.eclipse.core.resources.IProjectNatureDescriptor;
76
import org.eclipse.core.resources.IResource;
77
import org.eclipse.core.resources.IResourceChangeEvent;
78
import org.eclipse.core.resources.IResourceChangeListener;
79
import org.eclipse.core.resources.IResourceRuleFactory;
80
import org.eclipse.core.resources.IResourceStatus;
81
import org.eclipse.core.resources.ISaveContext;
82
import org.eclipse.core.resources.ISaveParticipant;
83
import org.eclipse.core.resources.ISavedState;
84
import org.eclipse.core.resources.ISynchronizer;
85
import org.eclipse.core.resources.IWorkspace;
86
import org.eclipse.core.resources.IWorkspaceDescription;
87
import org.eclipse.core.resources.IWorkspaceRoot;
88
import org.eclipse.core.resources.IWorkspaceRunnable;
89
import org.eclipse.core.resources.IncrementalProjectBuilder;
90
import org.eclipse.core.resources.ProjectScope;
91
import org.eclipse.core.resources.ResourcesPlugin;
92
import org.eclipse.core.resources.team.FileModificationValidationContext;
93
import org.eclipse.core.resources.team.FileModificationValidator;
94
import org.eclipse.core.resources.team.IMoveDeleteHook;
95
import org.eclipse.core.resources.team.TeamHook;
96
import org.eclipse.core.runtime.Assert;
97
import org.eclipse.core.runtime.CoreException;
98
import org.eclipse.core.runtime.IConfigurationElement;
99
import org.eclipse.core.runtime.ICoreRunnable;
100
import org.eclipse.core.runtime.IPath;
101
import org.eclipse.core.runtime.IProgressMonitor;
102
import org.eclipse.core.runtime.ISafeRunnable;
103
import org.eclipse.core.runtime.IStatus;
104
import org.eclipse.core.runtime.MultiStatus;
105
import org.eclipse.core.runtime.NullProgressMonitor;
106
import org.eclipse.core.runtime.OperationCanceledException;
107
import org.eclipse.core.runtime.Path;
108
import org.eclipse.core.runtime.Platform;
109
import org.eclipse.core.runtime.PlatformObject;
110
import org.eclipse.core.runtime.Plugin;
111
import org.eclipse.core.runtime.SafeRunner;
112
import org.eclipse.core.runtime.Status;
113
import org.eclipse.core.runtime.SubMonitor;
114
import org.eclipse.core.runtime.jobs.ISchedulingRule;
115
import org.eclipse.core.runtime.jobs.Job;
116
import org.eclipse.core.runtime.jobs.JobGroup;
45
import org.eclipse.osgi.util.NLS;
117
import org.eclipse.osgi.util.NLS;
46
import org.osgi.framework.Bundle;
118
import org.osgi.framework.Bundle;
47
import org.xml.sax.InputSource;
119
import org.xml.sax.InputSource;
Lines 188-193 Link Here
188
	protected IFileModificationValidator validator = null;
260
	protected IFileModificationValidator validator = null;
189
261
190
	/**
262
	/**
263
	 * Map K(new resource node Id (Long)) V(old resource (Resource)) used to 
264
	 * find the resource that was copied from.  Used only during Resource.copy()
265
	 * We use the nodeId as the key so we don't have to create a resource
266
	 * when checking the map during delta computation.  The value can be a resource
267
	 * because that's already available during the copy.
268
	 * 
269
	 * The copyMap is created automatically when first written to, and removed at
270
	 * the end of the top level operation if it exists.
271
	 * 
272
	 * fix bug 217489
273
	 */
274
	protected Map<Long, IResource> copyMap;
275
276
	/**
191
	 * Data structure for holding the multi-part outcome of
277
	 * Data structure for holding the multi-part outcome of
192
	 * <code>IWorkspace.computeProjectBuildConfigOrder</code>.
278
	 * <code>IWorkspace.computeProjectBuildConfigOrder</code>.
193
	 * <p>
279
	 * <p>
Lines 1139-1144 Link Here
1139
			project.writeDescription(updateFlags);
1225
			project.writeDescription(updateFlags);
1140
		}
1226
		}
1141
1227
1228
		// For tracking COPIED_FROM
1229
		getCopyMap().put(Long.valueOf(newInfo.getNodeId()), source);
1230
1142
		// do the recursion. if we have a file then it has no members so return. otherwise
1231
		// do the recursion. if we have a file then it has no members so return. otherwise
1143
		// recursively call this method on the container's members if the depth tells us to
1232
		// recursively call this method on the container's members if the depth tells us to
1144
		if (depth == IResource.DEPTH_ZERO || source.getType() == IResource.FILE)
1233
		if (depth == IResource.DEPTH_ZERO || source.getType() == IResource.FILE)
Lines 1195-1201 Link Here
1195
1284
1196
		IPath srcValue = URIUtil.toPath(srcPathVariableManager.getURIValue(variable));
1285
		IPath srcValue = URIUtil.toPath(srcPathVariableManager.getURIValue(variable));
1197
		if (srcValue == null) // if the variable doesn't exist, return another
1286
		if (srcValue == null) // if the variable doesn't exist, return another
1198
								// variable that doesn't exist either
1287
			// variable that doesn't exist either
1199
			return PathVariableUtil.getUniqueVariableName(variable, dest);
1288
			return PathVariableUtil.getUniqueVariableName(variable, dest);
1200
		IPath resolvedSrcValue = URIUtil.toPath(srcPathVariableManager.resolveURI(URIUtil.toURI(srcValue)));
1289
		IPath resolvedSrcValue = URIUtil.toPath(srcPathVariableManager.resolveURI(URIUtil.toURI(srcValue)));
1201
1290
Lines 1276-1294 Link Here
1276
		if (!tree.includes(root))
1365
		if (!tree.includes(root))
1277
			return 0;
1366
			return 0;
1278
		switch (depth) {
1367
		switch (depth) {
1279
			case IResource.DEPTH_ZERO :
1368
		case IResource.DEPTH_ZERO :
1280
				return 1;
1369
			return 1;
1281
			case IResource.DEPTH_ONE :
1370
		case IResource.DEPTH_ONE :
1282
				return 1 + tree.getChildCount(root);
1371
			return 1 + tree.getChildCount(root);
1283
			case IResource.DEPTH_INFINITE :
1372
		case IResource.DEPTH_INFINITE :
1284
				final int[] count = new int[1];
1373
			final int[] count = new int[1];
1285
				IElementContentVisitor visitor = (aTree, requestor, elementContents) -> {
1374
			IElementContentVisitor visitor = (aTree, requestor, elementContents) -> {
1286
					if (phantom || !((ResourceInfo) elementContents).isSet(M_PHANTOM))
1375
				if (phantom || !((ResourceInfo) elementContents).isSet(M_PHANTOM))
1287
						count[0]++;
1376
					count[0]++;
1288
					return true;
1377
				return true;
1289
				};
1378
			};
1290
				new ElementTreeIterator(tree, root).iterate(visitor);
1379
			new ElementTreeIterator(tree, root).iterate(visitor);
1291
				return count[0];
1380
			return count[0];
1292
		}
1381
		}
1293
		return 0;
1382
		return 0;
1294
	}
1383
	}
Lines 1639-1645 Link Here
1639
		for (IProject project : projects) {
1728
		for (IProject project : projects) {
1640
			if (!project.isAccessible()) {
1729
			if (!project.isAccessible()) {
1641
				continue;
1730
				continue;
1642
                        }
1731
			}
1643
			IProject[] refs = ((Project)project).internalGetDescription().getReferencedProjects(false);
1732
			IProject[] refs = ((Project)project).internalGetDescription().getReferencedProjects(false);
1644
			List<IProject> dangling = new ArrayList<>(refs.length);
1733
			List<IProject> dangling = new ArrayList<>(refs.length);
1645
			for (IProject ref : refs) {
1734
			for (IProject ref : refs) {
Lines 1904-1911 Link Here
1904
			//create anonymous subclass because TeamHook is abstract
1993
			//create anonymous subclass because TeamHook is abstract
1905
			if (teamHook == null)
1994
			if (teamHook == null)
1906
				teamHook = new TeamHook() {
1995
				teamHook = new TeamHook() {
1907
					// empty
1996
				// empty
1908
				};
1997
			};
1909
		}
1998
		}
1910
	}
1999
	}
1911
2000
Lines 2101-2116 Link Here
2101
	protected ResourceInfo newElement(int type) {
2190
	protected ResourceInfo newElement(int type) {
2102
		ResourceInfo result = null;
2191
		ResourceInfo result = null;
2103
		switch (type) {
2192
		switch (type) {
2104
			case IResource.FILE :
2193
		case IResource.FILE :
2105
			case IResource.FOLDER :
2194
		case IResource.FOLDER :
2106
				result = new ResourceInfo();
2195
			result = new ResourceInfo();
2107
				break;
2196
			break;
2108
			case IResource.PROJECT :
2197
		case IResource.PROJECT :
2109
				result = new ProjectInfo();
2198
			result = new ProjectInfo();
2110
				break;
2199
			break;
2111
			case IResource.ROOT :
2200
		case IResource.ROOT :
2112
				result = new RootInfo();
2201
			result = new RootInfo();
2113
				break;
2202
			break;
2114
		}
2203
		}
2115
		result.setNodeId(nextNodeId());
2204
		result.setNodeId(nextNodeId());
2116
		updateModificationStamp(result);
2205
		updateModificationStamp(result);
Lines 2133-2154 Link Here
2133
	public Resource newResource(IPath path, int type) {
2222
	public Resource newResource(IPath path, int type) {
2134
		String message;
2223
		String message;
2135
		switch (type) {
2224
		switch (type) {
2136
			case IResource.FOLDER :
2225
		case IResource.FOLDER :
2137
				if (path.segmentCount() < ICoreConstants.MINIMUM_FOLDER_SEGMENT_LENGTH) {
2226
			if (path.segmentCount() < ICoreConstants.MINIMUM_FOLDER_SEGMENT_LENGTH) {
2138
					message = "Path must include project and resource name: " + path.toString(); //$NON-NLS-1$
2227
				message = "Path must include project and resource name: " + path.toString(); //$NON-NLS-1$
2139
					Assert.isLegal(false, message);
2228
				Assert.isLegal(false, message);
2140
				}
2229
			}
2141
				return new Folder(path.makeAbsolute(), this);
2230
			return new Folder(path.makeAbsolute(), this);
2142
			case IResource.FILE :
2231
		case IResource.FILE :
2143
				if (path.segmentCount() < ICoreConstants.MINIMUM_FILE_SEGMENT_LENGTH) {
2232
			if (path.segmentCount() < ICoreConstants.MINIMUM_FILE_SEGMENT_LENGTH) {
2144
					message = "Path must include project and resource name: " + path.toString(); //$NON-NLS-1$
2233
				message = "Path must include project and resource name: " + path.toString(); //$NON-NLS-1$
2145
					Assert.isLegal(false, message);
2234
				Assert.isLegal(false, message);
2146
				}
2235
			}
2147
				return new File(path.makeAbsolute(), this);
2236
			return new File(path.makeAbsolute(), this);
2148
			case IResource.PROJECT :
2237
		case IResource.PROJECT :
2149
				return (Resource) getRoot().getProject(path.lastSegment());
2238
			return (Resource) getRoot().getProject(path.lastSegment());
2150
			case IResource.ROOT :
2239
		case IResource.ROOT :
2151
				return (Resource) getRoot();
2240
			return (Resource) getRoot();
2152
		}
2241
		}
2153
		Assert.isLegal(false);
2242
		Assert.isLegal(false);
2154
		// will never get here because of assertion.
2243
		// will never get here because of assertion.
Lines 2648-2651 Link Here
2648
		}
2737
		}
2649
		return Status.OK_STATUS;
2738
		return Status.OK_STATUS;
2650
	}
2739
	}
2740
2741
	public Map<Long, IResource> getCopyMap() {
2742
		if (copyMap == null)
2743
			copyMap = new HashMap<>();
2744
		return copyMap;
2745
	}
2746
2747
	public Map<Long, IResource> getCopyMapRead() {
2748
		// Don't create it
2749
		return copyMap;
2750
	}
2651
}
2751
}

Return to bug 217489