Skip to content

Commit

Permalink
Replace constants (static final CONSTANT_CASE) declaration type which…
Browse files Browse the repository at this point in the history
… use the general collection interface (e.g. List) with an immutable type (e.g. ImmutableList).

For constant field declarations, you should use the immutable type (such as ImmutableList) instead of the general collection interface type (such as List). This communicates to your callers important semantic guarantees ([]

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=149326590
  • Loading branch information
dorireuv authored and dimvar committed Mar 7, 2017
1 parent bf5f0e7 commit 5aaaddd
Show file tree
Hide file tree
Showing 2 changed files with 115 additions and 111 deletions.
224 changes: 114 additions & 110 deletions test/com/google/javascript/jscomp/IntegrationTestCase.java
Expand Up @@ -35,116 +35,120 @@ abstract class IntegrationTestCase extends TestCase {
protected static final Joiner LINE_JOINER = Joiner.on('\n'); protected static final Joiner LINE_JOINER = Joiner.on('\n');


/** Externs for the test */ /** Externs for the test */
protected static final List<SourceFile> DEFAULT_EXTERNS = protected static final ImmutableList<SourceFile> DEFAULT_EXTERNS =
ImmutableList.of(SourceFile.fromCode("externs", LINE_JOINER.join( ImmutableList.of(
"var arguments;", SourceFile.fromCode(
"var undefined;", "externs",
"var Math;", LINE_JOINER.join(
"var isNaN;", "var arguments;",
"var Infinity;", "var undefined;",
"/** @interface */", "var Math;",
"var Iterator = function() {};", "var isNaN;",
"/** @interface */", "var Infinity;",
"var Iterable = function() {};", "/** @interface */",
"/** @interface @extends {Iterator} @extends {Iterable} */", "var Iterator = function() {};",
"var IteratorIterable = function() {};", "/** @interface */",
"/** @interface */", "var Iterable = function() {};",
"function IArrayLike() {};", "/** @interface @extends {Iterator} @extends {Iterable} */",
// TODO(sdh): See if we can remove IIterableResult and Set once polyfills are split "var IteratorIterable = function() {};",
"/** @interface */", "/** @interface */",
"var IIterableResult = function() {};", "function IArrayLike() {};",
"/** @constructor */", // TODO(sdh): See if we can remove IIterableResult and Set once polyfills are
"var Map;", // split
"/** @constructor */", "/** @interface */",
"var Set;", "var IIterableResult = function() {};",
"/** @constructor */", "/** @constructor */",
"function ObjectPropertyDescriptor() {};", "var Map;",
"", "/** @constructor */",
"/** @constructor */ function Window() {}", "var Set;",
"/** @type {string} */ Window.prototype.name;", "/** @constructor */",
"/** @type {string} */ Window.prototype.offsetWidth;", "function ObjectPropertyDescriptor() {};",
"/** @type {Window} */ var window;", "",
"", "/** @constructor */ function Window() {}",
"/** @nosideeffects */ function noSideEffects() {}", "/** @type {string} */ Window.prototype.name;",
"", "/** @type {string} */ Window.prototype.offsetWidth;",
"/**", "/** @type {Window} */ var window;",
" * @constructor", "",
" * @nosideeffects", "/** @nosideeffects */ function noSideEffects() {}",
" */", "",
"function Widget() {}", "/**",
"/** @modifies {this} */ Widget.prototype.go = function() {};", " * @constructor",
"/** @return {string} */ var widgetToken = function() {};", " * @nosideeffects",
"", " */",
"function alert(message) {}", "function Widget() {}",
"", "/** @modifies {this} */ Widget.prototype.go = function() {};",
"/**", "/** @return {string} */ var widgetToken = function() {};",
" * @constructor", "",
" * @implements {IArrayLike}", "function alert(message) {}",
" * @return {!Array}", "",
" * @param {...*} var_args", "/**",
" */", " * @constructor",
"function Array(var_args) {}", " * @implements {IArrayLike}",
"", " * @return {!Array}",
"/**", " * @param {...*} var_args",
" * @constructor", " */",
" * @return {number}", "function Array(var_args) {}",
" * @param {*=} opt_n", "",
" */", "/**",
"function Number(opt_n) {}", " * @constructor",
"", " * @return {number}",
"/**", " * @param {*=} opt_n",
" * @constructor", " */",
" * @return {string}", "function Number(opt_n) {}",
" * @param {*=} opt_s", "",
" */", "/**",
"function String(opt_s) {}", " * @constructor",
"", " * @return {string}",
"/**", " * @param {*=} opt_s",
" * @constructor", " */",
" * @return {boolean}", "function String(opt_s) {}",
" * @param {*=} opt_b", "",
" */", "/**",
"function Boolean(opt_b) {}", " * @constructor",
"", " * @return {boolean}",
"/**", " * @param {*=} opt_b",
" * @constructor", " */",
" * @return {!TypeError}", "function Boolean(opt_b) {}",
" * @param {*=} opt_message", "",
" * @param {*=} opt_file", "/**",
" * @param {*=} opt_line", " * @constructor",
" */", " * @return {!TypeError}",
"function TypeError(opt_message, opt_file, opt_line) {}", " * @param {*=} opt_message",
"", " * @param {*=} opt_file",
"/**", " * @param {*=} opt_line",
" * @constructor", " */",
" * @param {*=} opt_value", "function TypeError(opt_message, opt_file, opt_line) {}",
" * @return {!Object}", "",
" */", "/**",
"function Object(opt_value) {}", " * @constructor",
"Object.seal;", " * @param {*=} opt_value",
"Object.defineProperties;", " * @return {!Object}",
"/** @type {!Function} */", " */",
"Object.prototype.constructor;", "function Object(opt_value) {}",
"", "Object.seal;",
"/** @typedef {?} */", "Object.defineProperties;",
"var symbol;", "/** @type {!Function} */",
"", "Object.prototype.constructor;",
"/**", "",
" * @param {string} s", "/** @typedef {?} */",
" * @return {symbol}", "var symbol;",
" */", "",
"function Symbol(s) {}", "/**",
"", " * @param {string} s",
"/**", " * @return {symbol}",
" * @param {...*} var_args", " */",
" * @constructor", "function Symbol(s) {}",
" */", "",
"function Function(var_args) {}", "/**",
"/** @param {...*} var_args */", " * @param {...*} var_args",
"Function.prototype.call = function (var_args) {};", " * @constructor",
"", " */",
"/** @constructor */", "function Function(var_args) {}",
"function Arguments() {}"))); "/** @param {...*} var_args */",
"Function.prototype.call = function (var_args) {};",
"",
"/** @constructor */",
"function Arguments() {}")));


protected List<SourceFile> externs = DEFAULT_EXTERNS; protected List<SourceFile> externs = DEFAULT_EXTERNS;


Expand Down
Expand Up @@ -1330,7 +1330,7 @@ public void foldDefineProperties1() {
testSame("Object.defineProperties(a, {anything:1})"); testSame("Object.defineProperties(a, {anything:1})");
} }


private static final List<String> LITERAL_OPERANDS = private static final ImmutableList<String> LITERAL_OPERANDS =
ImmutableList.of( ImmutableList.of(
"null", "null",
"undefined", "undefined",
Expand Down

0 comments on commit 5aaaddd

Please sign in to comment.