Web Inspector: Update CodeMirror to support numeric separators in JavaScript numbers
authorpecoraro@apple.com <pecoraro@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 20 Aug 2019 23:44:39 +0000 (23:44 +0000)
committerpecoraro@apple.com <pecoraro@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 20 Aug 2019 23:44:39 +0000 (23:44 +0000)
https://bugs.webkit.org/show_bug.cgi?id=200942

Cherry-pick a few CodeMirror changes:

    [javascript mode] Support numeric separators
    https://github.com/codemirror/CodeMirror/commit/beab8ed123683416bfec934df73d13401ec086b5#diff-9812850bb71d31e8dd60b476abb2bae8

    [javascript mode] fix tokenizing of underscore properties
    https://github.com/codemirror/CodeMirror/commit/463ea2c34ab442c0cae1d9732305219ca9b04dfe#diff-9812850bb71d31e8dd60b476abb2bae8

Reviewed by Timothy Hatcher.

* UserInterface/External/CodeMirror/javascript.js:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@248922 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebInspectorUI/ChangeLog
Source/WebInspectorUI/UserInterface/External/CodeMirror/javascript.js

index 027fc8b..23b0f68 100644 (file)
@@ -1,3 +1,20 @@
+2019-08-20  Joseph Pecoraro  <pecoraro@apple.com>
+
+        Web Inspector: Update CodeMirror to support numeric separators in JavaScript numbers
+        https://bugs.webkit.org/show_bug.cgi?id=200942
+
+        Cherry-pick a few CodeMirror changes:
+        
+            [javascript mode] Support numeric separators
+            https://github.com/codemirror/CodeMirror/commit/beab8ed123683416bfec934df73d13401ec086b5#diff-9812850bb71d31e8dd60b476abb2bae8
+
+            [javascript mode] fix tokenizing of underscore properties
+            https://github.com/codemirror/CodeMirror/commit/463ea2c34ab442c0cae1d9732305219ca9b04dfe#diff-9812850bb71d31e8dd60b476abb2bae8
+
+        Reviewed by Timothy Hatcher.
+
+        * UserInterface/External/CodeMirror/javascript.js:
+
 2019-08-20  Devin Rousso  <drousso@apple.com>
 
         Web Inspector: Sources: move the resource type scope bar to be next to the filter
index c3f99b0..33b365c 100644 (file)
@@ -104,7 +104,7 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) {
     if (ch == '"' || ch == "'") {
       state.tokenize = tokenString(ch);
       return state.tokenize(stream, state);
-    } else if (ch == "." && stream.match(/^\d+(?:[eE][+\-]?\d+)?/)) {
+    } else if (ch == "." && stream.match(/^\d[\d_]*(?:[eE][+\-]?[\d_]+)?/)) {
       return ret("number", "number");
     } else if (ch == "." && stream.match("..")) {
       return ret("spread", "meta");
@@ -112,10 +112,10 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) {
       return ret(ch);
     } else if (ch == "=" && stream.eat(">")) {
       return ret("=>", "operator");
-    } else if (ch == "0" && stream.match(/^(?:x[\da-f]+|o[0-7]+|b[01]+)n?/i)) {
+    } else if (ch == "0" && stream.match(/^(?:x[\dA-Fa-f_]+|o[0-7_]+|b[01_]+)n?/)) {
       return ret("number", "number");
     } else if (/\d/.test(ch)) {
-      stream.match(/^\d*(?:n|(?:\.\d*)?(?:[eE][+\-]?\d+)?)?/);
+      stream.match(/^[\d_]*(?:n|(?:\.[\d_]*)?(?:[eE][+\-]?[\d_]+)?)?/);
       return ret("number", "number");
     } else if (ch == "/") {
       if (stream.eat("*")) {