Community
Participate
Working Groups
I have enabled the completion, but the exception was thrown when I wasn't trying to explicitly trigger a postfix completion. I have not yet figured steps to reproduce the problem. Relevant stack trace: java.lang.NullPointerException at org.eclipse.jdt.internal.ui.text.java.PostfixCompletionProposalComputer.updateTemplateEngine(PostfixCompletionProposalComputer.java:157) at org.eclipse.jdt.internal.ui.text.java.PostfixCompletionProposalComputer.analyzeCoreContext(PostfixCompletionProposalComputer.java:114) at org.eclipse.jdt.internal.ui.text.java.PostfixCompletionProposalComputer.computeCompletionEngine(PostfixCompletionProposalComputer.java:103) at org.eclipse.jdt.internal.ui.text.java.AbstractTemplateCompletionProposalComputer.computeCompletionProposals(AbstractTemplateCompletionProposalComputer.java:71) at org.eclipse.jdt.internal.ui.text.java.CompletionProposalComputerDescriptor.computeCompletionProposals(CompletionProposalComputerDescriptor.java:345) at org.eclipse.jdt.internal.ui.text.java.CompletionProposalCategory.computeCompletionProposals(CompletionProposalCategory.java:340) at org.eclipse.jdt.internal.ui.text.java.ContentAssistProcessor.collectProposals(ContentAssistProcessor.java:334) at org.eclipse.jdt.internal.ui.text.java.ContentAssistProcessor.computeCompletionProposals(ContentAssistProcessor.java:291) at org.eclipse.jface.text.contentassist.ContentAssistant$2.lambda$0(ContentAssistant.java:2015) at org.eclipse.jface.text.contentassist.ContentAssistant$2$$Lambda$1118.0000000019CFD820.accept(Unknown Source) at java.base/java.util.Collections$SingletonSet.forEach(Collections.java:4797) at org.eclipse.jface.text.contentassist.ContentAssistant$2.run(ContentAssistant.java:2014) at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:45) at org.eclipse.jface.text.contentassist.ContentAssistant.computeCompletionProposals(ContentAssistant.java:2011) at org.eclipse.jface.text.contentassist.CompletionProposalPopup.computeProposals(CompletionProposalPopup.java:575) at org.eclipse.jface.text.contentassist.CompletionProposalPopup.lambda$0(CompletionProposalPopup.java:505) at org.eclipse.jface.text.contentassist.CompletionProposalPopup$$Lambda$1117.0000000019B7D620.run(Unknown Source) at org.eclipse.swt.custom.BusyIndicator.showWhile(BusyIndicator.java:72) at org.eclipse.jface.text.contentassist.CompletionProposalPopup.showProposals(CompletionProposalPopup.java:500) at org.eclipse.jface.text.contentassist.ContentAssistant$AutoAssistListener.lambda$0(ContentAssistant.java:380) at org.eclipse.jface.text.contentassist.ContentAssistant$AutoAssistListener$$Lambda$1115.0000000019CB7420.run(Unknown Source) at org.eclipse.swt.widgets.RunnableLock.run(RunnableLock.java:40) at org.eclipse.swt.widgets.Synchronizer.runAsyncMessages(Synchronizer.java:185) at org.eclipse.swt.widgets.Display.runAsyncMessages(Display.java:4145) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3812) at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$5.run(PartRenderingEngine.java:1160) at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:338) at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.run(PartRenderingEngine.java:1049) at org.eclipse.e4.ui.internal.workbench.E4Workbench.createAndRunUI(E4Workbench.java:155) at org.eclipse.ui.internal.Workbench.lambda$3(Workbench.java:660) at org.eclipse.ui.internal.Workbench$$Lambda$107.0000000000000000.run(Unknown Source) at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:338) at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:559) at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:150) at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:150) at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:203) at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:137) at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:107) at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:401) at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:255) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.base/java.lang.reflect.Method.invoke(Method.java:567) at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:657) at org.eclipse.equinox.launcher.Main.basicRun(Main.java:594) at org.eclipse.equinox.launcher.Main.run(Main.java:1465)
The API of org.eclipse.jdt.core.dom.CompilationUnit.findDeclaringNode(String) says that it can return null, but the code doesn't check for null in PostfixCompletionProposalComputer.updateTemplateEngine(PostfixCompletionProposalComputer.java:157). @Roland: the code is coming from bug 458804, so not a regression, but would be nice to fix in 4.14 RC1.
Yup, should be a simple null guard for the result of CompilationUnit#findDeclaringNode(..) .
New Gerrit change created: https://git.eclipse.org/r/153087
If you're able to find a way to reproduce it would be nice as we may be able to produce a testcase for it.
Okay, I think I've found a way to reproduce. * consider the following file (note the unused import): import java.nio.file.Files; public class Main { public static void main(String[] args) { Paths. } } * put your cursor at the end of the Paths. statement. * trigger autocomplete. * select the first option that appears, get(URI uri); this should give you Paths.get(null) with an additional 'java.nio.file.Paths' import. * select all of get(null). * trigger autocomplete. * undo (Ctrl + Z or appropriate shortcut). * the error should appear.
(In reply to Pierre-Yves B. from comment #5) > Okay, I think I've found a way to reproduce. > > * consider the following file (note the unused import): > import java.nio.file.Files; > > public class Main { > public static void main(String[] args) { > Paths. > } > } > * put your cursor at the end of the Paths. statement. > * trigger autocomplete. > * select the first option that appears, get(URI uri); this should give you > Paths.get(null) with an additional 'java.nio.file.Paths' import. > * select all of get(null). > * trigger autocomplete. > * undo (Ctrl + Z or appropriate shortcut). > * the error should appear. In order to reproduce I had to specifically make sure that in the workspace preferences, under Java -> Editor -> Content Assist, 'Fill method arguments and show guessed arguments' was enabled, and also set to 'Insert best guessed arguments'. Also, I noticed that even with postfix completion entirely disabled, performing your exact instructions still breaks the syntax highlighting (all text becomes black) in the editor, so there may still be a bug. Can you confirm this also ?
(In reply to Roland Grunberg from comment #6) > Also, I noticed that even with postfix completion entirely disabled, > performing your exact instructions still breaks the syntax highlighting (all > text becomes black) in the editor, so there may still be a bug. Can you > confirm this also ? I did notice that as well, though it does not seem to happen systematically with my setup, only occasionally.
I would propose pushing the current fix in as it is the right thing to do. We can create a testcase afterwards if possible and I'll file a bug for the additional issue discussed in comment #6 and #7 .
Gerrit change https://git.eclipse.org/r/153087 was merged to [master]. Commit: http://git.eclipse.org/c/jdt/eclipse.jdt.ui.git/commit/?id=e32ca6d0cdab95ae902e011cd38dd279e92b5307
I'll file a separate bug for issues mentioned here that are reproducible even without postfix completion enabled.
Verified for 4.14 RC1 using I20191204-0600 build.