Bug 154993 - org.eclipse.jdt.ui.JavaNoTypeCompletionProposalComputer throws a runtime exception when using content assist on 'this.' in annontations
Summary: org.eclipse.jdt.ui.JavaNoTypeCompletionProposalComputer throws a runtime exce...
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.2   Edit
Hardware: PC Windows XP
: P3 major (vote)
Target Milestone: 3.2.2   Edit
Assignee: David Audel CLA
QA Contact:
URL:
Whiteboard:
Keywords:
: 154992 (view as bug list)
Depends on:
Blocks:
 
Reported: 2006-08-24 03:32 EDT by Frank Paaske CLA
Modified: 2007-01-16 05:13 EST (History)
1 user (show)

See Also:


Attachments
Proposed fix (5.73 KB, patch)
2006-11-20 05:52 EST, David Audel CLA
no flags Details | Diff
Proposed fix for 3.2.2 (5.53 KB, patch)
2006-11-20 07:19 EST, David Audel CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Frank Paaske CLA 2006-08-24 03:32:13 EDT
When writing an annontation and trying to use content assist on 'this', org.eclipse.jdt.ui.JavaNoTypeCompletionProposalComputer throws a runtime exception.

Example:

@Description("Some description for " + this.getName())
                                           ^
Using content assist will cause runtime exception here.

Of course, one should not use 'this' in such a situation, but a proper error message should be displayed instead of the runtime exception dialog.
Comment 1 Dani Megert CLA 2006-08-24 03:36:24 EDT
*** Bug 154992 has been marked as a duplicate of this bug. ***
Comment 2 Dani Megert CLA 2006-08-24 03:37:13 EDT
Please provide more info, see:
http://www.eclipse.org/eclipse/platform-text/development/bug-incomplete.htm
Comment 3 Frank Paaske CLA 2006-08-24 04:16:24 EDT
Version: 3.2.0
Build id: M20060629-1905
Other plug-ins: EclipseME
Compiler compliance level: 5.0
Log entry:
!ENTRY org.eclipse.jdt.ui 2 0 2006-08-24 10:16: 45.598
!MESSAGE The 'org.eclipse.jdt.ui.JavaNoTypeCompletionProposalComputer' proposal computer from the 'org.eclipse.jdt.ui' plug-in did not complete normally. The extension has thrown a runtime exception.
!STACK 0
java.lang.NullPointerException
    at org.eclipse.jdt.internal.codeassist.CompletionEngine.findLocalMethods(CompletionEngine.java:3999)
    at org.eclipse.jdt.internal.codeassist.CompletionEngine.findMethods(CompletionEngine.java :4708)
    at org.eclipse.jdt.internal.codeassist.CompletionEngine.findFieldsAndMethods(CompletionEngine.java:2832)
    at org.eclipse.jdt.internal.codeassist.CompletionEngine.complete(CompletionEngine.java:1004)
    at org.eclipse.jdt.internal.codeassist.CompletionEngine.complete(CompletionEngine.java:1766)
    at org.eclipse.jdt.internal.core.Openable.codeComplete(Openable.java:123)
    at org.eclipse.jdt.internal.core.CompilationUnit.codeComplete (CompilationUnit.java:313)
    at org.eclipse.jdt.internal.core.CompilationUnit.codeComplete(CompilationUnit.java:306)
    at org.eclipse.jdt.internal.ui.text.java.JavaCompletionProposalComputer.internalComputeCompletionProposals

(JavaCompletionProposalComputer.java:213)
    at org.eclipse.jdt.internal.ui.text.java.JavaCompletionProposalComputer.computeCompletionProposals

(JavaCompletionProposalComputer.java:193)
    at org.eclipse.jdt.internal.ui.text.java.CompletionProposalComputerDescriptor.computeCompletionProposals

(CompletionProposalComputerDescriptor.java:300)
    at org.eclipse.jdt.internal.ui.text.java.CompletionProposalCategory.computeCompletionProposals

(CompletionProposalCategory.java:263)
    at org.eclipse.jdt.internal.ui.text.java.ContentAssistProcessor.collectProposals (ContentAssistProcessor.java:218)
    at org.eclipse.jdt.internal.ui.text.java.ContentAssistProcessor.computeCompletionProposals(ContentAssistProcessor.java:187)
    at org.eclipse.jface.text.contentassist.ContentAssistant.computeCompletionProposals (ContentAssistant.java:1612)
    at org.eclipse.jface.text.contentassist.CompletionProposalPopup.computeProposals(CompletionProposalPopup.java:473)
    at org.eclipse.jface.text.contentassist.CompletionProposalPopup.access$17 (CompletionProposalPopup.java:470)
    at org.eclipse.jface.text.contentassist.CompletionProposalPopup$2.run(CompletionProposalPopup.java:405)
    at org.eclipse.swt.custom.BusyIndicator.showWhile(BusyIndicator.java :67)
    at org.eclipse.jface.text.contentassist.CompletionProposalPopup.showProposals(CompletionProposalPopup.java:399)
    at org.eclipse.jface.text.contentassist.ContentAssistant$2.run(ContentAssistant.java:347)
    at org.eclipse.swt.widgets.RunnableLock.run(RunnableLock.java:35)
    at org.eclipse.swt.widgets.Synchronizer.runAsyncMessages(Synchronizer.java:123)
    at org.eclipse.swt.widgets.Display.runAsyncMessages(Display.java :3325)
    at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:2971)
    at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:1914)
    at org.eclipse.ui.internal.Workbench.runUI(Workbench.java :1878)
    at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:419)
    at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149)
    at org.eclipse.ui.internal.ide.IDEApplication.run (IDEApplication.java:95)
    at org.eclipse.core.internal.runtime.PlatformActivator$1.run(PlatformActivator.java:78)
    at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java :92)
    at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:68)
    at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:400)
    at org.eclipse.core.runtime.adaptor.EclipseStarter.run (EclipseStarter.java:177)
    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:336)
    at org.eclipse.core.launcher.Main.basicRun(Main.java:280)
    at org.eclipse.core.launcher.Main.run(Main.java:977)
    at org.eclipse.core.launcher.Main.main(Main.java:952)

Reproduction:
Description.java -
package test;
public @interface Description {
    String value();
}

Test.java - This is ok
package test;
public class Test {
    @Description("Some description")
    public void method() {
    }
}

Test.java - This will produce the error when pressing '.' after 'this'
package test;
public class Test {
    String description = "Some description";
    @Description(this.description)
    public void method() {
    }
}
Comment 4 Frank Paaske CLA 2006-08-24 04:37:08 EDT
changed the severity from trivial to minor as this is not a cosmetic problem
Comment 5 Dani Megert CLA 2006-08-24 05:54:43 EDT
Can reproduce.
Comment 6 Dani Megert CLA 2006-08-24 05:57:08 EDT
See also older bug 132665.
Comment 7 David Audel CLA 2006-11-20 05:52:10 EST
Created attachment 54161 [details]
Proposed fix
Comment 8 David Audel CLA 2006-11-20 06:41:15 EST
Released for 3.3 M4.

Test added
  CompletionTest_1_5#test0297()

No completion must be proposed when the completion node is a CompleteOnMemberAccess and the completion occurs inside an annotation.
Comment 9 Philipe Mulet CLA 2006-11-20 06:55:55 EST
+1 for 3.2.2
Comment 10 David Audel CLA 2006-11-20 07:17:01 EST
Reopen to be backported to 3.2.2.
Comment 11 David Audel CLA 2006-11-20 07:19:05 EST
Created attachment 54165 [details]
Proposed fix for 3.2.2
Comment 12 David Audel CLA 2006-11-20 09:12:54 EST
Released for 3.2.2.

Test added
  CompletionTest_1_5#test0297()
Comment 13 Olivier Thomann CLA 2006-12-11 14:13:24 EST
Leave a RESOLVED FIXED for verification during 3.2.2 verification pass
Comment 14 Frederic Fusier CLA 2007-01-16 05:13:03 EST
Verified for 3.2.2 using build M20060112-1200.