Author: xcoulon
Date: 2011-11-24 09:30:49 -0500 (Thu, 24 Nov 2011)
New Revision: 36617
Modified:
trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/builder/ElementChangedEventScanner.java
trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/builder/JaxrsMetamodelBuildJob.java
Log:
Prevent resource changes analysis if the enclosing project is closed
Modified:
trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/builder/ElementChangedEventScanner.java
===================================================================
---
trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/builder/ElementChangedEventScanner.java 2011-11-24
13:29:45 UTC (rev 36616)
+++
trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/builder/ElementChangedEventScanner.java 2011-11-24
14:30:49 UTC (rev 36617)
@@ -22,6 +22,7 @@
import org.eclipse.core.resources.IMarker;
import org.eclipse.core.resources.IMarkerDelta;
+import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.IResourceChangeEvent;
import org.eclipse.core.resources.IResourceDelta;
@@ -81,6 +82,10 @@
private List<JavaElementChangedEvent> scanDelta(IResourceDelta delta) throws
CoreException {
final List<JavaElementChangedEvent> events = new
ArrayList<JavaElementChangedEvent>();
final IResource resource = delta.getResource();
+ if(resource.getType() == IResource.PROJECT && !((IProject)resource).isOpen())
{
+ // skip as the project is closed
+ return Collections.emptyList();
+ }
final boolean isJavaFile = resource.getType() == IResource.FILE &&
("java").equals(resource.getFileExtension());
final boolean javaFileAdded = isJavaFile && delta.getKind() == ADDED;
final boolean javaFileWithMarkers = isJavaFile && delta.getKind() == CHANGED
@@ -142,6 +147,11 @@
private List<JavaElementChangedEvent> scanDelta(IJavaElementDelta delta) throws
CoreException {
final List<JavaElementChangedEvent> events = new
ArrayList<JavaElementChangedEvent>();
IJavaElement element = delta.getElement();
+ if(element == null || !element.getJavaProject().getProject().isOpen()) {
+ // skip as the project is closed
+ return Collections.emptyList();
+ }
+
int elementKind = element.getElementType(); // retrieveJavaElementKind(delta);
int deltaKind = retrieveDeltaKind(delta);
int[] flags = retrieveFlags(delta);
Modified:
trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/builder/JaxrsMetamodelBuildJob.java
===================================================================
---
trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/builder/JaxrsMetamodelBuildJob.java 2011-11-24
13:29:45 UTC (rev 36616)
+++
trunk/ws/plugins/org.jboss.tools.ws.jaxrs.core/src/org/jboss/tools/ws/jaxrs/core/internal/metamodel/builder/JaxrsMetamodelBuildJob.java 2011-11-24
14:30:49 UTC (rev 36617)
@@ -31,20 +31,18 @@
private static final int SCALE = 10;
- private final IJavaProject javaProject;
-
private final Object event;
public JaxrsMetamodelBuildJob(final IProject project, final boolean requiresReset)
throws CoreException {
super("JAX-RS Metamodel build for " + project.getName() + "...");
- this.javaProject = JavaCore.create(project);
+ IJavaProject javaProject = JavaCore.create(project);
JavaElementDelta delta = new JavaElementDelta(javaProject);
delta.added();
this.event = new ElementChangedEvent(delta, ElementChangedEvent.POST_RECONCILE);
final JaxrsMetamodel metamodel = JaxrsMetamodel.get(javaProject);
if (metamodel == null) {
JaxrsMetamodel.create(javaProject);
- } else if(requiresReset) {
+ } else if (requiresReset) {
metamodel.reset();
}
}
@@ -52,12 +50,10 @@
public JaxrsMetamodelBuildJob(final IResourceChangeEvent event) {
super("Incremental JAX-RS Metamodel build..."); //$NON-NLS-1$
this.event = event;
- this.javaProject = JavaCore.create(event.getDelta().getResource().getProject());
}
public JaxrsMetamodelBuildJob(final ElementChangedEvent event) {
super("Incremental JAX-RS Metamodel build..."); //$NON-NLS-1$
- this.javaProject = event.getDelta().getElement().getJavaProject();
this.event = event;
}
@@ -65,19 +61,9 @@
protected IStatus run(IProgressMonitor progressMonitor) {
try {
progressMonitor.beginTask("Build JAX-RS Metamodel", 8 * SCALE);
- /*
- * JaxrsMetamodel metamodel = JaxrsMetamodel.get(javaProject);
- * if (metamodel == null) {
- * metamodel = JaxrsMetamodel.create(javaProject);
- * }
- * if (kind == IncrementalProjectBuilder.FULL_BUILD) {
- * metamodel.reset();
- * }
- */
progressMonitor.worked(SCALE);
// create fake event at the JavaProject level:
// scan and filter delta, retrieve a list of java changes
-
final List<JavaElementChangedEvent> events = new
ElementChangedEventScanner().scanAndFilterEvent(event,
new SubProgressMonitor(progressMonitor, SCALE));
// process events against HTTP Methods, retrieve jaxrs changes
Show replies by date