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

Commit

Permalink
Merge pull request #11263 from sprintr/fix-php-js-hints
Browse files Browse the repository at this point in the history
Allow JavaScript Code Hints only in its context
  • Loading branch information
abose committed Jun 22, 2015
2 parents fb049f2 + 016e837 commit 4f7be02
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/extensions/default/JavaScriptCodeHints/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ define(function (require, exports, module) {
noHintsOnDot = false, // preference setting to prevent hints on dot
ignoreChange; // can ignore next "change" event if true;

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

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

/**
* @return {boolean} - true if the document is a html file
* @return {boolean} - true if the document supports inline JavaScript
*/
function isHTMLFile(document) {
return LanguageManager.getLanguageForPath(document.file.fullPath).getId() === "html";
function isInlineScriptSupported(document) {
var language = LanguageManager.getLanguageForPath(document.file.fullPath).getId();
return _inlineScriptLanguages.indexOf(language) !== -1;
}

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

if (isHTMLFile(session.editor.document)) {
if (isInlineScriptSupported(session.editor.document)) {
if (!isInlineScript(session.editor)) {
return false;
}
Expand Down

0 comments on commit 4f7be02

Please sign in to comment.