Community
Participate
Working Groups
In Eclipse 4.5 the JDT API was modified via Bug 433500 to support an implementation of postfix code completion. See https://github.com/trylimits/Eclipse-Postfix-Code-Completion for a demo. Nico the main developer indicated that he would be interested to contribute that to JDT and Dani indicated that we should create a Gerrit review for that. This bug is to track this effort.
Pushed to gerrit (for a first review): https://git.eclipse.org/r/#/c/40855/ This commit covers all changes which would be needed to integrate Postfix Code Completion templates into JDT. As this commit is for review purposes and not supposed to be merged into master I did not include copyright notice and extended javadoc. In my opinion the actual integration should be split into more atomic parts, i.e. - Fixing the access restriction to ASTNode (compile error atm) - Adding/Extending VariableResolvers (newType, newActualType, newField) to the Java context (these are pretty helpful for conventional templates too) and extend JavaContext accordingly (addField(..), addImportGeneric(..), ...) - Postfix functionality (ProposalComputer, TemplateEngine, PostfixContext, ...) Ofc I would be willing to invest further work for the integration.
WARNING: this patchset contains 1322 new lines of code and may require a Contribution Questionnaire (CQ) if the author is not a committer on the project. Please see:https://wiki.eclipse.org/Project_Management_Infrastructure/Creating_A_Contribution_Questionnaire
WARNING: this patchset contains 1321 new lines of code and may require a Contribution Questionnaire (CQ) if the author is not a committer on the project. Please see:https://wiki.eclipse.org/Project_Management_Infrastructure/Creating_A_Contribution_Questionnaire
(In reply to Nicolaj Hoess from comment #1) > Pushed to gerrit (for a first review): https://git.eclipse.org/r/#/c/40855/ To begin with the review, this part has to be fixed first: > - Fixing the access restriction to ASTNode (compile error atm) Currently applying the patch on jdt.ui results in 96 compile errors, all related to accessing multiple internal classes from jdt.core: Discouraged access: xxx is not API (restriction on required project 'org.eclipse.jdt.core') You should check if the existing APIs can be used for the above or request for new APIs in jdt.core if required.
*** Bug 487030 has been marked as a duplicate of this bug. ***
(In reply to Noopur Gupta from comment #5) > You should check if the existing APIs can be used for the above or request > for new APIs in jdt.core if required. Moving to 4.7 as it may need new APIs in jdt.core.
*** Bug 507929 has been marked as a duplicate of this bug. ***
Sad, that this is still not being part of the default Eclipse JDT installation ... https://github.com/trylimits/Eclipse-Postfix-Code-Completion/issues/20 https://blog.novatec-gmbh.de/working-postfix-code-completion/
(In reply to Marco Descher from comment #9) > Sad, that this is still not being part of the default Eclipse JDT > installation ... > > https://github.com/trylimits/Eclipse-Postfix-Code-Completion/issues/20 > > https://blog.novatec-gmbh.de/working-postfix-code-completion/ A high-quality patch to integrate it in JDT will be welcome.
@Lars you had a fork of the tryLimits postfix implementation right ? Can't we polish it and bring that to JDT. i wonder how the licensing will effect on the original work of the author.
(In reply to Gayan Perera from comment #11) > @Lars you had a fork of the tryLimits postfix implementation right ? Can't > we polish it and bring that to JDT. i wonder how the licensing will effect > on the original work of the author. No worked happened in the fork. I think a good starting point is the Gerrit from Nicolaj
(In reply to Gayan Perera from comment #11) > @Lars you had a fork of the tryLimits postfix implementation right ? Can't > we polish it and bring that to JDT. i wonder how the licensing will effect > on the original work of the author. Don't mind the licensing. Unfortunately, I don't have enough knowledge to choose an adequate license type, but if I would have such knowledge, I would choose one which basically says: "I'm looking forward to see this feature integrated into Eclipse. I'm glad to grant any permission on the source code to anybody who is pursuing this goal."
(In reply to Nicolaj Hoess from comment #13 Great to hear that you are still around. :-)
I was thinking of taking this but I see the original author is still active. I'd be interested in reviewing this but just need to solidify an existing feature, then I could have a look.
(In reply to Roland Grunberg from comment #15) > I was thinking of taking this but I see the original author is still active. > I'd be interested in reviewing this but just need to solidify an existing > feature, then I could have a look. Nicolaj is not active anymore so it would be great if you can take this.
New Gerrit change created: https://git.eclipse.org/r/40855
New Gerrit change created: https://git.eclipse.org/r/147806
(In reply to Nicolaj Hoess from comment #13) > (In reply to Gayan Perera from comment #11) > > @Lars you had a fork of the tryLimits postfix implementation right ? Can't > > we polish it and bring that to JDT. i wonder how the licensing will effect > > on the original work of the author. > > Don't mind the licensing. > Unfortunately, I don't have enough knowledge to choose an adequate license > type, but if I would have such knowledge, I would choose one which basically > says: "I'm looking forward to see this feature integrated into Eclipse. I'm > glad to grant any permission on the source code to anybody who is pursuing > this goal." Hi Nicolaj, I know you're not active on the change but would it be possible for you to add license headers to the top of ActualTypeResolver.java, InnerExpressionResolver.java, JavaPostfixContext.java, JavaPostfixContextType.java, NewFieldResolver.java, and default-postfixtemplates.xml . Something like : /******************************************************************************* * Copyright (c) 2019 Nicolaj Hoess * * This program and the accompanying materials are made * available under the terms of the Eclipse Public License 2.0 * which is available at https://www.eclipse.org/legal/epl-2.0/ * * SPDX-License-Identifier: EPL-2.0 * * Contributors: * Nicolaj Hoess - Initial Contribution *******************************************************************************/ for the java files and using <!-- --> for the xml file. Most contributions are made under EPL-2.0 and that would be ideal for Eclipse, but, if you would strongly prefer to use another license, let me know so we can determine if it would be compatible.
(In reply to Roland Grunberg from comment #19) > (In reply to Nicolaj Hoess from comment #13) > > (In reply to Gayan Perera from comment #11) > > > @Lars you had a fork of the tryLimits postfix implementation right ? Can't > > > we polish it and bring that to JDT. i wonder how the licensing will effect > > > on the original work of the author. > > > > Don't mind the licensing. > > Unfortunately, I don't have enough knowledge to choose an adequate license > > type, but if I would have such knowledge, I would choose one which basically > > says: "I'm looking forward to see this feature integrated into Eclipse. I'm > > glad to grant any permission on the source code to anybody who is pursuing > > this goal." > > Hi Nicolaj, I know you're not active on the change but would it be possible > for you to add license headers to the top of ActualTypeResolver.java, > InnerExpressionResolver.java, JavaPostfixContext.java, > JavaPostfixContextType.java, NewFieldResolver.java, and > default-postfixtemplates.xml . > > Something like : > > / > ***************************************************************************** > ** > * Copyright (c) 2019 Nicolaj Hoess > * > * This program and the accompanying materials are made > * available under the terms of the Eclipse Public License 2.0 > * which is available at https://www.eclipse.org/legal/epl-2.0/ > * > * SPDX-License-Identifier: EPL-2.0 > * > * Contributors: > * Nicolaj Hoess - Initial Contribution > **************************************************************************** > ***/ > > for the java files and using <!-- --> for the xml file. Most contributions > are made under EPL-2.0 and that would be ideal for Eclipse, but, if you > would strongly prefer to use another license, let me know so we can > determine if it would be compatible. Sure, I'll do that asap (probably tomorrow evening). And btw. I really appreciate your help and contributions :-)
(In reply to Nicolaj Hoess from comment #20) > Sure, I'll do that asap (probably tomorrow evening). > And btw. I really appreciate your help and contributions :-) @Nicolaj, Thanks again for doing this. It seems I completely missed to ask for PostfixCompletionProposalComputer.java, PostfixTemplateEngine.java, PostfixTemplateProposal.java . They'll need headers the same as the previous ones. Thanks again.
Filed https://dev.eclipse.org/ipzilla/show_bug.cgi?id=20875 .
Gerrit change https://git.eclipse.org/r/40855 was merged to [master]. Commit: http://git.eclipse.org/c/jdt/eclipse.jdt.ui.git/commit/?id=42b307ea649ed9bda4fba37faf022b561da50fc1
Thanks Roland and Nicolaj for working on this. Should be report issues with postfix completion in this bug, or is it better to close this one and open new dependent bugs for it?
New Gerrit change created: https://git.eclipse.org/r/150450
(In reply to Lars Vogel from comment #24) > Thanks Roland and Nicolaj for working on this. > > Should be report issues with postfix completion in this bug, or is it better > to close this one and open new dependent bugs for it? I would open separate bugs. The only changes that will be associated with this are the N&N and possible formatting changes. Also, please note that PostFixCompletionTest seems to have many failures now, but this is due to Bug 549989 . The commit for that refactoring seems to have changed how certain template variables get resolved.
Created attachment 280128 [details] Current behavior in latest integration build. (In reply to Roland Grunberg from comment #26) > (In reply to Lars Vogel from comment #24) > > Thanks Roland and Nicolaj for working on this. > > > > Should be report issues with postfix completion in this bug, or is it better > > to close this one and open new dependent bugs for it? > > I would open separate bugs. The only changes that will be associated with > this are the N&N and possible formatting changes. > > Also, please note that PostFixCompletionTest seems to have many failures > now, but this is due to Bug 549989 . The commit for that refactoring seems > to have changed how certain template variables get resolved. I just tested the latest build and it seems that the current state is not usable at all, e.g. if I apply false.var$ it ends up in a text selection /false.|var - if I then apply the template again it resolves correctly (see attached gif for examples). I would appreciate if these integration issues are solved, before this ticket is closed.
Gerrit change https://git.eclipse.org/r/150450 was merged to [master]. Commit: http://git.eclipse.org/c/jdt/eclipse.jdt.ui.git/commit/?id=17553e2c1bee643caad649a7a930ba59d89dba5f
(In reply to Nicolaj Hoess from comment #27) > I just tested the latest build and it seems that the current state is not > usable at all, e.g. if I apply false.var$ it ends up in a text selection > /false.|var - if I then apply the template again it resolves correctly (see > attached gif for examples). > > I would appreciate if these integration issues are solved, before this > ticket is closed. Those issues were also caused by bug 549989, but should now be solved. Latest I-Build works correctly for me again, so I guess it's just the N&N that is needed now.
New Gerrit change created: https://git.eclipse.org/r/150616
Gerrit change https://git.eclipse.org/r/150616 was merged to [master]. Commit: http://git.eclipse.org/c/jdt/eclipse.jdt.ui.git/commit/?id=61dc417877d6f08c8ad7446136520671f41ddc23
New Gerrit change created: https://git.eclipse.org/r/150630
New Gerrit change created: https://git.eclipse.org/r/150631
New Gerrit change created: https://git.eclipse.org/r/150632
Gerrit change https://git.eclipse.org/r/150630 was merged to [master]. Commit: http://git.eclipse.org/c/jdt/eclipse.jdt.ui.git/commit/?id=98392df9bdef2f736420e927e1dbf1fe2afa0866
Gerrit change https://git.eclipse.org/r/150631 was merged to [master]. Commit: http://git.eclipse.org/c/jdt/eclipse.jdt.ui.git/commit/?id=9e6afb3d413c227d3526655926c1f40639e1d3fc
Thanks, Roland. Closing this for M1. Please add N&N for this and release new fixes in separate bug reports.
Verified for 4.14 M1 using I20191009-0600 build.
New Gerrit change created: https://git.eclipse.org/r/150965
Gerrit change https://git.eclipse.org/r/150965 was merged to [master]. Commit: http://git.eclipse.org/c/www.eclipse.org/eclipse/news.git/commit/?id=cb1a6e1b03a83ec4ac8ad37c968043c6cec886da
I've using the latest JDT nightly build, I just got the exception with postfix completion enabled: 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)
(In reply to Pierre-Yves B. from comment #41) > I've using the latest JDT nightly build, I just got the exception with > postfix completion enabled: Please file a new bug report with steps to reproduce if possible.
(In reply to Dani Megert from comment #42) > (In reply to Pierre-Yves B. from comment #41) > > I've using the latest JDT nightly build, I just got the exception with > > postfix completion enabled: > Please file a new bug report with steps to reproduce if possible. Done, see Bug 553279.
Please check bug 558434, that seem to be caused by the new proposal code added here.
(In reply to Andrey Loskutov from comment #44) > Please check bug 558434, that seem to be caused by the new proposal code > added here. See also bug 558436 and bug 558435.