Basic support for code hinting in html files.

For HTML files, we replace the HTML sections with whitespace, leaving only the text of the script tags for Tern to see.
This way the offset/cursor positions don't need to be translated, which would be necessary to get jump-to-def to work.
This commit is contained in:
Erik Tierney committed 2013-05-02 16:28:39 -04:00
1 parent f083ad3111
commit 0755c30d58
3 files changed
+119 -9

No files matched your search

@@ -286,7 +286,7 @@ define(function (require, exports, module) {
* @return {jQuery.Promise} - The promise will not complete until the tern
* hints have completed.
*/
function requestHints(session, document, offset) {
function requestHints(session, document) {
var path = document.file.fullPath,
split = HintUtils.splitPath(path),
dir = split.dir,
@@ -295,12 +295,14 @@ define(function (require, exports, module) {
var $deferredHints = $.Deferred(),
hintPromise,
fnTypePromise,
propsPromise;
propsPromise,
text = session.getJavascriptText(),
offset = session.getOffset();
hintPromise = getTernHints(dir, file, offset, document.getText());
hintPromise = getTernHints(dir, file, offset, text);
var sessionType = session.getType();
if (sessionType.property) {
propsPromise = getTernProperties(dir, file, offset, document.getText());
propsPromise = getTernProperties(dir, file, offset, text);
} else {
var $propsDeferred = $.Deferred();
propsPromise = $propsDeferred.promise();
@@ -309,7 +311,7 @@ define(function (require, exports, module) {
if (sessionType.showFunctionType) {
// Show function sig
fnTypePromise = getTernFunctionType(dir, file, sessionType.functionCallPos, offset, document.getText());
fnTypePromise = getTernFunctionType(dir, file, sessionType.functionCallPos, offset, text);
} else {
var $fnTypeDeferred = $.Deferred();
fnTypePromise = $fnTypeDeferred.promise();