Tweaking Code Completion Assistant via Extension Point

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Tweaking Code Completion Assistant via Extension Point

Romain Bioteau
Hi, I'm working on a project where we have embedded a Groovy editor in a
SWT Dialog to provide a simple Groovy Script Editor.
We have done this using the M1 and we are now migrating to M2. Much
improvements have been made on the content assist. Therefore
our code based on M1 for the tweaking of the content assist is now
obselete. The major tweak we want to make are :
- add some variables in the VariableScope for the
LocalVariableCompletionProcessor.
- remove the contributed methods from DefaultGroovyMethod
- addind method contribution

I see that in the M2 there is an extension point provided but without
any schema.xsd. Is this extension point working in M2 ?
If yes, how ?
If not, I'm open to any suggestions to do the job as clean as possible
(avoid forking existing code).

Thanks
Romain


---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply | Threaded
Open this post in threaded view
|

Re: Tweaking Code Completion Assistant via Extension Point

Romain Bioteau
I manage to perform a good part of my goals using the completionProposalProvider like this :

<extension point="org.codehaus.groovy.eclipse.codeassist.completion.completionProposalProvider">
       <proposalProvider proposalProvider="org.bonitasoft.studio.groovy.contentassist.BonitaProposalProvider">
                <appliesTo projectNature = "org.eclipse.jdt.groovy.core.groovyNature"/>
       </proposalProvider>
</extension>

As the schema seems to be missing, I have made some investigation in the code and found the extension point structure and how to use it.  
Using this extension point I was able to add my own IGroovyProposal (for Variable and Methods).
It could be great to have an extension point to filter the proposals (by example : hide/remove the DefaultGroovyMethods)
 
I appreciate the improvements made in this M2 with the execution time of the content assist, great job !

2009/12/21 Romain Bioteau <[hidden email]>
Hi, I'm working on a project where we have embedded a Groovy editor in a SWT Dialog to provide a simple Groovy Script Editor.
We have done this using the M1 and we are now migrating to M2. Much improvements have been made on the content assist. Therefore
our code based on M1 for the tweaking of the content assist is now obselete. The major tweak we want to make are :
- add some variables in the VariableScope for the LocalVariableCompletionProcessor.
- remove the contributed methods from DefaultGroovyMethod
- addind method contribution

I see that in the M2 there is an extension point provided but without any schema.xsd. Is this extension point working in M2 ?
If yes, how ?
If not, I'm open to any suggestions to do the job as clean as possible (avoid forking existing code).

Thanks
Romain




--
<div><p><span style="font-weight: bold;">Romain Bioteau<br><span style="color: rgb(204, 0, 0);">Directeur R&D Engeneer</span><br>

</span></p><table><tbody><tr><td><a href="http://www.bonitasoft.com" target="_blank"><img src="http://www.bonitasoft.com/images/logo-bonitasoft-mini.jpg" alt="BonitaSoft - Open your processes" style="border: medium none ;"></a></td><td style="padding-left: 15px;">
Reply | Threaded
Open this post in threaded view
|

Re: Tweaking Code Completion Assistant via Extension Point

Andrew Eisenberg
In reply to this post by Romain Bioteau
Hi Romain,

I have been planning to blog about this for a while, and this is just
a reminder.  :)

To summarize, there are 3 extension points that you might be interested in:
* org.eclipse.jdt.groovy.core.typeLookup --- adds new types to the
inferencing engine.  See
org.eclipse.jdt.groovy.search.AbstractSimplifiedTypeLookup and
org.eclipse.jdt.groovy.search.ITypeLookup for sample implementations
* org.codehaus.groovy.eclipse.ui.syntaxHightlightingExtension --- adds
new keywords and syntax highlighting rules to the editor.
* org.codehaus.groovy.eclipse.codeassist.completion.completionProposalProvider
--- Adds new content assist proposals.

Based on your description, I think you will want to extend
org.eclipse.jdt.groovy.core.typeLookup and subclass
org.eclipse.jdt.groovy.search.AbstractSimplifiedTypeLookup.  When you
implement the initialize() method, you can add whatever you want to
the VariableScope.

All of these extension points are nature based, so they only apply if
your project has the nature specified in the extension point.

These 3 extension points are what we are using to implement Grails
support.  Although they are meant to be general, since we only have
one use case so far, they may be less general than we would like them
to be.  So, you can consider them to be still provisional and so if
you find that they are somehow insufficient for what you need, let me
know and I will try to support your use case.

And you're right...the schema files should be included in the source
build.  I'll add that today.

hope this helps,
--a

On Mon, Dec 21, 2009 at 1:35 AM, Romain Bioteau
<[hidden email]> wrote:

> Hi, I'm working on a project where we have embedded a Groovy editor in a SWT
> Dialog to provide a simple Groovy Script Editor.
> We have done this using the M1 and we are now migrating to M2. Much
> improvements have been made on the content assist. Therefore
> our code based on M1 for the tweaking of the content assist is now obselete.
> The major tweak we want to make are :
> - add some variables in the VariableScope for the
> LocalVariableCompletionProcessor.
> - remove the contributed methods from DefaultGroovyMethod
> - addind method contribution
>
> I see that in the M2 there is an extension point provided but without any
> schema.xsd. Is this extension point working in M2 ?
> If yes, how ?
> If not, I'm open to any suggestions to do the job as clean as possible
> (avoid forking existing code).
>
> Thanks
> Romain
>
>
> ---------------------------------------------------------------------
> To unsubscribe from this list, please visit:
>
>   http://xircles.codehaus.org/manage_email
>
>
>

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply | Threaded
Open this post in threaded view
|

Re: Re: Tweaking Code Completion Assistant via Extension Point

Andrew Eisenberg
In reply to this post by Romain Bioteau
> It could be great to have an extension point to filter the proposals (by
> example : hide/remove the DefaultGroovyMethods)

That sounds reasonable.  Would you be willing to submit a patch for
this?  If not, perhaps you could raise a jira issue.

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply | Threaded
Open this post in threaded view
|

Re: Tweaking Code Completion Assistant via Extension Point

Andrew Eisenberg
In reply to this post by Andrew Eisenberg
The schema files are now available in the latest snapshot release.

Just to make things clear below, if you extend the
org.eclipse.jdt.groovy.core.typeLookup extension point, then you can
add types to the inferencing engine.  This will ensure that those
references are not underlined and will help with navigation, etc, but
this will not add the references to content assist.  For that, you
need to use org.codehaus.groovy.eclipse.codeassist.completion.completionProposalProvider.

Hope this makes sense.

On Mon, Dec 21, 2009 at 8:49 AM, Andrew Eisenberg <[hidden email]> wrote:

> Hi Romain,
>
> I have been planning to blog about this for a while, and this is just
> a reminder.  :)
>
> To summarize, there are 3 extension points that you might be interested in:
> * org.eclipse.jdt.groovy.core.typeLookup --- adds new types to the
> inferencing engine.  See
> org.eclipse.jdt.groovy.search.AbstractSimplifiedTypeLookup and
> org.eclipse.jdt.groovy.search.ITypeLookup for sample implementations
> * org.codehaus.groovy.eclipse.ui.syntaxHightlightingExtension --- adds
> new keywords and syntax highlighting rules to the editor.
> * org.codehaus.groovy.eclipse.codeassist.completion.completionProposalProvider
> --- Adds new content assist proposals.
>
> Based on your description, I think you will want to extend
> org.eclipse.jdt.groovy.core.typeLookup and subclass
> org.eclipse.jdt.groovy.search.AbstractSimplifiedTypeLookup.  When you
> implement the initialize() method, you can add whatever you want to
> the VariableScope.
>
> All of these extension points are nature based, so they only apply if
> your project has the nature specified in the extension point.
>
> These 3 extension points are what we are using to implement Grails
> support.  Although they are meant to be general, since we only have
> one use case so far, they may be less general than we would like them
> to be.  So, you can consider them to be still provisional and so if
> you find that they are somehow insufficient for what you need, let me
> know and I will try to support your use case.
>
> And you're right...the schema files should be included in the source
> build.  I'll add that today.
>
> hope this helps,
> --a
>
> On Mon, Dec 21, 2009 at 1:35 AM, Romain Bioteau
> <[hidden email]> wrote:
>> Hi, I'm working on a project where we have embedded a Groovy editor in a SWT
>> Dialog to provide a simple Groovy Script Editor.
>> We have done this using the M1 and we are now migrating to M2. Much
>> improvements have been made on the content assist. Therefore
>> our code based on M1 for the tweaking of the content assist is now obselete.
>> The major tweak we want to make are :
>> - add some variables in the VariableScope for the
>> LocalVariableCompletionProcessor.
>> - remove the contributed methods from DefaultGroovyMethod
>> - addind method contribution
>>
>> I see that in the M2 there is an extension point provided but without any
>> schema.xsd. Is this extension point working in M2 ?
>> If yes, how ?
>> If not, I'm open to any suggestions to do the job as clean as possible
>> (avoid forking existing code).
>>
>> Thanks
>> Romain
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe from this list, please visit:
>>
>>   http://xircles.codehaus.org/manage_email
>>
>>
>>
>

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email