[jbosstools-dev] Playing with Tern

Angelo zerr angelo.zerr at gmail.com
Mon Mar 24 10:53:13 EDT 2014


2014-03-24 15:36 GMT+01:00 Victor Rubezhny <vrubezhny at exadel.com>:

>  Angelo,
>
> Yes, CordovaJS plug-in certainly could and should be improved.
>
> cordova.addXXXEventHandler('xxx') methods don't return an event object.
> These methods take an event name as an argument, then create, register and
> return back a handler (which is a function "fn()" - probably the only
> arguments could be specified here, but I don't know how i can specify them
> in a return value). But they don't return an Event object.
>

I suggest you that you see angular.js tern plugin. There is complex case.To
manage return value with tern, you can :

1) hard coded the returns value (as you have done with -> fn())
2) use -> !this if your return value is the same instance than your
function property
3) use +MyType if your function must returns an instance of MyType that you
have declared.
4) use custom!MyFunction where MyFunction is registered with
infer.registerFunction("MyFunction", ...
With that you can develop your own JS logic. See angular_bind for instance.


> There is such an object (Event) but looks like it comes from document, so
> it looks like CordovaJS plug-in should depend on some ecma5 or browser
> support plug-in or library. Also, I don't see a place when the Event object
> is used directly in publicly declared functions (as an argument or a return
> value). The pair of arguments used: 'event' (actually a name of event) and
> handler function for that event.
>

Have you tried to use Event+ in your tern plugin? If you see jquery.json
tern def, it use Element too and it is not declared in the jquery.json but
in the browser.json

>
> So, I should investigate it a bit more in order to support it correctly.
>
> Thanks in advance,
> Victor
>
>
> On 03/24/2014 05:22 PM, Angelo zerr wrote:
>
> Hi Victor,
>
>  Thank's for your work.
>
>  I don't know CordovaJS, but I think you could improve this plugin by
> managing type like event.
>
>  For instance :
>
>
> ------------------------------------------------------------------------------------------------------------------------------------------------------
>  var event = cordova.addDocumentEventHandler('xxx') //<-Ctrl+Space shows
> cordova object's members:
> event. <= Ctrl+Click open events methods.
>
> ------------------------------------------------------------------------------------------------------------------------------------------------------
>
>  jquery and browser tern plugin do that.
>
>  Regards Angelo
>
> 2014-03-21 17:11 GMT+01:00 Victor Rubezhny <vrubezhny at exadel.com>:
>
>>  We've pushed CordovaJS plug-in into Angelo's repository.
>>
>> Wiki page:
>> https://github.com/angelozerr/tern.java/wiki/Tern-&-CordovaJS-support
>>
>> You can play a little demo on cordova object (as well as some other
>> variables and functions) content assist provided by cordovajs.js Tern
>> plug-in with Code Mirror here:
>> http://codemirror-java.opensagres.eu.cloudbees.net/codemirror-javascript/demo/cordovajs.html
>>
>> Regards,
>> Victor
>>
>>
>> On 03/18/2014 07:30 PM, Victor Rubezhny wrote:
>>
>> I've updated the cordovajs plugin for Tern/Node.js:
>>
>> - all global vars from cordova.js and require.js (the Cordova's one) are
>> listed in Content Assist
>> - status constants defined in cordova.js are listed in Content Assist
>> - some global object's vars that are defined in cordova.js/require.js are
>> listed in Content Assist
>>
>> Guys (and especially Denis and Gorkem), I'd like you to review the
>> plugin.
>>
>> It's in my branch on GitHub:
>> https://github.com/vrubezhny/tern.java/tree/cordovajs (currently it's
>> rebased over agelozerr's today's master)
>>
>> Have fun at EC,
>> Victor
>>
>>
>> On 03/13/2014 06:19 PM, Victor Rubezhny wrote:
>>
>> Hi, guys!
>>
>> While playing with Tern I was able to make a very simple plugin that
>> allows to show 'cordova' object and some of its members in Content Assist.
>>
>>
>>
>> This is a very first and simple script that shows 'cordova' object and
>> its members in content assistant without requiring to have any kind of
>> cordova.js included to a project.
>> But it requires:
>> - to have Tern.java (updated with cordovajs.js plugin)
>> - to have Tern nature enabled on your project
>> - to have cordovajs plug-in enabled in project's Turn preferences.
>>
>> You can look at the code changes in my branch on GitHub:
>> https://github.com/vrubezhny/tern.java/tree/cordovajs (currently it's
>> rebased over agelozerr's master)
>> There are no any special inference done due to get some objects/values
>> from the modules that are loaded by require/define functionality.
>> This probably will require more sophisticated coding to be done.
>>
>> /Victor
>>
>>
>>
>> _______________________________________________
>> jbosstools-dev mailing listjbosstools-dev at lists.jboss.orghttps://lists.jboss.org/mailman/listinfo/jbosstools-dev
>>
>>
>>
>>
>> _______________________________________________
>> jbosstools-dev mailing listjbosstools-dev at lists.jboss.orghttps://lists.jboss.org/mailman/listinfo/jbosstools-dev
>>
>>
>>
>> _______________________________________________
>> jbosstools-dev mailing list
>> jbosstools-dev at lists.jboss.org
>> https://lists.jboss.org/mailman/listinfo/jbosstools-dev
>>
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/jbosstools-dev/attachments/20140324/db0a231c/attachment-0001.html 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: image/png
Size: 293180 bytes
Desc: not available
Url : http://lists.jboss.org/pipermail/jbosstools-dev/attachments/20140324/db0a231c/attachment-0001.png 


More information about the jbosstools-dev mailing list