Bug 100868 - [code assist] Code assist does not recommend methods in anonymous enum subclass
Summary: [code assist] Code assist does not recommend methods in anonymous enum subclass
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 3.1   Edit
Hardware: PC Windows XP
: P3 minor (vote)
Target Milestone: 3.1.1   Edit
Assignee: Tobias Widmer CLA Friend
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-06-20 11:50 EDT by David Saff CLA Friend
Modified: 2005-09-02 09:47 EDT (History)
2 users (show)

See Also:


Attachments
Proposed patch (1.05 KB, text/plain)
2005-06-21 09:19 EDT, David Audel CLA Friend
no flags Details
Better patch (1.54 KB, text/plain)
2005-07-06 04:50 EDT, David Audel CLA Friend
no flags Details
Proposed fix (1.83 KB, patch)
2005-08-09 10:10 EDT, Olivier Thomann CLA Friend
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description David Saff CLA Friend 2005-06-20 11:50:22 EDT
In RC3.  Consider code:

public enum Foo {
	A {
		tos<<>>
	};
}

Where the cursor is at <<>>.  Invoking code assist does not offer to override
toString: it only offers class names.
Comment 1 David Audel CLA Friend 2005-06-21 09:19:26 EDT
Created attachment 23613 [details]
Proposed patch

sourceEnd of the enum constant node is at '{' location instead of ')' or name's
sourceEnd location. So recovery believe that { is not present.
Comment 2 David Audel CLA Friend 2005-07-06 04:50:58 EDT
Created attachment 24375 [details]
Better patch

sourceEnd of enum constant must not be changed. This patch improve recovery
instead.
Comment 3 David Audel CLA Friend 2005-07-06 04:55:24 EDT
Fix released and test added
  EnumCompletionParserTest#test0014()
Comment 4 Olivier Thomann CLA Friend 2005-08-09 09:54:25 EDT
Reopen.
Now I get the completion for toString(), but it fails with:
java.lang.ClassCastException: org.eclipse.jdt.core.dom.EnumConstantDeclaration
	at
org.eclipse.jdt.internal.ui.text.java.OverrideCompletionProposal.updateReplacementString(OverrideCompletionProposal.java:109)
	at
org.eclipse.jdt.internal.ui.text.java.JavaTypeCompletionProposal.apply(JavaTypeCompletionProposal.java:95)
	at
org.eclipse.jdt.internal.ui.text.java.JavaCompletionProposal.apply(JavaCompletionProposal.java:565)
	at
org.eclipse.jface.text.contentassist.CompletionProposalPopup.insertProposal(CompletionProposalPopup.java:502)
	at
org.eclipse.jface.text.contentassist.CompletionProposalPopup.insertSelectedProposalWithMask(CompletionProposalPopup.java:453)
	at
org.eclipse.jface.text.contentassist.CompletionProposalPopup.access$23(CompletionProposalPopup.java:449)
	at
org.eclipse.jface.text.contentassist.CompletionProposalPopup$5.widgetDefaultSelected(CompletionProposalPopup.java:390)
	at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java:97)
	at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:66)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:868)
	at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:3137)
	at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:2765)
	at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:1734)
	at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:1698)
	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:338)
	at org.eclipse.core.launcher.Main.basicRun(Main.java:282)
	at org.eclipse.core.launcher.Main.run(Main.java:977)
	at org.eclipse.core.launcher.Main.main(Main.java:952)

Move to JDT/UI
Comment 5 Olivier Thomann CLA Friend 2005-08-09 10:10:57 EDT
Created attachment 25897 [details]
Proposed fix

The fix is trivial. AnonymousClassDeclaration were considered only with a
ClassInstanceCreation as a parent. An EnumConstantDeclaration can also have
such child.
Comment 6 Philipe Mulet CLA Friend 2005-08-10 05:19:13 EDT
Given we addressed this issue in 3.1.1, it would be good that UI fix also gets
released for 3.1.1
Comment 7 Dirk Baeumer CLA Friend 2005-08-10 05:23:55 EDT
Tobias, can you please have a look. I opt to fix this for 3.1.1 since it now
causes a CCE.
Comment 8 Tobias Widmer CLA Friend 2005-08-10 06:49:52 EDT
patch looks good to me

+1 for 3.1.1

Markus, can you please vote on this one?
Comment 9 Markus Keller CLA Friend 2005-08-10 14:21:42 EDT
+1. The patch looks good (modulo compact assignment and indentation of the case
statements:-).
Comment 10 Olivier Thomann CLA Friend 2005-08-10 14:24:25 EDT
I'll be more careful next time I provide a patch :-).
Will this be fixed for 3.2M1?
Comment 11 Tobias Widmer CLA Friend 2005-08-11 04:23:02 EDT
No, it didn't make it into M1
Comment 12 Tobias Widmer CLA Friend 2005-08-11 04:24:53 EDT
Fixed in 3.1.1 maintenance stream > 20050811
Comment 13 Tobias Widmer CLA Friend 2005-08-15 04:43:00 EDT
Fixed in HEAD > 20050815
Comment 14 Tom Hofmann CLA Friend 2005-09-02 08:40:30 EDT
verifying...
Comment 15 Tom Hofmann CLA Friend 2005-09-02 09:47:59 EDT
verified the proposal works and there is no CCE