Merge pull request #8272 from adobe/rlim/code-hints-pref

Simple code hints preferences to enable/disable individual/all code hints providers.
This commit is contained in:
Randy Edmunds committed 2014-07-19 09:43:43 -07:00
commit 2ab6dff333
2 files changed
+59 -16

No files matched your search

@@ -48,13 +48,15 @@ define(function (require, exports, module) {
Session = require("Session"),
Acorn = require("thirdparty/acorn/acorn");
var session = null, // object that encapsulates the current session state
cachedCursor = null, // last cursor of the current hinting session
cachedHints = null, // sorted hints for the current hinting session
cachedType = null, // describes the lookup type and the object context
cachedToken = null, // the token used in the current hinting session
matcher = null, // string matcher for hints
ignoreChange; // can ignore next "change" event if true;
var session = null, // object that encapsulates the current session state
cachedCursor = null, // last cursor of the current hinting session
cachedHints = null, // sorted hints for the current hinting session
cachedType = null, // describes the lookup type and the object context
cachedToken = null, // the token used in the current hinting session
matcher = null, // string matcher for hints
jsHintsEnabled = true, // preference setting to enable/disable the hint session
ignoreChange; // can ignore next "change" event if true;
// Define the detectedExclusions which are files that have been detected to cause Tern to run out of control.
PreferencesManager.definePreference("jscodehints.detectedExclusions", "array", []);
@@ -62,6 +64,26 @@ define(function (require, exports, module) {
// This preference controls when Tern will time out when trying to understand files
PreferencesManager.definePreference("jscodehints.inferenceTimeout", "number", 5000);
// This preference controls whether to create a session and process all JS files or not.
PreferencesManager.definePreference("codehint.JSHints", "boolean", true);
/**
* Check whether any of code hints preferences for JS Code Hints is disabled
* @return {boolean} enabled/disabled
*/
function _areHintsEnabled() {
return (PreferencesManager.get("codehint.JSHints") !== false) &&
(PreferencesManager.get("showCodeHints") !== false);
}
PreferencesManager.on("change", "codehint.JSHints", function () {
jsHintsEnabled = _areHintsEnabled();
});
PreferencesManager.on("change", "showCodeHints", function () {
jsHintsEnabled = _areHintsEnabled();
});
/**
* Sets the configuration, generally for testing/debugging use.
* Configuration keys are merged into the current configuration.
@@ -585,6 +607,10 @@ define(function (require, exports, module) {
// always clean up cached scope and hint info
resetCachedHintContext();
if (!jsHintsEnabled) {
return;
}
if (editor && HintUtils.isSupportedLanguage(LanguageManager.getLanguageForPath(editor.document.file.fullPath).getId())) {
initializeSession(editor, previousEditor);
$(editor)