Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Unified Diff: lib/matcher.js

Issue 29897555: Issue 6940 - Use underscore prefixes lib/matcher.js (Closed)
Patch Set: Created Oct. 1, 2018, 5:46 a.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/matcher.js
===================================================================
--- a/lib/matcher.js
+++ b/lib/matcher.js
@@ -36,56 +36,56 @@
* @type {Map.<string,(Filter|Filter[])>}
*/
this.filterByKeyword = new Map();
/**
* Lookup table for keywords by the filter
* @type {Map.<Filter,string>}
*/
- this.keywordByFilter = new Map();
+ this._keywordByFilter = new Map();
Manish Jethani 2018/10/01 15:08:59 I think we should add the `@private` tag here. Ot
Manish Jethani 2018/10/01 15:10:00 I'm wondering where exactly it should be added. I
Jon Sonesen 2018/10/21 03:07:07 Done.
}
/**
* Removes all known filters
*/
clear()
{
this.filterByKeyword.clear();
- this.keywordByFilter.clear();
+ this._keywordByFilter.clear();
}
/**
* Adds a filter to the matcher
* @param {RegExpFilter} filter
*/
add(filter)
{
- if (this.keywordByFilter.has(filter))
+ if (this._keywordByFilter.has(filter))
return;
// Look for a suitable keyword
let keyword = this.findKeyword(filter);
let oldEntry = this.filterByKeyword.get(keyword);
if (typeof oldEntry == "undefined")
this.filterByKeyword.set(keyword, filter);
else if (oldEntry.length == 1)
this.filterByKeyword.set(keyword, [oldEntry, filter]);
else
oldEntry.push(filter);
- this.keywordByFilter.set(filter, keyword);
+ this._keywordByFilter.set(filter, keyword);
}
/**
* Removes a filter from the matcher
* @param {RegExpFilter} filter
*/
remove(filter)
{
- let keyword = this.keywordByFilter.get(filter);
+ let keyword = this._keywordByFilter.get(filter);
if (typeof keyword == "undefined")
return;
let list = this.filterByKeyword.get(keyword);
if (list.length <= 1)
this.filterByKeyword.delete(keyword);
else
{
@@ -93,17 +93,17 @@
if (index >= 0)
{
list.splice(index, 1);
if (list.length == 1)
this.filterByKeyword.set(keyword, list[0]);
}
}
- this.keywordByFilter.delete(filter);
+ this._keywordByFilter.delete(filter);
}
/**
* Chooses a keyword to be associated with the filter
* @param {Filter} filter
* @returns {string} keyword or an empty string if no keyword could be found
*/
findKeyword(filter)
@@ -140,28 +140,28 @@
/**
* Checks whether a particular filter is being matched against.
* @param {RegExpFilter} filter
* @returns {boolean}
*/
hasFilter(filter)
{
- return this.keywordByFilter.has(filter);
+ return this._keywordByFilter.has(filter);
}
/**
* Returns the keyword used for a filter, <code>null</code>
* for unknown filters.
* @param {RegExpFilter} filter
* @returns {?string}
*/
getKeywordForFilter(filter)
{
- let keyword = this.keywordByFilter.get(filter);
+ let keyword = this._keywordByFilter.get(filter);
return typeof keyword != "undefined" ? keyword : null;
}
/**
* Checks whether the entries for a particular keyword match a URL
* @param {string} keyword
* @param {string} location
* @param {number} typeMask
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld