Bug 127323 - context assist exception when trying to autocomplete inside a malformed enum switch
Summary: context assist exception when trying to autocomplete inside a malformed enum ...
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.1.1   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 3.2 M6   Edit
Assignee: David Audel CLA
QA Contact:
URL:
Whiteboard:
Keywords:
: 120347 (view as bug list)
Depends on:
Blocks:
 
Reported: 2006-02-10 15:22 EST by Michael Schierl CLA
Modified: 2006-03-28 10:03 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 Michael Schierl CLA 2006-02-10 15:22:35 EST
Take the following example (in a java1.5 enabled project):

package enumbug;

public class EnumBug {
	
	public static enum Foo {foo, bar, baz}

	public void bar(Foo f) {
		switch(f) {
		case Foo.baz:
		case  // <-- invoke context assist here!
		}
	}
}

It is incorrect since you may not qualify enums in a switch statement. Now try to complete the next case with context assist.

Resulting exception:

!ENTRY org.eclipse.ui 4 4 2006-02-10 21:20:15.668
!MESSAGE "Content Assist" did not complete normally.  Please see the log for more information.

!ENTRY org.eclipse.ui 4 0 2006-02-10 21:20:15.668
!MESSAGE org.eclipse.jdt.internal.compiler.ast.QualifiedNameReference
!STACK 0
java.lang.ClassCastException: org.eclipse.jdt.internal.compiler.ast.QualifiedNameReference
	at org.eclipse.jdt.internal.codeassist.CompletionEngine.findEnumConstant(CompletionEngine.java:1806)
	at org.eclipse.jdt.internal.codeassist.CompletionEngine.complete(CompletionEngine.java:719)
	at org.eclipse.jdt.internal.codeassist.CompletionEngine.complete(CompletionEngine.java:1533)
	at org.eclipse.jdt.internal.core.Openable.codeComplete(Openable.java:128)
	at org.eclipse.jdt.internal.core.CompilationUnit.codeComplete(CompilationUnit.java:301)
	at org.eclipse.jdt.internal.core.CompilationUnit.codeComplete(CompilationUnit.java:294)
	at org.eclipse.jdt.internal.ui.text.java.JavaCompletionProcessor.internalComputeCompletionProposals(JavaCompletionProcessor.java:336)
	at org.eclipse.jdt.internal.ui.text.java.JavaCompletionProcessor.computeCompletionProposals(JavaCompletionProcessor.java:313)
	at org.eclipse.jface.text.contentassist.ContentAssistant.computeCompletionProposals(ContentAssistant.java:1503)
	at org.eclipse.jface.text.contentassist.CompletionProposalPopup.computeProposals(CompletionProposalPopup.java:301)
	at org.eclipse.jface.text.contentassist.CompletionProposalPopup.access$13(CompletionProposalPopup.java:298)
	at org.eclipse.jface.text.contentassist.CompletionProposalPopup$2.run(CompletionProposalPopup.java:261)
	at org.eclipse.swt.custom.BusyIndicator.showWhile(BusyIndicator.java:69)
	at org.eclipse.jface.text.contentassist.CompletionProposalPopup.showProposals(CompletionProposalPopup.java:256)
	at org.eclipse.jface.text.contentassist.ContentAssistant.showPossibleCompletions(ContentAssistant.java:1352)
	at org.eclipse.jdt.internal.ui.javaeditor.CompilationUnitEditor$AdaptedSourceViewer.doOperation(CompilationUnitEditor.java:188)
	at org.eclipse.ui.texteditor.ContentAssistAction$1.run(ContentAssistAction.java:82)
	at org.eclipse.swt.custom.BusyIndicator.showWhile(BusyIndicator.java:69)
	at org.eclipse.ui.texteditor.ContentAssistAction.run(ContentAssistAction.java:80)
	at org.eclipse.jface.action.Action.runWithEvent(Action.java:996)
	at org.eclipse.ui.commands.ActionHandler.execute(ActionHandler.java:182)
	at org.eclipse.ui.internal.handlers.LegacyHandlerWrapper.execute(LegacyHandlerWrapper.java:108)
	at org.eclipse.core.commands.Command.execute(Command.java:311)
	at org.eclipse.core.commands.ParameterizedCommand.execute(ParameterizedCommand.java:396)
	at org.eclipse.ui.internal.keys.WorkbenchKeyboard.executeCommand(WorkbenchKeyboard.java:459)
	at org.eclipse.ui.internal.keys.WorkbenchKeyboard.press(WorkbenchKeyboard.java:781)
	at org.eclipse.ui.internal.keys.WorkbenchKeyboard.processKeyEvent(WorkbenchKeyboard.java:828)
	at org.eclipse.ui.internal.keys.WorkbenchKeyboard.filterKeySequenceBindings(WorkbenchKeyboard.java:550)
	at org.eclipse.ui.internal.keys.WorkbenchKeyboard.access$3(WorkbenchKeyboard.java:493)
	at org.eclipse.ui.internal.keys.WorkbenchKeyboard$KeyDownFilter.handleEvent(WorkbenchKeyboard.java:117)
	at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:66)
	at org.eclipse.swt.widgets.Display.filterEvent(Display.java:917)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:842)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:867)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:852)
	at org.eclipse.swt.widgets.Widget.sendKeyEvent(Widget.java:880)
	at org.eclipse.swt.widgets.Widget.sendKeyEvent(Widget.java:876)
	at org.eclipse.swt.widgets.Widget.wmChar(Widget.java:1190)
	at org.eclipse.swt.widgets.Control.WM_CHAR(Control.java:3135)
	at org.eclipse.swt.widgets.Control.windowProc(Control.java:3038)
	at org.eclipse.swt.widgets.Display.windowProc(Display.java:3706)
	at org.eclipse.swt.internal.win32.OS.DispatchMessageW(Native Method)
	at org.eclipse.swt.internal.win32.OS.DispatchMessage(OS.java:1656)
	at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:2711)
	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(Unknown Source)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
	at java.lang.reflect.Method.invoke(Unknown Source)
	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)
Comment 1 Jerome Lanneluc CLA 2006-02-17 10:48:58 EST
Reproduced with latest.
Comment 2 David Audel CLA 2006-02-20 06:38:22 EST
Fixed and test added
  CompletionTests_1_5#test0265()

Added protection in CompletionEngine.findEnumConstant()
Comment 3 David Audel CLA 2006-02-28 09:39:33 EST
*** Bug 120347 has been marked as a duplicate of this bug. ***
Comment 4 Olivier Thomann CLA 2006-03-28 10:03:13 EST
Verified using I20060328-0010 for 3.2M6