Index: src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/builder/JavaElementDeltaFilter.java =================================================================== --- src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/builder/JavaElementDeltaFilter.java (revision 44111) +++ src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/builder/JavaElementDeltaFilter.java (working copy) @@ -41,6 +41,7 @@ import org.eclipse.jdt.core.ElementChangedEvent; import org.eclipse.jdt.core.IJavaElement; import org.eclipse.jdt.core.IJavaElementDelta; +import org.eclipse.jdt.core.IPackageFragmentRoot; import org.jboss.tools.ws.jaxrs.core.internal.utils.ConstantUtils; import org.jboss.tools.ws.jaxrs.core.internal.utils.Logger; import org.jboss.tools.ws.jaxrs.core.jdt.JdtUtils; @@ -124,7 +125,8 @@ IJavaElement element = event.getElement(); // prevent processing java elements in a closed java project // prevent processing of any file named 'package-info.java' - if (isProjectClosed(element) || isPackageInfoFile(element)) { + // prevent processing of any jar file + if (isProjectClosed(element) || isPackageInfoFile(element) || isJarArchive(element)) { return false; } int flags = event.getFlags(); @@ -142,6 +144,16 @@ } /** + * + * @param element + * @return true if the given java element is a Jar archive. + */ + private boolean isJarArchive(IJavaElement element) { + return (element.getElementType() == IJavaElement.PACKAGE_FRAGMENT_ROOT && ((IPackageFragmentRoot)element).isArchive()); + + } + + /** * Returns true if the element resource is a file named 'package-info.java' (whatever the containing folder) * @param element * @return Index: src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/builder/JavaElementDeltaFilterTestCase.java =================================================================== --- src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/builder/JavaElementDeltaFilterTestCase.java (revision 43939) +++ src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/builder/JavaElementDeltaFilterTestCase.java (working copy) @@ -13,7 +13,7 @@ import static org.eclipse.core.resources.IResourceDelta.REMOVED; import static org.eclipse.jdt.core.ElementChangedEvent.POST_CHANGE; import static org.eclipse.jdt.core.ElementChangedEvent.POST_RECONCILE; -import static org.eclipse.jdt.core.IJavaElement.ANNOTATION; +import static org.eclipse.jdt.core.IJavaElement.*; import static org.eclipse.jdt.core.IJavaElement.COMPILATION_UNIT; import static org.eclipse.jdt.core.IJavaElement.METHOD; import static org.eclipse.jdt.core.IJavaElement.TYPE; @@ -30,6 +30,7 @@ import org.eclipse.jdt.core.ICompilationUnit; import org.eclipse.jdt.core.IJavaElement; import org.eclipse.jdt.core.IMethod; +import org.eclipse.jdt.core.IPackageFragmentRoot; import org.eclipse.jdt.core.IType; import org.eclipse.jdt.core.JavaModelException; import org.junit.Before; @@ -117,4 +118,18 @@ assertFalse("Wrong result", filter.apply(createEvent(element, REMOVED, POST_CHANGE, NO_FLAG))); } + @Test + public void shouldNotAcceptChangesInJarFile() { + IPackageFragmentRoot element = createMock(IPackageFragmentRoot.class, PACKAGE_FRAGMENT_ROOT); + IResource resource = mock(IResource.class); + when(element.getResource()).thenReturn(resource); + when(element.isArchive()).thenReturn(true); + when(resource.getType()).thenReturn(IResource.FILE); + assertFalse("Wrong result", filter.apply(createEvent(element, ADDED, POST_RECONCILE, NO_FLAG))); + assertFalse("Wrong result", filter.apply(createEvent(element, ADDED, POST_CHANGE, NO_FLAG))); + assertFalse("Wrong result", filter.apply(createEvent(element, CHANGED, POST_RECONCILE, NO_FLAG))); + assertFalse("Wrong result", filter.apply(createEvent(element, CHANGED, POST_CHANGE, NO_FLAG))); + assertFalse("Wrong result", filter.apply(createEvent(element, REMOVED, POST_RECONCILE, NO_FLAG))); + assertFalse("Wrong result", filter.apply(createEvent(element, REMOVED, POST_CHANGE, NO_FLAG))); + } } Index: src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/builder/JavaElementDeltaScannerTestCase.java =================================================================== --- src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/builder/JavaElementDeltaScannerTestCase.java (revision 44469) +++ src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/builder/JavaElementDeltaScannerTestCase.java (working copy) @@ -549,12 +549,12 @@ } @Test - public void shouldNotifyWhenLibraryAddedInClasspath() throws CoreException, InterruptedException { + public void shouldNotNotifyWhenLibraryAddedInClasspath() throws CoreException, InterruptedException { // operation IPackageFragmentRoot addedEntry = WorkbenchTasks.addClasspathEntry(javaProject, "slf4j-api-1.5.2.jar", new NullProgressMonitor()); // verifications - verifyEventNotification(addedEntry, ADDED, POST_CHANGE, NO_FLAG, times(1)); + verifyEventNotification(addedEntry, ADDED, POST_CHANGE, NO_FLAG, times(0)); } @Test @@ -567,13 +567,13 @@ } @Test - public void shouldNotifyWhenLibraryRemovedFromClasspath() throws CoreException, InterruptedException { + public void shouldNotNotifyWhenLibraryRemovedFromClasspath() throws CoreException, InterruptedException { // operation List removedEntries = WorkbenchUtils.removeClasspathEntry(javaProject, "jaxrs-api-2.0.1.GA.jar", null); // verifications for (IPackageFragmentRoot removedEntry : removedEntries) { - verifyEventNotification(removedEntry, REMOVED, POST_CHANGE, F_REMOVED_FROM_CLASSPATH, times(1)); + verifyEventNotification(removedEntry, REMOVED, POST_CHANGE, F_REMOVED_FROM_CLASSPATH, times(0)); } }