Web Inspector: Should be able to pretty print module code (import / export statements)
https://bugs.webkit.org/show_bug.cgi?id=161891
<rdar://problem/28272784>

Patch by Joseph Pecoraro <pecoraro@apple.com> on 2016-09-13
Reviewed by Yusuke Suzuki.

Source/WebInspectorUI:

* Tools/Formatting/EsprimaFormatterDebug.js:
* Tools/Formatting/index.html:
Update the formatting tool to toggle between source type modes.

* UserInterface/Proxies/FormatterWorkerProxy.js:
* UserInterface/Workers/Formatter/FormatterWorker.js:
(FormatterWorker.prototype.formatJavaScript):
Provide a flag to parse the input as a module instead of a script/program.

* UserInterface/Views/TextEditor.js:
(WebInspector.TextEditor.prototype._startWorkerPrettyPrint):
Using the formatter here, we may have module scripts in the future.

* UserInterface/Views/SourceCodeTextEditor.js:
(WebInspector.SourceCodeTextEditor.prototype._showPopoverForFunction.didGetDetails):
Using the formatter for a function is not module source.

* UserInterface/Workers/Formatter/ESTreeWalker.js:
(ESTreeWalker.prototype._walkChildren):
Visit children of Export/Import nodes.

* UserInterface/Workers/Formatter/EsprimaFormatter.js:
(EsprimaFormatter.prototype._handleTokenAtNode):
Output tokens with appropriate whitespace.

LayoutTests:

* inspector/formatting/formatting-javascript-expected.txt:
* inspector/formatting/formatting-javascript.html:
* inspector/formatting/resources/javascript-tests/modules-expected.js: Added.
* inspector/formatting/resources/javascript-tests/modules.js: Added.
Include a new test for modules.

* inspector/formatting/formatting-json.html:
All of these are non-module source code.

* inspector/formatting/resources/utilities.js:
Determine if module or not based on the test name.

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@205866 268f45cc-cd09-0410-ab3c-d52691b4dbfc
16 files changed