Integrating with C++ Editor

18 views
Skip to first unread message

Stefano Mtangoo

unread,
Jul 13, 2015, 3:30:10 PM7/13/15
to tern...@googlegroups.com
Hi,
I just found Tern when I was searching for Integrating with my own inhouse Editor/IDE.
I wanted to know where do I start as beginner in Tern? I have experience with Js/JQuery as well as C++.
My Editor is written in C++/wxWidgets. I have read the docs cannot really grasp it.
Any C++ Editor using tern? If no where do I start?

NB: I have installed tern in my folder with npm install tern

Marijn Haverbeke

unread,
Jul 13, 2015, 3:56:19 PM7/13/15
to Stefano Mtangoo, tern-dev
You'll want to use the stand-alone server (bin/tern) and talk to it
over HTTP. If you are familiar with Python, reading the code for the
Sublime Text plugin [1] is probably a good start.

[1]: https://github.com/marijnh/tern_for_sublime
> --
> You received this message because you are subscribed to the Google Groups
> "tern-dev" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to tern-dev+u...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

Stefano Mtangoo

unread,
Jul 13, 2015, 4:06:20 PM7/13/15
to tern...@googlegroups.com, mwinj...@gmail.com
Hi,


On Monday, July 13, 2015 at 9:56:19 PM UTC+2, Marijn Haverbeke wrote:
You'll want to use the stand-alone server (bin/tern) and talk to it
over HTTP. If you are familiar with Python, reading the code for the
Sublime Text plugin [1] is probably a good start.
 
Thanks for the quick response.
I have managed to start standalone server and its listening.
I can send HTTP fine with HTTP classes or libcurl. I have few questions:

1. How do I tell tern that "this is the list of files to deals with? (for Autocomplete)?
2. How do I add/Remove file from that list in (1)?
3. Any Specific format I need to send to server for different query (symbols list in a file, autocomplete, et al)

Thanks again for help.

Marijn Haverbeke

unread,
Jul 13, 2015, 4:14:04 PM7/13/15
to Stefano Mtangoo, tern-dev
The HTTP protocol is documented at http://ternjs.net/doc/manual.html#protocol .

Stefano Mtangoo

unread,
Jul 13, 2015, 4:24:13 PM7/13/15
to tern...@googlegroups.com, mwinj...@gmail.com
Hi,


On Monday, July 13, 2015 at 10:14:04 PM UTC+2, Marijn Haverbeke wrote:
The HTTP protocol is documented at http://ternjs.net/doc/manual.html#protocol .
 
Its great documentation but I cannot find how to add file and query for example list of symbols.
I just want to get started, then I can try to take off from there.
something like this scenario.

I have file C:\file.js and have code below.
Now I want to tell sever, parse for me me this file and give me all symbols in file

function xyz(){
}

function anotheFunc(arg1,arg2){}

Please forgive my ignorance if these are obvious things. I can't create a basic example out of docs

Stefano Mtangoo

unread,
Jul 16, 2015, 3:54:56 AM7/16/15
to tern...@googlegroups.com
Hi,
I have made some progress, started server registered files like this

{"files":[
    {"text":"var arr = [\"\"]\r\narr.\r\n","name":"/home/stefano/Desktop/Server/exampl1.js","type":"full"},
    {"text":"var arr = [\"\"]\r\narr.\r\n","name":"/home/stefano/Desktop/exampl1.html","type":"full"}
]}


 and send a http post like this one
{"query":{"file":"/home/stefano/Desktop/exampl1.html","urls":true,"types":true,"type":"completions","end":32,"lineCharPositions":true}}
 
Now I can see only JavaScript functions in Autocomplete list but I can't see functions defined in exampl1.js which is included in exampl1.html in head tag like this
<script type="text/JavaScript" src="exampl1.js"></script>

Does Tern support this?
Thanks again!

Marijn Haverbeke

unread,
Jul 16, 2015, 3:56:14 AM7/16/15
to Stefano Mtangoo, tern-dev
Tern doesn't parse HTML. If your editor does, you could have it send
the files included by the HTML to Tern.

Stefano Mtangoo

unread,
Jul 16, 2015, 4:02:03 AM7/16/15
to tern...@googlegroups.com, mwinj...@gmail.com


On Thursday, July 16, 2015 at 10:56:14 AM UTC+3, Marijn Haverbeke wrote:
Tern doesn't parse HTML. If your editor does, you could have it send
the files included by the HTML to Tern.
 
Thank you a lot.
Last question for this thread: Can I query all symbols from a current file with line number for each symbol?

Marijn Haverbeke

unread,
Jul 16, 2015, 4:17:12 AM7/16/15
to Stefano Mtangoo, tern-dev
Nope, no such query exists. What did you want to use it for?

Angelo zerr

unread,
Jul 17, 2015, 4:51:20 AM7/17/15
to Marijn Haverbeke, tern-dev, Stefano Mtangoo

Hi stephano

If you wish to use tern with html you could use

Angelo zerr

unread,
Jul 17, 2015, 4:57:41 AM7/17/15
to Marijn Haverbeke, tern-dev, Stefano Mtangoo

Sorry for my mistake

I restart. If you wish to use tern with html you could try https://github.com/angelozerr/tern-browser-extension

Stefano Mtangoo

unread,
Jul 17, 2015, 5:26:54 AM7/17/15
to Angelo zerr, Marijn Haverbeke, tern-dev
Sounds cool. How do I install it?
There is no instruction on how to do that!

Thanks
--
for me to live is Christ to die is gain

Stefano Mtangoo

unread,
Jul 17, 2015, 7:44:14 AM7/17/15
to tern...@googlegroups.com, angel...@gmail.com, mar...@gmail.com


On Friday, July 17, 2015 at 12:26:54 PM UTC+3, Stefano Mtangoo wrote:
Sounds cool. How do I install it?
There is no instruction on how to do that!
I used tern-browser-extension name and npm did install

Angelo zerr

unread,
Jul 17, 2015, 5:02:01 PM7/17/15
to Stefano Mtangoo, Marijn Haverbeke, tern-dev

Glad that you had installed with sucess you can benefit with css selectors completion navigation validation see https://github.com/angelozerr/tern.java/wiki/Tern-&-Browser-Extension-support

But tern browser extension doesnt support load of script/@src

Stefano Mtangoo

unread,
Jul 19, 2015, 2:08:03 AM7/19/15
to tern...@googlegroups.com
Thank you.
I will find a way to scan <script>and send the src.
So far its a big milestone with what TernJs can accomplish
Reply all
Reply to author
Forward
0 new messages