Bug 41598 NPE in TypedPosition on commenting
20030813+0815 export select a sequence of lines and press ctrl+/ java.fullversion=J2RE 1.3.1 IBM J9 build 20030605 (JIT enabled) BootLoader constants: OS=win32, ARCH=x86, WS=win32, NL=en_US Command-line arguments: -os win32 -ws win32 -arch x86 -data d:\eclipseWorkbench7 \plugins -showlocation -install file:D:/eclipse20030813/eclipse/ !ENTRY org.eclipse.ui 4 4 Aug 15, 2003 11:43:32.739 !MESSAGE Unhandled exception caught in event loop. !ENTRY org.eclipse.ui 4 0 Aug 15, 2003 11:43:32.759 !MESSAGE java.lang.NullPointerException !STACK 0 java.lang.NullPointerException at java.lang.Throwable.<init>(Throwable.java) at java.lang.Throwable.<init>(Throwable.java) at java.lang.NullPointerException.<init>(NullPointerException.java:63) at org.eclipse.jface.text.TypedPosition.<init>(TypedPosition.java:41) at org.eclipse.jface.text.presentation.PresentationReconciler$InternalListener.docu mentAboutToBeChanged(PresentationReconciler.java:153) at org.eclipse.jface.text.AbstractDocument.fireDocumentAboutToBeChanged (AbstractDocument.java:549) at org.eclipse.jface.text.AbstractDocument.replace (AbstractDocument.java:956) at org.eclipse.jdt.internal.ui.javaeditor.PartiallySynchronizedDocument.replace (PartiallySynchronizedDocument.java:61) at org.eclipse.jface.text.TextViewer.shiftRight(TextViewer.java:3594) at org.eclipse.jface.text.TextViewer.shift(TextViewer.java:3546) at org.eclipse.jface.text.TextViewer.doOperation(TextViewer.java:3279) at org.eclipse.jface.text.source.SourceViewer.doOperation (SourceViewer.java:507) at org.eclipse.jdt.internal.ui.javaeditor.JavaSourceViewer.doOperation (JavaSourceViewer.java:72) at org.eclipse.jdt.internal.ui.javaeditor.CompilationUnitEditor$AdaptedSourceViewer .doOperation(CompilationUnitEditor.java:164) at org.eclipse.ui.texteditor.TextOperationAction$1.run (TextOperationAction.java:127) at org.eclipse.swt.custom.BusyIndicator.showWhile(BusyIndicator.java) at org.eclipse.ui.texteditor.TextOperationAction.run (TextOperationAction.java:125) at org.eclipse.jface.action.Action.runWithEvent(Action.java:842) at org.eclipse.ui.actions.RetargetAction.runWithEvent (RetargetAction.java:203) at org.eclipse.ui.internal.WWinPluginAction.runWithEvent (WWinPluginAction.java:212) at org.eclipse.jface.action.ActionContributionItem.handleWidgetSelection (ActionContributionItem.java:542) at org.eclipse.jface.action.ActionContributionItem.access$4 (ActionContributionItem.java:496) at org.eclipse.jface.action.ActionContributionItem$6.handleEvent (ActionContributionItem.java:468) at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java) at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java) at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:1676) at org.eclipse.ui.internal.Workbench.run(Workbench.java:1659) at org.eclipse.core.internal.boot.InternalBootLoader.run (InternalBootLoader.java:858) at org.eclipse.core.boot.BootLoader.run(BootLoader.java:461) at java.lang.reflect.AccessibleObject.invokeL(AccessibleObject.java:207) at java.lang.reflect.Method.invoke(Method.java:271) at org.eclipse.core.launcher.Main.basicRun(Main.java:291) at org.eclipse.core.launcher.Main.run(Main.java:747) at org.eclipse.core.launcher.Main.main(Main.java:583)
org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/javadoc/JavaDocAutoIndentStrategy.java
while (line == currentLine || isJavaDocLine(document, currentLine)) {
			
			if (buffer.length() != 0 && !Character.isWhitespace(buffer.charAt(buffer.length() - 1))) {
				buffer.append(' ');
				if (currentLine <= caretLine) {
					
					++caret;
				}
			}
			String string= getLineContents(document, currentLine);			
			buffer.append(string);
			currentLine++;
		}
		String paragraph= buffer.toString();
		
		if (paragraph.trim().length() == 0)
			return;
		caretOffset[0]= caretRelativeToParagraphOffset ? caret : 0;
		String delimiter= document.getLineDelimiter(0);
		String wrapped= formatParagraph(paragraph, caretOffset, indent, delimiter, getMargin());
		int beginning= document.getLineOffset(line);
		int end= document.getLineOffset(currentLine);
		document.replace(beginning, end - beginning, wrapped.toString());
		caretOffset[0]= caretRelativeToParagraphOffset ? caretOffset[0] + beginning : caret + beginning;
	}
	
	/**
	 * Line break iterator to handle whitespaces as first class citizens. 
	 */
	private static class LineBreakIterator {