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

Cleanup change automatically generated

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=149221315
  • Loading branch information
dorireuv authored and dimvar committed Mar 6, 2017
1 parent eb6fc61 commit 6df616f
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 17 deletions.
6 changes: 3 additions & 3 deletions src/com/google/javascript/jscomp/CheckConformance.java
Expand Up @@ -23,7 +23,6 @@
import com.google.javascript.rhino.Node; import com.google.javascript.rhino.Node;
import com.google.protobuf.Descriptors; import com.google.protobuf.Descriptors;
import com.google.protobuf.TextFormat; import com.google.protobuf.TextFormat;

import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.HashSet; import java.util.HashSet;
Expand Down Expand Up @@ -114,8 +113,9 @@ private static ImmutableList<Rule> initRules(
return builder.build(); return builder.build();
} }


private static final Set<String> EXTENDABLE_FIELDS = ImmutableSet.of( private static final ImmutableSet<String> EXTENDABLE_FIELDS =
"extends", "whitelist", "whitelist_regexp", "only_apply_to", "only_apply_to_regexp"); ImmutableSet.of(
"extends", "whitelist", "whitelist_regexp", "only_apply_to", "only_apply_to_regexp");


/** /**
* Gets requirements from all configs. Merges whitelists of requirements with 'extends' equal to * Gets requirements from all configs. Merges whitelists of requirements with 'extends' equal to
Expand Down
35 changes: 26 additions & 9 deletions src/com/google/javascript/jscomp/CheckRegExp.java
Expand Up @@ -20,7 +20,6 @@
import com.google.javascript.jscomp.regex.RegExpTree; import com.google.javascript.jscomp.regex.RegExpTree;
import com.google.javascript.rhino.Node; import com.google.javascript.rhino.Node;
import com.google.javascript.rhino.Token; import com.google.javascript.rhino.Token;
import java.util.Set;


/** /**
* Look for references to the global RegExp object that would cause * Look for references to the global RegExp object that would cause
Expand All @@ -39,14 +38,32 @@ class CheckRegExp extends AbstractPostOrderCallback implements CompilerPass {
"JSC_MALFORMED_REGEXP", "JSC_MALFORMED_REGEXP",
"Malformed Regular Expression: {0}"); "Malformed Regular Expression: {0}");


private static final Set<String> REGEXP_PROPERTY_BLACKLIST = ImmutableSet.of( private static final ImmutableSet<String> REGEXP_PROPERTY_BLACKLIST =
"$1", "$2", "$3", "$4", "$5", "$6", "$7", "$8", "$9", ImmutableSet.of(
"$_", "$input", "$1",
// The following would also be blacklisted, but they aren't valid "$2",
// identifiers, so can't be accessed with the '.' operator anyway. "$3",
// "$*", "$&", "$+", "$`", "$'", "$4",
"input", "lastMatch", "lastParen", "leftContext", "rightContext", "$5",
"global", "ignoreCase", "lastIndex", "multiline", "source"); "$6",
"$7",
"$8",
"$9",
"$_",
"$input",
// The following would also be blacklisted, but they aren't valid
// identifiers, so can't be accessed with the '.' operator anyway.
// "$*", "$&", "$+", "$`", "$'",
"input",
"lastMatch",
"lastParen",
"leftContext",
"rightContext",
"global",
"ignoreCase",
"lastIndex",
"multiline",
"source");


private final AbstractCompiler compiler; private final AbstractCompiler compiler;
private boolean globalRegExpPropertiesUsed = false; private boolean globalRegExpPropertiesUsed = false;
Expand Down
27 changes: 22 additions & 5 deletions src/com/google/javascript/jscomp/RescopeGlobalSymbols.java
Expand Up @@ -55,12 +55,29 @@ final class RescopeGlobalSymbols implements CompilerPass {
// Appended to variables names that conflict with globalSymbolNamespace. // Appended to variables names that conflict with globalSymbolNamespace.
private static final String DISAMBIGUATION_SUFFIX = "$"; private static final String DISAMBIGUATION_SUFFIX = "$";
private static final String WINDOW = "window"; private static final String WINDOW = "window";
private static final Set<String> SPECIAL_EXTERNS = private static final ImmutableSet<String> SPECIAL_EXTERNS =
ImmutableSet.of(WINDOW, "eval", "arguments", "undefined", ImmutableSet.of(
WINDOW,
"eval",
"arguments",
"undefined",
// The javascript built-in objects (listed in Ecma 262 section 4.2) // The javascript built-in objects (listed in Ecma 262 section 4.2)
"Object", "Function", "Array", "String", "Boolean", "Number", "Math", "Object",
"Date", "RegExp", "JSON", "Error", "EvalError", "ReferenceError", "Function",
"SyntaxError", "TypeError", "URIError"); "Array",
"String",
"Boolean",
"Number",
"Math",
"Date",
"RegExp",
"JSON",
"Error",
"EvalError",
"ReferenceError",
"SyntaxError",
"TypeError",
"URIError");


private final AbstractCompiler compiler; private final AbstractCompiler compiler;
private final String globalSymbolNamespace; private final String globalSymbolNamespace;
Expand Down

0 comments on commit 6df616f

Please sign in to comment.