[222077] Automatically remove closing HTML element when user short-cutting no-body element
diff --git a/bundles/org.eclipse.wst.html.ui/src/org/eclipse/wst/html/ui/internal/autoedit/StructuredAutoEditStrategyHTML.java b/bundles/org.eclipse.wst.html.ui/src/org/eclipse/wst/html/ui/internal/autoedit/StructuredAutoEditStrategyHTML.java
index b4643ac..3985d55 100644
--- a/bundles/org.eclipse.wst.html.ui/src/org/eclipse/wst/html/ui/internal/autoedit/StructuredAutoEditStrategyHTML.java
+++ b/bundles/org.eclipse.wst.html.ui/src/org/eclipse/wst/html/ui/internal/autoedit/StructuredAutoEditStrategyHTML.java
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2001, 2006 IBM Corporation and others.
+ * Copyright (c) 2001, 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
@@ -51,6 +51,7 @@
 				if (command.text != null) {
 					smartInsertForComment(command, document, model);
 					smartInsertForEndTag(command, document, model);
+					smartRemoveEndTag(command, document, model);
 				}
 			}
 		}
@@ -67,6 +68,32 @@
 	private boolean isDocumentNode(IDOMNode node) {
 		return (node != null && node.getNodeType() == Node.DOCUMENT_NODE);
 	}
+	
+	/**
+	 * Attempts to clean up an end-tag if a start-tag is converted into an empty-element
+	 * tag (e.g., <node />) and the original element was empty.
+	 * 
+	 * @param command the document command describing the change
+	 * @param document the document that will be changed
+	 * @param model the model based on the document
+	 */
+	private void smartRemoveEndTag(DocumentCommand command, IDocument document, IStructuredModel model) {
+		try {
+			// An opening tag is now a self-terminated end-tag
+			if ("/".equals(command.text) && ">".equals(document.get(command.offset, 1))) { //$NON-NLS-1$ //$NON-NLS-2$
+				IDOMNode node = (IDOMNode) model.getIndexedRegion(command.offset);
+				if (node != null && !node.hasChildNodes()) {
+					IStructuredDocumentRegion region = node.getEndStructuredDocumentRegion();
+
+					if (region != null && region.isEnded())
+						document.replace(region.getStartOffset(), region.getLength(), ""); //$NON-NLS-1$
+				}
+			}
+		}
+		catch (BadLocationException e) {
+			Logger.logException(e);
+		}
+	}
 
 	private void smartInsertForComment(DocumentCommand command, IDocument document, IStructuredModel model) {
 		try {