Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(32)

Side by Side Diff: tool/node_format_service.dart

Issue 1640023002: Support deploying an npm package exporting a formatCode method. (Closed) Base URL: git@github.com:dart-lang/dart_style.git@master
Patch Set: ptal Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « tool/grind.dart ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file.
4
5 import 'package:js/js.dart';
6
7 import 'package:dart_style/dart_style.dart';
8
9 @JS()
10 @anonymous
11 class FormatResult {
12 external factory FormatResult({String code, String error});
13 external String get code;
14 external String get error;
15 }
16
17 @JS('exports.formatCode')
18 external set formatCode(Function formatter);
19
20 void main() {
21 formatCode = allowInterop((String source) {
22 var formatter = new DartFormatter();
23 try {
24 return new FormatResult(
25 code: new DartFormatter().format(source));
26 } on FormatterException {
27 // Do nothing.
28 }
29
30 // Maybe it's a statement.
31 try {
32 return new FormatResult(
33 code: formatter.formatStatement(source));
34 } on FormatterException catch (err) {
35 return new FormatResult(code: source, error: "$err");
36 }
37 });
38 }
OLDNEW
« no previous file with comments | « tool/grind.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698