EzDevInfo.com

tern

A JavaScript code analyzer for deep, cross-editor language support

Tern doesn't work properly with eclipse

Recently I installed the AngularJS Eclipse plugin (Link).

I use Eclipse Luna. I followed the Getting Started section and made all described steps.

But the tern seems to work not properly.

The Tern cannot find the names of my controllers, modules, cannot navigate to it.

It seams NodeJS (which I installed in C - PrgrammFiles) works properly, but on the console I get following error:

I also get an empty Angular Explorer view

I googled but couldn't find any solution.

Please help me.


Source: (StackOverflow)

How to disable Tern synchronization in Eclipse Luna?

I use Eclipse Luna SP2 for Java EE for some JavaScript development. Every now and then (mostly on .js file open but also on some timer) I get the following popup error

    An internal error occurred during: "Synchronizing script resources with Tern server...".
    loader constraint violation: loader (instance of org/eclipse/osgi/internal/loader/EquinoxClassLoader) 
previously initiated loading for a different type with name "org/apache/http/HttpEntity"

I don't need Tern functionality and I would like to disable it or at least get rid of the popup error

I googled about but could not find any relevant information. For the moment I tried to disable all validators and to change the .js editor but no luck by now.

Any idea?


Source: (StackOverflow)

Advertisements

how to set jump to method definition key binding in sublime 3 for tern-js

i've installed the tern-js plugin for sublime 3, however for some reason I cannot make its command work with sublime's key bindings (I'm a sublime nube btw) according to the documentation.. ternjs_jump_to_definition is supposed to be a valid command.

So i put this in the default (OSX).sublime-keymap file:

{ "keys": ["super+ctrl+j"], "command": "ternjs_jump_to_definition"},
{ "keys": ["super+ctrl+r"], "command": "ternjs_reload"},

I also put this.. still didn't work:

{ "keys": ["super+ctrl+j"], "command": "ternjs_jump_to_definition", "context":
    [
            { "key": "has_next_field", "operator": "equal", "operand": true }
    ]
}

any idea what's going on wrong? I know that tern-js is installed.. because typing Ctrl+Space for code completion actually works:

any idea what I'm doing wrong? I simply want typing command+ctrl+j to jump to method definition.

Also I looked at the default sublime 3 jump to method definition (ie alt+command+down), and it only works on the same file even if i add libraries to the project. (I'm using mapbox, which works on top of leaflet).

enter image description here


Source: (StackOverflow)

Unable to get DOM support in TernJS sublime plugin for Javascript autocompletion

As described in this link, I have added the code in my .sublime-project but it's not workig. Here is my code

{
    "folders": [{
        "path": "/Applications/XAMPP/xamppfiles/htdocs/zohocharts"
    }],
    "ternjs": {
        "exclude": ["wordpress/**", "node_modules/**"],
        "libs": ["browser", "jquery"],
        "plugins": {
            "requirejs": {
                "baseURL": "./js"
            }
        }
    }
}

Source: (StackOverflow)

CodeMirror with Tern - Custom "Types" with Javascript Intellisense

I am using tern to give some enhanced intellisense to a window that runs with CodeMirror, and it works fine, but I am having an issue where I would like to add some custom "types", so to speak, so that there can be icons next to them in the drop down. I have narrowed the code down a bit...

In the .json definition files, types seem to be declared using the !type directive, like this;

  "Infinity": {
    "!type": "number",
    "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Infinity",
    "!doc": "A numeric value representing infinity."
  },
  "undefined": {
    "!type": "?",
    "!url": "https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/undefined",
    "!doc": "The value undefined."
  }

These correspond a bit with the CSS, like this.

.CodeMirror-Tern-completion-object:before {
    content: "O";
    background: #77c;
}
.CodeMirror-Tern-completion-fn:before {
    content: "F";
    background: #7c7;
}
.CodeMirror-Tern-completion-array:before {
    content: "A";
    background: #c66;
}
.CodeMirror-Tern-completion-number:before {
    content: "1";
    background: #999;
}

Alright, that's all fine and good. I can style those, no problem. But I want to add some of my own, and am having a heck of a hard time doing that. For instance, if I just do ...

  "Character": {
    "!type": "entity",
    "!url": "some-url",
    "!doc": "This is a character entity."
  },
  "User": {
    "!type": "user",
    "!url": "some-url-again",
    "!doc": "This is a user entity."
  }

It just kind of causes the whole thing to not work; Like tern just kind of says nope nope nope and does nothing. I have been trying for hours, and have really dug through the source code, but cannot really find a way to just make up my own types. I want to simply give the users of this specific code editor (which won't be 'exactly' javascript, it'll be javascript, but with some dumbed-down literals, since they are not coders) some simple flags to make it easier on them.

Any suggestions are welcome! Thank you for your time.

Update

As a user requested, I am posting more code to try and get more help. This is what I want; I have a .json file that defines the layout of an object. The object will mirror an actual C# object/database object. (That part isn't important, just know that I have a specific model)

I am also using the default tern ecma5.json and jquery.json def files. They are found here;

https://github.com/marijnh/tern/blob/master/defs/ecma5.json https://github.com/marijnh/tern/blob/master/defs/jquery.json

So when the user hits CTRL+SPACE and sees CHARACTER, I want it to have a type of [CHARACTER] next to it. So I thought the first step was to specify character as the type.

character.json

"character": {
    "!type": "Character",
    "!doc": "Represents the character model.",
    "Coefficients":{
        "!doc": "The coefficients that govern many of the calculative formulas"
    }
}

What happened is the following screen.

ctrl+space with character as defined type

Now I tried to trace this down, I discovered a function called typeToIcon in the addons/tern.js (not the actual tern files, the addon file that plugs into codemirror)

function typeToIcon(type) {
    var suffix;

    if (type == "?") suffix = "unknown";
    else if (
        type == "number"        || 
        type == "string"        || 
        type == "bool"          
    ) suffix = type;

    else if (/^fn\(/.test(type)) suffix = "fn";
    else if (/^\[/.test(type)) suffix = "array";
    else suffix = "object";

    return cls + "completion " + cls + "completion-" + suffix;
}

So I though AHA! This is it!!, so I figured I could add my type here.

I added console.log(type); to the function to see what the output was like. This never fired though, even when I hit CTRL+SPACE, I never saw a console output, so it tells me that this code was not reached. I had to go further back.

I hunted down a function called TypeParser in def.js, part of the actual tern download.

  var TypeParser = exports.TypeParser = function (spec, start, base, forceNew) {
    this.pos = start || 0;
    this.spec = spec;
    this.base = base;
    this.forceNew = forceNew;
  };

putting a console log here gave me some results, and they looked like many of the types that were available, and that were defined in jquery.json and ecma5.json.

This is as far as I have gotten, I have absolutely no idea how to proceed.


Source: (StackOverflow)

ternJS - Generate JSON type definition file

ternJS have several. JSON files defs which contains the definition of librarys. Can someone explain to me how I can best generate my own to my javascript libraries / or only definition objects?

I can not see that there is no common procedure for this?


Source: (StackOverflow)

Eclipse orion code completion

I read somewhere that orion uses tern for code completion for JavaScript but after running the server, creating a js file and then creating another file the other file is unaware of any code in the first file.

It seems that completion only works for symbols defined in the currently open file.

Is there a way to configure tern in orion so it will produce some helpful completion instead of a working demo without any real value?


Source: (StackOverflow)

Jump to definition does not work on objects defined as property on window

In my tern set up in emacs, this code works fine when I do M-. when my cursor is under the foo of obj.foo() (in the last line):

var obj = {};
obj.foo = function() {
    return true;
};

obj.foo();

But when I do the same on the following, it says "No definition found."

window.obj = {};
obj.foo = function() {
    return true;
};

obj.foo();

I tried making each refernce to obj as window.obj. Doesn't seem to help. Am I missing something?


Source: (StackOverflow)

Using tern_for_vim plugin in HTML files

I'm trying to set up tern_for_vim plugin to have nice autocompletion in JavaScript. While editing ".js" files, "Ctrl+X Ctrl+O" gives nice semantic results, picking up the "backbone.js" and other libraries. However, when I'm editing a JS block inside an HTML file, this doesn't work, I only see the buffer-based standard completion. I can't figure out what's the problem. How to fix this?


Source: (StackOverflow)

CodeMirror - styling Tern intellisense labels

I'm using the Tern plugin for CodeMirror, which adds intellisense features to the editor (i.e. pops up inline hint-labels).

I want to change the hint-labels style, how to do so?


Source: (StackOverflow)

Tern JS for Vim using NVM

I'm trying to get Tern JS working in Vim on OSX 10.10.x.

I'm currently using NVM and as the Tern JS documentation states you can't use NVM.

Caution: Because the node process is not run using your standard shell, >the NVM version of node.js won't work. You need a global node executable.

I'm not sure how to fix this. Do I need to install Node the "regular" way or is there a better way of solving this problem?

Thanks!


Source: (StackOverflow)

How to auto-generate Tern project files based on bower/npm?

I just integrated Tern with my editor of choice, and the experience has been pretty incredible so far.

One thing that would make the experience all the more intuitive, however, would be the ability to tap into my existing front- and back-end dependency management systems (i.e. the bower.json and package.json files) rather than having to manage the .tern-project file manually.

Is there some existing way of doing this?


Source: (StackOverflow)

Sublime Text - plugin_host exited unexpectedly after installing sublime_tern

I have installed sublime_tern package to help me with my MeteorJS development. After installing this package, any time I start Sublime I get: plugin_host exited unexpectedly. What can I do to troubleshoot this?


Source: (StackOverflow)

tern auto-complete gives ac-show-menu (wrong-type-argument stringp nil)

I'm trying to get tern autocomplete working. I'm on OSX 10.10

Stacktrace: http://pastebin.com/FDSc2Ymv

I found this link maybe regarding this issue: https://github.com/auto-complete/auto-complete/issues/309

My version of popup is latest (0.5.1)

Here is a segment of what my init.el looks like

;; JavaScript Mode
(require 'js2-mode)
(add-to-list 'auto-mode-alist '("\\.js\\'" . js2-mode))
(add-hook 'js2-mode-hook (lambda () (tern-mode t)))
(eval-after-load 'tern
   '(progn
     (require 'tern-auto-complete)
     (tern-ac-setup)))

Any ideas? I've tried directly copying the repo, adding it to the load path, so I'm inclined to believe it's something with my auto-complete.


Source: (StackOverflow)

Adobe-Brackets Angularjs Code Completion

I am using adobe-brackets sprint39 to build the front end of websites. I am a heavy user of Angularjs. https://angularjs.org/

Is it possible to activate angularjs code completion on the adobe-brackets ide? Tern has been integrated with adobe-brackets and it has an angular plugin. http://ternjs.net/doc/manual.html#plugin_angular The angular-ui team have written an angularjs plugin for brackets. https://github.com/angular-ui/AngularJS-brackets

I have installed it as an extension, however, am not still able to achieve angularjs code completion.

Has anyone managed to have angularjs code completion on adobe-brackets? If so, would you be kind enough to show me how to do so? Does the adobe-brackets angularjs code completion work on the html markup or does it only work when one is coding the javascript? Any help would be appreciated. I have searched on the internet and have not found any clear instructions on how to achieve angularjs code-completion on adobe-brackets. Thanks....


Source: (StackOverflow)