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.

Bug 134239 - Provide SPI for "Insert Code"
Summary: Provide SPI for "Insert Code"
Status: RESOLVED FIXED
Alias: None
Product: editor
Classification: Unclassified
Component: -- Other -- (show other bugs)
Version: 6.x
Hardware: All All
: P3 blocker (vote)
Assignee: Max Sauer
URL:
Keywords: API, API_REVIEW_FAST
Depends on:
Blocks: 123448
  Show dependency tree
 
Reported: 2008-04-30 10:43 UTC by Dusan Balek
Modified: 2008-05-21 16:06 UTC (History)
9 users (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
Proposed change to the editor.lib2 SPI. (115.53 KB, patch)
2008-04-30 12:03 UTC, Dusan Balek
Details | Diff
Adding missing tests and how-to. (25.38 KB, patch)
2008-05-07 12:31 UTC, Dusan Balek
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Dusan Balek 2008-04-30 10:43:21 UTC
Create and provide SPI for adding additional actions into the "Insert Code" popup.
Comment 1 Dusan Balek 2008-04-30 12:03:49 UTC
Created attachment 60863 [details]
Proposed change to the editor.lib2 SPI.
Comment 2 Andrei Badea 2008-04-30 13:44:55 UTC
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.
Comment 3 Jan Pokorsky 2008-04-30 13:55:42 UTC
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 :-)
Comment 4 Marek Fukala 2008-04-30 14:56:36 UTC
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? 
Comment 5 Dusan Balek 2008-04-30 20:12:27 UTC
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.
Comment 6 Jaroslav Tulach 2008-05-02 17:33:41 UTC
Y01 Write some tests.
Y02 Write wizard into API support.
Y03 Write how to.
Comment 7 Dusan Balek 2008-05-07 12:31:27 UTC
Created attachment 61116 [details]
Adding missing tests and how-to.
Comment 8 Dusan Balek 2008-05-07 12:34:51 UTC
ad Y02) I would not see it as an objection to the API quality but rather a nice future enhancement.
Comment 9 Dusan Balek 2008-05-09 11:22:35 UTC
Integrated into main repository.

changeset 683559c2e1ee in main
details: http://hg.netbeans.org/main?cmd=changeset;node=683559c2e1ee
Comment 10 Quality Engineering 2008-05-10 04:32:49 UTC
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.
Comment 11 Geertjan Wielenga 2008-05-17 13:49:33 UTC
"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...
Comment 12 Geertjan Wielenga 2008-05-17 14:24:46 UTC
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.
Comment 13 Vitezslav Stejskal 2008-05-19 11:57:40 UTC
> 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?
Comment 14 Geertjan Wielenga 2008-05-19 14:23:21 UTC
>> 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.
Comment 15 Max Sauer 2008-05-21 12:24:12 UTC
The wizard has been added.
---
http://hg.netbeans.org/main/rev/e06c73e552f7
Comment 16 Quality Engineering 2008-05-21 16:06:15 UTC
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