aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorszarnekow2009-04-15 09:07:41 (EDT)
committersefftinge2009-04-15 09:07:41 (EDT)
commit9885fab4777b4aa82e9693846fc48a54d1c45ba5 (patch)
tree3682f7ef253353eb00253b295b8047f7e154293a
parent4d7f07c53a1d8823879400803facd787f15365c6 (diff)
downloadorg.eclipse.xtext-9885fab4777b4aa82e9693846fc48a54d1c45ba5.zip
org.eclipse.xtext-9885fab4777b4aa82e9693846fc48a54d1c45ba5.tar.gz
org.eclipse.xtext-9885fab4777b4aa82e9693846fc48a54d1c45ba5.tar.bz2
Fix: Suppress NPE in XtextDocument, added pointers to some "unexpected" code
-rw-r--r--plugins/org.eclipse.xtext.ui.core/src/org/eclipse/xtext/ui/core/editor/model/XtextDocument.java3
-rw-r--r--plugins/org.eclipse.xtext.ui.core/src/org/eclipse/xtext/ui/core/editor/model/XtextDocumentProvider.java6
2 files changed, 6 insertions, 3 deletions
diff --git a/plugins/org.eclipse.xtext.ui.core/src/org/eclipse/xtext/ui/core/editor/model/XtextDocument.java b/plugins/org.eclipse.xtext.ui.core/src/org/eclipse/xtext/ui/core/editor/model/XtextDocument.java
index 1721128..db9103b 100644
--- a/plugins/org.eclipse.xtext.ui.core/src/org/eclipse/xtext/ui/core/editor/model/XtextDocument.java
+++ b/plugins/org.eclipse.xtext.ui.core/src/org/eclipse/xtext/ui/core/editor/model/XtextDocument.java
@@ -100,8 +100,9 @@ public class XtextDocument extends Document implements IXtextDocument {
resource.setValidationDisabled(file == null);
}
+ // XXX why is this one not called inside an readOnly action???
public boolean isReferenced(IResource anIResource) {
- if (!(anIResource instanceof IFile))
+ if (!(anIResource instanceof IFile) || resource == null || resource.getResourceSet() == null)
return false;
EList<Resource> resources = resource.getResourceSet().getResources();
final Map<String, Resource> uriToRes = new HashMap<String, Resource>();
diff --git a/plugins/org.eclipse.xtext.ui.core/src/org/eclipse/xtext/ui/core/editor/model/XtextDocumentProvider.java b/plugins/org.eclipse.xtext.ui.core/src/org/eclipse/xtext/ui/core/editor/model/XtextDocumentProvider.java
index 1f9d229..1c67ee9 100644
--- a/plugins/org.eclipse.xtext.ui.core/src/org/eclipse/xtext/ui/core/editor/model/XtextDocumentProvider.java
+++ b/plugins/org.eclipse.xtext.ui.core/src/org/eclipse/xtext/ui/core/editor/model/XtextDocumentProvider.java
@@ -57,6 +57,8 @@ public class XtextDocumentProvider extends FileDocumentProvider {
this.document = document;
}
+ // XXX: Is this a potential dead lock? A UoW tries to spawn another one for
+ // another document. This one may try to lock the first one ...
public void resourceChanged(final IResourceChangeEvent event) {
final ResourceDeltaVisitor visitor = new ResourceDeltaVisitor(document);
@@ -116,7 +118,7 @@ public class XtextDocumentProvider extends FileDocumentProvider {
}
});
return Status.OK_STATUS;
- }}.schedule();
+ }}.schedule(); // do we need to lock the workspace?
}
}
}
@@ -140,7 +142,7 @@ public class XtextDocumentProvider extends FileDocumentProvider {
int flags = delta.getFlags();
if ((kind == IResourceDelta.REMOVED ||
(kind == IResourceDelta.CHANGED && ((IResourceDelta.CONTENT & flags) != 0)))
- && document.isReferenced(res)) {
+ && document.isReferenced(res)) { // this should be a UoW as we access the resource
deltas.add(delta);
}
return true;