Coder Social home page Coder Social logo

Comments (12)

Sevin777 avatar Sevin777 commented on August 28, 2024

This is very similar to https://github.com/sevin7676/Ace.Tern/issues/18

This specific Tern extension has a quick hack to enable using the Reference Path tag supported by Visual Studio intellisense (also used by Type Script).

You can use this syntax as follows: (must be at top of file, multiple lines allowed)

/// <reference path="../a.js" />
/// <reference path="https://code.jquery.com/jquery-2.1.3.js" />

Also, the reference paths are not checked or updated until you call: editor.ternServer.docChanged(editor)

This method is a quick hack that is poorly implemented because I'm just using it for something specific. However, Tern supports adding other files for reference by configuring the RequireJS plugin or Node plugin. Example for rqeuireJS:

enableTern accepts boolean or configuration options

 var editor = ace.edit("editor");
 ace.config.loadModule('ace/ext/language_tools', function() {
     ace.config.loadModule('ace/ext/tern', function() {
         editor.setOptions({
             enableTern: {
                 plugins: {
                     requirejs: {
                         baseURL: '(set this)',
                         paths: '(optional)',
                         override: '(optional)',
                     },
                     doc_comment: {
                         fullDocs: true
                     }
                 }
             },
             enableSnippets: false,
             enableBasicAutocompletion: true,
         });
     });
 });

from ace.tern.

postacik avatar postacik commented on August 28, 2024

I'm using your Caret-T Chrome application and when I put the reference line at the top of a file, it has no effect on autocomplete.

///

Is this feature possible in Caret-T?

(I posted the question in this project because Caret-T about box points to this project for getting the source code instead of CaretTern project)

from ace.tern.

Sevin777 avatar Sevin777 commented on August 28, 2024

Yes it works in Caret-T. After you add the file reference to the top of the file switch to another tab, then switch back and it will reload the references.

Open Chrome's dev tools and look at the console as it logs info when it adds references including if it runs into an error:

image

success:

image

from ace.tern.

postacik avatar postacik commented on August 28, 2024

I have the following lines in b.js

var goo = {
//stringProp
stringProp: "",
//mest property
numProp: 10
};

goo.stringProp = "str";
goo.numProp = 20;

And a.js looks like this:

image

When I type "goo." in a.js it does not display object goo's properties as they listed while working in b.js.

from ace.tern.

Sevin777 avatar Sevin777 commented on August 28, 2024

There is a bug that prevents local paths from working correctly unless they start with ../, and they must not be at the root. So it will work if your file is [root]/scripts/b.js and you use /// <reference path="../scripts/b.js" />

I haven't got around to fixing this bug yet.

from ace.tern.

postacik avatar postacik commented on August 28, 2024

Thanks, it works when library and projects files are in seperate folders under the same root.

from ace.tern.

postacik avatar postacik commented on August 28, 2024

Can you update the project source code to include library files in demo.html file as you explain in your first answer to this issue?

from ace.tern.

Sevin777 avatar Sevin777 commented on August 28, 2024

I'm not sure what you referring to: include library files in demo.html

from ace.tern.

postacik avatar postacik commented on August 28, 2024

I mean adding external js files for autocomplete with the following code change:

image

from ace.tern.

postacik avatar postacik commented on August 28, 2024

In ext-tern.js the following line exists in function loadExplicitVsRefs:

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

Can I add my js libraries to be used in autocomplete using this function?

from ace.tern.

Sevin777 avatar Sevin777 commented on August 28, 2024

Thats the code that automatically reads the /// <reference path="" /> comments.

You can also use: editor.ternServer.addDoc(fileName,fileContents) to manually add your source. https://github.com/sevin7676/Ace.Tern/blob/2d814fb4d2d68d0b4a765b6fcd07f96f8aaeb98f/ace-builds/src-noconflict/ext-tern.js#L425.

The demo has now been updated with better comments: https://github.com/sevin7676/Ace.Tern/blob/master/demo.html#L108

from ace.tern.

postacik avatar postacik commented on August 28, 2024

Thank you very much. The following instruction does what I need.

editor.ternServer.addDoc(fileName,fileContents)

from ace.tern.

Related Issues (20)

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.