Switch to glob for defaultExclusions, per review feedback.

This commit is contained in:
Kevin Dangoor committed 2014-05-05 08:26:51 -04:00
1 parent d8f4bbf465
commit 45a9b6fc07
2 files changed
+16 -24

No files matched your search

@@ -44,6 +44,7 @@ define(function (require, exports, module) {
FileUtils = brackets.getModule("file/FileUtils"),
CodeMirror = brackets.getModule("thirdparty/CodeMirror2/lib/codemirror"),
PreferencesManager = brackets.getModule("preferences/PreferencesManager"),
globmatch = brackets.getModule("thirdparty/globmatch"),
HintUtils = require("HintUtils"),
MessageIds = require("MessageIds"),
Preferences = require("Preferences");
@@ -217,7 +218,18 @@ define(function (require, exports, module) {
return false;
}
return excludes.test(file.name);
if (excludes.test(file.name)) {
return true;
}
var 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. defaultExclusions is an array of globs.
return defaultExclusions
&& _.isArray(defaultExclusions)
&& _.some(defaultExclusions, _.partial(globmatch, file.fullPath));
}
/**
@@ -741,17 +753,6 @@ 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
*
@@ -768,17 +769,7 @@ define(function (require, exports, module) {
});
}
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, "");
}
var name = request.file;
/**
* Helper function to get the text of a given document and send it to tern.
@@ -56,7 +56,8 @@ define(function (require, exports, module) {
matcher = null, // string matcher for hints
ignoreChange; // can ignore next "change" event if true;
PreferencesManager.definePreference("jscodehints.defaultExclusions", "array", ["ionic(-.*|\\.bundle|)\\.min\\.js$"]);
// Define the defaultExclusions which are files that are known to cause Tern to run out of control.
PreferencesManager.definePreference("jscodehints.defaultExclusions", "array", ["ionic*.min.js"]);
/**
* Sets the configuration, generally for testing/debugging use.