[webkit-changes] [WebKit/WebKit] 2c7d4e: Web Inspector: Adopt esprima-next fork of esprima ...

Patrick Angle noreply at github.com
Thu Mar 16 08:56:14 PDT 2023


  Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 2c7d4e7fbcc5794d397898df5de15f8d9faebd29
      https://github.com/WebKit/WebKit/commit/2c7d4e7fbcc5794d397898df5de15f8d9faebd29
  Author: Patrick Angle <pangle at apple.com>
  Date:   2023-03-16 (Thu, 16 Mar 2023)

  Changed paths:
    M LayoutTests/inspector/formatting/formatting-javascript-expected.txt
    M LayoutTests/inspector/formatting/formatting-javascript.html
    M LayoutTests/inspector/formatting/resources/javascript-tests/classes-expected.js
    M LayoutTests/inspector/formatting/resources/javascript-tests/classes.js
    M LayoutTests/inspector/formatting/resources/javascript-tests/modules-expected.js
    M LayoutTests/inspector/formatting/resources/javascript-tests/modules.js
    A LayoutTests/inspector/formatting/resources/javascript-tests/optional-chaining-expected.js
    A LayoutTests/inspector/formatting/resources/javascript-tests/optional-chaining.js
    A LayoutTests/inspector/formatting/resources/javascript-tests/private-classes-expected.js
    A LayoutTests/inspector/formatting/resources/javascript-tests/private-classes.js
    M LayoutTests/inspector/formatting/resources/javascript-tests/unary-binary-expressions-expected.js
    M LayoutTests/inspector/formatting/resources/javascript-tests/unary-binary-expressions.js
    M LayoutTests/inspector/model/parse-script-syntax-tree-expected.txt
    M LayoutTests/inspector/model/parse-script-syntax-tree.html
    M Source/WebInspectorUI/Tools/JSFormatter/JSFormatterDebug.js
    M Source/WebInspectorUI/Tools/JSFormatter/index.html
    M Source/WebInspectorUI/UserInterface/External/Esprima/esprima.js
    M Source/WebInspectorUI/UserInterface/Models/ScriptSyntaxTree.js
    M Source/WebInspectorUI/UserInterface/Workers/Formatter/CSSFormatter.js
    M Source/WebInspectorUI/UserInterface/Workers/Formatter/ESTreeWalker.js
    M Source/WebInspectorUI/UserInterface/Workers/Formatter/FormatterContentBuilder.js
    M Source/WebInspectorUI/UserInterface/Workers/Formatter/JSFormatter.js

  Log Message:
  -----------
  Web Inspector: Adopt esprima-next fork of esprima to support ES2022 syntax
https://bugs.webkit.org/show_bug.cgi?id=253856
rdar://89097522

Reviewed by Devin Rousso.

Adopt a fork of esprima, esprima-next, which has been updated with ES2022 features, and also includes our previously
up-streamed changes, as well as equivalent fixes for patches that had not been up-streamed. This commit includes commit
a002247e9cb92768ea91ef838b223012fe4fee9f of https://github.com/node-projects/esprima-next/.

Some adoption on JSFormatter/ESTreeWalker is necessary to handle a renamed piece of syntax, as well as support both
public and private class-level variable declarations.

* LayoutTests/inspector/formatting/formatting-javascript-expected.txt:
* LayoutTests/inspector/formatting/formatting-javascript.html:
- Fix simple class test case to extend some superclass to allow super to legally be used.
- Add cases to verify ImportExpression, ChainExpression, PrivateIdentifier, ImportAttribute, and StaticBlock types.

* LayoutTests/inspector/formatting/formatting-javascript-expected.txt:
* LayoutTests/inspector/formatting/formatting-javascript.html:

* LayoutTests/inspector/formatting/resources/javascript-tests/classes-expected.js:
* LayoutTests/inspector/formatting/resources/javascript-tests/classes.js:
- Add new test case for static blocks.

* LayoutTests/inspector/formatting/resources/javascript-tests/modules-expected.js:
* LayoutTests/inspector/formatting/resources/javascript-tests/modules.js:
- Add new test cases for conditional assignments.

* LayoutTests/inspector/formatting/resources/javascript-tests/optional-chaining-expected.js: Added.
* LayoutTests/inspector/formatting/resources/javascript-tests/optional-chaining.js: Added.
* LayoutTests/inspector/formatting/resources/javascript-tests/private-classes-expected.js: Added.
* LayoutTests/inspector/formatting/resources/javascript-tests/private-classes.js: Added.
- Add new test cases for optional chaining and private class members.

* LayoutTests/inspector/formatting/resources/javascript-tests/unary-binary-expressions-expected.js:
* LayoutTests/inspector/formatting/resources/javascript-tests/unary-binary-expressions.js:
- Add new test cases import assertions.

* Source/WebInspectorUI/Tools/JSFormatter/index.html:

* Source/WebInspectorUI/UserInterface/External/Esprima/esprima.js:
- Updated to https://github.com/node-projects/esprima-next/commit/a002247e9cb92768ea91ef838b223012fe4fee9f

* Source/WebInspectorUI/UserInterface/Models/ScriptSyntaxTree.js:
(WI.ScriptSyntaxTree.prototype._recurse):
- Handle new types from esprima and convert them into our AST tree, based on the estree spec: https://github.com/estree/estree

* Source/WebInspectorUI/UserInterface/Workers/Formatter/ESTreeWalker.js:
(ESTreeWalker.prototype._walkChildren):
(ESTreeWalker):
- Add pass-through cases for optional chaining and private identifiers.
- Adopt renamed "ImportExpression" (previously "Import").

* Source/WebInspectorUI/UserInterface/Workers/Formatter/JSFormatter.js:
(JSFormatter.prototype._before):
(JSFormatter.prototype._after):
- ChainExpression tokens don't have a range.

(JSFormatter.prototype._handleTokenAtNode):
- Added handling of "PrivateIdentifier", matching existing "Identifier" handling.
- Fixed issue where generator functions would incorrectly attempt to remove the previous white space before a "*", even
if there wasn't any white space to remove.
- Add support for static properties, private properties, and property assignment inside classes.
- Add support for private methods.
- Add generic handling of "AssignmentPattern" and "ChainExpression".

Canonical link: https://commits.webkit.org/261748@main




More information about the webkit-changes mailing list