is content assist possible with dynamic methods or properties?

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

is content assist possible with dynamic methods or properties?

Carl Parisi

Is it possible have content assist on dynamic methods that were defined in the same method? 
Given the following code, is it possible to have the "newDynamicMethod" be content-assist-presented on the myObj?

def myCode(){

  com.me.MyClass.metaClass.newDynamicMethod = { 
      String string->
      def rel = delegate.runOldMethod(string);
      
      return rel;
   } 

   com.me.MyClass myObj = getMyObj();

   myObj.newDynamicMethod("hello");

}

Reply | Threaded
Open this post in threaded view
|

Re: is content assist possible with dynamic methods or properties?

Andrew Eisenberg-2
You will need to create a dsld for this. See here http://groovy.codehaus.org/DSL+Descriptors+for+Groovy-Eclipse

On Saturday, February 2, 2013, Carl Parisi wrote:

Is it possible have content assist on dynamic methods that were defined in the same method? 
Given the following code, is it possible to have the "newDynamicMethod" be content-assist-presented on the myObj?

def myCode(){

  com.me.MyClass.metaClass.newDynamicMethod = { 
      String string->
      def rel = delegate.runOldMethod(string);
      
      return rel;
   } 

   com.me.MyClass myObj = getMyObj();

   myObj.newDynamicMethod("hello");

}

Reply | Threaded
Open this post in threaded view
|

Re: is content assist possible with dynamic methods or properties?

Carl Parisi
Thanks for the response. I have been looking at the DSLD but was not clear on how to define a method in which the name is dynamic
and unknown. Since the groovy code has not been executed yet, how is the dsld determine what the new method name will be?


On Sat, Feb 2, 2013 at 10:12 AM, Andrew Eisenberg <[hidden email]> wrote:
You will need to create a dsld for this. See here http://groovy.codehaus.org/DSL+Descriptors+for+Groovy-Eclipse

On Saturday, February 2, 2013, Carl Parisi wrote:

Is it possible have content assist on dynamic methods that were defined in the same method? 
Given the following code, is it possible to have the "newDynamicMethod" be content-assist-presented on the myObj?

def myCode(){

  com.me.MyClass.metaClass.newDynamicMethod = { 
      String string->
      def rel = delegate.runOldMethod(string);
      
      return rel;
   } 

   com.me.MyClass myObj = getMyObj();

   myObj.newDynamicMethod("hello");

}


Reply | Threaded
Open this post in threaded view
|

Re: is content assist possible with dynamic methods or properties?

Andrew Eisenberg
Sorry...I wrote the response early in the morning and didn't fully
understand your problem.

DSLD is not good at adding methods with dynamically generated names.
If there is an algorithmic way of generating the names, then you can
use that to generate the methods in dsld, but if the method names are
truly arbitrary, then there's not much that can be done.

Exactly how will these names be generated?

On Sat, Feb 2, 2013 at 7:33 AM, Carl Parisi <[hidden email]> wrote:

> Thanks for the response. I have been looking at the DSLD but was not clear
> on how to define a method in which the name is dynamic
> and unknown. Since the groovy code has not been executed yet, how is the
> dsld determine what the new method name will be?
>
>
> On Sat, Feb 2, 2013 at 10:12 AM, Andrew Eisenberg
> <[hidden email]> wrote:
>>
>> You will need to create a dsld for this. See here
>> http://groovy.codehaus.org/DSL+Descriptors+for+Groovy-Eclipse
>>
>> On Saturday, February 2, 2013, Carl Parisi wrote:
>>>
>>>
>>> Is it possible have content assist on dynamic methods that were defined
>>> in the same method?
>>> Given the following code, is it possible to have the "newDynamicMethod"
>>> be content-assist-presented on the myObj?
>>>
>>> def myCode(){
>>>
>>>   com.me.MyClass.metaClass.newDynamicMethod = {
>>>       String string->
>>>       def rel = delegate.runOldMethod(string);
>>>
>>>       return rel;
>>>    }
>>>
>>>    com.me.MyClass myObj = getMyObj();
>>>
>>>    myObj.newDynamicMethod("hello");
>>>
>>> }
>>>
>

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

    http://xircles.codehaus.org/manage_email


Reply | Threaded
Open this post in threaded view
|

Re: is content assist possible with dynamic methods or properties?

Carl Parisi
I have an api similar to this:

-----------------------
// given these interfaces:
interface Person {
     String getFirstName();
     String getLastName();
}

interface Place {
     String getLocation();
}

// select the methods you need
table.select(Person.getFirstName);
table.select(Place.getLocation);

// Create a new interface with the selected methods
newInterface = table.createNewInterface();

newInterface.getPersonFirstName();
newInterface.getPlaceLocation();


----------------
The method names can be calculated, but I have no idea if it is possible
to have the groovy plugin figure out the new names.




On 2/2/2013 3:52 PM, Andrew Eisenberg wrote:

> Sorry...I wrote the response early in the morning and didn't fully
> understand your problem.
>
> DSLD is not good at adding methods with dynamically generated names.
> If there is an algorithmic way of generating the names, then you can
> use that to generate the methods in dsld, but if the method names are
> truly arbitrary, then there's not much that can be done.
>
> Exactly how will these names be generated?
>
> On Sat, Feb 2, 2013 at 7:33 AM, Carl Parisi <[hidden email]> wrote:
>> Thanks for the response. I have been looking at the DSLD but was not clear
>> on how to define a method in which the name is dynamic
>> and unknown. Since the groovy code has not been executed yet, how is the
>> dsld determine what the new method name will be?
>>
>>
>> On Sat, Feb 2, 2013 at 10:12 AM, Andrew Eisenberg
>> <[hidden email]> wrote:
>>> You will need to create a dsld for this. See here
>>> http://groovy.codehaus.org/DSL+Descriptors+for+Groovy-Eclipse
>>>
>>> On Saturday, February 2, 2013, Carl Parisi wrote:
>>>>
>>>> Is it possible have content assist on dynamic methods that were defined
>>>> in the same method?
>>>> Given the following code, is it possible to have the "newDynamicMethod"
>>>> be content-assist-presented on the myObj?
>>>>
>>>> def myCode(){
>>>>
>>>>    com.me.MyClass.metaClass.newDynamicMethod = {
>>>>        String string->
>>>>        def rel = delegate.runOldMethod(string);
>>>>
>>>>        return rel;
>>>>     }
>>>>
>>>>     com.me.MyClass myObj = getMyObj();
>>>>
>>>>     myObj.newDynamicMethod("hello");
>>>>
>>>> }
>>>>
> ---------------------------------------------------------------------
> 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: is content assist possible with dynamic methods or properties?

Andrew Eisenberg
DSLD is not appropriate for any kind of complex static analysis.  The
reason for this is that the DSLD scripts are invoked once for every
expression in the current file.  The scripts should be declarative as
much as possible or else they will run too slowly.

If you do want to do something like this, then you will need to create
your own plugin and and use a lower-level api to get more fine-grained
control over the inferencing engine.  You can read this blog post to
see how this can be done:

http://contraptionsforprogramming.blogspot.com/2009/12/extending-groovy-eclipse-for-use-with.html

Grails-ide uses a mix of DSLD and extension points to implement its
editor features. You can see here
https://github.com/SpringSource/grails-ide/blob/master/org.grails.ide.eclipse.editor.groovy/src/org/grails/ide/eclipse/editor/groovy/contentassist/GrailsProposalProvider.java
and here
https://github.com/SpringSource/grails-ide/blob/master/org.grails.ide.eclipse.editor.groovy/src/org/grails/ide/eclipse/editor/groovy/types/GrailsTypeLookup.java
for the implementation.

And here is the grails.dsld file:
https://github.com/SpringSource/grails-ide/blob/master/org.grails.ide.eclipse.resources/dsl-support/dsld/grails.dsld

On Mon, Feb 4, 2013 at 4:45 AM, Carl Parisi <[hidden email]> wrote:

> I have an api similar to this:
>
> -----------------------
> // given these interfaces:
> interface Person {
>     String getFirstName();
>     String getLastName();
> }
>
> interface Place {
>     String getLocation();
> }
>
> // select the methods you need
> table.select(Person.getFirstName);
> table.select(Place.getLocation);
>
> // Create a new interface with the selected methods
> newInterface = table.createNewInterface();
>
> newInterface.getPersonFirstName();
> newInterface.getPlaceLocation();
>
>
> ----------------
> The method names can be calculated, but I have no idea if it is possible to
> have the groovy plugin figure out the new names.
>
>
>
>
>
> On 2/2/2013 3:52 PM, Andrew Eisenberg wrote:
>>
>> Sorry...I wrote the response early in the morning and didn't fully
>> understand your problem.
>>
>> DSLD is not good at adding methods with dynamically generated names.
>> If there is an algorithmic way of generating the names, then you can
>> use that to generate the methods in dsld, but if the method names are
>> truly arbitrary, then there's not much that can be done.
>>
>> Exactly how will these names be generated?
>>
>> On Sat, Feb 2, 2013 at 7:33 AM, Carl Parisi <[hidden email]>
>> wrote:
>>>
>>> Thanks for the response. I have been looking at the DSLD but was not
>>> clear
>>> on how to define a method in which the name is dynamic
>>> and unknown. Since the groovy code has not been executed yet, how is the
>>> dsld determine what the new method name will be?
>>>
>>>
>>> On Sat, Feb 2, 2013 at 10:12 AM, Andrew Eisenberg
>>> <[hidden email]> wrote:
>>>>
>>>> You will need to create a dsld for this. See here
>>>> http://groovy.codehaus.org/DSL+Descriptors+for+Groovy-Eclipse
>>>>
>>>> On Saturday, February 2, 2013, Carl Parisi wrote:
>>>>>
>>>>>
>>>>> Is it possible have content assist on dynamic methods that were defined
>>>>> in the same method?
>>>>> Given the following code, is it possible to have the "newDynamicMethod"
>>>>> be content-assist-presented on the myObj?
>>>>>
>>>>> def myCode(){
>>>>>
>>>>>    com.me.MyClass.metaClass.newDynamicMethod = {
>>>>>        String string->
>>>>>        def rel = delegate.runOldMethod(string);
>>>>>
>>>>>        return rel;
>>>>>     }
>>>>>
>>>>>     com.me.MyClass myObj = getMyObj();
>>>>>
>>>>>     myObj.newDynamicMethod("hello");
>>>>>
>>>>> }
>>>>>
>> ---------------------------------------------------------------------
>> 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
>
>

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

    http://xircles.codehaus.org/manage_email