Bug 40038 [typing] Smart semicolon fooled by method braces
Build: I20030710 Start writing a setter method, like this: public void setValue(int i) {} Then position cursor between the braces and fill in the method body. You end up with this: public void setValue(int i) {this.value=i}; Problem: when you type the semicolon, it jumps over the closing method body brace and places it at the end of the line, resulting in a syntax error.
org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/java/SmartSemicolonAutoEditStrategy.java
import org.eclipse.jface.text.ITextSelection;
import org.eclipse.jface.text.ITypedRegion;
import org.eclipse.jface.text.Region;
import org.eclipse.jface.text.TextSelection;
import org.eclipse.jface.text.TextUtilities;
import org.eclipse.ui.IEditorPart;
import org.eclipse.ui.IWorkbenchPage;
import org.eclipse.ui.texteditor.ITextEditorExtension2;
import org.eclipse.ui.texteditor.ITextEditorExtension3;
import org.eclipse.jdt.ui.PreferenceConstants;
import org.eclipse.jdt.internal.core.Assert;
import org.eclipse.jdt.internal.ui.JavaPlugin;
import org.eclipse.jdt.internal.ui.javaeditor.CompilationUnitEditor;
import org.eclipse.jdt.internal.ui.text.IJavaPartitions;
import org.eclipse.jdt.internal.ui.text.SmartBackspaceManager;
import org.eclipse.jdt.internal.ui.text.SmartBackspaceManager.UndoSpec;
/**
 * Modifies <code>DocumentCommand</code>s inserting semicolons and opening braces to place them
 * smartly, i.e. moving them to the end of a line if that is what the user expects.
 * 
 * <p>In practice,  semicolons and braces (and the caret) are moved to the end of the line if they are typed
 * anywhere except for semicolons in a <code>for</code> statements definition. If the line contains a semicolon
 * or brace after the current caret position, the cursor is moved after it.</p>
 * 
 * @see org.eclipse.jface.text.DocumentCommand
 * @since 3.0
 */
public class SmartSemicolonAutoEditStrategy implements IAutoEditStrategy {
	
	private static final String SEMICOLON= ";";