[109942] NPE during JSP Editing while quickly coping/pasting code
diff --git a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/document/AttrImpl.java b/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/document/AttrImpl.java
index 1b7b25b..ab29bca 100644
--- a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/document/AttrImpl.java
+++ b/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/document/AttrImpl.java
@@ -356,15 +356,26 @@
return this.valueRegion;
}
+ /**
+ * ISSUE: what should behavior be if this.value == null?
+ * It's an "error" to be in that state, but seems to
+ * occur relatively easily ... probably due to threading
+ * bugs ... but this just shows its needs to be spec'd.
+ *
+ */
public int getValueRegionStartOffset() {
if (this.ownerElement == null)
return 0;
// assuming the firstStructuredDocumentRegion is the one that contains
- // attributes
- IStructuredDocumentRegion flatNode = this.ownerElement.getFirstStructuredDocumentRegion();
- if (flatNode == null)
+ // the valueRegion -- should make smarter?
+ IStructuredDocumentRegion structuredDocumentRegion = this.ownerElement.getFirstStructuredDocumentRegion();
+ if (structuredDocumentRegion == null)
return 0;
- return flatNode.getStartOffset(this.valueRegion);
+ // ensure we never pass null to getStartOffset.
+ if (this.valueRegion == null) {
+ return 0;
+ }
+ return structuredDocumentRegion.getStartOffset(this.valueRegion);
}
public String getValueRegionText() {