Bug 54094 Assertion failed in auto indent strategy
(in HEAD) The snippet editor subclasses the JavaSourceViewerConfiguration, and inherits its autoindent strategy. This is causing the following exception, when I attempt to enter a carriage return at the end of a snippet editor. For example, my editor cantained the following text. Placing the cursor at the end and pressing 'Enter' results in the stack trace. Should we not use the indent strategy? or can JUI allow us to continue using it? java.util.Vector v = null; v.add("Sam"); for (int i = 0; i < 100; i++) { } v.toString() org.eclipse.jface.text.Assert$AssertionFailedException: Assertion failed: at org.eclipse.jface.text.Assert.isTrue(Assert.java:175) at org.eclipse.jface.text.Assert.isTrue(Assert.java:160) at org.eclipse.jdt.internal.ui.text.JavaHeuristicScanner.scanForward (JavaHeuristicScanner.java:638) at org.eclipse.jdt.internal.ui.text.JavaHeuristicScanner.findNonWhitespaceForwardI nAnyPartition(JavaHeuristicScanner.java:607) at org.eclipse.jdt.internal.ui.text.JavaIndenter.skipToPreviousListItemOrListStart (JavaIndenter.java:759) at org.eclipse.jdt.internal.ui.text.JavaIndenter.findReferencePosition (JavaIndenter.java:559) at org.eclipse.jdt.internal.ui.text.JavaIndenter.findReferencePosition (JavaIndenter.java:405) at org.eclipse.jdt.internal.ui.text.JavaIndenter.getReferenceIndentation (JavaIndenter.java:105) at org.eclipse.jdt.internal.ui.text.JavaIndenter.computeIndentation (JavaIndenter.java:138) at org.eclipse.jdt.internal.ui.text.JavaIndenter.computeIndentation (JavaIndenter.java:124) at org.eclipse.jdt.internal.ui.text.java.JavaAutoIndentStrategy.smartIndentAfterNe wLine(JavaAutoIndentStrategy.java:261) at org.eclipse.jdt.internal.ui.text.java.JavaAutoIndentStrategy.customizeDocumentC ommand(JavaAutoIndentStrategy.java:996) at org.eclipse.jface.text.TextViewer.customizeDocumentCommand (TextViewer.java:3132) at org.eclipse.jface.text.TextViewer.handleVerifyEvent (TextViewer.java:3160) at org.eclipse.jface.text.TextViewer$TextVerifyListener.verifyText (TextViewer.java:322) at org.eclipse.swt.widgets.TypedListener.handleEvent (TypedListener.java:193) at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:82) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:833) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:857) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:842) at org.eclipse.swt.widgets.Widget.notifyListeners(Widget.java:650) at org.eclipse.swt.custom.StyledText.modifyContent (StyledText.java:5951) at org.eclipse.swt.custom.StyledText.sendKeyEvent(StyledText.java:6935) at org.eclipse.swt.custom.StyledText.doContent(StyledText.java:2557) at org.eclipse.swt.custom.StyledText.handleKey(StyledText.java:5304) at org.eclipse.swt.custom.StyledText.handleKeyDown (StyledText.java:5327) at org.eclipse.swt.custom.StyledText$7.handleEvent (StyledText.java:5070) at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:82) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:833) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:857) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:842) at org.eclipse.swt.widgets.Control.sendKeyEvent(Control.java:1716) at org.eclipse.swt.widgets.Control.sendKeyEvent(Control.java:1712) at org.eclipse.swt.widgets.Control.WM_CHAR(Control.java:3037) at org.eclipse.swt.widgets.Control.windowProc(Control.java:2940) at org.eclipse.swt.widgets.Display.windowProc(Display.java:2880) at org.eclipse.swt.internal.win32.OS.DispatchMessageW(Native Method) at org.eclipse.swt.internal.win32.OS.DispatchMessage(OS.java:1376) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:2031) at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:1509) at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:1480) at org.eclipse.ui.internal.Workbench.createAndRunWorkbench (Workbench.java:257) at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:139) at org.eclipse.ui.internal.ide.IDEApplication.run (IDEApplication.java:48) at org.eclipse.core.internal.runtime.PlatformActivator$1.run (PlatformActivator.java:260) at org.eclipse.core.runtime.adaptor.EclipseStarter.run (EclipseStarter.java:173) at org.eclipse.core.runtime.adaptor.EclipseStarter.run (EclipseStarter.java:106) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:324) at org.eclipse.core.launcher.Main.basicRun(Main.java:305) at org.eclipse.core.launcher.Main.run(Main.java:745) at org.eclipse.core.launcher.Main.main(Main.java:713)
org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/JavaIndenter.java
*/
	private void unindent(StringBuffer indent) {
		CharSequence oneIndent= createIndent();
		int i= indent.lastIndexOf(oneIndent.toString()); 
		if (i != -1) {
			indent.delete(i, i + oneIndent.length());
		}			
	}
	/**
	 * Creates an indentation string of the length indent - start + 1,
	 * consisting of the content in <code>fDocument</code> in the range
	 * [start, indent), with every character replaced by a space except for
	 * tabs, which are kept as such.
	 * 
	 * <p>Every run of the number of spaces that make up a tab are replaced
	 * by a tab character.</p>
	 * 
	 * @return the indentation corresponding to the document content specified
	 *         by <code>start</code> and <code>indent</code>
	 */
	private StringBuffer createIndent(int start, int indent) {
		final int tabLen= prefTabLength();		
		StringBuffer ret= new StringBuffer();
		try {
			int spaces= 0;
			while (start < indent) {
				
				char ch= fDocument.getChar(start);
				if (ch == '\t') {
					ret.append('\t');