Skip to content

Commit

Permalink
Simplify AliasString so that backoffs are only done one way.
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 700008495
  • Loading branch information
concavelenz authored and copybara-github committed Nov 25, 2024
1 parent 511b313 commit 7513c0d
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/com/google/javascript/jscomp/AliasStrings.java
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,8 @@ public void process(Node externs, Node root) {
@Override
public boolean shouldTraverse(NodeTraversal nodeTraversal, Node n, Node parent) {
switch (n.getToken()) {
case REGEXP: // string nodes that are children of REGEXP literals can not be aliased
case GETPROP: // string nodes that are children of GETPROP nodes can not be aliased
case TEMPLATELIT:
case TAGGED_TEMPLATELIT:
case TEMPLATELIT_SUB: // technically redundant, since it must be a child of the others
Expand All @@ -131,7 +133,7 @@ public boolean shouldTraverse(NodeTraversal nodeTraversal, Node n, Node parent)

@Override
public void visit(NodeTraversal t, Node n, Node parent) {
if (n.isStringLit() && !parent.isRegExp()) {
if (n.isStringLit()) {
String str = n.getString();

// "undefined" is special-cased, since it needs to be used when JS code
Expand Down

0 comments on commit 7513c0d

Please sign in to comment.