Bug 6913 - Exception during "Organize imports"
Summary: Exception during "Organize imports"
Status: RESOLVED DUPLICATE of bug 6855
Alias: None
Product: JDT
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 2.0   Edit
Hardware: PC Windows 2000
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Erich Gamma CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2001-12-13 15:32 EST by Olivier Thomann CLA
Modified: 2001-12-14 04:21 EST (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Olivier Thomann CLA 2001-12-13 15:32:33 EST
From EC:

There is more information on my particular "crash case" (if it is 
related...). The following error occures if "organize import" is called for a 
file with syntax error. In this case it throws an exception if a semicolon is 
missing (with it everything wa fine):

4 org.eclipse.ui 0 Index out of bounds
java.lang.IllegalArgumentException: Index out of bounds
	at org.eclipse.swt.SWT.error(SWT.java:1873)
	at org.eclipse.swt.SWT.error(SWT.java:1819)
	at org.eclipse.swt.custom.StyledText.getLocationAtOffset
(StyledText.java:3294)
	at org.eclipse.jface.text.TextViewer.getWidthInPixels
(TextViewer.java:1460)
	at org.eclipse.jface.text.TextViewer.internalRevealRange
(TextViewer.java:1402)
	at org.eclipse.jface.text.TextViewer.revealRange(TextViewer.java:1341)
	at org.eclipse.ui.texteditor.AbstractTextEditor.selectAndReveal
(AbstractTextEditor.java:2100)
	at org.eclipse.jdt.internal.ui.javaeditor.OrganizeImportsAction.run
(OrganizeImportsAction.java:89)
	at org.eclipse.ui.texteditor.RetargetTextEditorAction.run
(RetargetTextEditorAction.java:103)
	at org.eclipse.jface.action.Action.runWithEvent(Action.java:452)
	at 
org.eclipse.jface.action.ActionContributionItem.handleWidgetSelection
(ActionContributionItem.java:407)
	at org.eclipse.jface.action.ActionContributionItem.handleWidgetEvent
(ActionContributionItem.java:361)
	at org.eclipse.jface.action.ActionContributionItem.access$0
(ActionContributionItem.java:352)
	at org.eclipse.jface.action.ActionContributionItem
$ActionListener.handleEvent(ActionContributionItem.java:47)
	at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:54)
	at org.eclipse.swt.widgets.Widget.notifyListeners(Widget.java:635)
	at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:1408)
	at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:1200)
	at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:775)
	at org.eclipse.ui.internal.Workbench.run(Workbench.java:758)
	at org.eclipse.core.internal.boot.InternalBootLoader.run
(InternalBootLoader.java:820)
	at org.eclipse.core.boot.BootLoader.run(BootLoader.java:285)
	at java.lang.reflect.Method.invoke(Native Method)
	at org.eclipse.core.launcher.Main.basicRun(Main.java:151)
	at org.eclipse.core.launcher.Main.run(Main.java:502)
	at org.eclipse.core.launcher.Main.main(Main.java:362)
Comment 1 Alexander Demenchuk CLA 2001-12-13 15:55:50 EST
Observed in 20011211 and 20011212. Could be related to bug 6855.
Comment 2 Olivier Thomann CLA 2001-12-13 15:59:39 EST
You should still provide the test case you have.
Comment 3 Alexander Demenchuk CLA 2001-12-13 16:07:18 EST
It also manifests itself in 20011213.
But! Only when "Show Source of Selected Element Only" is ON. Also, while this 
option is ON, an exception similar to the one in bug 6855 when one "jumps" to a 
source line (I clicked on a line in JUnit Failure Trace):

4 org.eclipse.ui 0 Index out of bounds
java.lang.IllegalArgumentException: Index out of bounds
	at org.eclipse.swt.SWT.error(SWT.java:1873)
	at org.eclipse.swt.SWT.error(SWT.java:1819)
	at org.eclipse.swt.custom.StyledText.getLocationAtOffset
(StyledText.java:3294)
	at org.eclipse.jface.text.TextViewer.getWidthInPixels
(TextViewer.java:1460)
	at org.eclipse.jface.text.TextViewer.internalRevealRange
(TextViewer.java:1398)
	at org.eclipse.jface.text.TextViewer.revealRange(TextViewer.java:1341)
	at org.eclipse.ui.texteditor.AbstractTextEditor.selectAndReveal
(AbstractTextEditor.java:2100)
	at org.eclipse.jdt.internal.junit.ui.TestRunnerViewPart.goToTest
(TestRunnerViewPart.java:585)
	at org.eclipse.jdt.internal.junit.ui.TestRunnerViewPart.goToFile
(TestRunnerViewPart.java:562)
	at 
org.eclipse.jdt.internal.junit.ui.FailureDetailView$1.mouseDoubleClick
(FailureDetailView.java:43)
	at org.eclipse.swt.widgets.TypedListener.handleEvent
(TypedListener.java:132)
	at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:54)
	at org.eclipse.swt.widgets.Widget.notifyListeners(Widget.java:635)
	at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:1408)
	at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:1200)
	at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:775)
	at org.eclipse.ui.internal.Workbench.run(Workbench.java:758)
	at org.eclipse.core.internal.boot.InternalBootLoader.run
(InternalBootLoader.java:820)
	at org.eclipse.core.boot.BootLoader.run(BootLoader.java:285)
	at java.lang.reflect.Method.invoke(Native Method)
	at org.eclipse.core.launcher.Main.basicRun(Main.java:151)
	at org.eclipse.core.launcher.Main.run(Main.java:502)
	at org.eclipse.core.launcher.Main.main(Main.java:362)
Comment 4 Alexander Demenchuk CLA 2001-12-13 16:13:15 EST
Test case:
1. create a class, f.e. like this

// I'm using the one where I can reproduce it, as it does not fail predictably
// - only with certain classes (and my guess here is worse than yours)

import junit.framework.Test;
import junit.framework.TestSuite;

public class AllTests {

	public static void main(String[] args) {
		TestRunner.run( suite() );
	}
	
	public static Test suite() {
		TestSuite suite = new TestSuite();
		//...
		return suite;
	}
}

2. (!!!) ensure that Outliner's option "Show Source of Selected Element Only" 
is selected
3. try to "Organize Import" - menu or shortcut would do the job

Comment 5 Erich Gamma CLA 2001-12-14 04:21:28 EST
this is a duplicate of 6855
since there was on integration build on Dec 13 you have to install the patch 
attached to 6855

*** This bug has been marked as a duplicate of 6855 ***