[81690] BasicStructuredDocument.get(int, int) throws Error
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 c3fc646..ec17ad6 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
@@ -1272,15 +1272,16 @@
offset = moreOffset;
}
else {
- // should never happen
- throw new Error();
+ // can happen if myLength is 0.
+ // no adjustment possible.
+ result = new String();
}
}
}
- // if ((0 > offset) || (0 > length) || (offset + length > myLength))
- // throw new BadLocationException();
- result = getStore().get(offset, length);
+ if (result == null) {
+ result = getStore().get(offset, length);
+ }
return result;
}
diff --git a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/document/XMLModelImpl.java b/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/document/XMLModelImpl.java
index 88da683..de19c94 100644
--- a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/document/XMLModelImpl.java
+++ b/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/document/XMLModelImpl.java
@@ -123,7 +123,7 @@
* calling aboutToChangeModel first.
*
* In the case of embedded calls, the notification is just sent once.
- *
+ *
*/
public void changedModel() {
// NOTE: the order of 'changedModel' and 'endChanging' is significant.
@@ -374,7 +374,8 @@
parent = child;
child = (IDOMNode) parent.getFirstChild();
}
- } else {
+ }
+ else {
// search from the last
IDOMNode child = (IDOMNode) this.document.getLastChild();
while (child != null) {
@@ -452,9 +453,11 @@
this.document.removeChildNodes();
try {
parser.replaceStructuredDocumentRegions(getStructuredDocument().getRegionList(), null);
- } catch (Exception ex) {
+ }
+ catch (Exception ex) {
Logger.logException(ex);
- } finally {
+ }
+ finally {
setActive(null);
if (!isChanging)
notifier.endChanging();
@@ -550,25 +553,28 @@
if (structuredDocument != getStructuredDocument())
setStructuredDocument(structuredDocument);
IStructuredDocumentRegionList flatNodes = structuredDocument.getRegionList();
- if (flatNodes == null)
+ if ((flatNodes == null) || (flatNodes.getLength() == 0)) {
return;
+ }
if (this.document == null)
return; // being constructed
XMLModelUpdater updater = getActiveUpdater();
if (updater != null) { // being updated
try {
updater.replaceStructuredDocumentRegions(flatNodes, null);
- } catch (Exception ex) {
+ }
+ catch (Exception ex) {
Logger.logException(ex);
this.refresh = true;
handleRefresh();
- } finally {
+ }
+ finally {
setActive(null);
}
- // // for new model, we might need to
- // // re-init, e.g. if someone calls setText
- // // on an existing model
- // checkForReinit();
+ // // for new model, we might need to
+ // // re-init, e.g. if someone calls setText
+ // // on an existing model
+ // checkForReinit();
return;
}
XMLModelNotifier notifier = getModelNotifier();
@@ -580,10 +586,12 @@
this.document.removeChildNodes();
try {
parser.replaceStructuredDocumentRegions(flatNodes, null);
- } catch (Exception ex) {
+ }
+ catch (Exception ex) {
Logger.logException(ex);
// meaningless to refresh, because the result might be the same
- } finally {
+ }
+ finally {
setActive(null);
if (!isChanging) {
getModelNotifier().endChanging();
@@ -591,7 +599,7 @@
// ignore refresh
this.refresh = false;
}
- // checkForReinit();
+ // checkForReinit();
}
/**
@@ -602,15 +610,17 @@
// cleanup updater staffs
try {
updater.replaceStructuredDocumentRegions(null, null);
- } catch (Exception ex) {
+ }
+ catch (Exception ex) {
Logger.logException(ex);
this.refresh = true;
handleRefresh();
- } finally {
+ }
+ finally {
setActive(null);
}
// I guess no chanage means the model could not need re-init
- //checkForReinit();
+ // checkForReinit();
return;
}
}
@@ -630,18 +640,21 @@
if (updater != null) { // being updated
try {
updater.replaceStructuredDocumentRegions(newStructuredDocumentRegions, oldStructuredDocumentRegions);
- } catch (Exception ex) {
+ }
+ catch (Exception ex) {
if (ex.getClass().equals(StructuredDocumentRegionManagementException.class)) {
Logger.traceException(TRACE_PARSER_MANAGEMENT_EXCEPTION, ex);
- } else {
+ }
+ else {
Logger.logException(ex);
}
this.refresh = true;
handleRefresh();
- } finally {
+ }
+ finally {
setActive(null);
}
- //checkForReinit();
+ // checkForReinit();
return;
}
XMLModelNotifier notifier = getModelNotifier();
@@ -652,11 +665,13 @@
setActive(parser);
try {
parser.replaceStructuredDocumentRegions(newStructuredDocumentRegions, oldStructuredDocumentRegions);
- } catch (Exception ex) {
+ }
+ catch (Exception ex) {
Logger.logException(ex);
this.refresh = true;
handleRefresh();
- } finally {
+ }
+ finally {
setActive(null);
if (!isChanging) {
notifier.endChanging();
@@ -685,14 +700,16 @@
if (updater != null) { // being updated
try {
updater.changeRegion(flatNode, region);
- } catch (Exception ex) {
+ }
+ catch (Exception ex) {
Logger.logException(ex);
this.refresh = true;
handleRefresh();
- } finally {
+ }
+ finally {
setActive(null);
}
- // checkForReinit();
+ // checkForReinit();
return;
}
XMLModelNotifier notifier = getModelNotifier();
@@ -703,18 +720,20 @@
setActive(parser);
try {
parser.changeRegion(flatNode, region);
- } catch (Exception ex) {
+ }
+ catch (Exception ex) {
Logger.logException(ex);
this.refresh = true;
handleRefresh();
- } finally {
+ }
+ finally {
setActive(null);
if (!isChanging) {
notifier.endChanging();
handleRefresh();
}
}
- // checkForReinit();
+ // checkForReinit();
}
/**
@@ -737,14 +756,16 @@
if (updater != null) { // being updated
try {
updater.replaceRegions(flatNode, newRegions, oldRegions);
- } catch (Exception ex) {
+ }
+ catch (Exception ex) {
Logger.logException(ex);
this.refresh = true;
handleRefresh();
- } finally {
+ }
+ finally {
setActive(null);
}
- // checkForReinit();
+ // checkForReinit();
return;
}
XMLModelNotifier notifier = getModelNotifier();
@@ -755,25 +776,27 @@
setActive(parser);
try {
parser.replaceRegions(flatNode, newRegions, oldRegions);
- } catch (Exception ex) {
+ }
+ catch (Exception ex) {
Logger.logException(ex);
this.refresh = true;
handleRefresh();
- } finally {
+ }
+ finally {
setActive(null);
if (!isChanging) {
notifier.endChanging();
handleRefresh();
}
}
- // checkForReinit();
+ // checkForReinit();
}
/**
*/
public void releaseFromEdit() {
if (!isShared()) {
- //this.document.releaseStyleSheets();
+ // this.document.releaseStyleSheets();
this.document.releaseDocumentType();
}
super.releaseFromEdit();
@@ -783,7 +806,7 @@
*/
public void releaseFromRead() {
if (!isShared()) {
- //this.document.releaseStyleSheets();
+ // this.document.releaseStyleSheets();
this.document.releaseDocumentType();
}
super.releaseFromRead();
@@ -798,7 +821,8 @@
// (and not used)
if (active == null) {
document.activateTagNameCache(true);
- } else {
+ }
+ else {
document.activateTagNameCache(false);
}