tern-outline

0.2.0 • Public • Published

tern-outline

Build Status NPM version

Usage

tern-outline is a tern plugin which can be used to display the outline of a JavaScript file.

Editors / IDE

CodeMirror

Eclipse

Tern Explorer View is filled with tern-outline :

Tern Explorer View

Other editors

Takes a sample :

var arr = ["string"];
 
var n1 = 10;
n1 = "";
 
function sum(x1, x2) {
    var tmp = x1 * x2;
    return tmp;
}
 
var n2 = arr;

If you wish to integrate the tern lint with an editor (Vim, Sublime, etc), here the JSON request to post to the tern server :

{
  "query": {
    "type": "outline",
    "file": "b.js"
  },
  "files": [
    {
      "name": "b.js",
      "text": "var arr = [\"string\"];\r\n\r\nvar n1 = 10;\r\nn1 = \"\";\r\n\r\nfunction sum(x1, x2) {\r\n\tvar tmp = x1 * x2;\r\n\treturn tmp;\r\n}\r\n\r\nvar n2 = arr;",
      "type": "full"
    }
  ]
}

and the JSON response of the tern server :

{
  "outline": [
    {
      "name": "arr",
      "type": "[string]",
      "start": 4,
      "end": 7
    },
    {
      "name": "n1",
      "type": "number|string",
      "start": 29,
      "end": 31
    },
    {
      "name": "sum",
      "type": "fn(x1: ?, x2: ?) -> number",
      "start": 51,
      "end": 111,
      "children": [
        {
          "name": "tmp",
          "type": "number",
          "start": 80,
          "end": 83
        }
      ]
    },
    {
      "name": "n2",
      "type": "[string]",
      "start": 119,
      "end": 121
    }
  ]
}

Readme

Keywords

Package Sidebar

Install

npm i tern-outline

Weekly Downloads

1

Version

0.2.0

License

MIT

Last publish

Collaborators

  • angelozerr