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 |
} |