[199053] Syntax errors outside of scripting areas not reported
diff --git a/bundles/org.eclipse.jst.jsp.core/src/org/eclipse/jst/jsp/core/internal/validation/JSPJavaValidator.java b/bundles/org.eclipse.jst.jsp.core/src/org/eclipse/jst/jsp/core/internal/validation/JSPJavaValidator.java
index 130e8fa..880bf0f 100644
--- a/bundles/org.eclipse.jst.jsp.core/src/org/eclipse/jst/jsp/core/internal/validation/JSPJavaValidator.java
+++ b/bundles/org.eclipse.jst.jsp.core/src/org/eclipse/jst/jsp/core/internal/validation/JSPJavaValidator.java
@@ -19,8 +19,10 @@
 import org.eclipse.core.runtime.Platform;
 import org.eclipse.jdt.core.compiler.IProblem;
 import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.Position;
 import org.eclipse.jst.jsp.core.internal.Logger;
 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.internal.java.JSPTranslationExtension;
 import org.eclipse.jst.jsp.core.internal.modelhandler.ModelHandlerForJSP;
@@ -101,17 +103,39 @@
 	 */
 	private IMessage createMessageFromProblem(IProblem problem, IFile f, IJSPTranslation translation, IStructuredDocument structuredDoc) {
 
+		int sev = problem.isError() ? IMessage.HIGH_SEVERITY : IMessage.NORMAL_SEVERITY;
 		int sourceStart = translation.getJspOffset(problem.getSourceStart());
 		int sourceEnd = translation.getJspOffset(problem.getSourceEnd());
-		if (sourceStart == -1)
-			return null;
+		if (sourceStart == -1) {
+			int problemID = problem.getID();
+			/*
+			 * Quoting IProblem doc: "When a problem is tagged as Internal, it
+			 * means that no change other than a local source code change can
+			 * fix the corresponding problem." Assuming that our generated
+			 * code is correct, that should reduce the reported problems to
+			 * those the user can correct.
+			 */
+			if (((problemID & IProblem.Internal) != 0) && ((problemID & IProblem.Syntax) != 0) && translation instanceof JSPTranslation) {
+				// Attach to the last code scripting section
+				JSPTranslation jspTranslation = ((JSPTranslation) translation);
+				Position[] jspPositions = (Position[]) jspTranslation.getJsp2JavaMap().keySet().toArray(new Position[jspTranslation.getJsp2JavaMap().size()]);
+				for (int i = 0; i < jspPositions.length; i++) {
+					sourceStart = Math.max(sourceStart, jspPositions[i].getOffset());
+				}
+				IMessage m = new LocalizedMessage(sev, problem.getMessage(), f);
+				m.setOffset(sourceStart);
+				m.setLength(1);
+				return m;
+			}
+			else {
+ 				return null;
+			}
+		}
 
 		// line number for marker starts @ 1
 		// line number from document starts @ 0
 		int lineNo = structuredDoc.getLineOfOffset(sourceStart) + 1;
 
-		int sev = problem.isError() ? IMessage.HIGH_SEVERITY : IMessage.NORMAL_SEVERITY;
-
 		IMessage m = new LocalizedMessage(sev, problem.getMessage(), f);
 
 		m.setLineNo(lineNo);
diff --git a/bundles/org.eclipse.jst.jsp.ui/plugin.xml b/bundles/org.eclipse.jst.jsp.ui/plugin.xml
index 427ba85..2d57a28 100644
--- a/bundles/org.eclipse.jst.jsp.ui/plugin.xml
+++ b/bundles/org.eclipse.jst.jsp.ui/plugin.xml
@@ -78,8 +78,6 @@
 				</partitionType>
 				<partitionType id="org.eclipse.jst.jsp.SCRIPT.JAVA">
 				</partitionType>
-				<partitionType id="org.eclipse.jst.jsp.SCRIPT.DELIMITER">
-				</partitionType>
 				<partitionType id="org.eclipse.jst.jsp.JSP_DIRECTIVE">
 				</partitionType>
 			</contentTypeIdentifier>
@@ -410,6 +408,10 @@
 			targetID="org.eclipse.ui.NavigateActionSet">
 			<part id="org.eclipse.jst.jsp.core.jspsource.source" />
 		</actionSetPartAssociation>
+		<actionSetPartAssociation
+            targetID="org.eclipse.debug.ui.launchActionSet">
+            <part id="org.eclipse.jst.jsp.core.jspsource.source"/>
+		</actionSetPartAssociation>
 	</extension>
 
 	<!--======================================================================================-->
diff --git a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/reconcile/DirtyRegionProcessor.java b/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/reconcile/DirtyRegionProcessor.java
index feb94ae..1a500b9 100644
--- a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/reconcile/DirtyRegionProcessor.java
+++ b/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/reconcile/DirtyRegionProcessor.java
@@ -62,7 +62,7 @@
 			if (isInRewriteSession() && fReprocessAfterRewrite)
 				return;
 			// save partition type (to see if it changes in documentChanged())
-			fLastPartitions = getPartitions(event.getOffset(), event.getLength());
+			fLastPartitions = getPartitionRegions(event.getOffset(), event.getLength());
 		}
 
 		public void documentChanged(DocumentEvent event) {
@@ -137,14 +137,14 @@
 				length = event.getText().length();
 			}
 
-			String[] newPartitions = getPartitions(event.getOffset(), length);
+			ITypedRegion[] newPartitions = getPartitionRegions(event.getOffset(), length);
 			if (fLastPartitions != null) {
 				if (fLastPartitions.length != newPartitions.length) {
 					changed = true;
 				}
 				else {
 					for (int i = 0; i < fLastPartitions.length; i++) {
-						if (!fLastPartitions[i].equals(newPartitions[i])) {
+						if (!fLastPartitions[i].getType().equals(newPartitions[i].getType())) {
 							changed = true;
 							break;
 						}
@@ -238,7 +238,7 @@
 	/**
 	 * so we can tell if a partition changed after the last edit
 	 */
-	String[] fLastPartitions;
+	ITypedRegion[] fLastPartitions;
 
 	List fNonIncrementalStrategiesAlreadyProcessed = new ArrayList(1);
 
@@ -472,6 +472,29 @@
 		return partitions;
 	}
 
+	ITypedRegion[] getPartitionRegions(int drOffset, int drLength) {
+		ITypedRegion[] regions = new ITypedRegion[0];
+		int docLength = getDocument().getLength();
+
+		if (drOffset > docLength) {
+			drOffset = docLength;
+			drLength = 0;
+		}
+		else if (drOffset + drLength > docLength) {
+			drLength = docLength - drOffset;
+		}
+
+		try {
+			regions = TextUtilities.computePartitioning(getDocument(), getDocumentPartitioning(), drOffset, drLength, true);
+		}
+		catch (BadLocationException e) {
+			Logger.logException(e);
+			regions = new ITypedRegion[0];
+		}
+		return regions;
+	}
+		
+		
 	/**
 	 * Returns the reconciling strategy registered with the reconciler for the
 	 * specified partition type.
@@ -498,7 +521,7 @@
 	 */
 	private synchronized DirtyRegion[] getRequests() {
 		DirtyRegion[] toRefresh = (DirtyRegion[]) fDirtyRegionQueue.toArray(new DirtyRegion[fDirtyRegionQueue.size()]);
-		fDirtyRegionQueue.clear();
+		flushDirtyRegionQueue();
 		return toRefresh;
 	}
 
@@ -677,8 +700,25 @@
 
 			// since we're marking the entire doc dirty
 			flushDirtyRegionQueue();
-			DirtyRegion entireDocument = createDirtyRegion(0, document.getLength(), DirtyRegion.INSERT);
-			processDirtyRegion(entireDocument);
+
+			/**
+			 * https://bugs.eclipse.org/bugs/show_bug.cgi?id=199053
+			 * 
+			 * Process the strategies for the last known-good partitions to
+			 * ensure all problem annotations are cleared if needed.
+			 */
+			if (fLastPartitions != null && document.getLength() == 0) {
+				for (int i = 0; i < fLastPartitions.length; i++) {
+					IReconcilingStrategy strategy = getReconcilingStrategy(fLastPartitions[i].getType());
+					if (strategy != null) {
+						strategy.reconcile(fLastPartitions[i]);
+					}
+				}
+			}
+			else {
+				DirtyRegion entireDocument = createDirtyRegion(0, document.getLength(), DirtyRegion.INSERT);
+				processDirtyRegion(entireDocument);
+			}
 		}
 	}
 
diff --git a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/reconcile/DocumentRegionProcessor.java b/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/reconcile/DocumentRegionProcessor.java
index fe472cb..90b5b0a 100644
--- a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/reconcile/DocumentRegionProcessor.java
+++ b/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/reconcile/DocumentRegionProcessor.java
@@ -21,6 +21,7 @@
 import org.eclipse.core.runtime.content.IContentType;
 import org.eclipse.jface.text.IDocument;
 import org.eclipse.jface.text.ITypedRegion;
+import org.eclipse.jface.text.Region;
 import org.eclipse.jface.text.reconciler.DirtyRegion;
 import org.eclipse.jface.text.reconciler.IReconcilingStrategy;
 import org.eclipse.jface.text.source.ISourceViewer;
@@ -199,7 +200,27 @@
 			fSpellcheckStrategy.setDocument(doc);
 		}
 	}
+	 
+	protected void setEntireDocumentDirty(IDocument document) {
+		super.setEntireDocumentDirty(document);
 
+		// make the entire document dirty
+		// this also happens on a "save as"
+		if (document != null && isInstalled() && fLastPartitions != null && document.getLength() == 0) {
+			/**
+			 * https://bugs.eclipse.org/bugs/show_bug.cgi?id=199053
+			 * 
+			 * Process the strategies for the last known-good partitions.
+			 */
+			for (int i = 0; i < fLastPartitions.length; i++) {
+				getValidatorStrategy().reconcile(fLastPartitions[i], createDirtyRegion(fLastPartitions[i], DirtyRegion.REMOVE));
+			}
+			if (fSpellcheckStrategy != null) {
+				fSpellcheckStrategy.reconcile(new Region(0, document.getLength()));
+			}
+		}
+	}
+	
 	/**
 	 * @see org.eclipse.wst.sse.ui.internal.reconcile.DirtyRegionProcessor#uninstall()
 	 */
diff --git a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/reconcile/validator/ValidatorStrategy.java b/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/reconcile/validator/ValidatorStrategy.java
index 2e63f9e..d660826 100644
--- a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/reconcile/validator/ValidatorStrategy.java
+++ b/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/reconcile/validator/ValidatorStrategy.java
@@ -84,6 +84,8 @@
 	public void beginProcessing() {
 		if (fTotalScopeValidatorsAlreadyRun == null)
 			fTotalScopeValidatorsAlreadyRun = new ArrayList();
+		else
+			fTotalScopeValidatorsAlreadyRun.clear();
 	}
 
 	/**