Bug 100795 - [content assist] Content Assist with 'Completion overwrites' gives IAE at end of file
Summary: [content assist] Content Assist with 'Completion overwrites' gives IAE at end...
Status: RESOLVED DUPLICATE of bug 100808
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Text (show other bugs)
Version: 3.1   Edit
Hardware: PC Windows XP
: P3 major (vote)
Target Milestone: ---   Edit
Assignee: Tom Hofmann CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-06-20 06:57 EDT by Markus Keller CLA
Modified: 2005-06-21 11:22 EDT (History)
3 users (show)

See Also:


Attachments
ContentAssistant.diff (3.04 KB, patch)
2005-06-21 05:47 EDT, Tom Hofmann CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Markus Keller CLA 2005-06-20 06:57:54 EDT
- new workspace, new Java project, new package 'org.test'
- change preference 'Java > Editor > Code Assist > Insertion' to 'Completion
overwrites'
- create a new empty file 'Test.java'
- write 'package org.' and wait for content assist auto-activation

=> no content assist, but a log entry:

org.eclipse.swt.SWTException: Failed to execute runnable
(java.lang.IllegalArgumentException: Argument not valid)
        at org.eclipse.swt.SWT.error(SWT.java:2940)
        at org.eclipse.swt.SWT.error(SWT.java:2863)
        at
org.eclipse.swt.widgets.Synchronizer.runAsyncMessages(Synchronizer.java:121)
        at org.eclipse.swt.widgets.Display.runAsyncMessages(Display.java:3047)
        at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:2706)
        at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:1699)
        at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:1663)
        at
org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:367)
        at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:143)
        at org.eclipse.ui.internal.ide.IDEApplication.run(IDEApplication.java:103)
        at
org.eclipse.core.internal.runtime.PlatformActivator$1.run(PlatformActivator.java:226)
        at
org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:376)
        at
org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:163)
        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:585)
        at org.eclipse.core.launcher.Main.invokeFramework(Main.java:334)
        at org.eclipse.core.launcher.Main.basicRun(Main.java:278)
        at org.eclipse.core.launcher.Main.run(Main.java:973)
        at org.eclipse.core.launcher.Main.main(Main.java:948)
Caused by: java.lang.IllegalArgumentException: Argument not valid
        at org.eclipse.swt.SWT.error(SWT.java:2924)
        at org.eclipse.swt.SWT.error(SWT.java:2863)
        at org.eclipse.swt.SWT.error(SWT.java:2834)
        at
org.eclipse.swt.custom.StyledText.getStyleRangeAtOffset(StyledText.java:4305)
        at
org.eclipse.jdt.internal.ui.text.java.JavaCompletionProposal.updateStyle(JavaCompletionProposal.java:624)
        at
org.eclipse.jdt.internal.ui.text.java.JavaCompletionProposal.selected(JavaCompletionProposal.java:648)
        at
org.eclipse.jface.text.contentassist.CompletionProposalPopup.selectProposal(CompletionProposalPopup.java:822)
        at
org.eclipse.jface.text.contentassist.CompletionProposalPopup.setProposals(CompletionProposalPopup.java:608)
        at
org.eclipse.jface.text.contentassist.CompletionProposalPopup.access$13(CompletionProposalPopup.java:577)
        at
org.eclipse.jface.text.contentassist.CompletionProposalPopup$1.run(CompletionProposalPopup.java:236)
        at org.eclipse.swt.custom.BusyIndicator.showWhile(BusyIndicator.java:69)
        at
org.eclipse.jface.text.contentassist.CompletionProposalPopup.showProposals(CompletionProposalPopup.java:212)
        at
org.eclipse.jface.text.contentassist.ContentAssistant$2.run(ContentAssistant.java:327)
        at org.eclipse.swt.widgets.RunnableLock.run(RunnableLock.java:35)
        at
org.eclipse.swt.widgets.Synchronizer.runAsyncMessages(Synchronizer.java:118)
        ... 18 more
Failed to execute runnable (java.lang.IllegalArgumentException: Argument not valid)
Comment 1 Dani Megert CLA 2005-06-20 07:47:39 EDT
Code assist no longer works afterwards. Worked in 3.0.
Tom, please investigate whether there's an easy fix.
Comment 2 Tom Hofmann CLA 2005-06-20 09:31:10 EDT
The CompletionProposal instances received from core specify an illegal
replacement range. In the given example, the package completion proposals
specify a replaceOffset of 8 (the position of 'org' in the document) and an
exclusive replaceEnd of 13, while the document length is 12.

Note that the proposal is correct if there is a trailing space behind the caret.
Then, the core proposal specifies a replace range of [8, 12).

I filed bug 100808 against jdt-core about this.

Should guard against illegal proposals?
Comment 3 Dani Megert CLA 2005-06-20 09:52:01 EDT
yes.
Comment 4 Tom Hofmann CLA 2005-06-21 05:47:38 EDT
Created attachment 23602 [details]
ContentAssistant.diff

Patch against ContentAssistant.

Whenever one of the popups (proposals, contexts) is asked to display proposals,
this can lead to unexpected exceptions in the client side ICompletionProposal
implementations. If this happens, this patch tries to regularly shut down the
content assistant (closing popup shells, removing listeners) and then rethrows
the exception.
Comment 5 Dani Megert CLA 2005-06-21 06:01:23 EDT
+1 for 3.1 RC4.

Dirk and Martin, please cast your vote.
Comment 6 Martin Aeschlimann CLA 2005-06-21 10:08:13 EDT
+1 to fix this for RC4. Having the editor in a state where code assist doesn't
work anymore is worth a fix.
I'm hestitating to ok the patch as I don't see how it guarantees to prevent the
bad state. I would suggest to not try to solve the whole problem, but just the
given scenario of invalid ranges:
- either don't create the proposals with the invalid ranges at all
- or add extra checks in the proposal before applying/selecting and do nothing
Comment 7 Dani Megert CLA 2005-06-21 11:22:39 EDT
No action then. If we only want to handle just this instance for 3.1 then this
has to be done on J Core side (see bug 100808 comment 1).

Bug 101033 is about better protecting the content assistant.

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