| author | szarnekow | 2009-03-09 13:50:57 (EDT) |
|---|---|---|
| committer | sefftinge | 2009-03-09 13:50:57 (EDT) |
| commit | 13a7c44f8ee66a019bcb1b0eb571f93633251a28 (patch) (side-by-side diff) | |
| tree | 6ca4d4b65d2f691a22de6ad63f3fde1172fd799d | |
| parent | af66cc540eb1e5e4620083eb54fe08c0b886ec96 (diff) | |
| download | org.eclipse.xtext-13a7c44f8ee66a019bcb1b0eb571f93633251a28.zip org.eclipse.xtext-13a7c44f8ee66a019bcb1b0eb571f93633251a28.tar.gz org.eclipse.xtext-13a7c44f8ee66a019bcb1b0eb571f93633251a28.tar.bz2 | |
Some cosmetics in Manifest merger, some stability improvements for the Xtext-editor
3 files changed, 25 insertions, 18 deletions
diff --git a/plugins/org.eclipse.xtext.ui.common/src/org/eclipse/xtext/ui/common/editor/outline/impl/LazyTransformingTreeProvider.java b/plugins/org.eclipse.xtext.ui.common/src/org/eclipse/xtext/ui/common/editor/outline/impl/LazyTransformingTreeProvider.java index 0e33ae4..e2f55c0 100644 --- a/plugins/org.eclipse.xtext.ui.common/src/org/eclipse/xtext/ui/common/editor/outline/impl/LazyTransformingTreeProvider.java +++ b/plugins/org.eclipse.xtext.ui.common/src/org/eclipse/xtext/ui/common/editor/outline/impl/LazyTransformingTreeProvider.java @@ -86,12 +86,13 @@ public class LazyTransformingTreeProvider extends LabelProvider implements ILazy public void updateChildCount(Object element, int currentChildCount) { int length = 0; - if (element instanceof IXtextDocument) { - length = outlineModel.getChildren().size(); - } - else if (element instanceof ContentOutlineNode) { - ContentOutlineNode node = (ContentOutlineNode) element; - length = node.getChildren().size(); + if (outlineModel != null) { // happens, when tree was disposed. + if (element instanceof IXtextDocument) { + length = outlineModel.getChildren().size(); + } else if (element instanceof ContentOutlineNode) { + ContentOutlineNode node = (ContentOutlineNode) element; + length = node.getChildren().size(); + } } viewer.setChildCount(element, length); } diff --git a/plugins/org.eclipse.xtext.ui.core/src/org/eclipse/xtext/ui/core/editor/model/UnitOfWork.java b/plugins/org.eclipse.xtext.ui.core/src/org/eclipse/xtext/ui/core/editor/model/UnitOfWork.java index 498dde0..fe89bec 100644 --- a/plugins/org.eclipse.xtext.ui.core/src/org/eclipse/xtext/ui/core/editor/model/UnitOfWork.java +++ b/plugins/org.eclipse.xtext.ui.core/src/org/eclipse/xtext/ui/core/editor/model/UnitOfWork.java @@ -13,15 +13,15 @@ import org.eclipse.xtext.resource.XtextResource; /** * A unit of work acts as a transaction block, which can be passed to an * IXtextDocument in order to get read or write access to it's parsed models. - * - * + * * @author Sven Efftinge - Initial contribution and API * @author Sebastian Zarnekow */ public interface UnitOfWork<T> { /** - * @param resource - The resource containing the current state - <b>Do not return any references to something contained in this resource</b> + * @param resource - The resource containing the current state - + * <b>Do not return any references to something contained in this resource</b> * @return * @throws Exception */ 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 caeab92..86cbffc 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 @@ -120,10 +120,13 @@ public class XtextDocument extends Document implements IXtextDocument { public <T> T readOnly(UnitOfWork<T> work) { readLock.lock(); try { - updateContentBeforeRead(); - T exec = work.exec(resource); - ensureThatStateIsNotReturned(exec, work); - return exec; + if (resource != null) { + updateContentBeforeRead(); + T exec = work.exec(resource); + ensureThatStateIsNotReturned(exec, work); + return exec; + } + return null; } catch (RuntimeException e) { throw e; } catch (Exception e) { @@ -136,11 +139,14 @@ public class XtextDocument extends Document implements IXtextDocument { public <T> T modify(UnitOfWork<T> work) { writeLock.lock(); try { - T exec = work.exec(resource); - ensureThatStateIsNotReturned(exec, work); - notifyModelListeners(resource); - // TODO track modifications and serialize back to the text buffer - return exec; + if (resource != null) { + T exec = work.exec(resource); + ensureThatStateIsNotReturned(exec, work); + notifyModelListeners(resource); + // TODO track modifications and serialize back to the text buffer + return exec; + } + return null; } catch (RuntimeException e) { throw e; } catch (Exception e) { |

