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

Collapse All | Expand All

(-)model/org/eclipse/jdt/internal/core/ExternalFoldersManager.java (-21 / +35 lines)
Lines 14-19 Link Here
14
import java.io.FileOutputStream;
14
import java.io.FileOutputStream;
15
import java.io.IOException;
15
import java.io.IOException;
16
import java.util.ArrayList;
16
import java.util.ArrayList;
17
import java.util.Collections;
17
import java.util.HashMap;
18
import java.util.HashMap;
18
import java.util.HashSet;
19
import java.util.HashSet;
19
import java.util.Iterator;
20
import java.util.Iterator;
Lines 39-47 Link Here
39
public class ExternalFoldersManager {
40
public class ExternalFoldersManager {
40
	private static final String EXTERNAL_PROJECT_NAME = ".org.eclipse.jdt.core.external.folders"; //$NON-NLS-1$
41
	private static final String EXTERNAL_PROJECT_NAME = ".org.eclipse.jdt.core.external.folders"; //$NON-NLS-1$
41
	private static final String LINKED_FOLDER_NAME = ".link"; //$NON-NLS-1$
42
	private static final String LINKED_FOLDER_NAME = ".link"; //$NON-NLS-1$
42
	private HashMap folders;
43
	private Map folders;
43
	private int counter = 0;
44
	private int counter = 0;
44
45
	/* Singleton instance */
46
	private static ExternalFoldersManager MANAGER = new ExternalFoldersManager();
47
	
48
	private ExternalFoldersManager() {
49
		super();
50
		getFolders();
51
	}
52
	
53
	public static ExternalFoldersManager getExternalFoldersManager() {
54
		return MANAGER;
55
	}
56
	
45
	/*
57
	/*
46
	 * Returns a set of external path to external folders referred to on the given classpath.
58
	 * Returns a set of external path to external folders referred to on the given classpath.
47
	 * Returns null if none.
59
	 * Returns null if none.
Lines 92-99 Link Here
92
		return addFolder(externalFolderPath, getExternalFoldersProject());
104
		return addFolder(externalFolderPath, getExternalFoldersProject());
93
	}
105
	}
94
106
95
	private synchronized IFolder addFolder(IPath externalFolderPath, IProject externalFoldersProject) {
107
	private IFolder addFolder(IPath externalFolderPath, IProject externalFoldersProject) {
96
		HashMap knownFolders = getFolders();
108
		Map knownFolders = getFolders();
97
		Object existing = knownFolders.get(externalFolderPath);
109
		Object existing = knownFolders.get(externalFolderPath);
98
		if (existing != null) {
110
		if (existing != null) {
99
			return (IFolder) existing;
111
			return (IFolder) existing;
Lines 129-153 Link Here
129
			project.delete(true, monitor);
141
			project.delete(true, monitor);
130
	}
142
	}
131
143
132
	private synchronized ArrayList getFoldersToCleanUp(IProgressMonitor monitor) throws CoreException {
144
	private ArrayList getFoldersToCleanUp(IProgressMonitor monitor) throws CoreException {
133
		DeltaProcessingState state = JavaModelManager.getDeltaState();
145
		DeltaProcessingState state = JavaModelManager.getDeltaState();
134
		HashMap roots = state.roots;
146
		HashMap roots = state.roots;
135
		HashMap sourceAttachments = state.sourceAttachments;
147
		HashMap sourceAttachments = state.sourceAttachments;
136
		if (roots == null && sourceAttachments == null)
148
		if (roots == null && sourceAttachments == null)
137
			return null;
149
			return null;
138
		HashMap knownFolders = getFolders();
150
		Map knownFolders = getFolders();
139
		Iterator iterator = knownFolders.entrySet().iterator();
140
		ArrayList result = null;
151
		ArrayList result = null;
141
		while (iterator.hasNext()) {
152
		synchronized (knownFolders) {
142
			Map.Entry entry = (Map.Entry) iterator.next();
153
			Iterator iterator = knownFolders.entrySet().iterator();
143
			IPath path = (IPath) entry.getKey();
154
			while (iterator.hasNext()) {
144
			if ((roots != null && !roots.containsKey(path))
155
				Map.Entry entry = (Map.Entry) iterator.next();
145
					&& (sourceAttachments != null && !sourceAttachments.containsKey(path))) {
156
				IPath path = (IPath) entry.getKey();
146
				IFolder folder = (IFolder) entry.getValue();
157
				if ((roots != null && !roots.containsKey(path))
147
				if (folder != null) {
158
						&& (sourceAttachments != null && !sourceAttachments.containsKey(path))) {
148
					if (result == null)
159
					IFolder folder = (IFolder) entry.getValue();
149
						result = new ArrayList();
160
					if (folder != null) {
150
					result.add(folder);
161
						if (result == null)
162
							result = new ArrayList();
163
						result.add(folder);
164
					}
151
				}
165
				}
152
			}
166
			}
153
		}
167
		}
Lines 222-234 Link Here
222
		project.create(desc, IResource.HIDDEN, monitor);
236
		project.create(desc, IResource.HIDDEN, monitor);
223
	}
237
	}
224
238
225
	public synchronized IFolder getFolder(IPath externalFolderPath) {
239
	public IFolder getFolder(IPath externalFolderPath) {
226
		return (IFolder) getFolders().get(externalFolderPath);
240
		return (IFolder) getFolders().get(externalFolderPath);
227
	}
241
	}
228
242
229
	private HashMap getFolders() {
243
	private Map getFolders() {
230
		if (this.folders == null) {
244
		if (this.folders == null) {
231
			this.folders = new HashMap();
245
			this.folders = Collections.synchronizedMap(new HashMap());
232
			IProject project = getExternalFoldersProject();
246
			IProject project = getExternalFoldersProject();
233
			try {
247
			try {
234
				if (!project.isAccessible()) {
248
				if (!project.isAccessible()) {
Lines 308-314 Link Here
308
		return;
322
		return;
309
	}
323
	}
310
324
311
	public synchronized IFolder removeFolder(IPath externalFolderPath) {
325
	public IFolder removeFolder(IPath externalFolderPath) {
312
		return (IFolder) getFolders().remove(externalFolderPath);
326
		return (IFolder) getFolders().remove(externalFolderPath);
313
	}
327
	}
314
328
(-)model/org/eclipse/jdt/internal/core/JavaModelManager.java (-1 / +1 lines)
Lines 451-457 Link Here
451
	/* whether an AbortCompilationUnit should be thrown when the source of a compilation unit cannot be retrieved */
451
	/* whether an AbortCompilationUnit should be thrown when the source of a compilation unit cannot be retrieved */
452
	public ThreadLocal abortOnMissingSource = new ThreadLocal();
452
	public ThreadLocal abortOnMissingSource = new ThreadLocal();
453
453
454
	private ExternalFoldersManager externalFoldersManager = new ExternalFoldersManager();
454
	private ExternalFoldersManager externalFoldersManager = ExternalFoldersManager.getExternalFoldersManager();
455
455
456
	/**
456
	/**
457
	 * Returns whether the given full path (for a package) conflicts with the output location
457
	 * Returns whether the given full path (for a package) conflicts with the output location

Return to bug 310159