Coder Social home page Coder Social logo

ace.tern's People

Contributors

304notmodified avatar sevin7676 avatar sevin777 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

ace.tern's Issues

old TODO.md list

LEFTOFF

  • requirejs is not working correctly.. need to figure out why

NOTES

- have not copied over the new version of ext-tern.js because I want to test other things first

  • CodeMirror.Doc (which is whats passed to tern server):
    Each editor is associated with an instance of CodeMirror.Doc, its document. A document represents the editor content, plus a selection, an undo history, and a mode. A document can only be associated with a single editor at a time. You can create new documents by calling the CodeMirror.Doc(text, mode, firstLineNumber) constructor. The last two arguments are optional and can be used to set a mode for the document and make it start at a line number other than 0, respectively. http://codemirror.net/doc/manual.html#api_doc
  • Ace Edit Session: Stores all the data about Editor state providing easy way to change editors state. EditSession can be attached to only one Document. Same Document can be attached to several EditSessions. http://ace.c9.io/#nav=api&api=edit_session.
  • https://github.com/ajaxorg/ace/wiki/Embedding-API

Clean this up and remove when done:

Ace keeps all the editor states (selection, scroll position, etc.) in editor.session, which is very useful for making a tabbed editor:

var EditSession = require("ace/edit_session").EditSession
var js = new EditSession("some js code")
var css = new EditSession(["some", "css", "code here"])
// and then to load document into editor, just call
editor.setSession(js)

IT APPEARS THAT CODEMIRROR.DOC AND ACE.EDITSESSION ARE THE SAME THING (OR CLOSE TO IT)
There is also ace.document: Contains the text of the document. Document can be attached to several EditSessions.--this is different from CM.Doc

gotit:

CodeMirror.tern works by passing the CodeMirror instance to functions that require it, and the CodeMirror.Doc to functions that dont need the instance
- paralel: Ace should pass the editor instance to some functions, and the edit session to others
- NOTE: the codeMirror doc has a property 'cm' that contains the editor instance that is holding that doc...
        but it doesnt appear to be used by the plugin
        this would be the equivalent of adding the editor instance to the edit session (could do this if needed)
  • might need to add the current editor to the edit session

Fix Parse JsDoc Params

 /**
  * @param {function} cb - callback to execute before setting value.
  *      Will only be executed if value is passed.
  *      1st param {object} v -  is new value.
  *      2nd param {fn->bool} [same] - callback that returns bool indicating if new value is same as current
  *      3rd param {object} [current] - the current value for this property
  *      Returns new value to use for setting value, or undefined to not set value.
  */
 function test(cb) {}

When more than one {type} string exists within a single parameter it messes up such that:

  • All types after the first are removed from the resulting documentation

Need to change parsing to not replace all, but only replace the first. (but make sure that all get highlighted)

Mispelled variable editor ext-tern.js:173

Hi,

Thanks you for your work...

I think the two line :
var pos = editor.getSelectionRange().end;
var tok = editor.session.getTokenAt(pos.row, pos.column);

have editor variable misspelled, on my local file I've changed by :
var pos = e.editor.getSelectionRange().end;
var tok = e.editor.session.getTokenAt(pos.row, pos.column);

it's work fine

have a good day
Sebastien


//automatically start auto complete when period is typed
var onAfterExec_Tern = function(e, commandManager) {
    if (e.command.name === "insertstring" && e.args === ".") {
        if (e.editor.ternServer && e.editor.ternServer.enabledAtCurrentLocation(e.editor)) {
            var pos = e.editor.getSelectionRange().end;
            var tok = e.editor.session.getTokenAt(pos.row, pos.column);

Caret-T: custom snippets feature request

Hi @sevin7676 ,

thanks for working on Caret-T, I just found out (not by myself) that it supports inserting snippets, which I was looking for a lot (I'm on a chromebook).
I guess would be good to write about it in the features list on it's chrome store page, as many folks like me have no idea that "Tern" means snippets too.

Now my actual question: is it possible to define our own snippets, perhaps in some .json file, that the app will search too when offering suggestions when clicking on tab?

Jump To Def Problems

Jump to definition not working in complex structures. Will get could not find definition when the same property will work with find references and show type. try Chart.js ~line 122 CT.c.init();

Autocomplete from previously loaded scripts

I'm not sure if this is possible or not, but is there a way to get Tern to analyse a particular JS file that I'm pulling in so that when I reference the objects from that file in my Ace edited script the available properties, functions, etc show up?

For example, say I'm loading a utility or API JS like D3 or JQuery or something like that. When I make use of that API in my Ace editor I only see autocomplete choices that are derived from what I've already done in my local JS (say if I have previously invoked function "a" I will see "a" show up as a suggestion). Is there some way to get it to go a step further with the analysis/search?

don't clean path when adding vs refs

in TernServer:

editor.ternServer.addDoc(path.replace(/^.*[\\\/]/, ''), xhr.responseText);

remove the .replace.... after path as the popup that shows the source cleans the path

Fix getCallPos in for loop

This code makes makes the editor think its in a function call when its not:

for (var i = 1; i < count.length; i++) {
    count[i]
}

server.getCallPos(editor); //test

When should I call editor.ternServer.addDoc? (Ace.Tern)

When is the right time to call the following function?

editor.ternServer.addDoc(fileName,fileContents)

Is there an event which tells that tern server is started?

I'm asking this because sometimes the fileContents I add using the addDoc function are not shown in autocomplete popup.

Here is where I call the function:

            ace.config.loadModule('ace/ext/language_tools', function() {
                ace.config.loadModule('ace/ext/tern', function() {
                    editor.setOptions({
                        enableTern: {
                            /* http://ternjs.net/doc/manual.html#option_defs */
                            defs: ['jquery', 'browser', 'ecma5'], 
                            /* defs: ['jquery', 'ecma5'], */
                            /* http://ternjs.net/doc/manual.html#plugins */
                            plugins: {
                                doc_comment: {
                                    fullDocs: true
                                }
                            },
                            useWorker: useWebWorker,
                            switchToDoc: function(name, start) {
                                console.log('switchToDoc called but not defined. name=' + name + '; start=', start);
                            },
                            startedCb: function() {
                                //once tern is enabled, it can be accessed via editor.ternServer
                                console.log('editor.ternServer:', editor.ternServer);

                                var library = _external.getLibrary();
                                console.log(library);
                                editor.ternServer.addDoc('mylib',library);
                            },
                        },
                        enableSnippets: false,
                        enableBasicAutocompletion: true,
                    });
                });
            });

Add hidden variables and functions as hint

Is there any way I can add variables and functions to the autocomplete which are not actually presented in the code editor?

Like I have this in the code editor:

function send(x, y) {
 // Things are happening here
 return true;
}

And what I would like to do is, I create some objects like:

var things = {
    "hello": "world"
}

And I would like that if I start to type things. + ctrl+space into the editor, I get the hello as a hint.
Can we do something like this?

Find References: Auto Focus

After find references is called, auto focus on the first item in the select box so keys can be used instead of having to click in the box.

Beautify extension

Can you please explain how the beautify extension you've included in the project works?

I could not find out how the following code helps to beautify the code.

        ace.config.loadModule('ace/ext/html_beautify', function() {
            editor.setOptions({
                autoBeautify: true
            });
        });

New Feature: Generate JSDoc

Add a feature that generates a JS doc outline for an existing function

function test(a,b){
    return a*b;
}

Should generate:

/**
 * @returns {number} {description}
 * @param {number} a - {description}
 * @param {number b - {description}
 */

The result should use Ace's snippets feature (generate a dynamic snippet example). Each {description} placeholder is part of the snippet. Use tern to infer type, and if type cant be inferred then make type part of the snippet;

There is already an existing extension for Brackets that does something like this, so check it out first.

TODO: Add Beautify Configuration to Caret-T

add user configuration beautify options

ace.config.loadModule('ace/ext/html_beautify', function (beautify) {
            editor.setOptions({
                autoBeautify: true
            });            

            //modify beautify options as needed:
            beautifyOptions = {}//user options (will have to parse each) 
        });

caret-T not available on chrome webstore

I just got a new chromebook and was dismayed to see my favorite editor was missing from the chrome webstore, I hope it it temporary or else I will have to figure out how install it from github.

Keep up the good work
Aonghus

How should this be integrated with ACE.

Is it possible to integrate this plugin using existing ACE by just adding an ext-tern from this library. Or we should use the ace editor completely from this repository?

Chrome Apps No Longer Supported

As Google is slowly removing support for Chrome Apps in favor of PWAs and Chrome Extensions, are there plans to convert Caret-T to one or the other? Windows, Linux, and Mac support is already gone, and ChromeOS support will follow eventually.

NOTE: Can Copy From Caret-T

Its okay to copy ext-tern.js from Caret-T as its Chrome App specific content has been removed. However, worker-tern.js can't be copied because it has ChromeApp junk in the header, so only copy all of the libs and the comments at the top of the header.

Memory leak

Usage of ace.tern in dynamic tab creation is resulting in tremendous memory increase.
The memory used for an editor in a tab will not be cleared, when the editor gets destroyed, this results in crashing the browser object.

A sample code used for the dynamic creation and termination of an editor

aceEditor = { append : function(editor,tabId){

        var useWebWorker = true;
        editor.getSession().setUseWorker(useWebWorker);
        editor.session.setMode("ace/mode/javascript");
        editor.getSession().setUseWrapMode(true);
        editor.getSession().setWrapLimitRange(null, null);
        editor.setShowPrintMargin(false);

        ace.config.loadModule('ace/ext/language_tools', function() {
            ace.config.loadModule('ace/ext/tern', function() {
                editor.setOptions({
                    enableTern: {
                        defs: ['browser', 'ecma5', 'ourData'],
                        plugins: {
                            doc_comment: {
                                fullDocs: true
                            }
                        },
                        useWorker: useWebWorker,
                        switchToDoc: function(name, start) {
                            console.log('switchToDoc called but not defined. name=' + name + '; start=', start);
                        },

                        startedCb: function() {
                            console.log('editor.ternServer:', editor.ternServer);
                        },
                    },
                    enableSnippets: false,
                    enableBasicAutocompletion: true,
                });
            });
        });

        // Append editor into tabs using "tabId"
    },
remove : function(editor,tabId){
        editor.setSession(null);
        editor.destroy();
        // Remove tab from tabs using "tabId"
}

}

Files getting 'damaged'

I don't even know what to call this, but here this is what I tend to get with your app http://imgur.com/4zYDNOP I thought it was because of my laptop suddenly shutting down but today I closed it before my laptop went off and still this happened. The image you see was my home page for a site I was working on.

Use Ace Libraries where possible

There is a lot of functionality that is using custom functions that can be replaced by Ace's built in libs. Examples:

  • escape html in ace/lib/lang
exports.escapeHTML = function(str) {
    return str.replace(/&/g, "&#38;").replace(/"/g, "&#34;").replace(/'/g, "&#39;").replace(/</g, "&#60;");
};
  • dom lib

Fix getCallPos()

Right now it will return the wrong position when there are parenthesis relatively close to current call (like on line before or after)

Make Rename work with non-vars

Tern won't support this as marijnh said its not a problem...

Use a quick and ghetto hack to make it work:

  • Attempt rename using tern
  • If rename fails, then use find refs to get all refs, then update all refs using their range

The real problem is marijnh refuses to support this, which is silly because find refs works but rename won't because marijnh says it won't work 100% of the time, but the whole idea of tern is its a best-effort add on.

Upgrade using C9 Tern for ideas

https://github.com/c9/c9.ide.language.javascript.tern

https://github.com/c9/c9.ide.language.jsonalyzer

See get call position function:

function getCallNode(currentNode, cursorPos) {
    var result;
    currentNode.traverseUp(
        'Call(e, args)', 'New(e, args)', function(b, node) {
            result = node;
            return node;
        },
        function(node) {
            // Show tooltip only on first line if call spans multiple lines
            var pos = node.getPos();
            if (pos && pos.sl !== cursorPos.row)
                return node;
        }
    );
    return result;
}

Caret-T autocomplete vs. Ace.Tern

Caret-T autocomplete feature runs very well.

Can you compare Ace.Tern autocomplete to Caret-T?

Is the following project status stated in the demo application still valid or is the current version suitable for production environment?

"Under heavy development, not ready for prime time yet"
"This demo is not isolated, it has extra stuff that is not related to the demo that needs to be removed"

Caret-T: Javascript autocomplete

Suppose I have file (a.js) with my functions in it.

In file b.js I write code which uses functions in a.js.

Can autocomplete give information about functions in a.js while working in b.js?

Integrates tern-browser-extension in the demo

I have seen, that you have a demo with html (mode). In this demo if you type some javascript anywhere (inside html content), altough js must be inserted inside script tag:

<html>
var s = "";

<script>
  // here completion for s is available, although it should not.
</script>

</html>

To fix this problem you could integrates https://github.com/angelozerr/tern-browser-extension which parse your HTML with SAX and extract JS code from script tags. It gives you more features than completion for HTML elements ids, CSS selectors and event types.

Is it not possible to run demo.html locally?

I get the following error when I run demo.html locally.

Uncaught SecurityError: Failed to construct 'Worker': Script at 'file:///C:/Users/Desktop/Ace.Tern-master/ace-builds/src-noconflict/worker-tern.js' cannot be accessed from origin 'null'.

Is it not possible to run demo.html locally?

Fix Ace Text Completor Performance

When tern uses the built in Ace Text Completed its very slow

This is not the case in the Ace Kitchen sink without Tern (test with large JS file)

Is the removing of duplicate entries causing the massive slow down?

Update to work with latest version of Ace

I noticed that this only works with Ace version 1.1.9. The latest version of Ace is 1.2.5. That has lots of bug fixes. Unfortunately you can't just replace Ace and its ext, modes, etc. The tern webworker seems to break with that. Any idea how to get this working with a newer version of Ace?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.