234781 Fixes needed for JSP validation and other minor updates
diff --git a/tests/org.eclipse.jst.jsp.ui.tests/META-INF/MANIFEST.MF b/tests/org.eclipse.jst.jsp.ui.tests/META-INF/MANIFEST.MF
index 76ca07d..353ca10 100644
--- a/tests/org.eclipse.jst.jsp.ui.tests/META-INF/MANIFEST.MF
+++ b/tests/org.eclipse.jst.jsp.ui.tests/META-INF/MANIFEST.MF
@@ -28,6 +28,7 @@
 Require-Bundle: org.eclipse.jface.text,
  org.eclipse.ui,
  org.eclipse.core.resources,
+ org.eclipse.jdt.ui,
  org.eclipse.jdt.core,
  org.eclipse.jst.jsp.ui,
  org.junit,
@@ -45,5 +46,7 @@
  org.eclipse.wst.xml.ui,
  com.ibm.icu,
  org.eclipse.wst.html.ui,
- org.eclipse.wst.validation
+ org.eclipse.wst.validation,
+ org.eclipse.core.commands,
+ org.eclipse.core.expressions
 Eclipse-LazyStart: true
diff --git a/tests/org.eclipse.jst.jsp.ui.tests/plugin.properties b/tests/org.eclipse.jst.jsp.ui.tests/plugin.properties
index 645b414..4d345d5 100644
--- a/tests/org.eclipse.jst.jsp.ui.tests/plugin.properties
+++ b/tests/org.eclipse.jst.jsp.ui.tests/plugin.properties
@@ -1,4 +1,5 @@
 # properties file for org.eclipse.jst.jsp.ui.tests
 Bundle-Vendor.0 = Eclipse.org
 Bundle-Name.0 = Structured Source Editor for JSP Tests
-view.name.0 = Embedded JSP Structured Text Viewer
\ No newline at end of file
+view.name.0 = Embedded JSP Structured Text Viewer
+_UI_SHOW_TRANSLATION=Show Translation
\ No newline at end of file
diff --git a/tests/org.eclipse.jst.jsp.ui.tests/plugin.xml b/tests/org.eclipse.jst.jsp.ui.tests/plugin.xml
index 4e05633..05d3aef 100644
--- a/tests/org.eclipse.jst.jsp.ui.tests/plugin.xml
+++ b/tests/org.eclipse.jst.jsp.ui.tests/plugin.xml
@@ -10,5 +10,29 @@
 			class="org.eclipse.jst.jsp.ui.tests.viewer.ViewerTestJSP"
 			id="org.eclipse.jst.jsp.ui.tests.viewer.ViewerTestJSP" />
 	</extension>
+    <extension
+       point="org.eclipse.ui.commands">
+	    <command
+	          id="org.eclipse.jst.jsp.ui.showTranslation"
+	          name="%_UI_SHOW_TRANSLATION">
+	    </command>
+	</extension>
+	<extension point="org.eclipse.ui.bindings">
+      <!--  win32:  M1=CTRL,    M2=SHIFT, M3=ALT, M4=-
+            carbon: M1=COMMAND, M2=SHIFT, M3=ALT, M4=CTRL
+            gtk: ? 
+      -->
+		<key
+			sequence="M1+M2+9"
+			contextId="org.eclipse.wst.sse.ui.structuredTextEditorScope"
+			commandId="org.eclipse.jst.jsp.ui.showTranslation"
+			schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"/>
+	</extension>
+    <extension point="org.eclipse.ui.handlers">
+       <handler
+             class="org.eclipse.jst.jsp.ui.tests.ShowTranslationHandler"
+             commandId="org.eclipse.jst.jsp.ui.showTranslation">
+       </handler>
+	</extension>
 
 </plugin>
diff --git a/tests/org.eclipse.jst.jsp.ui.tests/src/org/eclipse/jst/jsp/ui/tests/JSPTranslationEditorInput.java b/tests/org.eclipse.jst.jsp.ui.tests/src/org/eclipse/jst/jsp/ui/tests/JSPTranslationEditorInput.java
new file mode 100644
index 0000000..d0f7382
--- /dev/null
+++ b/tests/org.eclipse.jst.jsp.ui.tests/src/org/eclipse/jst/jsp/ui/tests/JSPTranslationEditorInput.java
@@ -0,0 +1,168 @@
+/*******************************************************************************
+ * Copyright (c) 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * 
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.jst.jsp.ui.tests;
+
+import java.io.InputStream;
+
+import org.eclipse.core.resources.IStorage;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.jst.jsp.core.internal.java.IJSPTranslation;
+import org.eclipse.jst.jsp.core.internal.java.JSPTranslationAdapter;
+import org.eclipse.ui.IPersistableElement;
+import org.eclipse.ui.IStorageEditorInput;
+import org.eclipse.wst.sse.core.internal.util.DocumentInputStream;
+import org.eclipse.wst.xml.core.internal.provisional.document.IDOMModel;
+
+/**
+ * @author nitin
+ * 
+ */
+public class JSPTranslationEditorInput implements IStorageEditorInput {
+	private class JSPTranslationStorage implements IStorage {
+		/**
+		 * 
+		 */
+		public JSPTranslationStorage(IDOMModel jspModel) {
+			fModel = jspModel;
+		}
+
+		/*
+		 * (non-Javadoc)
+		 * 
+		 * @see
+		 * org.eclipse.core.runtime.IAdaptable#getAdapter(java.lang.Class)
+		 */
+		public Object getAdapter(Class adapter) {
+			return fModel.getAdapter(adapter);
+		}
+
+		/*
+		 * (non-Javadoc)
+		 * 
+		 * @see org.eclipse.core.resources.IStorage#getContents()
+		 */
+		public InputStream getContents() throws CoreException {
+			return new DocumentInputStream(getTranslationAdapter().getJSPTranslation().getJavaDocument());
+		}
+
+		/*
+		 * (non-Javadoc)
+		 * 
+		 * @see org.eclipse.core.resources.IStorage#getFullPath()
+		 */
+		public IPath getFullPath() {
+			return new Path(getTranslationAdapter().getJSPTranslation().getJavaPath());
+		}
+
+		/*
+		 * (non-Javadoc)
+		 * 
+		 * @see org.eclipse.core.resources.IStorage#getName()
+		 */
+		public String getName() {
+			return getTranslationAdapter().getJSPTranslation().getCompilationUnit().getElementName();
+		}
+
+		/*
+		 * (non-Javadoc)
+		 * 
+		 * @see org.eclipse.core.resources.IStorage#isReadOnly()
+		 */
+		public boolean isReadOnly() {
+			return true;
+		}
+	}
+
+	IDOMModel fModel;
+
+	private JSPTranslationStorage fStorage;
+
+	/**
+	 * 
+	 */
+	public JSPTranslationEditorInput(IDOMModel model) {
+		fStorage = new JSPTranslationStorage(model);
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see org.eclipse.ui.IEditorInput#exists()
+	 */
+	public boolean exists() {
+		return false;
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see org.eclipse.core.runtime.IAdaptable#getAdapter(java.lang.Class)
+	 */
+	public Object getAdapter(Class adapter) {
+		return fModel.getAdapter(adapter);
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see org.eclipse.ui.IEditorInput#getImageDescriptor()
+	 */
+	public ImageDescriptor getImageDescriptor() {
+		return null;
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see org.eclipse.ui.IEditorInput#getName()
+	 */
+	public String getName() {
+		return new Path(fModel.getBaseLocation()).lastSegment() + ".java";
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see org.eclipse.ui.IEditorInput#getPersistable()
+	 */
+	public IPersistableElement getPersistable() {
+		return null;
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see org.eclipse.ui.IStorageEditorInput#getStorage()
+	 */
+	public IStorage getStorage() throws CoreException {
+		return fStorage;
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see org.eclipse.ui.IEditorInput#getToolTipText()
+	 */
+	public String getToolTipText() {
+		return fModel.getBaseLocation();
+	}
+
+	JSPTranslationAdapter getTranslationAdapter() {
+		JSPTranslationAdapter adapter = (JSPTranslationAdapter) fModel.getDocument().getAdapterFor(IJSPTranslation.class);
+		return adapter;
+	}
+
+
+}
diff --git a/tests/org.eclipse.jst.jsp.ui.tests/src/org/eclipse/jst/jsp/ui/tests/ShowTranslationHandler.java b/tests/org.eclipse.jst.jsp.ui.tests/src/org/eclipse/jst/jsp/ui/tests/ShowTranslationHandler.java
new file mode 100644
index 0000000..c89e24c
--- /dev/null
+++ b/tests/org.eclipse.jst.jsp.ui.tests/src/org/eclipse/jst/jsp/ui/tests/ShowTranslationHandler.java
@@ -0,0 +1,120 @@
+/*******************************************************************************
+ * Copyright (c) 2008 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ * 
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.jst.jsp.ui.tests;
+
+import java.util.List;
+
+import org.eclipse.core.commands.AbstractHandler;
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.core.expressions.EvaluationContext;
+import org.eclipse.core.resources.IMarker;
+import org.eclipse.jdt.core.compiler.IProblem;
+import org.eclipse.jdt.ui.JavaUI;
+import org.eclipse.jface.text.Position;
+import org.eclipse.jface.text.source.Annotation;
+import org.eclipse.jface.text.source.IAnnotationModel;
+import org.eclipse.jst.jsp.core.internal.java.IJSPTranslation;
+import org.eclipse.jst.jsp.core.internal.java.JSPTranslationAdapter;
+import org.eclipse.jst.jsp.core.internal.java.JSPTranslationExtension;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.ui.IEditorPart;
+import org.eclipse.ui.IStorageEditorInput;
+import org.eclipse.ui.PartInitException;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.ide.IDE;
+import org.eclipse.ui.texteditor.AnnotationTypeLookup;
+import org.eclipse.ui.texteditor.ITextEditor;
+import org.eclipse.wst.sse.core.internal.provisional.INodeAdapter;
+import org.eclipse.wst.xml.core.internal.provisional.document.IDOMModel;
+import org.eclipse.wst.xml.core.internal.provisional.document.IDOMNode;
+
+
+/**
+ * Opens the current JSP editor's current translated source in a Java editor
+ * 
+ * Invoke with M1+M2+9
+ * 
+ * @author nitin
+ */
+public class ShowTranslationHandler extends AbstractHandler {
+
+	/**
+	 * 
+	 */
+	public ShowTranslationHandler() {
+	}
+
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see
+	 * org.eclipse.core.commands.IHandler#execute(org.eclipse.core.commands
+	 * .ExecutionEvent)
+	 */
+	public Object execute(ExecutionEvent event) throws ExecutionException {
+		// IDE.openEditor(event.getApplicationContext(), createEditorInput(),
+		// JavaUI.ID_CU_EDITOR, true);
+		EvaluationContext evaluationContext = (EvaluationContext) event.getApplicationContext();
+		if (evaluationContext != null) {
+			Object selection = evaluationContext.getDefaultVariable();
+			if (selection instanceof List) {
+				List list = (List) selection;
+				if (!list.isEmpty()) {
+					if (list.get(0) instanceof IDOMNode) {
+						IDOMModel model = ((IDOMNode) list.get(0)).getModel();
+						INodeAdapter adapter = model.getDocument().getAdapterFor(IJSPTranslation.class);
+						if (adapter != null) {
+							// create an IEditorInput for the Java editor
+							IStorageEditorInput input = new JSPTranslationEditorInput(model);
+							try {
+								IEditorPart editor = IDE.openEditor(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage(), input, JavaUI.ID_CU_EDITOR, true);
+								// Now add the problems we found
+								if (editor instanceof ITextEditor) {
+									IAnnotationModel annotationModel = ((ITextEditor) editor).getDocumentProvider().getAnnotationModel(input);
+									JSPTranslationAdapter translationAdapter = (JSPTranslationAdapter) model.getDocument().getAdapterFor(IJSPTranslation.class);
+									JSPTranslationExtension translation = translationAdapter.getJSPTranslation();
+									translation.reconcileCompilationUnit();
+									List problemsList = translation.getProblems();
+									IProblem[] problems = (IProblem[]) problemsList.toArray(new IProblem[problemsList.size()]);
+									AnnotationTypeLookup lookup = new AnnotationTypeLookup();
+									for (int i = 0; i < problems.length; i++) {
+										int length = problems[i].getSourceEnd() - problems[i].getSourceStart() + 1;
+										Position position = new Position(problems[i].getSourceStart(), length);
+										Annotation annotation = null;
+										String type = lookup.getAnnotationType(IMarker.PROBLEM, IMarker.SEVERITY_INFO);
+										if (problems[i].isError()) {
+											type = lookup.getAnnotationType(IMarker.PROBLEM, IMarker.SEVERITY_ERROR);
+										}
+										else if (problems[i].isWarning()) {
+											type = lookup.getAnnotationType(IMarker.PROBLEM, IMarker.SEVERITY_WARNING);
+										}
+										annotation = new Annotation(type, false, problems[i].getMessage());
+										if (annotation != null) {
+											annotationModel.addAnnotation(annotation, position);
+										}
+									}
+								}
+							}
+							catch (PartInitException e) {
+								e.printStackTrace();
+								Display.getCurrent().beep();
+							}
+						}
+					}
+				}
+			}
+		}
+		return null;
+	}
+}
diff --git a/tests/org.eclipse.jst.jsp.ui.tests/src/org/eclipse/jst/jsp/ui/tests/contentassist/JSPJavaTranslatorTest.java b/tests/org.eclipse.jst.jsp.ui.tests/src/org/eclipse/jst/jsp/ui/tests/contentassist/JSPJavaTranslatorTest.java
index ade3dce..ba38d50 100644
--- a/tests/org.eclipse.jst.jsp.ui.tests/src/org/eclipse/jst/jsp/ui/tests/contentassist/JSPJavaTranslatorTest.java
+++ b/tests/org.eclipse.jst.jsp.ui.tests/src/org/eclipse/jst/jsp/ui/tests/contentassist/JSPJavaTranslatorTest.java
@@ -12,14 +12,21 @@
 
 import java.io.IOException;
 import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.Reader;
 import java.io.UnsupportedEncodingException;
 
 import junit.framework.TestCase;
 
+import org.eclipse.jst.jsp.core.internal.java.IJSPTranslation;
+import org.eclipse.jst.jsp.core.internal.java.JSPTranslationAdapterFactory;
+import org.eclipse.jst.jsp.core.internal.java.JSPTranslationUtil;
 import org.eclipse.jst.jsp.core.internal.java.JSPTranslator;
 import org.eclipse.wst.sse.core.StructuredModelManager;
 import org.eclipse.wst.sse.core.internal.provisional.IModelManager;
+import org.eclipse.wst.sse.core.internal.provisional.INodeAdapterFactory;
 import org.eclipse.wst.sse.core.internal.provisional.IStructuredModel;
+import org.eclipse.wst.sse.core.utils.StringUtils;
 import org.eclipse.wst.xml.core.internal.provisional.document.IDOMNode;
 
 /**
@@ -64,6 +71,38 @@
 		}
 	}
 
+	public void testMultipleJSPSectionsInJavascript() throws Exception {
+		String filename = "testfiles/jspInJavascript2.jsp";
+		IStructuredModel sm = getStructuredModelForRead(filename);
+		assertNotNull("couldn't load JSP for test", sm);
+		JSPTranslationUtil translationUtil = new JSPTranslationUtil(sm.getStructuredDocument());
+
+		String javaText = StringUtils.replace(translationUtil.getTranslation().getJavaText(), "\r\n", "\n");
+		javaText = StringUtils.replace(javaText, "\r", "\n");
+		sm.releaseFromRead();
+
+		String translatedText = loadContents("testfiles/jspInJavascript2.javasource");
+		assertEquals("translated contents are not as expected", translatedText, javaText);
+	}
+
+	/**
+	 * @return
+	 */
+	private String loadContents(String filename) throws IOException {
+		Reader reader = new InputStreamReader(getClass().getResourceAsStream(filename));
+		char[] readBuffer = new char[2048];
+		int n = reader.read(readBuffer);
+		StringBuffer s = new StringBuffer();
+		while (n > 0) {
+			s.append(readBuffer, 0, n);
+			n = reader.read(readBuffer);
+		}
+
+		String source = StringUtils.replace(s.toString(), "\r\n", "\n");
+		source = StringUtils.replace(source, "\r", "\n");
+		return source;
+	}
+
 	/**
 	 * IMPORTANT whoever calls this must releaseFromRead after they are done
 	 * using it.
@@ -78,6 +117,13 @@
 		IModelManager modelManager = StructuredModelManager.getModelManager();
 		InputStream inStream = getClass().getResourceAsStream(filename);
 		IStructuredModel sModel = modelManager.getModelForRead(filename, inStream, null);
+		
+		INodeAdapterFactory factory = sModel.getFactoryRegistry().getFactoryFor(IJSPTranslation.class);
+		if (factory == null) {
+			factory = new JSPTranslationAdapterFactory();
+			sModel.getFactoryRegistry().addFactory(factory);
+		}
+		
 		return sModel;
 	}
 }
\ No newline at end of file
diff --git a/tests/org.eclipse.jst.jsp.ui.tests/src/org/eclipse/jst/jsp/ui/tests/contentassist/JSPTranslationTest.java b/tests/org.eclipse.jst.jsp.ui.tests/src/org/eclipse/jst/jsp/ui/tests/contentassist/JSPTranslationTest.java
index b890f33..3aa1aff 100644
--- a/tests/org.eclipse.jst.jsp.ui.tests/src/org/eclipse/jst/jsp/ui/tests/contentassist/JSPTranslationTest.java
+++ b/tests/org.eclipse.jst.jsp.ui.tests/src/org/eclipse/jst/jsp/ui/tests/contentassist/JSPTranslationTest.java
@@ -185,7 +185,7 @@
 			
 			int jspTestPosition = translation.getJspText().indexOf("<%= ") + 4;
 			int javaOffset = translation.getJavaOffset(jspTestPosition) - classnameLength;
-			assertEquals("JSPTranslation java offset:", 972, javaOffset);
+			assertEquals("JSPTranslation java offset:", 1009, javaOffset);
 			
 			// (<%= | %>)
 			int javaTestPostition = translation.getJavaText().indexOf("out.print(\"\"+\n   \n);") + 14;
diff --git a/tests/org.eclipse.jst.jsp.ui.tests/src/org/eclipse/jst/jsp/ui/tests/contentassist/testfiles/jspInJavascript2.javasource b/tests/org.eclipse.jst.jsp.ui.tests/src/org/eclipse/jst/jsp/ui/tests/contentassist/testfiles/jspInJavascript2.javasource
new file mode 100644
index 0000000..03b0b36
--- /dev/null
+++ b/tests/org.eclipse.jst.jsp.ui.tests/src/org/eclipse/jst/jsp/ui/tests/contentassist/testfiles/jspInJavascript2.javasource
@@ -0,0 +1,36 @@
+import javax.servlet.*;

+import javax.servlet.http.*;

+import javax.servlet.jsp.*;

+

+public class _testfiles_2F_jspInJavascript2_2E_jsp extends javax.servlet.http.HttpServlet{

+String testJspString = "testJspString"; 

+

+public void _jspService(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)

+		throws java.io.IOException, javax.servlet.ServletException {

+javax.servlet.jsp.PageContext pageContext = null;

+javax.servlet.ServletContext application = null;

+javax.servlet.ServletConfig config = null;

+javax.servlet.jsp.JspWriter out = null;

+Object page = null;

+javax.servlet.http.HttpSession session = null;

+

+try {

+out.print(""+

+ testJspString 

+);

+  

+

+        if( request.getAttribute("SoapURL") != null )

+        {

+        

+out.print(""+

+ (String)request.getAttribute("SoapURL")

+);

+

+        }

+        else

+        { 

+        

+ } 

+ } catch (java.lang.Exception e) {} 

+}}

diff --git a/tests/org.eclipse.jst.jsp.ui.tests/src/org/eclipse/jst/jsp/ui/tests/contentassist/testfiles/jspInJavascript2.jsp b/tests/org.eclipse.jst.jsp.ui.tests/src/org/eclipse/jst/jsp/ui/tests/contentassist/testfiles/jspInJavascript2.jsp
new file mode 100644
index 0000000..e63843c
--- /dev/null
+++ b/tests/org.eclipse.jst.jsp.ui.tests/src/org/eclipse/jst/jsp/ui/tests/contentassist/testfiles/jspInJavascript2.jsp
@@ -0,0 +1,41 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+<HTML>
+<HEAD>
+<%@ page 
+language="java"
+contentType="text/html; charset=ISO-8859-1"
+pageEncoding="ISO-8859-1"
+%>
+<META http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
+<META name="GENERATOR" content="IBM WebSphere Studio">
+<TITLE>pmr.jsp</TITLE>
+
+<%!String testJspString = "testJspString"; %>
+<script> 
+
+var test = <%= testJspString %>;
+
+</script>
+
+
+
+</HEAD>
+<BODY>
+<%  %>
+<P>Place jspInJavascript2.jsp's content here.</P>
+   <script type="text/javascript">                      
+        <%
+        if( request.getAttribute("SoapURL") != null )
+        {
+        %>
+        var soapURL = "<%= (String)request.getAttribute("SoapURL")%>";
+        <%
+        }
+        else
+        { 
+        %>
+        var soapURL = document.location.href;
+   </script>
+<% } %>
+</BODY>
+</HTML>
diff --git a/tests/org.eclipse.jst.jsp.ui.tests/src/org/eclipse/jst/jsp/ui/tests/contentassist/translated_text.bin b/tests/org.eclipse.jst.jsp.ui.tests/src/org/eclipse/jst/jsp/ui/tests/contentassist/translated_text.bin
index 27a10c2..280b55a 100644
--- a/tests/org.eclipse.jst.jsp.ui.tests/src/org/eclipse/jst/jsp/ui/tests/contentassist/translated_text.bin
+++ b/tests/org.eclipse.jst.jsp.ui.tests/src/org/eclipse/jst/jsp/ui/tests/contentassist/translated_text.bin
@@ -28,6 +28,8 @@
 javax.swing.JButton BEAN_includedBean = new javax.swing.JButton();

  int include_include_int = 5; 

 javax.swing.JButton includesUseBean = new javax.swing.JButton();

+{ // <gifts:gift>

+} // </gifts:gift>

 out.print(""+

    

 );

diff --git a/tests/org.eclipse.jst.jsp.ui.tests/src/org/eclipse/jst/jsp/ui/tests/other/ScannerUnitTests.java b/tests/org.eclipse.jst.jsp.ui.tests/src/org/eclipse/jst/jsp/ui/tests/other/ScannerUnitTests.java
index 8449843..9c502fb 100644
--- a/tests/org.eclipse.jst.jsp.ui.tests/src/org/eclipse/jst/jsp/ui/tests/other/ScannerUnitTests.java
+++ b/tests/org.eclipse.jst.jsp.ui.tests/src/org/eclipse/jst/jsp/ui/tests/other/ScannerUnitTests.java
@@ -29,6 +29,7 @@
 import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegion;
 import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegionList;
 import org.eclipse.wst.sse.core.internal.provisional.text.ITextRegion;
+import org.eclipse.wst.sse.core.internal.provisional.text.ITextRegionCollection;
 import org.eclipse.wst.sse.core.internal.provisional.text.ITextRegionContainer;
 import org.eclipse.wst.sse.core.internal.provisional.text.ITextRegionList;
 import org.eclipse.wst.sse.core.internal.text.CoreNodeList;
@@ -520,6 +521,16 @@
 
 		testContent(setUpXML("hello world"));
 	}
+	
+	public void testDirectiveInTagBody() {
+		String text = "<BODY <%@ include file=\"commonEventHandlers.jspf\" %> dir=\"ltr\"> ";
+		IStructuredDocumentRegionList documentRegionList = setUpJSP(text);
+		verifyLengths(0, documentRegionList, text);
+
+		checkSimpleRegionTypes(documentRegionList.item(0).getRegions(), new String[]{DOMRegionContext.XML_TAG_OPEN, DOMRegionContext.XML_TAG_NAME, DOMRegionContext.XML_TAG_ATTRIBUTE_NAME, DOMRegionContext.XML_TAG_ATTRIBUTE_NAME, DOMRegionContext.XML_TAG_ATTRIBUTE_EQUALS, DOMRegionContext.XML_TAG_ATTRIBUTE_VALUE, DOMRegionContext.XML_TAG_CLOSE});
+		ITextRegionCollection coll = (ITextRegionCollection) documentRegionList.item(0).getRegions().get(2);
+		checkSimpleRegionTypes(coll.getRegions(), new String[]{DOMJSPRegionContexts.JSP_DIRECTIVE_OPEN, DOMRegionContext.WHITE_SPACE, DOMJSPRegionContexts.JSP_DIRECTIVE_NAME, DOMRegionContext.WHITE_SPACE, DOMRegionContext.XML_TAG_ATTRIBUTE_NAME, DOMRegionContext.XML_TAG_ATTRIBUTE_EQUALS, DOMRegionContext.XML_TAG_ATTRIBUTE_VALUE, DOMRegionContext.WHITE_SPACE, DOMJSPRegionContexts.JSP_DIRECTIVE_CLOSE});
+	}
 
 	public void testDollarsign_Leading() {
 		IStructuredDocumentRegionList nodes = setUpJSP("<a type=\"$ \"/>");