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

Side by Side Diff: lib/src/codegen/js_printer.dart

Issue 1524843002: JS: Format if statements with no else on a single line (Closed) Base URL: git@github.com:dart-lang/dev_compiler.git@master
Patch Set: rebased Created 5 years 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 | « lib/runtime/dart/typed_data.js ('k') | lib/src/js/printer.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 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. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 library dev_compiler.src.codegen.js_printer; 5 library dev_compiler.src.codegen.js_printer;
6 6
7 import 'dart:convert' show JSON, JsonEncoder; 7 import 'dart:convert' show JSON, JsonEncoder;
8 import 'dart:io' show Directory, File, Platform, Process; 8 import 'dart:io' show Directory, File, Platform, Process;
9 9
10 import 'package:analyzer/src/generated/ast.dart'; 10 import 'package:analyzer/src/generated/ast.dart';
(...skipping 16 matching lines...) Expand all
27 JS.JavaScriptPrintingContext context; 27 JS.JavaScriptPrintingContext context;
28 if (emitSourceMaps) { 28 if (emitSourceMaps) {
29 var printer = new srcmaps.Printer(outFilename); 29 var printer = new srcmaps.Printer(outFilename);
30 context = new SourceMapPrintingContext(printer, outDir); 30 context = new SourceMapPrintingContext(printer, outDir);
31 } else { 31 } else {
32 context = new JS.SimpleJavaScriptPrintingContext(); 32 context = new JS.SimpleJavaScriptPrintingContext();
33 } 33 }
34 34
35 var opts = new JS.JavaScriptPrintingOptions( 35 var opts = new JS.JavaScriptPrintingOptions(
36 allowKeywordsInProperties: true, 36 allowKeywordsInProperties: true,
37 allowSingleLineIfStatements: true,
37 arrowFnBindThisWorkaround: arrowFnBindThisWorkaround); 38 arrowFnBindThisWorkaround: arrowFnBindThisWorkaround);
38 var jsNamer = new TemporaryNamer(jsTree); 39 var jsNamer = new TemporaryNamer(jsTree);
39 jsTree.accept(new JS.Printer(opts, context, localNamer: jsNamer)); 40 jsTree.accept(new JS.Printer(opts, context, localNamer: jsNamer));
40 41
41 String text; 42 String text;
42 if (context is SourceMapPrintingContext) { 43 if (context is SourceMapPrintingContext) {
43 var printer = context.printer; 44 var printer = context.printer;
44 printer.add('//# sourceMappingURL=$outFilename.map\n'); 45 printer.add('//# sourceMappingURL=$outFilename.map\n');
45 // Write output file and source map 46 // Write output file and source map
46 text = printer.text; 47 text = printer.text;
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
129 _currentTopLevelDeclaration == null; 130 _currentTopLevelDeclaration == null;
130 return; 131 return;
131 } 132 }
132 } 133 }
133 134
134 String _getIdentifier(AstNode node) { 135 String _getIdentifier(AstNode node) {
135 if (node is SimpleIdentifier) return node.name; 136 if (node is SimpleIdentifier) return node.name;
136 return null; 137 return null;
137 } 138 }
138 } 139 }
OLDNEW
« no previous file with comments | « lib/runtime/dart/typed_data.js ('k') | lib/src/js/printer.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698