CodeMirror-XQuery icon indicating copy to clipboard operation
CodeMirror-XQuery copied to clipboard

Autocompletion of Method Parameters for User-Defined Functions?

Open ayush-jayaswal opened this issue 12 years ago • 13 comments

How can we acheive Autocompletion of Method Parameters for User-Defined Functions. It only displays Autocompletion for javascript functions. I want to achieve this for my functions used in that particular project.

ayush-jayaswal avatar Jul 19 '13 09:07 ayush-jayaswal

Could you explain more your need?

Perhaps you should see https://github.com/angelozerr/CodeMirror-XQuery/blob/master/codemirror-javascript/addon/hint/tern/tern-extension.js (CodeMirror.ternHint = function(cm, c) { function c1(data) { => line 43), I have extended the éofficial" CodeMirror tern addon to add "templates" hint.

angelozerr avatar Jul 20 '13 23:07 angelozerr

I am actually working on a project and we have created a JS editor which provides auto completion. So i have used your add ons. But on using this add on it displays only JavaScript functions in autocompletion. Since my project contains many infra files also and i need to show functions of that infra files through autocompletion feature. So how can i achieve that?

P.S i need autocompletion with method parameters too..

ayush-jayaswal avatar Jul 21 '13 10:07 ayush-jayaswal

To add your own completion with tern, the best mean is to create defs file like I have done here https://github.com/angelozerr/CodeMirror-XQuery/tree/master/codemirror-javascript/addon/hint/tern/defs

But perhaps you wish to use directly your js file and your file should be added to tern server (I must modify my addon to do that).

For parameter completion, I would like to manage that too (eg: show only number vars after str.slice( but I must study if it's possible with tern.

angelozerr avatar Jul 21 '13 12:07 angelozerr

If i have multiple functions in multiple Js files then what can i do? Can i simply directly declare all these function signature in a global array and with tern it could automatically detect all the functions with method parameters. Can you provide code of this?

ayush-jayaswal avatar Jul 21 '13 18:07 ayush-jayaswal

Creating your own Tern def (see https://github.com/angelozerr/CodeMirror-XQuery/tree/master/codemirror-javascript/addon/hint/tern/defs ) could help you no?

angelozerr avatar Jul 22 '13 00:07 angelozerr

So i will have to write my own def but seems a quite lengthy process to declare all the functions.. Is there any way by which i could import the Js files and the code could automatically detect all the functions inside that Js File.

ayush-jayaswal avatar Jul 23 '13 04:07 ayush-jayaswal

I'm not a big expert with Tern, but I think you could define use getFile function to add your own JS file. Never played with that.

angelozerr avatar Jul 23 '13 07:07 angelozerr

Can you provide the function through which we can import JS files directly.

ayush-jayaswal avatar Jul 27 '13 12:07 ayush-jayaswal

I suggest you to post your question on CodeMirror forum.

angelozerr avatar Jul 29 '13 14:07 angelozerr

@ayush-jayaswal Tern demo uses something like server.addFile and Tern demo shows completion for custom function as you may seen in Tern demo

as3boyan avatar Mar 05 '14 21:03 as3boyan

How do i configure tern server to include user-defined .js files so as to provide method auto complete.

ayush-jayaswal avatar Apr 07 '14 13:04 ayush-jayaswal

As I said you, I suggest you to post your question on CodeMirror forum.

angelozerr avatar Apr 07 '14 13:04 angelozerr

Any chance to re-open this requirement?

sebasmoyano avatar Oct 06 '17 20:10 sebasmoyano