This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.
Create and provide SPI for adding additional actions into the "Insert Code" popup.
Created attachment 60863 [details] Proposed change to the editor.lib2 SPI.
API looks fine to me. A nice enhancement would be the ability to order the factories into a tree. The four-letter competitor has this, as visible e.g. in their Spring Framework support. I do not consider this an integration blocker, just mentioning one of the possible future requirements.
JP1: I do not like using the Lookup as a black hole in API. I would welcome some supporting class JavaFactory implementing CodeGenerator.Factory and providing CompilationInfo, TreePath and JTextComponent as parameters. Now, you pull them magically as rabbits out of the hat in all your implementations :-)
Looks ok to me, maybe I am just not sure what will contextProviders = MimeLookup.getLookup(mimePath).lookupAll(CodeGeneratorContextProvider.class).iterator(); return. Will it be a list of providers for all of the languages on the mimetype or just the bottom most one? Is the idea that just the most deeply embedded language code generator will be used?
ad JP1) The JavaFactory as the Java specific helper class is IMHO out of the scope of this general SPI. I would rather see it as a possible enhancement to the java.editor SPI. ad mfukala) The context providers registered for the most deeply embedded language would be returned. There could be more of them registered by different modules.
Y01 Write some tests. Y02 Write wizard into API support. Y03 Write how to.
Created attachment 61116 [details] Adding missing tests and how-to.
ad Y02) I would not see it as an objection to the API quality but rather a nice future enhancement.
Integrated into main repository. changeset 683559c2e1ee in main details: http://hg.netbeans.org/main?cmd=changeset;node=683559c2e1ee
Integrated into 'main-golden', available in NB_Trunk_Production #186 build Changeset: http://hg.netbeans.org/main/rev/683559c2e1ee User: Dusan Balek <dbalek@netbeans.org> Log: 'Insert Code' SPI added - see issue #134239.
"ad Y02) I would not see it as an objection to the API quality but rather a nice future enhancement." Do you want external people to use this API? If "yes", you will create an apisupport wizard. If "no", you will continue believing that your statement makes sense...
I am reopening this issue, because nothing is provided anywhere (i.e., no tests, nothing in the API docs, nothing anywhere at all) to show how CodeGenerator.invoke should be used. Right now, this is unusable to external people.
> Do you want external people to use this API? If "yes", you will create an apisupport wizard. If "no", > you will continue believing that your statement makes sense... Oh, come on Geertjan, don't be so harsh. Of course we want external people to use our APIs. Please, I don't mean to fight over this, but has having a wizard become compulsory for new APIs? If so, we should turn Y02 into a TCR and fix it before releasing 6.5. If not, then I agree with Dusan and we will implement Y02 as time permits. > I am reopening this issue, because nothing is provided anywhere (i.e., no tests, nothing in the API docs, nothing > anywhere at all) to show how CodeGenerator.invoke should be used. Right now, this is unusable to external people. I'm not sure where you looked, but I can see the API description here http://bits.netbeans.org/dev/javadoc/org-netbeans-modules-editor-lib2/overview-summary.html (click on the codegen package) and the tests are in editor module, Unit Test Packages, org.netbeans.modules.editor.codegen. What exactly do you expect us to provide?
>> Do you want external people to use this API? If "yes", you will create an apisupport wizard. If "no", >> you will continue believing that your statement makes sense... >Oh, come on Geertjan, don't be so harsh. Sorry. >> Of course we want external people to use our APIs. Please, I don't mean to >> fight over this, but has having a wizard become compulsory for new APIs? If so, >> we should turn Y02 into a TCR and fix it >> before releasing 6.5. I would agree with that. If you create a wizard, even a very simple one, there is a 100% guarantee that people will use it -- it will be documented in the JavaHelp, there will be tutorials, you will have implicitly provided an entry point into the API, etc. Without a wizard... how will (most) people even know the API exists? >>What exactly do you expect us to provide? Some simple & complex implementations of CodeGenerator.invoke, for different MIME types. I made some here, but don't know if they're correct: http://blogs.sun.com/geertjan/entry/code_generator_spi_officially_available Based on the above, I still believe that, right now, the official support we have for this API is insufficient.
The wizard has been added. --- http://hg.netbeans.org/main/rev/e06c73e552f7
Integrated into 'main-golden', available in NB_Trunk_Production #209 build Changeset: http://hg.netbeans.org/main/rev/e06c73e552f7 User: Max Sauer <msauer@netbeans.org> Log: #134239: adding wizard for Code Generator SPI