[ 119176] ArrayIndexOutOfBoundException is thrown while editing HTML model
diff --git a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/document/CSSModelImpl.java b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/document/CSSModelImpl.java
index c130c40..d28e4a5 100644
--- a/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/document/CSSModelImpl.java
+++ b/bundles/org.eclipse.wst.css.core/src/org/eclipse/wst/css/core/internal/document/CSSModelImpl.java
@@ -281,16 +281,22 @@
}
public IStructuredDocument getStructuredDocument() {
- IStructuredDocument structuredDocument = super.getStructuredDocument();
- if (structuredDocument != null)
- return structuredDocument;
+ IStructuredDocument structuredDocument = null;
+ beginLock();
+ try {
+ structuredDocument = super.getStructuredDocument();
+ if (structuredDocument != null)
+ return structuredDocument;
- // the first time
- Assert.isNotNull(getModelHandler());
- structuredDocument = (IStructuredDocument) getModelHandler().getDocumentLoader().createNewStructuredDocument();
+ // the first time
+ Assert.isNotNull(getModelHandler());
+ structuredDocument = (IStructuredDocument) getModelHandler().getDocumentLoader().createNewStructuredDocument();
- setStructuredDocument(structuredDocument);
-
+ setStructuredDocument(structuredDocument);
+ }
+ finally {
+ endLock();
+ }
return structuredDocument;
}
@@ -537,19 +543,25 @@
}
public void setStructuredDocument(IStructuredDocument newStructuredDocument) {
- IStructuredDocument oldStructuredDocument = super.getStructuredDocument();
- if (newStructuredDocument == oldStructuredDocument)
- return; // noting to do
+ beginLock();
+ try {
+ IStructuredDocument oldStructuredDocument = super.getStructuredDocument();
+ if (newStructuredDocument == oldStructuredDocument)
+ return; // noting to do
- if (oldStructuredDocument != null)
- oldStructuredDocument.removeDocumentChangingListener(this);
- super.setStructuredDocument(newStructuredDocument);
+ if (oldStructuredDocument != null)
+ oldStructuredDocument.removeDocumentChangingListener(this);
+ super.setStructuredDocument(newStructuredDocument);
- if (newStructuredDocument != null) {
- if (newStructuredDocument.getLength() > 0) {
- newModel(new NewDocumentEvent(newStructuredDocument, this));
+ if (newStructuredDocument != null) {
+ if (newStructuredDocument.getLength() > 0) {
+ newModel(new NewDocumentEvent(newStructuredDocument, this));
+ }
+ newStructuredDocument.addDocumentChangingListener(this);
}
- newStructuredDocument.addDocumentChangingListener(this);
+ }
+ finally {
+ endLock();
}
}
diff --git a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/model/AbstractStructuredModel.java b/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/model/AbstractStructuredModel.java
index 4e3fa78..2cb012f 100644
--- a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/model/AbstractStructuredModel.java
+++ b/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/model/AbstractStructuredModel.java
@@ -199,7 +199,7 @@
private Object[] fModelStateListeners;
private boolean fNewState = false;
private URIResolver fResolver;
- IStructuredDocument fStructuredDocument;
+ protected IStructuredDocument fStructuredDocument;
/**
* The time stamp of the underlying resource's modification date, at the
* time this model was created, or the last time it was saved. Note: for
@@ -210,6 +210,7 @@
public long fSynchronizationStamp = IResource.NULL_STAMP;
private boolean reinitializationNeeded;
private Object reinitializeStateData;
+ private ILock fModelOnlyLock = Platform.getJobManager().newLock();
/**
* AbstractStructuredModel constructor comment.
@@ -330,9 +331,11 @@
}
/**
- *
+ * This lock to lock the small bits of data and operations in the models
+ * themselfes. this lock is "shared" with document, so, eventually,
+ * changes can be made safefly from either side.
*/
- private void beginLock() {
+ protected final void beginLock() {
// if we get a different lock object
// than we had before, besure to release
@@ -728,16 +731,27 @@
// we always "get afresh" the lock object from our document,
// just in case the instance of the document changes.
ILock result = null;
- IStructuredDocument doc = getStructuredDocument();
- if (doc instanceof ILockable) {
- // remember, more than one client can get the
- // lock object, its during the aquire that the
- // lock on the thread is obtained.
- result = ((ILockable) doc).getLockObject();
+ IStructuredDocument doc = fStructuredDocument;
+ if (doc != null) {
+ if (doc instanceof ILockable) {
+ // remember, more than one client can get the
+ // lock object, its during the aquire that the
+ // lock on the thread is obtained.
+ result = ((ILockable) doc).getLockObject();
+ }
}
return result;
}
+ /**
+ * This lock is for "large" data strcutured, of the model, such as set/get
+ * the document, releaseing themodel.
+ *
+ */
+ protected final void beginModelOnlyLock() {
+ fModelOnlyLock.acquire();
+ }
+
/**
* Gets the contentTypeDescription.
@@ -810,7 +824,15 @@
public IStructuredDocument getStructuredDocument() {
- return fStructuredDocument;
+ IStructuredDocument result = null;
+ beginModelOnlyLock();
+ try {
+ result = fStructuredDocument;
+ }
+ finally {
+ endModelOnlyLock();
+ }
+ return result;
}
/**
@@ -1041,28 +1063,33 @@
*/
public void releaseFromEdit() {
+ beginModelOnlyLock();
+ try {
+ if (getModelManager() == null) {
+ throw new IllegalStateException(MODEL_MANAGER_NULL); //$NON-NLS-1$
+ }
+ else {
+ // be sure to check the shared state before releasing. (Since
+ // isShared assumes a count
+ // of 1 means not shared ... and we want our '1' to be that
+ // one.)
+ boolean isShared = isShared();
- if (getModelManager() == null) {
- throw new IllegalStateException(MODEL_MANAGER_NULL); //$NON-NLS-1$
+ if (!isShared) {
+ signalPreLifeCycleEventRelease(this);
+ }
+
+ _getModelManager().releaseFromEdit(getId());
+ // if no one else is using us, free up
+ // our resources
+ if (!isShared) {
+ _commonRelease();
+ signalPostLifeCycleListenerRelease(this);
+ }
+ }
}
- else {
- // be sure to check the shared state before releasing. (Since
- // isShared assumes a count
- // of 1 means not shared ... and we want our '1' to be that
- // one.)
- boolean isShared = isShared();
-
- if (!isShared) {
- signalPreLifeCycleEventRelease(this);
- }
-
- _getModelManager().releaseFromEdit(getId());
- // if no one else is using us, free up
- // our resources
- if (!isShared) {
- _commonRelease();
- signalPostLifeCycleListenerRelease(this);
- }
+ finally {
+ endModelOnlyLock();
}
}
@@ -1072,29 +1099,35 @@
*/
public void releaseFromRead() {
+ beginModelOnlyLock();
+ try {
- if (getModelManager() == null) {
- throw new IllegalStateException(MODEL_MANAGER_NULL); //$NON-NLS-1$
+ if (getModelManager() == null) {
+ throw new IllegalStateException(MODEL_MANAGER_NULL); //$NON-NLS-1$
+ }
+ else {
+ // be sure to check the shared state before
+ // releasing. (Since isShared assumes a count
+ // of 1 means not shared ... and we want
+ // our '1' to be that one.)
+ boolean isShared = isShared();
+
+ if (!isShared) {
+ signalPreLifeCycleEventRelease(this);
+ }
+
+ _getModelManager().releaseFromRead(getId());
+ // if no one else is using us, free up
+ // an resources
+ if (!isShared) {
+ // factoryRegistry.release();
+ _commonRelease();
+ signalPostLifeCycleListenerRelease(this);
+ }
+ }
}
- else {
- // be sure to check the shared state before
- // releasing. (Since isShared assumes a count
- // of 1 means not shared ... and we want
- // our '1' to be that one.)
- boolean isShared = isShared();
-
- if (!isShared) {
- signalPreLifeCycleEventRelease(this);
- }
-
- _getModelManager().releaseFromRead(getId());
- // if no one else is using us, free up
- // an resources
- if (!isShared) {
- // factoryRegistry.release();
- _commonRelease();
- signalPostLifeCycleListenerRelease(this);
- }
+ finally {
+ endModelOnlyLock();
}
}
@@ -1505,42 +1538,57 @@
public void setStructuredDocument(IStructuredDocument newStructuredDocument) {
+ beginModelOnlyLock();
+ try {
+ boolean lifeCycleNotification = false;
+ if (fStructuredDocument != null) {
+ fStructuredDocument.removeDocumentChangedListener(fDirtyStateWatcher);
+ fStructuredDocument.removeDocumentAboutToChangeListener(fDocumentToModelNotifier);
+ fStructuredDocument.removeDocumentChangedListener(fDocumentToModelNotifier);
+ // prechange notificaiton
+ lifeCycleNotification = true;
+ ModelLifecycleEvent modelLifecycleEvent = new DocumentChanged(ModelLifecycleEvent.PRE_EVENT, this, fStructuredDocument, newStructuredDocument);
+ signalLifecycleEvent(modelLifecycleEvent);
+ }
- boolean lifeCycleNotification = false;
- if (fStructuredDocument != null) {
- fStructuredDocument.removeDocumentChangedListener(fDirtyStateWatcher);
- fStructuredDocument.removeDocumentAboutToChangeListener(fDocumentToModelNotifier);
- fStructuredDocument.removeDocumentChangedListener(fDocumentToModelNotifier);
- // prechange notificaiton
- lifeCycleNotification = true;
- ModelLifecycleEvent modelLifecycleEvent = new DocumentChanged(ModelLifecycleEvent.PRE_EVENT, this, fStructuredDocument, newStructuredDocument);
- signalLifecycleEvent(modelLifecycleEvent);
+ // hold for life cycle notification
+ IStructuredDocument previousDocument = fStructuredDocument;
+ // the actual change
+ fStructuredDocument = newStructuredDocument;
+
+
+ // at the super class level, we'll listen for structuredDocument
+ // changes
+ // so we can set our dirty state flag
+ if (fStructuredDocument != null) {
+ fStructuredDocument.addDocumentChangedListener(fDirtyStateWatcher);
+ fStructuredDocument.addDocumentAboutToChangeListener(fDocumentToModelNotifier);
+ fStructuredDocument.addDocumentChangedListener(fDocumentToModelNotifier);
+ }
+
+ if (lifeCycleNotification) {
+ // post change notification
+ ModelLifecycleEvent modelLifecycleEvent = new DocumentChanged(ModelLifecycleEvent.POST_EVENT, this, previousDocument, newStructuredDocument);
+ signalLifecycleEvent(modelLifecycleEvent);
+ }
}
-
- // hold for life cycle notification
- IStructuredDocument previousDocument = fStructuredDocument;
- // the actual change
- fStructuredDocument = newStructuredDocument;
-
-
- // at the super class level, we'll listen for structuredDocument
- // changes
- // so we can set our dirty state flag
- if (fStructuredDocument != null) {
- fStructuredDocument.addDocumentChangedListener(fDirtyStateWatcher);
- fStructuredDocument.addDocumentAboutToChangeListener(fDocumentToModelNotifier);
- fStructuredDocument.addDocumentChangedListener(fDocumentToModelNotifier);
- }
-
- if (lifeCycleNotification) {
- // post change notification
- ModelLifecycleEvent modelLifecycleEvent = new DocumentChanged(ModelLifecycleEvent.POST_EVENT, this, previousDocument, newStructuredDocument);
- signalLifecycleEvent(modelLifecycleEvent);
+ finally {
+ endModelOnlyLock();
}
}
/**
+ * This lock is for "large" data strcutured, of the model, such as set/get
+ * the document, releaseing themodel.
+ *
+ */
+ protected final void endModelOnlyLock() {
+ fModelOnlyLock.release();
+ }
+
+
+ /**
* Insert the method's description here. Creation date: (9/7/2001 2:30:26
* PM)
*
diff --git a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/provisional/text/IStructuredDocument.java b/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/provisional/text/IStructuredDocument.java
index 14bc3fa..9cff78e 100644
--- a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/provisional/text/IStructuredDocument.java
+++ b/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/provisional/text/IStructuredDocument.java
@@ -19,7 +19,6 @@
import org.eclipse.wst.sse.core.internal.provisional.document.IEncodedDocument;
import org.eclipse.wst.sse.core.internal.provisional.events.IModelAboutToBeChangedListener;
import org.eclipse.wst.sse.core.internal.provisional.events.IStructuredDocumentListener;
-import org.eclipse.wst.sse.core.internal.provisional.events.NewDocumentEvent;
import org.eclipse.wst.sse.core.internal.provisional.events.StructuredDocumentEvent;
import org.eclipse.wst.sse.core.internal.undo.IStructuredTextUndoManager;
@@ -212,7 +211,7 @@
*
* The setText method replaces all text in the model.
*/
- NewDocumentEvent setText(Object requester, String allText);
+ StructuredDocumentEvent setText(Object requester, String allText);
void setUndoManager(IStructuredTextUndoManager undoManager);
diff --git a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/text/BasicStructuredDocument.java b/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/text/BasicStructuredDocument.java
index df613c5..5a3e195 100644
--- a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/text/BasicStructuredDocument.java
+++ b/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/text/BasicStructuredDocument.java
@@ -53,7 +53,6 @@
import org.eclipse.wst.sse.core.internal.provisional.events.AboutToBeChangedEvent;
import org.eclipse.wst.sse.core.internal.provisional.events.IModelAboutToBeChangedListener;
import org.eclipse.wst.sse.core.internal.provisional.events.IStructuredDocumentListener;
-import org.eclipse.wst.sse.core.internal.provisional.events.NewDocumentEvent;
import org.eclipse.wst.sse.core.internal.provisional.events.NoChangeEvent;
import org.eclipse.wst.sse.core.internal.provisional.events.RegionChangedEvent;
import org.eclipse.wst.sse.core.internal.provisional.events.RegionsReplacedEvent;
@@ -477,34 +476,6 @@
}
}
- private void _fireEvent(Object[] listeners, NewDocumentEvent event) {
- // we must assign listeners to local variable, since the add and
- // remove
- // listner
- // methods can change the actual instance of the listener array from
- // another thread
- if (listeners != null) {
- Object[] holdListeners = listeners;
- for (int i = 0; i < holdListeners.length; i++) {
- if (Debug.perfTest || Debug.perfTestStructuredDocumentEventOnly) {
- startTime = System.currentTimeMillis();
- }
- // safeguard from listeners that throw exceptions
- try {
- // this is a safe cast, since addListners requires a
- // IStructuredDocumentListener
- ((IStructuredDocumentListener) holdListeners[i]).newModel(event);
- }
- catch (Exception exception) {
- Logger.logException(exception);
- }
- if (Debug.perfTest || Debug.perfTestStructuredDocumentEventOnly) {
- long stopTime = System.currentTimeMillis();
- System.out.println("\n\t\t\t\t IStructuredDocument::fireStructuredDocumentEvent. Time was " + (stopTime - startTime) + " msecs to fire NewModelEvent to instance of " + holdListeners[i].getClass()); //$NON-NLS-2$//$NON-NLS-1$
- }
- }
- }
- }
private void _fireEvent(Object[] listeners, NoChangeEvent event) {
// we must assign listeners to local variable, since the add and
@@ -1179,15 +1150,6 @@
// _clearDocumentEvent();
}
- private void fireStructuredDocumentEvent(NewDocumentEvent event) {
- _fireEvent(fStructuredDocumentChangingListeners, event);
- _fireEvent(fStructuredDocumentChangedListeners, event);
- _fireDocumentChanged(fPrenotifiedDocumentListeners, event);
- notifyDocumentPartitionersDocumentChanged(event);
- _fireDocumentChanged(fDocumentListeners, event);
- _clearDocumentEvent();
- }
-
private void fireStructuredDocumentEvent(NoChangeEvent event) {
_fireEvent(fStructuredDocumentChangingListeners, event);
_fireEvent(fStructuredDocumentChangedListeners, event);
@@ -1719,15 +1681,21 @@
* <br>
* eg.
* <p>
- * <br>eg.
- * <pre><html>[<head></head>]</html> returns <head>,</head></pre>
- * <pre><ht[ml><head></he]ad></html> returns <html>,<head>,</head></pre>
+ * <br>
+ * eg.
*
* <pre>
- * <html>[<head></head>]</html> returns <head>,</head>
+ * <html>[<head></head>]</html> returns <head>,</head>
* </pre>
* <pre>
- * <ht[ml><head></he]ad></html> returns <html>,<head>,</head>
+ * <ht[ml><head></he]ad></html> returns <html>,<head>,</head>
+ * </pre>
+ *
+ * <pre>
+ * <html>[<head></head>]</html> returns <head>,</head>
+ * </pre>
+ * <pre>
+ * <ht[ml><head></he]ad></html> returns <html>,<head>,</head>
* </pre>
*
* </p>
@@ -1757,7 +1725,7 @@
}
// need to add that last end region
// can be null in the case of an empty document
- if(endRegion != null)
+ if (endRegion != null)
results.add(endRegion);
}
finally {
@@ -2536,40 +2504,12 @@
/**
* One of the APIs to manipulate the IStructuredDocument in terms of text.
*/
- public NewDocumentEvent setText(Object requester, String theString) {
+ public StructuredDocumentEvent setText(Object requester, String theString) {
- NewDocumentEvent result = null;
- stopPostNotificationProcessing();
- clearReadOnly();
- // Note: event must be computed before 'fire' method called
- // Note: judging from code in AbstractDocument, apparently the
- // length in this event is the current length of
- // the document.
- fDocumentEvent = new DocumentEvent(this, 0, length(), theString);
- fireDocumentAboutToChanged();
+ StructuredDocumentEvent result = null;
- acquireLock();
-
- try {
- getStore().set(theString);
- getTracker().set(theString);
- //
- CharSequenceReader subSetTextStoreReader = new CharSequenceReader((CharSequence) getStore(), 0, getStore().getLength());
- resetParser(subSetTextStoreReader, 0);
- //
- setCachedDocumentRegion(getParser().getDocumentRegions());
- // when starting afresh, our cachedNode should be our firstNode,
- // so be sure to initialize the firstNode and lastNode
- initializeFirstAndLastDocumentRegion();
- StructuredDocumentRegionIterator.setParentDocument(getCachedDocumentRegion(), this);
- }
- finally {
- releaseLock();
- }
-
- result = new NewDocumentEvent(this, requester);
- fireStructuredDocumentEvent(result);
- resumePostNotificationProcessing();
+ result = replaceText(requester, 0, getLength(), theString, true);
+
return result;
}
diff --git a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/text/JobSafeStructuredDocument.java b/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/text/JobSafeStructuredDocument.java
index 3dc85a9..41ab2bb 100644
--- a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/text/JobSafeStructuredDocument.java
+++ b/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/text/JobSafeStructuredDocument.java
@@ -25,7 +25,7 @@
public class JobSafeStructuredDocument extends BasicStructuredDocument implements IExecutionDelegatable, ILockable {
private IExecutionDelegate fExecutionDelegate;
- private ILock fLockable = null;
+ private ILock fLockable = Platform.getJobManager().newLock();
public JobSafeStructuredDocument() {
super();
@@ -55,9 +55,6 @@
*/
public ILock getLockObject() {
- if (fLockable == null) {
- fLockable = Platform.getJobManager().newLock();
- }
return fLockable;
}
@@ -127,8 +124,8 @@
}
- public NewDocumentEvent setText(final Object requester, final String theString) {
- NewDocumentEvent event = null;
+ public StructuredDocumentEvent setText(final Object requester, final String theString) {
+ StructuredDocumentEvent event = null;
if (getExecutionDelegate() == null) {
// if the delegate has not been set, we execute on current
// thread, like "normal". This is the case for normal
diff --git a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/text/MinimalDocument.java b/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/text/MinimalDocument.java
index 1c023ff..a3d63f8 100644
--- a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/text/MinimalDocument.java
+++ b/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/text/MinimalDocument.java
@@ -28,7 +28,6 @@
import org.eclipse.wst.sse.core.internal.ltk.parser.RegionParser;
import org.eclipse.wst.sse.core.internal.provisional.events.IModelAboutToBeChangedListener;
import org.eclipse.wst.sse.core.internal.provisional.events.IStructuredDocumentListener;
-import org.eclipse.wst.sse.core.internal.provisional.events.NewDocumentEvent;
import org.eclipse.wst.sse.core.internal.provisional.events.StructuredDocumentEvent;
import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocument;
import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegion;
@@ -384,7 +383,7 @@
throw new NotImplementedException("intentionally not implemented"); //$NON-NLS-1$
}
- public NewDocumentEvent setText(Object requester, String allText) {
+ public StructuredDocumentEvent setText(Object requester, String allText) {
throw new NotImplementedException("intentionally not implemented"); //$NON-NLS-1$
}
diff --git a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/document/DOMModelImpl.java b/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/document/DOMModelImpl.java
index 60c2c1e..d977ee2 100644
--- a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/document/DOMModelImpl.java
+++ b/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/document/DOMModelImpl.java
@@ -155,7 +155,8 @@
// end lock before noticiation loop, since directly or indirectly
// we may be "called from foriegn code" during notification.
endLock();
- // we null out here to avoid spurious"warning" message while debug tracing is enabled
+ // we null out here to avoid spurious"warning" message while debug
+ // tracing is enabled
fLockObject = null;
// the notifier is what controls adaper notification, which
// should be sent out before the 'modelChanged' event.
@@ -549,8 +550,15 @@
if (structuredDocument == null)
return;
// this should not happen, but for the case
- if (structuredDocument != getStructuredDocument())
+ if (fStructuredDocument != null && fStructuredDocument != structuredDocument)
setStructuredDocument(structuredDocument);
+
+ internalSetNewDocument(structuredDocument);
+ }
+
+ private void internalSetNewDocument(IStructuredDocument structuredDocument) {
+ if (structuredDocument == null)
+ return;
IStructuredDocumentRegionList flatNodes = structuredDocument.getRegionList();
if ((flatNodes == null) || (flatNodes.getLength() == 0)) {
return;
@@ -598,7 +606,6 @@
// ignore refresh
this.refresh = false;
}
- // checkForReinit();
}
/**
@@ -853,17 +860,21 @@
* @param structuredDocument
*/
public void setStructuredDocument(IStructuredDocument structuredDocument) {
- IStructuredDocument oldStructuredDocument = super.getStructuredDocument();
- if (structuredDocument == oldStructuredDocument)
- return; // nothing to do
- if (oldStructuredDocument != null)
- oldStructuredDocument.removeDocumentChangingListener(this);
- super.setStructuredDocument(structuredDocument);
- if (structuredDocument != null) {
- if (structuredDocument.getLength() > 0) {
- newModel(new NewDocumentEvent(structuredDocument, this));
+ beginLock();
+ try {
+ IStructuredDocument oldStructuredDocument = super.getStructuredDocument();
+ if (structuredDocument == oldStructuredDocument)
+ return; // nothing to do
+ if (oldStructuredDocument != null)
+ oldStructuredDocument.removeDocumentChangingListener(this);
+ super.setStructuredDocument(structuredDocument);
+ if (structuredDocument != null) {
+ internalSetNewDocument(structuredDocument);
+ structuredDocument.addDocumentChangingListener(this);
}
- structuredDocument.addDocumentChangingListener(this);
+ }
+ finally {
+ endLock();
}
}