Comments (12)
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.
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.
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:
success:
from ace.tern.
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:
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.
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.
Thanks, it works when library and projects files are in seperate folders under the same root.
from ace.tern.
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.
I'm not sure what you referring to: include library files in demo.html
from ace.tern.
I mean adding external js files for autocomplete with the following code change:
from ace.tern.
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.
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.
Thank you very much. The following instruction does what I need.
editor.ternServer.addDoc(fileName,fileContents)
from ace.tern.
Related Issues (20)
- TODO: Add Tern configurations to Caret-T HOT 1
- TODO: Add Beautify Configuration to Caret-T
- Files getting 'damaged' HOT 2
- Beautify extension HOT 2
- Memory leak
- caret-T not available on chrome webstore HOT 2
- undo/redo operation only working for first tab!! HOT 4
- How should this be integrated with ACE. HOT 3
- Suggestions for custom methods
- Support other languages HOT 1
- Update to work with latest version of Ace HOT 3
- Add hidden variables and functions as hint
- Is this using the newest version of ACE?
- Chrome Apps No Longer Supported HOT 3
- disappearing tabs
- file resized to few lines after re-launching caret-t
- Reading JSDoc style comment from external javascript files
- Class objects methods and variables not being found
- Ace.Tern with VueJs?
- Cannot read properties of undefined (reading 'getData')
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ace.tern.