committing work in progress to temp branch
diff --git a/bundles/org.eclipse.jst.jsp.ui/src/org/eclipse/jst/jsp/ui/internal/contentassist/JSPCompletionProcessor.java b/bundles/org.eclipse.jst.jsp.ui/src/org/eclipse/jst/jsp/ui/internal/contentassist/JSPCompletionProcessor.java
index 79c410b..22b7508 100644
--- a/bundles/org.eclipse.jst.jsp.ui/src/org/eclipse/jst/jsp/ui/internal/contentassist/JSPCompletionProcessor.java
+++ b/bundles/org.eclipse.jst.jsp.ui/src/org/eclipse/jst/jsp/ui/internal/contentassist/JSPCompletionProcessor.java
@@ -27,6 +27,7 @@
 import org.eclipse.jst.jsp.core.internal.java.IJSPTranslation;
 import org.eclipse.jst.jsp.core.internal.java.JSPTranslation;
 import org.eclipse.jst.jsp.core.internal.java.JSPTranslationAdapter;
+import org.eclipse.jst.jsp.core.model.parser.XMLJSPRegionContexts;
 import org.eclipse.jst.jsp.ui.internal.Logger;
 import org.eclipse.wst.sse.core.StructuredModelManager;
 import org.eclipse.wst.sse.core.text.IStructuredDocumentRegion;
@@ -37,7 +38,6 @@
 import org.eclipse.wst.xml.core.document.XMLDocument;
 import org.eclipse.wst.xml.core.document.XMLModel;
 import org.eclipse.wst.xml.core.document.XMLNode;
-import org.eclipse.wst.xml.core.jsp.model.parser.temp.XMLJSPRegionContexts;
 import org.osgi.framework.Bundle;
 import org.osgi.framework.BundleException;
 
@@ -48,12 +48,12 @@
 	// for debugging
 	private static final boolean DEBUG;
 	static {
-		String value= Platform.getDebugOption("org.eclipse.jst.jsp.core/debug/jsptranslation"); //$NON-NLS-1$
-		DEBUG= value != null && value.equalsIgnoreCase("true"); //$NON-NLS-1$
+		String value = Platform.getDebugOption("org.eclipse.jst.jsp.core/debug/jsptranslation"); //$NON-NLS-1$
+		DEBUG = value != null && value.equalsIgnoreCase("true"); //$NON-NLS-1$
 	}
-	
+
 	private static final String JDT_CORE_PLUGIN_ID = "org.eclipse.jdt.core"; //$NON-NLS-1$
-    
+
 	protected int fJspSourcePosition, fJavaPosition;
 	protected IResource fResource;
 	protected JSPCompletionRequestor fCollector;
@@ -66,43 +66,48 @@
 	}
 
 	/**
-	 * Returns a list of completion proposals based on the
-	 * specified location within the document that corresponds
-	 * to the current cursor position within the text viewer.
-	 *
-	 * @param viewer the viewer whose document is used to compute the proposals
-	 * @param documentPosition an offset within the document for which completions should be computed
-	 * @return an array of completion proposals or <code>null</code> if no proposals are possible
+	 * Returns a list of completion proposals based on the specified location
+	 * within the document that corresponds to the current cursor position
+	 * within the text viewer.
+	 * 
+	 * @param viewer
+	 *            the viewer whose document is used to compute the proposals
+	 * @param documentPosition
+	 *            an offset within the document for which completions should
+	 *            be computed
+	 * @return an array of completion proposals or <code>null</code> if no
+	 *         proposals are possible
 	 */
 	public ICompletionProposal[] computeCompletionProposals(ITextViewer viewer, int pos) {
 		initialize(pos);
+		XMLModel xmlModel = null;
 		try {
 			if (viewer instanceof StructuredTextViewer)
 				fViewer = (StructuredTextViewer) viewer;
 
-			XMLModel xmlModel = (XMLModel) StructuredModelManager.getModelManager().getExistingModelForRead(fViewer.getDocument());
+			xmlModel = (XMLModel) StructuredModelManager.getModelManager().getExistingModelForRead(fViewer.getDocument());
+
 			XMLDocument xmlDoc = xmlModel.getDocument();
-			xmlModel.releaseFromRead();
 			if (fTranslationAdapter == null)
 				fTranslationAdapter = (JSPTranslationAdapter) xmlDoc.getAdapterFor(IJSPTranslation.class);
 			if (fTranslationAdapter != null) {
-				
+
 				JSPTranslation translation = fTranslationAdapter.getJSPTranslation();
 				fJavaPosition = translation.getJavaOffset(getDocumentPosition());
-				
-                fCollector.setCodeAssistOffset(fJavaPosition);
-                fCollector.setJavaToJSPOffset(fJspSourcePosition - fJavaPosition);
-                fCollector.setCursorInExpression(cursorInExpression());
-                
+
+				fCollector.setCodeAssistOffset(fJavaPosition);
+				fCollector.setJavaToJSPOffset(fJspSourcePosition - fJavaPosition);
+				fCollector.setCursorInExpression(cursorInExpression());
+
 
 				if (DEBUG)
 					System.out.println(debug(translation));
 
 				try {
-                    			
+
 					ICompilationUnit cu = translation.getCompilationUnit();
 					fCollector.setCompilationUnit(cu);
-                    
+
 					// can't get java proposals w/out a compilation unit
 					if (cu == null)
 						return new ICompletionProposal[0];
@@ -112,7 +117,8 @@
 					}
 				}
 				catch (CoreException coreEx) {
-					// a possible Java Model Exception due to not being a Web (Java) Project
+					// a possible Java Model Exception due to not being a Web
+					// (Java) Project
 					coreEx.printStackTrace();
 				}
 			}
@@ -121,7 +127,11 @@
 			exc.printStackTrace();
 			// throw out exceptions on code assist.
 		}
-        
+		finally {
+			if (xmlModel != null) {
+				xmlModel.releaseFromRead();
+			}
+		}
 		ICompletionProposal[] results = fCollector.getResults();
 		if (results == null || results.length < 1)
 			fErrorMessage = SSEUIPlugin.getResourceString("%Java_Content_Assist_is_not_UI_"); //$NON-NLS-1$ = "Java Content Assist is not available for the current cursor location"
@@ -131,6 +141,7 @@
 
 	/**
 	 * For debugging translation mapping only.
+	 * 
 	 * @param translation
 	 */
 	private String debug(JSPTranslation translation) {
@@ -166,33 +177,38 @@
 		XMLNode xmlNode = null;
 		xmlModel.releaseFromRead();
 		xmlNode = (XMLNode) xmlModel.getIndexedRegion(fJspSourcePosition);
-        if(xmlNode != null) {
-            XMLNode parent = (XMLNode)xmlNode.getParentNode();
-            if(parent != null) {
-                sdRegion = parent.getFirstStructuredDocumentRegion();
-                inExpression = sdRegion != null && (sdRegion.getType() == XMLJSPRegionContexts.JSP_EXPRESSION_OPEN || sdRegion.getType() == XMLJSPRegionContexts.JSP_SCRIPTLET_OPEN);
-            }
-        }
+		if (xmlNode != null) {
+			XMLNode parent = (XMLNode) xmlNode.getParentNode();
+			if (parent != null) {
+				sdRegion = parent.getFirstStructuredDocumentRegion();
+				inExpression = sdRegion != null && (sdRegion.getType() == XMLJSPRegionContexts.JSP_EXPRESSION_OPEN || sdRegion.getType() == XMLJSPRegionContexts.JSP_SCRIPTLET_OPEN);
+			}
+		}
 		return inExpression;
 	}
 
 	/**
-	 * Returns information about possible contexts based on the
-	 * specified location within the document that corresponds
-	 * to the current cursor position within the text viewer.
-	 *
-	 * @param viewer the viewer whose document is used to compute the possible contexts
-	 * @param documentPosition an offset within the document for which context information should be computed
-	 * @return an array of context information objects or <code>null</code> if no context could be found
+	 * Returns information about possible contexts based on the specified
+	 * location within the document that corresponds to the current cursor
+	 * position within the text viewer.
+	 * 
+	 * @param viewer
+	 *            the viewer whose document is used to compute the possible
+	 *            contexts
+	 * @param documentPosition
+	 *            an offset within the document for which context information
+	 *            should be computed
+	 * @return an array of context information objects or <code>null</code>
+	 *         if no context could be found
 	 */
 	public org.eclipse.jface.text.contentassist.IContextInformation[] computeContextInformation(org.eclipse.jface.text.ITextViewer viewer, int documentOffset) {
 		return null;
 	}
 
 	/**
-	 * Returns a string of characters which when pressed should
-	 * automatically display content-assist proposals.
-	 *
+	 * Returns a string of characters which when pressed should automatically
+	 * display content-assist proposals.
+	 * 
 	 * @return string of characters
 	 */
 	public java.lang.String getAutoProposalInvocationCharacters() {
@@ -200,9 +216,9 @@
 	}
 
 	/**
-	 * Returns a string of characters which when pressed should
-	 * automatically display a content-assist tip.
-	 *
+	 * Returns a string of characters which when pressed should automatically
+	 * display a content-assist tip.
+	 * 
 	 * @return string of characters
 	 */
 	public java.lang.String getAutoTipInvocationCharacters() {
@@ -212,9 +228,9 @@
 	/**
 	 * Returns the characters which when entered by the user should
 	 * automatically trigger the presentation of possible completions.
-	 *
-	 * @return the auto activation characters for completion proposal or <code>null</code>
-	 *		if no auto activation is desired
+	 * 
+	 * @return the auto activation characters for completion proposal or
+	 *         <code>null</code> if no auto activation is desired
 	 */
 	public char[] getCompletionProposalAutoActivationCharacters() {
 		return null;
@@ -223,21 +239,22 @@
 	/**
 	 * Returns the characters which when entered by the user should
 	 * automatically trigger the presentation of context information.
-	 *
-	 * @return the auto activation characters for presenting context information
-	 *		or <code>null</code> if no auto activation is desired
+	 * 
+	 * @return the auto activation characters for presenting context
+	 *         information or <code>null</code> if no auto activation is
+	 *         desired
 	 */
 	public char[] getContextInformationAutoActivationCharacters() {
 		return null;
 	}
 
 	/**
-	 * Returns a validator used to determine when displayed context information
-	 * should be dismissed. May only return <code>null</code> if the processor is
-	 * incapable of computing context information.
-	 *
-	 * @return a context information validator, or <code>null</code> if the processor
-	 * 			is incapable of computing context information
+	 * Returns a validator used to determine when displayed context
+	 * information should be dismissed. May only return <code>null</code> if
+	 * the processor is incapable of computing context information.
+	 * 
+	 * @return a context information validator, or <code>null</code> if the
+	 *         processor is incapable of computing context information
 	 */
 	public org.eclipse.jface.text.contentassist.IContextInformationValidator getContextInformationValidator() {
 		return null;
@@ -248,9 +265,10 @@
 	}
 
 	public String getErrorMessage() {
-        // TODO:
-//		if (fCollector.getErrorMessage() != null && fCollector.getErrorMessage().length() > 0)
-//			return fCollector.getErrorMessage();
+		// TODO:
+		// if (fCollector.getErrorMessage() != null &&
+		// fCollector.getErrorMessage().length() > 0)
+		// return fCollector.getErrorMessage();
 		return fErrorMessage;
 	}
 
@@ -272,7 +290,7 @@
 		initializeJavaPlugins();
 
 		// fCollector = new JSPResultCollector();
-        fCollector = new JSPCompletionRequestor();
+		fCollector = new JSPCompletionRequestor();
 		fJspSourcePosition = pos;
 		fErrorMessage = null;
 	}
@@ -290,7 +308,9 @@
 		}
 	}
 
-	/* (non-Javadoc)
+	/*
+	 * (non-Javadoc)
+	 * 
 	 * @see com.ibm.sse.editor.IReleasable#release()
 	 */
 	public void release() {
diff --git a/bundles/org.eclipse.jst.jsp.ui/src/org/eclipse/jst/jsp/ui/preferences/ui/JSPColorPage.java b/bundles/org.eclipse.jst.jsp.ui/src/org/eclipse/jst/jsp/ui/preferences/ui/JSPColorPage.java
index b7a90ee..803ee62 100644
--- a/bundles/org.eclipse.jst.jsp.ui/src/org/eclipse/jst/jsp/ui/preferences/ui/JSPColorPage.java
+++ b/bundles/org.eclipse.jst.jsp.ui/src/org/eclipse/jst/jsp/ui/preferences/ui/JSPColorPage.java
@@ -17,6 +17,7 @@
 
 import org.eclipse.jface.preference.IPreferenceStore;
 import org.eclipse.jst.jsp.core.contenttype.ContentTypeIdForJSP;
+import org.eclipse.jst.jsp.core.model.parser.XMLJSPRegionContexts;
 import org.eclipse.jst.jsp.ui.internal.JSPUIPlugin;
 import org.eclipse.jst.jsp.ui.internal.editor.IHelpContextIds;
 import org.eclipse.swt.widgets.Composite;
@@ -28,7 +29,6 @@
 import org.eclipse.wst.sse.ui.internal.preferences.OverlayPreferenceStore;
 import org.eclipse.wst.sse.ui.internal.preferences.OverlayPreferenceStore.OverlayKey;
 import org.eclipse.wst.sse.ui.preferences.ui.StyledTextColorPicker;
-import org.eclipse.wst.xml.core.jsp.model.parser.temp.XMLJSPRegionContexts;
 import org.eclipse.wst.xml.core.parser.XMLRegionContext;
 import org.eclipse.wst.xml.ui.preferences.XMLColorPage;
 import org.eclipse.wst.xml.ui.style.IStyleConstantsXML;
diff --git a/bundles/org.eclipse.wst.html.ui/src/org/eclipse/wst/html/ui/preferences/ui/HTMLColorPage.java b/bundles/org.eclipse.wst.html.ui/src/org/eclipse/wst/html/ui/preferences/ui/HTMLColorPage.java
index 756030e..5f39ed0 100644
--- a/bundles/org.eclipse.wst.html.ui/src/org/eclipse/wst/html/ui/preferences/ui/HTMLColorPage.java
+++ b/bundles/org.eclipse.wst.html.ui/src/org/eclipse/wst/html/ui/preferences/ui/HTMLColorPage.java
@@ -27,9 +27,7 @@
 import org.eclipse.wst.sse.ui.internal.preferences.OverlayPreferenceStore;
 import org.eclipse.wst.sse.ui.internal.preferences.OverlayPreferenceStore.OverlayKey;
 import org.eclipse.wst.sse.ui.preferences.ui.StyledTextColorPicker;
-import org.eclipse.wst.xml.core.jsp.model.parser.temp.XMLJSPRegionContexts;
 import org.eclipse.wst.xml.ui.preferences.XMLColorPage;
-import org.eclipse.wst.xml.ui.style.IStyleConstantsXML;
 
 public class HTMLColorPage extends XMLColorPage {
 
@@ -60,18 +58,12 @@
 
 		initCommonContextStyleMap(contextStyleMap);
 		initDocTypeContextStyleMap(contextStyleMap);
-		//	contextStyleMap.put(XMLJSPRegionContexts.JSP_SCRIPTLET_OPEN, HTMLColorManager.SCRIPT_AREA_BORDER);
-		//	contextStyleMap.put(XMLJSPRegionContexts.JSP_CONTENT, HTMLColorManager.SCRIPT_AREA);
-		//	contextStyleMap.put(XMLJSPRegionContexts.BLOCK_TEXT, HTMLColorManager.SCRIPT_AREA);
-		//	contextStyleMap.put(XMLJSPRegionContexts.JSP_DECLARATION_OPEN, HTMLColorManager.SCRIPT_AREA_BORDER);
-		//	contextStyleMap.put(XMLJSPRegionContexts.JSP_EXPRESSION_OPEN, HTMLColorManager.SCRIPT_AREA_BORDER);
-		//	contextStyleMap.put(XMLJSPRegionContexts.JSP_DIRECTIVE_OPEN, HTMLColorManager.SCRIPT_AREA_BORDER);
-		//	contextStyleMap.put(XMLJSPRegionContexts.JSP_DIRECTIVE_CLOSE, HTMLColorManager.SCRIPT_AREA_BORDER);
-		//	contextStyleMap.put(XMLJSPRegionContexts.JSP_CLOSE, HTMLColorManager.SCRIPT_AREA_BORDER);
-		contextStyleMap.put(XMLJSPRegionContexts.JSP_DIRECTIVE_NAME, IStyleConstantsXML.TAG_NAME);
-		contextStyleMap.put(XMLJSPRegionContexts.JSP_COMMENT_OPEN, IStyleConstantsXML.COMMENT_BORDER);
-		contextStyleMap.put(XMLJSPRegionContexts.JSP_COMMENT_TEXT, IStyleConstantsXML.COMMENT_TEXT);
-		contextStyleMap.put(XMLJSPRegionContexts.JSP_COMMENT_CLOSE, IStyleConstantsXML.COMMENT_BORDER);
+		// FIXME: these were "brute forced" commented out when moving XMLJSPRegionContexts
+		// effect is unknown, but thought just to effect preference page
+		//contextStyleMap.put(XMLJSPRegionContexts.JSP_DIRECTIVE_NAME, IStyleConstantsXML.TAG_NAME);
+		//contextStyleMap.put(XMLJSPRegionContexts.JSP_COMMENT_OPEN, IStyleConstantsXML.COMMENT_BORDER);
+		//contextStyleMap.put(XMLJSPRegionContexts.JSP_COMMENT_TEXT, IStyleConstantsXML.COMMENT_TEXT);
+		//contextStyleMap.put(XMLJSPRegionContexts.JSP_COMMENT_CLOSE, IStyleConstantsXML.COMMENT_BORDER);
 	}
 
 	protected void initDescriptions(Dictionary descriptions) {
diff --git a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/format/NodeFormatter.java b/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/format/NodeFormatter.java
index 73d7afc..79c2c2b 100644
--- a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/format/NodeFormatter.java
+++ b/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/format/NodeFormatter.java
@@ -32,8 +32,9 @@
 import org.eclipse.wst.xml.core.document.XMLNode;
 import org.eclipse.wst.xml.core.internal.XMLCorePlugin;
 import org.eclipse.wst.xml.core.internal.document.CDATASectionImpl;
+import org.eclipse.wst.xml.core.internal.document.CharacterDataImpl;
+import org.eclipse.wst.xml.core.internal.document.CommentImpl;
 import org.eclipse.wst.xml.core.internal.parser.regions.TagNameRegion;
-import org.eclipse.wst.xml.core.jsp.model.parser.temp.XMLJSPRegionContexts;
 import org.eclipse.wst.xml.core.parser.XMLRegionContext;
 import org.w3c.dom.Node;
 
@@ -538,8 +539,8 @@
 	protected String getNodeText(XMLNode node) {
 		String text = null;
 
-		if ((node instanceof org.eclipse.wst.xml.core.internal.document.CharacterDataImpl) && !(node instanceof org.eclipse.wst.xml.core.internal.document.CommentImpl) && !(node instanceof org.eclipse.wst.xml.core.internal.document.CDATASectionImpl) && !isJSPTag(node))
-			text = ((org.eclipse.wst.xml.core.internal.document.CharacterDataImpl) node).getSource();
+		if ((node instanceof CharacterDataImpl) && !(node instanceof CommentImpl) && !(node instanceof CDATASectionImpl) && !isJSPTag(node))
+			text = ((CharacterDataImpl) node).getSource();
 		else
 			text = node.getFirstStructuredDocumentRegion().getText();
 
@@ -675,27 +676,6 @@
 		return result;
 	}
 
-	protected boolean isJSPTag(XMLNode node) {
-		boolean result = false;
-
-		IStructuredDocumentRegion flatNode = node.getFirstStructuredDocumentRegion();
-		// in some cases, the nodes exists, but hasn't been associated with
-		// a flatnode yet (the screen updates can be initiated on a different
-		// thread,
-		// so the request for a flatnode can come in before the node is fully
-		// formed.
-		// if the flatnode is null, we'll just allow the defaults to apply.
-		// (html adapter in this case).
-		if (flatNode != null) {
-			String flatNodeType = flatNode.getType();
-			if ((flatNodeType == XMLJSPRegionContexts.JSP_CONTENT) || (flatNodeType == XMLJSPRegionContexts.JSP_EXPRESSION_OPEN) || (flatNodeType == XMLJSPRegionContexts.JSP_SCRIPTLET_OPEN) || (flatNodeType == XMLJSPRegionContexts.JSP_DECLARATION_OPEN) || (flatNodeType == XMLJSPRegionContexts.JSP_DIRECTIVE_CLOSE) || (flatNodeType == XMLJSPRegionContexts.JSP_DIRECTIVE_NAME) || (flatNodeType == XMLJSPRegionContexts.JSP_DIRECTIVE_OPEN) || (flatNodeType == XMLJSPRegionContexts.JSP_CLOSE)) {
-				result = true;
-			}
-		}
-
-		return result;
-	}
-
 	protected boolean nodeHasSiblings(XMLNode node) {
 		return (node.getPreviousSibling() != null) || (node.getNextSibling() != null);
 	}
@@ -762,4 +742,54 @@
 	public void setProgressMonitor(IProgressMonitor monitor) {
 		fProgressMonitor = monitor;
 	}
+
+	/**
+	 * ISSUE: this is a bit of hidden JSP knowledge that was implemented this
+	 * way for expedency. Should be evolved in future to depend on "nestedContext".
+	 */
+	private boolean isJSPTag(Node node) {
+	
+		final String JSP_CLOSE = "JSP_CLOSE"; //$NON-NLS-1$
+		// final String JSP_COMMENT_CLOSE = "JSP_COMMENT_CLOSE"; //$NON-NLS-1$
+	
+		// final String JSP_COMMENT_OPEN = "JSP_COMMENT_OPEN"; //$NON-NLS-1$
+		// final String JSP_COMMENT_TEXT = "JSP_COMMENT_TEXT"; //$NON-NLS-1$
+	
+		final String JSP_CONTENT = "JSP_CONTENT"; //$NON-NLS-1$
+		final String JSP_DECLARATION_OPEN = "JSP_DECLARATION_OPEN"; //$NON-NLS-1$
+		final String JSP_DIRECTIVE_CLOSE = "JSP_DIRECTIVE_CLOSE"; //$NON-NLS-1$
+		final String JSP_DIRECTIVE_NAME = "JSP_DIRECTIVE_NAME"; //$NON-NLS-1$
+	
+		final String JSP_DIRECTIVE_OPEN = "JSP_DIRECTIVE_OPEN"; //$NON-NLS-1$
+		final String JSP_EXPRESSION_OPEN = "JSP_EXPRESSION_OPEN"; //$NON-NLS-1$
+	
+		// final String JSP_ROOT_TAG_NAME = "JSP_ROOT_TAG_NAME"; //$NON-NLS-1$
+	
+		final String JSP_SCRIPTLET_OPEN = "JSP_SCRIPTLET_OPEN"; //$NON-NLS-1$
+	
+		boolean result = false;
+	
+		if (node instanceof XMLNode) {
+			IStructuredDocumentRegion flatNode = ((XMLNode) node).getFirstStructuredDocumentRegion();
+			// in some cases, the nodes exists, but hasn't been associated
+			// with
+			// a flatnode yet (the screen updates can be initiated on a
+			// different thread,
+			// so the request for a flatnode can come in before the node is
+			// fully formed.
+			// if the flatnode is null, we'll just allow the defaults to
+			// apply.
+			if (flatNode != null) {
+				String flatNodeType = flatNode.getType();
+				// should not be null, but just to be sure
+				if (flatNodeType != null) {
+					if ((flatNodeType.equals(JSP_CONTENT)) || (flatNodeType.equals(JSP_EXPRESSION_OPEN)) || (flatNodeType.equals(JSP_SCRIPTLET_OPEN)) || (flatNodeType.equals(JSP_DECLARATION_OPEN)) || (flatNodeType.equals(JSP_DIRECTIVE_CLOSE)) || (flatNodeType.equals(JSP_DIRECTIVE_NAME)) || (flatNodeType.equals(JSP_DIRECTIVE_OPEN)) || (flatNodeType.equals(JSP_CLOSE))) {
+						result = true;
+					}
+				}
+			}
+		}
+	
+		return result;
+	}
 }