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

Commit

Permalink
Implement jscodehints.defaultExclusions preference.
Browse files Browse the repository at this point in the history
We've had a number of people report problems with Ionic in their projects.
Tern appears to have an issue with the minified Ionic files. I had planned
to add default exclusions so that we could quickly solve pain like this
and this problem appeared to be a good candidate. The repro steps
[reported here](#7262 (comment))
are fixed with this change.
  • Loading branch information
dangoor committed May 3, 2014
1 parent adbba96 commit d8f4bbf
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 3 deletions.
26 changes: 24 additions & 2 deletions src/extensions/default/JavaScriptCodeHints/ScopeManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ define(function (require, exports, module) {
FileSystem = brackets.getModule("filesystem/FileSystem"),
FileUtils = brackets.getModule("file/FileUtils"),
CodeMirror = brackets.getModule("thirdparty/CodeMirror2/lib/codemirror"),
PreferencesManager = brackets.getModule("preferences/PreferencesManager"),
HintUtils = require("HintUtils"),
MessageIds = require("MessageIds"),
Preferences = require("Preferences");
Expand Down Expand Up @@ -739,7 +740,18 @@ define(function (require, exports, module) {

return addPendingRequest(path, OFFSET_ZERO, MessageIds.TERN_UPDATE_FILE_MSG);
}


/**
* Checks filename to see if it matches the exclusion regex.
*
* @param {string} name filename to check
* @param {string} exclusion uncompiled exclusion regular expression
* @return {boolean} true if the file should be excluded
*/
function checkExclusion(name, exclusion) {
return new RegExp(exclusion).exec(name);
}

/**
* Handle a request from the worker for text of a file
*
Expand All @@ -756,7 +768,17 @@ define(function (require, exports, module) {
});
}

var name = request.file;
var name = request.file,
defaultExclusions = PreferencesManager.get("jscodehints.defaultExclusions");

// The defaultExclusions are the ones we ship with Brackets to filter out files that we know
// to be troublesome with current versions of Tern. They can be overridden with a .brackets.json
// file in your project.
if (defaultExclusions
&& _.isArray(defaultExclusions)
&& _.some(defaultExclusions, _.partial(checkExclusion, name))) {
replyWith(name, "");
}

/**
* Helper function to get the text of a given document and send it to tern.
Expand Down
5 changes: 4 additions & 1 deletion src/extensions/default/JavaScriptCodeHints/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ define(function (require, exports, module) {
StringMatch = brackets.getModule("utils/StringMatch"),
LanguageManager = brackets.getModule("language/LanguageManager"),
ProjectManager = brackets.getModule("project/ProjectManager"),
PreferencesManager = brackets.getModule("preferences/PreferencesManager"),
ParameterHintManager = require("ParameterHintManager"),
HintUtils = require("HintUtils"),
ScopeManager = require("ScopeManager"),
Expand All @@ -54,7 +55,9 @@ define(function (require, exports, module) {
cachedToken = null, // the token used in the current hinting session
matcher = null, // string matcher for hints
ignoreChange; // can ignore next "change" event if true;


PreferencesManager.definePreference("jscodehints.defaultExclusions", "array", ["ionic(-.*|\\.bundle|)\\.min\\.js$"]);

/**
* Sets the configuration, generally for testing/debugging use.
* Configuration keys are merged into the current configuration.
Expand Down

0 comments on commit d8f4bbf

Please sign in to comment.