Skip to content
This repository was archived by the owner on Sep 6, 2021. It is now read-only.

Commit 016e837

Browse files
committed
Allow JavaScript code hints in its own context
1 parent cc0bb85 commit 016e837

File tree

1 file changed

+7
-4
lines changed
  • src/extensions/default/JavaScriptCodeHints

1 file changed

+7
-4
lines changed

src/extensions/default/JavaScriptCodeHints/main.js

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,8 @@ define(function (require, exports, module) {
5656
noHintsOnDot = false, // preference setting to prevent hints on dot
5757
ignoreChange; // can ignore next "change" event if true;
5858

59+
// Languages that support inline JavaScript
60+
var _inlineScriptLanguages = ["html", "php"];
5961

6062
// Define the detectedExclusions which are files that have been detected to cause Tern to run out of control.
6163
PreferencesManager.definePreference("jscodehints.detectedExclusions", "array", [], {
@@ -341,10 +343,11 @@ define(function (require, exports, module) {
341343
};
342344

343345
/**
344-
* @return {boolean} - true if the document is a html file
346+
* @return {boolean} - true if the document supports inline JavaScript
345347
*/
346-
function isHTMLFile(document) {
347-
return LanguageManager.getLanguageForPath(document.file.fullPath).getId() === "html";
348+
function isInlineScriptSupported(document) {
349+
var language = LanguageManager.getLanguageForPath(document.file.fullPath).getId();
350+
return _inlineScriptLanguages.indexOf(language) !== -1;
348351
}
349352

350353
function isInlineScript(editor) {
@@ -442,7 +445,7 @@ define(function (require, exports, module) {
442445
JSHints.prototype.hasHints = function (editor, key) {
443446
if (session && HintUtils.hintableKey(key, !noHintsOnDot)) {
444447

445-
if (isHTMLFile(session.editor.document)) {
448+
if (isInlineScriptSupported(session.editor.document)) {
446449
if (!isInlineScript(session.editor)) {
447450
return false;
448451
}

0 commit comments

Comments
 (0)