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
}
		
		int ref= findReferencePosition(offset, danglingElse, matchBrace, matchParen, matchCase);
		if (unindent)
			fIndent--;
		if (indent)
			fIndent++;
		return ref;
	}
	
	/**
	 * Returns the reference position regarding to indentation for <code>position</code>,
	 * or <code>NOT_FOUND</code>.<code>fIndent</code> will contain the
	 * relative indentation (in indentation units, not characters) after the
	 * call. If there is a special alignment (e.g. for a method declaration
	 * where parameters should be aligned), <code>fAlign</code> will contain
	 * the absolute position of the alignment reference in <code>fDocument</code>,
	 * otherwise <code>fAlign</code> is set to <code>JavaHeuristicScanner.NOT_FOUND</code>.
	 * 
	 * @param offset the offset for which the reference is computed
	 * @param danglingElse whether a dangling else should be assumed at <code>position</code>
	 * @param matchBrace whether the position of the matching brace should be
	 *            returned instead of doing code analysis
	 * @param matchParen whether the position of the matching parenthesis
	 *            should be returned instead of doing code analysis
	 * @param matchCase whether the position of a switch statement reference
	 *            should be returned (either an earlier case statement or the
	 *            switch block brace)
	 * @return the reference statement relative to which <code>position</code>
	 *         should be indented, or {@link JavaHeuristicScanner#NOT_FOUND}