Skip to content
This repository was archived by the owner on Sep 6, 2021. It is now read-only.
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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"];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it make sense to define this as a preference?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't think so. These are the only two languages that support inline JS.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In case someone wants to disable JavaScript code hints in PHP, they can use language/php layer to disable them.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

jsp/asp I remember can do similar js mixin as PHP.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@abose jsp/asp files will be highlighted as html files.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe is something that could be defined as part of the language in the LanguageManager?


// 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