[108325] Typing enters text "in place" if exception occurs
diff --git a/bundles/org.eclipse.jst.jsp.core/src/org/eclipse/jst/jsp/core/internal/parser/JSPSourceParser.java b/bundles/org.eclipse.jst.jsp.core/src/org/eclipse/jst/jsp/core/internal/parser/JSPSourceParser.java
index 2183e8b..8ba4ecb 100644
--- a/bundles/org.eclipse.jst.jsp.core/src/org/eclipse/jst/jsp/core/internal/parser/JSPSourceParser.java
+++ b/bundles/org.eclipse.jst.jsp.core/src/org/eclipse/jst/jsp/core/internal/parser/JSPSourceParser.java
@@ -13,7 +13,6 @@
 import java.util.Iterator;
 import java.util.List;
 
-import org.eclipse.jst.jsp.core.internal.Logger;
 import org.eclipse.jst.jsp.core.internal.contentmodel.tld.provisional.JSP12TLDNames;
 import org.eclipse.jst.jsp.core.internal.parser.internal.JSPTokenizer;
 import org.eclipse.jst.jsp.core.internal.provisional.JSP12Namespace;
@@ -92,7 +91,7 @@
 					}
 				}
 				catch (StringIndexOutOfBoundsException sioobExc) {
-					//do nothing
+					// do nothing
 				}
 			}
 			// could test > 1, but since we only care if there are 5 (<,
@@ -247,7 +246,7 @@
 					currentNode.setLength(region.getStart() + region.getLength() - currentNode.getStart());
 					region.adjustStart(-currentNode.getStart());
 					// DW, 4/16/2003 token regions no longer have parents
-					//region.setParent(currentNode);
+					// region.setParent(currentNode);
 					if (region instanceof ITextRegionContainer) {
 						((ITextRegionContainer) region).setParent(currentNode);
 					}
@@ -276,7 +275,7 @@
 					region.adjustStart(-currentNode.getStart());
 					currentNode.addRegion(region);
 					// DW, 4/16/2003 token regions no longer have parents
-					//region.setParent(currentNode);
+					// region.setParent(currentNode);
 					if (region instanceof ITextRegionContainer) {
 						((ITextRegionContainer) region).setParent(currentNode);
 					}
@@ -284,10 +283,7 @@
 				}
 			}
 			// the following contexts OPEN new StructuredDocumentRegions
-			else if ((currentNode != null && currentNode.isEnded()) || (type == DOMRegionContext.XML_CONTENT) || (type == DOMRegionContext.XML_CHAR_REFERENCE) || (type == DOMRegionContext.XML_ENTITY_REFERENCE)
-						|| (type == DOMRegionContext.XML_PI_OPEN) || (type == DOMRegionContext.XML_TAG_OPEN) || (type == DOMRegionContext.XML_END_TAG_OPEN) || (type == DOMRegionContext.XML_COMMENT_OPEN) || (type == DOMRegionContext.XML_CDATA_OPEN)
-						|| (type == DOMRegionContext.XML_DECLARATION_OPEN) || (type == DOMJSPRegionContexts.JSP_COMMENT_OPEN) || (type == DOMJSPRegionContexts.JSP_DECLARATION_OPEN) || (type == DOMJSPRegionContexts.JSP_DIRECTIVE_OPEN)
-						|| (type == DOMJSPRegionContexts.JSP_EXPRESSION_OPEN) || (type == DOMJSPRegionContexts.JSP_SCRIPTLET_OPEN) || (type == DOMJSPRegionContexts.JSP_CLOSE) || type == DOMJSPRegionContexts.JSP_EL_OPEN) {
+			else if ((currentNode != null && currentNode.isEnded()) || (type == DOMRegionContext.XML_CONTENT) || (type == DOMRegionContext.XML_CHAR_REFERENCE) || (type == DOMRegionContext.XML_ENTITY_REFERENCE) || (type == DOMRegionContext.XML_PI_OPEN) || (type == DOMRegionContext.XML_TAG_OPEN) || (type == DOMRegionContext.XML_END_TAG_OPEN) || (type == DOMRegionContext.XML_COMMENT_OPEN) || (type == DOMRegionContext.XML_CDATA_OPEN) || (type == DOMRegionContext.XML_DECLARATION_OPEN) || (type == DOMJSPRegionContexts.JSP_COMMENT_OPEN) || (type == DOMJSPRegionContexts.JSP_DECLARATION_OPEN) || (type == DOMJSPRegionContexts.JSP_DIRECTIVE_OPEN) || (type == DOMJSPRegionContexts.JSP_EXPRESSION_OPEN) || (type == DOMJSPRegionContexts.JSP_SCRIPTLET_OPEN) || (type == DOMJSPRegionContexts.JSP_CLOSE) || type == DOMJSPRegionContexts.JSP_EL_OPEN) {
 				if (currentNode != null) {
 					// ensure that any existing node is at least terminated
 					if (!currentNode.isEnded()) {
@@ -308,7 +304,7 @@
 				currentNode.setLength(region.getStart() + region.getLength() - currentNode.getStart());
 				region.adjustStart(-currentNode.getStart());
 				// DW, 4/16/2003 token regions no longer have parents
-				//region.setParent(currentNode);
+				// region.setParent(currentNode);
 				if (region instanceof ITextRegionContainer) {
 					((ITextRegionContainer) region).setParent(currentNode);
 				}
@@ -316,29 +312,25 @@
 			}
 			// the following contexts NEITHER open nor close
 			// StructuredDocumentRegions; just add to them
-			else if ((type == DOMRegionContext.XML_TAG_NAME) || (type == DOMRegionContext.XML_TAG_ATTRIBUTE_NAME) || (type == DOMRegionContext.XML_TAG_ATTRIBUTE_EQUALS) || (type == DOMRegionContext.XML_TAG_ATTRIBUTE_VALUE)
-						|| (type == DOMRegionContext.XML_COMMENT_TEXT) || (type == DOMRegionContext.XML_PI_CONTENT) || (type == DOMRegionContext.XML_DOCTYPE_INTERNAL_SUBSET) || (type == DOMJSPRegionContexts.JSP_COMMENT_TEXT)
-						|| (type == DOMJSPRegionContexts.JSP_ROOT_TAG_NAME) || (type == DOMJSPRegionContexts.JSP_DIRECTIVE_NAME) || type == DOMJSPRegionContexts.JSP_EL_CONTENT) {
+			else if ((type == DOMRegionContext.XML_TAG_NAME) || (type == DOMRegionContext.XML_TAG_ATTRIBUTE_NAME) || (type == DOMRegionContext.XML_TAG_ATTRIBUTE_EQUALS) || (type == DOMRegionContext.XML_TAG_ATTRIBUTE_VALUE) || (type == DOMRegionContext.XML_COMMENT_TEXT) || (type == DOMRegionContext.XML_PI_CONTENT) || (type == DOMRegionContext.XML_DOCTYPE_INTERNAL_SUBSET) || (type == DOMJSPRegionContexts.JSP_COMMENT_TEXT) || (type == DOMJSPRegionContexts.JSP_ROOT_TAG_NAME) || (type == DOMJSPRegionContexts.JSP_DIRECTIVE_NAME) || type == DOMJSPRegionContexts.JSP_EL_CONTENT) {
 				currentNode.addRegion(region);
 				currentNode.setLength(region.getStart() + region.getLength() - currentNode.getStart());
 				region.adjustStart(-currentNode.getStart());
 				// DW, 4/16/2003 token regions no longer have parents
-				//region.setParent(currentNode);
+				// region.setParent(currentNode);
 				if (region instanceof ITextRegionContainer) {
 					((ITextRegionContainer) region).setParent(currentNode);
 				}
 			}
 			// the following contexts close off StructuredDocumentRegions
 			// cleanly
-			else if ((type == DOMRegionContext.XML_PI_CLOSE) || (type == DOMRegionContext.XML_TAG_CLOSE) || (type == DOMRegionContext.XML_EMPTY_TAG_CLOSE) || (type == DOMRegionContext.XML_COMMENT_CLOSE) || (type == DOMRegionContext.XML_CDATA_CLOSE)
-						|| (type == DOMJSPRegionContexts.JSP_CLOSE) || (type == DOMJSPRegionContexts.JSP_COMMENT_CLOSE) || (type == DOMJSPRegionContexts.JSP_DIRECTIVE_CLOSE) || (type == DOMRegionContext.XML_DECLARATION_CLOSE)
-						|| type == DOMJSPRegionContexts.JSP_EL_CLOSE) {
+			else if ((type == DOMRegionContext.XML_PI_CLOSE) || (type == DOMRegionContext.XML_TAG_CLOSE) || (type == DOMRegionContext.XML_EMPTY_TAG_CLOSE) || (type == DOMRegionContext.XML_COMMENT_CLOSE) || (type == DOMRegionContext.XML_CDATA_CLOSE) || (type == DOMJSPRegionContexts.JSP_CLOSE) || (type == DOMJSPRegionContexts.JSP_COMMENT_CLOSE) || (type == DOMJSPRegionContexts.JSP_DIRECTIVE_CLOSE) || (type == DOMRegionContext.XML_DECLARATION_CLOSE) || type == DOMJSPRegionContexts.JSP_EL_CLOSE) {
 				currentNode.setEnded(true);
 				currentNode.setLength(region.getStart() + region.getLength() - currentNode.getStart());
 				currentNode.addRegion(region);
 				region.adjustStart(-currentNode.getStart());
 				// DW, 4/16/2003 token regions no longer have parents
-				//region.setParent(currentNode);
+				// region.setParent(currentNode);
 				if (region instanceof ITextRegionContainer) {
 					((ITextRegionContainer) region).setParent(currentNode);
 				}
@@ -355,7 +347,7 @@
 					// but for now, will (re)set each time through
 					container.setParent(currentNode);
 					// DW, 4/16/2003 token regions no longer have parents
-					//region.setParent(container);
+					// region.setParent(container);
 					region.adjustStart(container.getLength() - region.getStart());
 				}
 				currentNode.getLastRegion().adjustLength(region.getLength());
@@ -390,7 +382,7 @@
 				currentNode.setLength(region.getStart() + region.getLength() - currentNode.getStart());
 				region.adjustStart(-currentNode.getStart());
 				// DW, 4/16/2003 token regions no longer have parents
-				//region.setParent(currentNode);
+				// region.setParent(currentNode);
 				if (region instanceof ITextRegionContainer) {
 					((ITextRegionContainer) region).setParent(currentNode);
 				}
@@ -406,8 +398,7 @@
 			// be more readable if that is handled here as well, but the
 			// current layout
 			// ensures that they open StructuredDocumentRegions the same way
-			if ((type == DOMRegionContext.XML_CONTENT) || (type == DOMRegionContext.XML_CHAR_REFERENCE) || (type == DOMRegionContext.XML_ENTITY_REFERENCE) || (type == DOMJSPRegionContexts.JSP_DECLARATION_OPEN)
-						|| (type == DOMJSPRegionContexts.JSP_EXPRESSION_OPEN) || (type == DOMJSPRegionContexts.JSP_SCRIPTLET_OPEN) || (type == DOMJSPRegionContexts.JSP_CONTENT) || (type == DOMJSPRegionContexts.JSP_CLOSE)) {
+			if ((type == DOMRegionContext.XML_CONTENT) || (type == DOMRegionContext.XML_CHAR_REFERENCE) || (type == DOMRegionContext.XML_ENTITY_REFERENCE) || (type == DOMJSPRegionContexts.JSP_DECLARATION_OPEN) || (type == DOMJSPRegionContexts.JSP_EXPRESSION_OPEN) || (type == DOMJSPRegionContexts.JSP_SCRIPTLET_OPEN) || (type == DOMJSPRegionContexts.JSP_CONTENT) || (type == DOMJSPRegionContexts.JSP_CLOSE)) {
 				currentNode.setEnded(true);
 			}
 			if (headNode == null && currentNode != null) {
@@ -415,12 +406,7 @@
 			}
 		}
 		if (currentNode != null) {
-			try {
-				fireNodeParsed(currentNode);
-			}
-			catch (Exception e) {
-				Logger.log(Logger.ERROR, e.getMessage());
-			}
+			fireNodeParsed(currentNode);
 			currentNode.setPrevious(lastNode);
 		}
 		primReset();
diff --git a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/parser/XMLSourceParser.java b/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/parser/XMLSourceParser.java
index bbcb27d..69fc6d5 100644
--- a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/parser/XMLSourceParser.java
+++ b/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/parser/XMLSourceParser.java
@@ -112,9 +112,21 @@
 	}
 
 	protected void fireNodeParsed(IStructuredDocumentRegion fCurrentNode) {
-		if (fCurrentNode != null && fStructuredDocumentRegionHandlers != null) {
-			for (int i = 0; i < fStructuredDocumentRegionHandlers.size(); i++)
-				((StructuredDocumentRegionHandler) fStructuredDocumentRegionHandlers.get(i)).nodeParsed(fCurrentNode);
+		// never let an Exceptions from foreign code interfere with completion
+		// of parsing. To get an exception here is definitely a program error
+		// somewhere,
+		// we can't afford to interrupt the flow of control. or backwards
+		// typing can result!
+		// 
+		// 
+		try {
+			if (fCurrentNode != null && fStructuredDocumentRegionHandlers != null) {
+				for (int i = 0; i < fStructuredDocumentRegionHandlers.size(); i++)
+					((StructuredDocumentRegionHandler) fStructuredDocumentRegionHandlers.get(i)).nodeParsed(fCurrentNode);
+			}
+		}
+		catch (Exception e) {
+			Logger.log(Logger.ERROR, e.getMessage());
 		}
 	}
 
@@ -125,7 +137,8 @@
 			if (marker.isCaseSensitive()) {
 				if (marker.getTagName().equals(tagName))
 					return marker;
-			} else {
+			}
+			else {
 				if (marker.getTagName().equalsIgnoreCase(tagName))
 					return marker;
 			}
@@ -151,7 +164,7 @@
 				stopTime = System.currentTimeMillis();
 				System.out.println(" -- creating nodes of IStructuredDocument -- "); //$NON-NLS-1$
 				System.out.println(" Time parse and init all regions: " + (stopTime - startTime) + " (msecs)"); //$NON-NLS-2$//$NON-NLS-1$
-				//System.out.println(" for " + fRegions.size() + "
+				// System.out.println(" for " + fRegions.size() + "
 				// Regions");//$NON-NLS-2$//$NON-NLS-1$
 				System.out.println("      and " + _countNodes(headnode) + " Nodes"); //$NON-NLS-2$//$NON-NLS-1$
 			}
@@ -164,14 +177,16 @@
 		try {
 			region = getTokenizer().getNextToken();
 			// DMW: 2/12/03 Removed state
-			//		if (region != null) {
-			//			fRegions.add(region);
-			//		}
+			// if (region != null) {
+			// fRegions.add(region);
+			// }
 			return region;
-		} catch (StackOverflowError e) {
+		}
+		catch (StackOverflowError e) {
 			Logger.logException(getClass().getName() + ": input could not be parsed correctly at position " + getTokenizer().getOffset(), e); //$NON-NLS-1$
 			throw e;
-		} catch (Exception e) {
+		}
+		catch (Exception e) {
 			Logger.logException(getClass().getName() + ": input could not be parsed correctly at position " + getTokenizer().getOffset() + " (" + e.getLocalizedMessage() + ")", e); //$NON-NLS-3$//$NON-NLS-2$//$NON-NLS-1$
 		}
 		return null;
@@ -185,7 +200,7 @@
 		IStructuredDocumentRegion headNode = null;
 		if (!getTokenizer().isEOF()) {
 			headNode = getDocumentRegions();
-			//		throw new IllegalStateException("parsing has not finished");
+			// throw new IllegalStateException("parsing has not finished");
 		}
 		// for memory recovery, we assume if someone
 		// requests all regions, we can reset our big
@@ -238,18 +253,22 @@
 			int start = fOffset + offset;
 			int end = start + length;
 			text = fCharSequenceSource.subSequence(start, end).toString();
-		} else if (fDocumentInput != null) {
+		}
+		else if (fDocumentInput != null) {
 			try {
 				text = fDocumentInput.get(offset, length);
-			} catch (BadLocationException e) {
+			}
+			catch (BadLocationException e) {
 				text = ""; //$NON-NLS-1$
 			}
-		} else {
+		}
+		else {
 			if (fStringInput == null || fStringInput.length() == 0 || offset + length > fStringInput.length() || offset < 0) {
 				text = ""; //$NON-NLS-1$
-			} else {
+			}
+			else {
 				// offset is entirely valid during parsing as the parse
-				//   numbers haven't been adjusted.
+				// numbers haven't been adjusted.
 				text = fStringInput.substring(offset, offset + length);
 			}
 		}
@@ -293,8 +312,9 @@
 					currentNode.setLength(region.getStart() + region.getLength() - currentNode.getStart());
 					region.adjustStart(-currentNode.getStart());
 					// DW 4/16/2003 regions no longer have parents
-					//region.setParent(currentNode);
-				} else {
+					// region.setParent(currentNode);
+				}
+				else {
 					// not continuing a IStructuredDocumentRegion
 					if (currentNode != null) {
 						// ensure that any existing node is at least
@@ -306,12 +326,7 @@
 						}
 						lastNode = currentNode;
 					}
-					try {
-						fireNodeParsed(currentNode);
-					}
-					catch (Exception e) {
-						Logger.log(Logger.ERROR, e.getMessage());
-					}
+					fireNodeParsed(currentNode);
 					currentNode = createStructuredDocumentRegion(type);
 					if (lastNode != null) {
 						lastNode.setNext(currentNode);
@@ -323,7 +338,7 @@
 					region.adjustStart(-currentNode.getStart());
 					currentNode.addRegion(region);
 					// DW 4/16/2003 regions no longer have parents
-					//region.setParent(currentNode);
+					// region.setParent(currentNode);
 				}
 			}
 			// the following contexts OPEN new StructuredDocumentRegions
@@ -337,12 +352,7 @@
 					}
 					lastNode = currentNode;
 				}
-				try {
-					fireNodeParsed(currentNode);
-				}
-				catch (Exception e) {
-					Logger.log(Logger.ERROR, e.getMessage());
-				}
+				fireNodeParsed(currentNode);
 				currentNode = createStructuredDocumentRegion(type);
 				if (lastNode != null) {
 					lastNode.setNext(currentNode);
@@ -353,7 +363,7 @@
 				currentNode.setLength(region.getStart() + region.getLength() - currentNode.getStart());
 				region.adjustStart(-currentNode.getStart());
 				// DW 4/16/2003 regions no longer have parents
-				//region.setParent(currentNode);
+				// region.setParent(currentNode);
 			}
 			// the following contexts neither open nor close
 			// StructuredDocumentRegions; just add to them
@@ -362,7 +372,7 @@
 				currentNode.setLength(region.getStart() + region.getLength() - currentNode.getStart());
 				region.adjustStart(-currentNode.getStart());
 				// DW 4/16/2003 regions no longer have parents
-				//region.setParent(currentNode);
+				// region.setParent(currentNode);
 			}
 			// the following contexts close off StructuredDocumentRegions
 			// cleanly
@@ -372,7 +382,7 @@
 				currentNode.addRegion(region);
 				region.adjustStart(-currentNode.getStart());
 				// DW 4/16/2003 regions no longer have parents
-				//region.setParent(currentNode);
+				// region.setParent(currentNode);
 			}
 			// this is extremely rare, but valid
 			else if (type == DOMRegionContext.WHITE_SPACE) {
@@ -386,12 +396,13 @@
 					// where else to do, so will do here for now.
 					container.setParent(currentNode);
 					// DW 4/16/2003 regions no longer have parents
-					//region.setParent(container);
+					// region.setParent(container);
 					region.adjustStart(container.getLength() - region.getStart());
 				}
 				currentNode.getLastRegion().adjustLength(region.getLength());
 				currentNode.adjustLength(region.getLength());
-			} else if (type == DOMRegionContext.UNDEFINED && currentNode != null) {
+			}
+			else if (type == DOMRegionContext.UNDEFINED && currentNode != null) {
 				// skip on a very-first region situation as the default
 				// behavior is good enough
 				// combine with previous if also undefined
@@ -405,7 +416,8 @@
 					currentNode.setLength(region.getStart() + region.getLength() - currentNode.getStart());
 					region.adjustStart(-currentNode.getStart());
 				}
-			} else {
+			}
+			else {
 				// if an unknown type is the first region in the document,
 				// ensure that a node exists
 				if (currentNode == null) {
@@ -416,7 +428,7 @@
 				currentNode.setLength(region.getStart() + region.getLength() - currentNode.getStart());
 				region.adjustStart(-currentNode.getStart());
 				// DW 4/16/2003 regions no longer have parents
-				//region.setParent(currentNode);
+				// region.setParent(currentNode);
 				if (Debug.debugTokenizer)
 					System.out.println(getClass().getName() + " found region of not specifically handled type " + region.getType() + " @ " + region.getStart() + "[" + region.getLength() + "]"); //$NON-NLS-4$//$NON-NLS-3$//$NON-NLS-2$//$NON-NLS-1$
 				//$NON-NLS-3$//$NON-NLS-2$//$NON-NLS-1$
@@ -436,28 +448,23 @@
 			}
 		}
 		if (currentNode != null) {
-			try {
-				fireNodeParsed(currentNode);
-			}
-			catch (Exception e) {
-				Logger.log(Logger.ERROR, e.getMessage());
-			}
+			fireNodeParsed(currentNode);
 			currentNode.setPrevious(lastNode);
 		}
-		//fStringInput = null;
+		// fStringInput = null;
 		primReset();
 		return headNode;
 	}
 
 	protected void primReset() {
-		//fNodes = null;
-		//fRegions = null;
-		//fInput = null;
+		// fNodes = null;
+		// fRegions = null;
+		// fInput = null;
 		fStringInput = null;
 		fCharSequenceSource = null;
 		fDocumentInput = null;
 		fOffset = 0;
-		//fCurrentNode = null;
+		// fCurrentNode = null;
 		// DMW: also reset tokenizer so it doesn't hold on
 		// to large arrays
 		getTokenizer().reset(new char[0]);
@@ -477,12 +484,14 @@
 		boolean result = false;
 		if (fCharSequenceSource != null && fCharSequenceSource instanceof IRegionComparible) {
 			result = ((IRegionComparible) fCharSequenceSource).regionMatches(offset, length, stringToCompare);
-		} else {
+		}
+		else {
 			// old fashioned ways
 			String test = null;
 			if (fCharSequenceSource != null) {
 				test = fCharSequenceSource.subSequence(offset, offset + length).toString();
-			} else if (fStringInput != null) {
+			}
+			else if (fStringInput != null) {
 				test = fStringInput.substring(offset, offset + length);
 			}
 			result = stringToCompare.equals(test);
@@ -498,12 +507,14 @@
 		boolean result = false;
 		if (fCharSequenceSource != null && fCharSequenceSource instanceof IRegionComparible) {
 			result = ((IRegionComparible) fCharSequenceSource).regionMatchesIgnoreCase(offset, length, stringToCompare);
-		} else {
+		}
+		else {
 			// old fashioned ways
 			String test = null;
 			if (fCharSequenceSource != null) {
 				test = fCharSequenceSource.subSequence(offset, offset + length).toString();
-			} else if (fStringInput != null) {
+			}
+			else if (fStringInput != null) {
 				test = fStringInput.substring(offset, offset + length);
 			}
 			result = stringToCompare.equalsIgnoreCase(test);
@@ -531,7 +542,7 @@
 	 */
 	public void reset(java.io.FileInputStream instream) {
 		primReset();
-		//fInput = instream;
+		// fInput = instream;
 		getTokenizer().reset(instream);
 	}
 
@@ -553,12 +564,14 @@
 			IDocument doc = ((DocumentReader) reader).getDocument();
 			if (doc instanceof CharSequence) {
 				fCharSequenceSource = (CharSequence) doc;
-			} else {
+			}
+			else {
 				// old fashioned IDocument
 				fDocumentInput = ((DocumentReader) reader).getDocument();
 			}
 
-		} else if (reader instanceof CharSequenceReader) {
+		}
+		else if (reader instanceof CharSequenceReader) {
 			fCharSequenceSource = ((CharSequenceReader) reader).getOriginalSource();
 		}
 	}