Bug 122868 - Web Inspector: ES6: JavaScript syntax highlighting and recognition of for..of
Summary: Web Inspector: ES6: JavaScript syntax highlighting and recognition of for..of
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Web Inspector (show other bugs)
Version: 528+ (Nightly build)
Hardware: All All
: P2 Normal
Assignee: Nobody
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2013-10-15 15:27 PDT by Joseph Pecoraro
Modified: 2013-12-12 11:49 PST (History)
6 users (show)

See Also:


Attachments
Patch (163.66 KB, patch)
2013-11-29 04:43 PST, Laszlo Vidacs
no flags Details | Formatted Diff | Diff
Patch (163.17 KB, patch)
2013-12-11 08:47 PST, Laszlo Vidacs
no flags Details | Formatted Diff | Diff
Patch (162.68 KB, patch)
2013-12-11 11:50 PST, Laszlo Vidacs
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Joseph Pecoraro 2013-10-15 15:27:26 PDT
JSC now supports for..of. We should syntax highlight it like for..in:

Compare these in the JS Console:

  js> for (var x in []) {}
  js> for (var x of []) {}

NOTE: Most likely CodeMirror JavaScript ES6 update.
Comment 1 Radar WebKit Bug Importer 2013-10-15 15:27:42 PDT
<rdar://problem/15235823>
Comment 2 Laszlo Vidacs 2013-11-14 02:19:01 PST
Pull request submitted to the CodeMirror repository: https://github.com/lvidacs/CodeMirror/commit/1cb45c87c70629e6cb5899403e07b2ab39354dca
Comment 3 Laszlo Vidacs 2013-11-14 02:36:59 PST
The patch landed in CodeMirror 
https://github.com/marijnh/CodeMirror/commit/39804ada3d6d14da5e0f237fa5904a5e0aaa4489
Comment 4 Timothy Hatcher 2013-11-14 09:20:58 PST
Sweet! We just need to update CodeMirror then.
Comment 5 Timothy Hatcher 2013-11-14 09:21:32 PST
Thanks for fixing this!
Comment 6 Laszlo Vidacs 2013-11-29 04:43:26 PST
Created attachment 218053 [details]
Patch
Comment 7 Laszlo Vidacs 2013-11-29 04:45:46 PST
CodeMirror release 3.20 contains javascript ES6 updates, among others the fix for this bug. Patch created according to the commnet in https://bugs.webkit.org/show_bug.cgi?id=120165 however not fully tested.
Comment 8 Timothy Hatcher 2013-12-02 13:07:08 PST
Comment on attachment 218053 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=218053&action=review

> Source/WebInspectorUI/Tools/PrettyPrinting/codemirror.js:5570
> -      var result = /\-[^ \-?]|\?[^ !\'\"\),.\-\/:;\?\]\}]/.test(str.slice(i - 1, i + 1));
> -      return result;
> +      return /\-[^ \-?]|\?[^ !\'\"\),.\-\/:;\?\]\}]/.test(str.slice(i - 1, i + 1));

This change breaks the jsmin.py script. It needs reverted. This is a local change to CodeMirror we have until we fix it. Testing copy-user-interface-resources.sh with COMBINE_INSPECTOR_RESOURCES = YES will show what I mean.

> Source/WebInspectorUI/Tools/PrettyPrinting/codemirror.js:5583
> -      var result = /[~!#%&*)=+}\]|\"\.>,:;][({[<]|-[^\-?\.\u2010-\u201f\u2026]|\?[\w~`@#$%\^&*(_=+{[|><]|â¦[\w~`@#$%\^&*(_=+{[><]/.test(str.slice(i - 1, i + 1));
> -      return result;
> +      return /[~!#%&*)=+}\]\\|\"\.>,:;][({[<]|-[^\-?\.\u2010-\u201f\u2026]|\?[\w~`@#$%\^&*(_=+{[|><]|â¦[\w~`@#$%\^&*(_=+{[><]/.test(str.slice(i - 1, i + 1));

Ditto.
Comment 9 Laszlo Vidacs 2013-12-11 08:47:50 PST
Created attachment 218969 [details]
Patch
Comment 10 Laszlo Vidacs 2013-12-11 08:52:54 PST
Patch updated accordingly; codemirror.js files in WebInspectorUI/Tools/PrettyPrinting/ and in WebInspectorUI/UserInterface/External/CodeMirror/ now differ.
Comment 11 Joseph Pecoraro 2013-12-11 10:15:07 PST
(In reply to comment #10)
> Patch updated accordingly; codemirror.js files in WebInspectorUI/Tools/PrettyPrinting/ and in WebInspectorUI/UserInterface/External/CodeMirror/ now differ.

No reason for these files to differ. PrettyPrinting should just be a copy of UserInterface/External/CodeMirror. It is nice to have them separate for development, but identical if you run pretty printing tests.
Comment 12 Timothy Hatcher 2013-12-11 10:16:33 PST
Comment on attachment 218969 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=218969&action=review

> Source/WebInspectorUI/UserInterface/External/CodeMirror/codemirror.js:5570
> -      var result = /\-[^ \-?]|\?[^ !\'\"\),.\-\/:;\?\]\}]/.test(str.slice(i - 1, i + 1));
> -      return result;
> +      return /\-[^ \-?]|\?[^ !\'\"\),.\-\/:;\?\]\}]/.test(str.slice(i - 1, i + 1));

Sorry for the confusion. My comment wasn't meant for the PrettyPrinting copy. It was meant for the main codemirror.js. The version in UserInterface is the one we use jsmin.js on, but both copies in our tree should be the same.

> Source/WebInspectorUI/UserInterface/External/CodeMirror/codemirror.js:5583
> -      var result = /[~!#%&*)=+}\]|\"\.>,:;][({[<]|-[^\-?\.\u2010-\u201f\u2026]|\?[\w~`@#$%\^&*(_=+{[|><]|â¦[\w~`@#$%\^&*(_=+{[><]/.test(str.slice(i - 1, i + 1));
> -      return result;
> +      return /[~!#%&*)=+}\]\\|\"\.>,:;][({[<]|-[^\-?\.\u2010-\u201f\u2026]|\?[\w~`@#$%\^&*(_=+{[|><]|â¦[\w~`@#$%\^&*(_=+{[><]/.test(str.slice(i - 1, i + 1));

Ditto.
Comment 13 Laszlo Vidacs 2013-12-11 11:50:52 PST
Created attachment 218990 [details]
Patch
Comment 14 Laszlo Vidacs 2013-12-11 11:54:28 PST
Sorry, I updated the patch with identical codemirror.js in both places.
Comment 15 WebKit Commit Bot 2013-12-12 11:49:42 PST
Comment on attachment 218990 [details]
Patch

Clearing flags on attachment: 218990

Committed r160500: <http://trac.webkit.org/changeset/160500>
Comment 16 WebKit Commit Bot 2013-12-12 11:49:44 PST
All reviewed patches have been landed.  Closing bug.