Skip to content

Commit

Permalink
Remove workaround for J2CL + Character.isLetter incompatibility
Browse files Browse the repository at this point in the history
We've removed the J2CL build of JSCompiler so this workaround is no longer necessary.

PiperOrigin-RevId: 707700404
  • Loading branch information
lauraharker committed Dec 20, 2024
1 parent 697931f commit bf1253b
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 25 deletions.
20 changes: 1 addition & 19 deletions src/com/google/javascript/jscomp/parsing/parser/Identifiers.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,25 +30,7 @@ public static boolean isIdentifierStart(char ch) {

// Handle non-ASCII characters.
// TODO(tjgq): This should include all characters with the ID_Start property.
if (Character.isLetter(ch)) {
return true;
}

// Workaround for b/36459436.
// When running under GWT/J2CL, Character.isLetter only handles ASCII.
// Angular relies heavily on Latin Small Letter Barred O and Greek Capital Letter Delta.
// Greek letters are occasionally found in math code.
// Latin letters are found in our own tests.
return (ch >= 0x00C0 & ch <= 0x00D6) // Latin letters
// 0x00D7 = multiplication sign, not a letter
| (ch >= 0x00D8 & ch <= 0x00F6) // Latin letters
// 0x00F7 = division sign, not a letter
| (ch >= 0x00F8 & ch <= 0x00FF) // Latin letters
| ch == 0x0275 // Latin Barred O
| (ch >= 0x0391 & ch <= 0x03A1) // Greek uppercase letters
// 0x03A2 = unassigned
| (ch >= 0x03A3 & ch <= 0x03A9) // Remaining Greek uppercase letters
| (ch >= 0x03B1 & ch <= 0x03C9); // Greek lowercase letters
return Character.isLetter(ch);
}

@SuppressWarnings("ShortCircuitBoolean") // Intentional to minimize branches in this code
Expand Down
7 changes: 1 addition & 6 deletions src/com/google/javascript/jscomp/regex/RegExpTree.java
Original file line number Diff line number Diff line change
Expand Up @@ -748,12 +748,7 @@ private static boolean isIdentifierStart(char ch) {
return ((ch >= 'A' && ch <= 'Z') || (ch >= 'a' && ch <= 'z') || (ch == '_' || ch == '$'));
}

// Workaround b/36459436
// When running under GWT, Character.isLetter only handles ASCII
// Angular relies heavily on U+0275 (Latin Barred O)
return ch == 0x0275
// TODO: UnicodeLetter also includes Letter Number (NI)
|| Character.isLetter(ch);
return Character.isLetter(ch);
}

/**
Expand Down

0 comments on commit bf1253b

Please sign in to comment.