Community
Participate
Working Groups
The following exception is produced when modifying the Java editor's document via an IRewriteTarget: java.lang.IllegalArgumentException: Index out of bounds at org.eclipse.swt.SWT.error(SWT.java:2677) at org.eclipse.swt.SWT.error(SWT.java:2616) at org.eclipse.swt.SWT.error(SWT.java:2587) at org.eclipse.swt.custom.StyledText.replaceStyleRanges (StyledText.java:6231) at org.eclipse.jface.text.TextViewer.addPresentation (TextViewer.java:4040) at org.eclipse.jface.text.TextViewer.changeTextPresentation (TextViewer.java:4119) at org.eclipse.jface.text.presentation.PresentationReconciler.applyTextRegionColle ction(PresentationReconciler.java:568) at org.eclipse.jface.text.presentation.PresentationReconciler.processDamage (PresentationReconciler.java:557) at org.eclipse.jface.text.presentation.PresentationReconciler.access$3 (PresentationReconciler.java:553) at org.eclipse.jface.text.presentation.PresentationReconciler$InternalListener.tex tChanged(PresentationReconciler.java:222) at org.eclipse.jface.text.TextViewer.updateTextListeners (TextViewer.java:2235) at org.eclipse.jface.text.TextViewer.fireRedrawChanged (TextViewer.java:4275) at org.eclipse.jface.text.TextViewer.enabledRedrawing (TextViewer.java:4345) at org.eclipse.jface.text.TextViewer.enabledRedrawing (TextViewer.java:4304) at org.eclipse.jface.text.TextViewer.setRedraw(TextViewer.java:4420) at org.eclipse.jface.text.TextViewer.setRedraw(TextViewer.java:4392) at org.eclipse.jface.text.TextViewer$RewriteTarget.setRedraw (TextViewer.java:951) Sample code to reproduce the problem: while (!validateEditorInputState()) { if (!display.readAndDispatch()) { display.sleep(); } } IRewriteTarget target= (IRewriteTarget) getTextEditor().getAdapter (IRewriteTarget.class); if (target != null) { target.beginCompoundChange(); target.setRedraw(false); } try { IDocument document = target.getDocument(); // modify the document here } finally { target.endCompoundChange(); target.setRedraw(true); } The exception is reproducible in build 200406180800
Changing the "ConvertLineDelimiterAction" to your snippet, I cannot reproduce the problem in RC3. Please attach the source you're using. What kind of editor are you working on?
I've managed to reproduce the problem by taking the following actions: 1. Open any .java file 2. In the Java editor, select all text by using the edit menu (CTRL+A probably works, too) 3. Press CTRL+I to fix indenting The following stack trace results: java.lang.IllegalArgumentException: Index out of bounds at org.eclipse.swt.SWT.error(SWT.java:2677) at org.eclipse.swt.SWT.error(SWT.java:2616) at org.eclipse.swt.SWT.error(SWT.java:2587) at org.eclipse.swt.custom.StyledText.replaceStyleRanges (StyledText.java:6231) at org.eclipse.jface.text.TextViewer.addPresentation (TextViewer.java:4042) at org.eclipse.jface.text.TextViewer.changeTextPresentation (TextViewer.java:4121) at org.eclipse.jface.text.presentation.PresentationReconciler.applyTextRegionColle ction(PresentationReconciler.java:568) at org.eclipse.jface.text.presentation.PresentationReconciler.processDamage (PresentationReconciler.java:557) at org.eclipse.jface.text.presentation.PresentationReconciler.access$3 (PresentationReconciler.java:553) at org.eclipse.jface.text.presentation.PresentationReconciler$InternalListener.tex tChanged(PresentationReconciler.java:222) at org.eclipse.jface.text.TextViewer.updateTextListeners (TextViewer.java:2237) at org.eclipse.jface.text.TextViewer.fireRedrawChanged (TextViewer.java:4277) at org.eclipse.jface.text.TextViewer.enabledRedrawing (TextViewer.java:4347) at org.eclipse.jface.text.TextViewer.enabledRedrawing (TextViewer.java:4306) at org.eclipse.jface.text.TextViewer.setRedraw(TextViewer.java:4422) at org.eclipse.jface.text.TextViewer.setRedraw(TextViewer.java:4394) at org.eclipse.jface.text.TextViewer$RewriteTarget.setRedraw (TextViewer.java:951) at org.eclipse.jdt.internal.ui.actions.IndentAction$1.run (IndentAction.java:173) at org.eclipse.swt.custom.BusyIndicator.showWhile (BusyIndicator.java:69) at org.eclipse.jdt.internal.ui.actions.IndentAction.run (IndentAction.java:181) at org.eclipse.jface.action.Action.runWithEvent(Action.java:881) at org.eclipse.ui.actions.RetargetAction.runWithEvent (RetargetAction.java:212) at org.eclipse.ui.internal.WWinPluginAction.runWithEvent (WWinPluginAction.java:211) at org.eclipse.ui.commands.ActionHandler.execute (ActionHandler.java:141) at org.eclipse.ui.internal.commands.Command.execute(Command.java:132) at org.eclipse.ui.internal.keys.WorkbenchKeyboard.executeCommand (WorkbenchKeyboard.java:469) at org.eclipse.ui.internal.keys.WorkbenchKeyboard.press (WorkbenchKeyboard.java:887) at org.eclipse.ui.internal.keys.WorkbenchKeyboard.processKeyEvent (WorkbenchKeyboard.java:928) at org.eclipse.ui.internal.keys.WorkbenchKeyboard.filterKeySequenceBindings (WorkbenchKeyboard.java:546) at org.eclipse.ui.internal.keys.WorkbenchKeyboard.access$2 (WorkbenchKeyboard.java:494) at org.eclipse.ui.internal.keys.WorkbenchKeyboard$1.handleEvent (WorkbenchKeyboard.java:259) at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:82) at org.eclipse.swt.widgets.Display.filterEvent(Display.java:714) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:795) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:820) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:805) at org.eclipse.swt.widgets.Control.sendKeyEvent(Control.java:1734) at org.eclipse.swt.widgets.Control.sendKeyEvent(Control.java:1730) at org.eclipse.swt.widgets.Control.WM_CHAR(Control.java:3067) at org.eclipse.swt.widgets.Control.windowProc(Control.java:2970) at org.eclipse.swt.widgets.Display.windowProc(Display.java:3298) at org.eclipse.swt.internal.win32.OS.DispatchMessageW(Native Method) at org.eclipse.swt.internal.win32.OS.DispatchMessage(OS.java:1467) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:2396) at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:1375) at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:1346) at org.eclipse.ui.internal.Workbench.createAndRunWorkbench (Workbench.java:252) at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:141) at org.eclipse.ui.internal.ide.IDEApplication.run (IDEApplication.java:96) at org.eclipse.core.internal.runtime.PlatformActivator$1.run (PlatformActivator.java:335) at org.eclipse.core.runtime.adaptor.EclipseStarter.run (EclipseStarter.java:272) at org.eclipse.core.runtime.adaptor.EclipseStarter.run (EclipseStarter.java:128) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at org.eclipse.core.launcher.Main.basicRun(Main.java:186) at org.eclipse.core.launcher.Main.run(Main.java:647) at org.eclipse.core.launcher.Main.main(Main.java:631) Note that I'm not able to reproduce this consistently: it appears to be timing- related.
BTW, the afore comment was in eclipse 3.0 RC3
Tried several *.java files using I200406230010 and could not reproduce.
David, What kind of visual decorations of the text do you have enabled? Semantic highlighting, find occurrences, etc.? Do you have any non-SDK implementer of ITextPresentationListener installed on the Java editor or are you running the bar SDK?
Thanks for your quick response. As far as visual decorations, I've got the following enabled: - code folding - highlight current line - line numbers Symantic highlighting is turned off. I do have an ITextPresentationListener installed on the Java editor.
Does it (the text presentation listener) come from the SDK or is it a custom one?
It is a custom one. It inspects the text presentation's extent offset and length, and if they meet certain criteria calls textPresentation.mergeStyle() with a new foreground color.
Oops... this one is a defect with my ITextPresentationListener that had an off- by-one index problem, not related to the eclipse codebase. My apologies to everyone for their effort on this one.
Get rid of deprecated state.
.