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

Collapse All | Expand All

(-)src/org/eclipse/pde/api/tools/internal/builder/IncrementalApiBuilder.java (-8 / +19 lines)
Lines 349-360 Link Here
349
			if(type == null) {
349
			if(type == null) {
350
				continue;
350
				continue;
351
			}
351
			}
352
			this.builder.updateMonitor(monitor, 0);
352
			this.builder.cleanupMarkers(file);
353
			this.builder.cleanupUnsupportedTagMarkers(file);
354
			this.builder.updateMonitor(monitor, 0);
355
			this.builder.cleanupCompatibilityMarkers(file);
356
			this.builder.updateMonitor(monitor, 0);
357
			this.builder.cleanupUsageMarkers(file);
358
			this.builder.updateMonitor(monitor, 0);
353
			this.builder.updateMonitor(monitor, 0);
359
			cnames.add(type.getFullyQualifiedName());
354
			cnames.add(type.getFullyQualifiedName());
360
			try {
355
			try {
Lines 376-390 Link Here
376
		IResource resource = project.findMember(ApiAnalysisBuilder.MANIFEST_PATH);
371
		IResource resource = project.findMember(ApiAnalysisBuilder.MANIFEST_PATH);
377
		if (resource != null) {
372
		if (resource != null) {
378
			try {
373
			try {
374
				//TODO we should find a way to cache markers to type names, that way to get all
375
				//the manifest markers for a given type name is time of O(1)
379
				IMarker[] markers = resource.findMarkers(IApiMarkerConstants.COMPATIBILITY_PROBLEM_MARKER, false, IResource.DEPTH_ZERO);
376
				IMarker[] markers = resource.findMarkers(IApiMarkerConstants.COMPATIBILITY_PROBLEM_MARKER, false, IResource.DEPTH_ZERO);
377
				String tname = null; 
380
				for (int i = 0; i < markers.length; i++) {
378
				for (int i = 0; i < markers.length; i++) {
381
					if(tnames.contains(Util.getTypeNameFromMarker(markers[i]))) {
379
					tname = Util.getTypeNameFromMarker(markers[i]);
380
					if(tnames.contains(tname) || cnames.contains(tname)) {
382
						markers[i].delete();
381
						markers[i].delete();
383
					}
382
					}
384
				}
383
				}
384
				//TODO we should find a way to cache markers to type names, that way to get all
385
				//the manifest markers for a given type name is time of O(1)
385
				markers = resource.findMarkers(IApiMarkerConstants.SINCE_TAGS_PROBLEM_MARKER, false, IResource.DEPTH_ZERO);
386
				markers = resource.findMarkers(IApiMarkerConstants.SINCE_TAGS_PROBLEM_MARKER, false, IResource.DEPTH_ZERO);
386
				for (int i = 0; i < markers.length; i++) {
387
				for (int i = 0; i < markers.length; i++) {
387
					if(tnames.contains(Util.getTypeNameFromMarker(markers[i]))) {
388
					tname = Util.getTypeNameFromMarker(markers[i]);
389
					if(tnames.contains(tname) || cnames.contains(tname)) {
390
						markers[i].delete();
391
					}
392
				}
393
				//TODO we should find a way to cache markers to type names, that way to get all
394
				//the manifest markers for a given type name is time of O(1)
395
				markers = resource.findMarkers(IApiMarkerConstants.UNUSED_FILTER_PROBLEM_MARKER, false, IResource.DEPTH_ZERO);
396
				for (int i = 0; i < markers.length; i++) {
397
					tname = Util.getTypeNameFromMarker(markers[i]);
398
					if(tnames.contains(tname) || cnames.contains(tname)) {
388
						markers[i].delete();
399
						markers[i].delete();
389
					}
400
					}
390
				}
401
				}
(-)src/org/eclipse/pde/api/tools/internal/builder/BaseApiAnalyzer.java (-52 / +13 lines)
Lines 27-33 Link Here
27
import java.util.jar.JarFile;
27
import java.util.jar.JarFile;
28
28
29
import org.eclipse.core.resources.IFile;
29
import org.eclipse.core.resources.IFile;
30
import org.eclipse.core.resources.IMarker;
31
import org.eclipse.core.resources.IProject;
30
import org.eclipse.core.resources.IProject;
32
import org.eclipse.core.resources.IResource;
31
import org.eclipse.core.resources.IResource;
33
import org.eclipse.core.runtime.CoreException;
32
import org.eclipse.core.runtime.CoreException;
Lines 292-317 Link Here
292
			if(typenames != null || changedTypes != null) {
291
			if(typenames != null || changedTypes != null) {
293
				//incremental
292
				//incremental
294
				Set typeNamesSet = null;
293
				Set typeNamesSet = null;
294
				IResource resource = null;
295
				if (typenames != null) {
295
				if (typenames != null) {
296
					typeNamesSet = new HashSet();
296
					typeNamesSet = new HashSet();
297
					for (int i = 0; i < typenames.length; i++) {
297
					for (int i = 0; i < typenames.length; i++) {
298
						String typeName = typenames[i];
298
						typeNamesSet.add(typenames[i]);
299
						typeNamesSet.add(typeName);
299
						resource = Util.getResource(project, fJavaProject.findType(typenames[i]));
300
						checkUnusedProblemFilters(store, project, typeName);
300
						if(resource != null) {
301
							createUnusedApiFilterProblems(store.getUnusedFilters(resource, typenames[i]));
302
						}
301
					}
303
					}
302
				}
304
				}
303
				if (changedTypes != null) {
305
				if (changedTypes != null) {
304
					// check the ones not already checked as part of type names check
306
					// check the ones not already checked as part of type names check
305
					for (int i = 0; i < changedTypes.length; i++) {
307
					for (int i = 0; i < changedTypes.length; i++) {
306
						String typeName = changedTypes[i];
308
						if (typeNamesSet == null || !typeNamesSet.remove(changedTypes[i])) {
307
						if (typeNamesSet == null || !typeNamesSet.remove(typeName)) {
309
							resource = Util.getResource(project, fJavaProject.findType(changedTypes[i]));
308
							checkUnusedProblemFilters(store, project, typeName);
310
							if(resource != null) {
311
								createUnusedApiFilterProblems(store.getUnusedFilters(resource, changedTypes[i]));
312
							}
309
						}
313
						}
310
					}
314
					}
311
				}
315
				}
312
			} else {
316
			} else {
313
				//full build, clean up all old markers
317
				//full build, clean up all old markers
314
				project.deleteMarkers(IApiMarkerConstants.UNUSED_FILTER_PROBLEM_MARKER, false, IResource.DEPTH_INFINITE);
315
				createUnusedApiFilterProblems(store.getUnusedFilters(null, null));
318
				createUnusedApiFilterProblems(store.getUnusedFilters(null, null));
316
			}
319
			}
317
		}
320
		}
Lines 323-371 Link Here
323
		}
326
		}
324
	}
327
	}
325
328
326
	private void checkUnusedProblemFilters(ApiFilterStore store,
327
			IProject project, String typeName) throws JavaModelException,
328
			CoreException {
329
		IType element = fJavaProject.findType(typeName);
330
		IResource resource = Util.getResource(project, element);
331
		if(resource != null) {
332
			if (!Util.isManifest(resource.getProjectRelativePath())) {
333
				resource.deleteMarkers(IApiMarkerConstants.UNUSED_FILTER_PROBLEM_MARKER, false, IResource.DEPTH_INFINITE);
334
				IResource manifestFile = project.findMember(Util.MANIFEST_PROJECT_RELATIVE_PATH);
335
				if (manifestFile != null) {
336
					try {
337
						IMarker[] markers = manifestFile.findMarkers(IApiMarkerConstants.UNUSED_FILTER_PROBLEM_MARKER, false, IResource.DEPTH_ZERO);
338
						loop: for (int j = 0, max = markers.length; j < max; j++) {
339
							IMarker marker = markers[j];
340
							String typeNameFromMarker = Util.getTypeNameFromMarker(marker);
341
							if (typeName.equals(typeNameFromMarker)) {
342
								marker.delete();
343
								continue loop;
344
							}
345
						}
346
					} catch (CoreException e) {
347
						ApiPlugin.log(e.getStatus());
348
					}
349
				}
350
			} else {
351
				try {
352
					IMarker[] markers = resource.findMarkers(IApiMarkerConstants.UNUSED_FILTER_PROBLEM_MARKER, false, IResource.DEPTH_ZERO);
353
					loop: for (int j = 0, max = markers.length; j < max; j++) {
354
						IMarker marker = markers[j];
355
						String typeNameFromMarker = Util.getTypeNameFromMarker(marker);
356
						if (typeName.equals(typeNameFromMarker)) {
357
							marker.delete();
358
							continue loop;
359
						}
360
					}
361
				} catch (CoreException e) {
362
					ApiPlugin.log(e.getStatus());
363
				}
364
			}
365
			createUnusedApiFilterProblems(store.getUnusedFilters(resource, typeName));
366
		}
367
	}
368
369
	/**
329
	/**
370
	 * Creates a new unused {@link IApiProblemFilter} problem
330
	 * Creates a new unused {@link IApiProblemFilter} problem
371
	 * @param filters the filters to create the problems for
331
	 * @param filters the filters to create the problems for
Lines 376-384 Link Here
376
			return;
336
			return;
377
		}
337
		}
378
		IApiProblemFilter filter = null;
338
		IApiProblemFilter filter = null;
339
		IApiProblem problem = null;
379
		for (int i = 0; i < filters.length; i++) {
340
		for (int i = 0; i < filters.length; i++) {
380
			filter = filters[i];
341
			filter = filters[i];
381
			IApiProblem problem = filter.getUnderlyingProblem();
342
			problem = filter.getUnderlyingProblem();
382
			if(problem == null) {
343
			if(problem == null) {
383
				return;
344
				return;
384
			}
345
			}
(-)src/org/eclipse/pde/api/tools/internal/builder/ApiAnalysisBuilder.java (+16 lines)
Lines 128-133 Link Here
128
	 * @param resource
128
	 * @param resource
129
	 */
129
	 */
130
	void cleanupMarkers(IResource resource) {
130
	void cleanupMarkers(IResource resource) {
131
		cleanUnusedFilterMarkers(resource);
131
		cleanupUsageMarkers(resource);
132
		cleanupUsageMarkers(resource);
132
		cleanupCompatibilityMarkers(resource);
133
		cleanupCompatibilityMarkers(resource);
133
		cleanupUnsupportedTagMarkers(resource);
134
		cleanupUnsupportedTagMarkers(resource);
Lines 183-188 Link Here
183
		}
184
		}
184
	}
185
	}
185
	
186
	
187
	/**
188
	 * Cleans up the unused API filter problems from the given resource
189
	 * @param resource
190
	 */
191
	void cleanUnusedFilterMarkers(IResource resource) {
192
		try {
193
			if(resource != null && resource.isAccessible()) {
194
				resource.deleteMarkers(IApiMarkerConstants.UNUSED_FILTER_PROBLEM_MARKER, false, IResource.DEPTH_INFINITE);
195
			}
196
		}
197
		catch(CoreException ce) {
198
			ApiPlugin.log(ce.getStatus());
199
		}
200
	}
201
	
186
	/* (non-Javadoc)
202
	/* (non-Javadoc)
187
	 * @see org.eclipse.core.resources.IncrementalProjectBuilder#build(int, java.util.Map, org.eclipse.core.runtime.IProgressMonitor)
203
	 * @see org.eclipse.core.resources.IncrementalProjectBuilder#build(int, java.util.Map, org.eclipse.core.runtime.IProgressMonitor)
188
	 */
204
	 */
(-)src/org/eclipse/pde/api/tools/builder/tests/usage/UnusedApiProblemFilterTests.java (-7 / +7 lines)
Lines 209-221 Link Here
209
				inc);
209
				inc);
210
	}
210
	}
211
	
211
	
212
//	public void testUnusedFilter2F() throws Exception {
212
	public void testUnusedFilter2F() throws Exception {
213
//		x2(false);
213
		x2(false);
214
//	}
214
	}
215
//	
215
	
216
//	public void testUnusedFilter2I() throws Exception {
216
	public void testUnusedFilter2I() throws Exception {
217
//		x2(true);
217
		x2(true);
218
//	}
218
	}
219
	
219
	
220
	/**
220
	/**
221
	 * Tests that there is no problem reported for a compilation unit that has been deleted, which has an api 
221
	 * Tests that there is no problem reported for a compilation unit that has been deleted, which has an api 

Return to bug 233643