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

Side by Side Diff: pkg/dev_compiler/lib/src/compiler/command.dart

Issue 2578463004: update DDC to use analyzer extractDefinedVariables (Closed)
Patch Set: merge Created 4 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 | « pkg/dev_compiler/lib/src/analyzer/context.dart ('k') | pkg/dev_compiler/test/codegen_test.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) 2016, the Dart project authors. Please see the AUTHORS file 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 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 import 'dart:io'; 5 import 'dart:io';
6 import 'package:analyzer/src/command_line/arguments.dart'
7 show extractDefinedVariables;
6 import 'package:analyzer/src/generated/source.dart' show Source; 8 import 'package:analyzer/src/generated/source.dart' show Source;
7 import 'package:analyzer/src/summary/package_bundle_reader.dart' 9 import 'package:analyzer/src/summary/package_bundle_reader.dart'
8 show InSummarySource; 10 show InSummarySource;
9 import 'package:args/args.dart' show ArgParser, ArgResults; 11 import 'package:args/args.dart' show ArgParser, ArgResults;
10 import 'package:args/command_runner.dart' show UsageException; 12 import 'package:args/command_runner.dart' show UsageException;
11 import 'package:path/path.dart' as path; 13 import 'package:path/path.dart' as path;
12 14
13 import '../analyzer/context.dart' show AnalyzerOptions, parseDeclaredVariables; 15 import '../analyzer/context.dart' show AnalyzerOptions;
14 import 'compiler.dart' show BuildUnit, CompilerOptions, ModuleCompiler; 16 import 'compiler.dart' show BuildUnit, CompilerOptions, ModuleCompiler;
15 import 'module_builder.dart'; 17 import 'module_builder.dart';
16 18
17 bool _verbose = false; 19 bool _verbose = false;
18 20
19 /// Runs a single compile for dartdevc. 21 /// Runs a single compile for dartdevc.
20 /// 22 ///
21 /// This handles argument parsing, usage, error handling. 23 /// This handles argument parsing, usage, error handling.
22 /// See bin/dartdevc.dart for the actual entry point, which includes Bazel 24 /// See bin/dartdevc.dart for the actual entry point, which includes Bazel
23 /// worker support. 25 /// worker support.
24 int compile(List<String> args, {void printFn(Object obj)}) { 26 int compile(List<String> args, {void printFn(Object obj)}) {
25 printFn ??= print; 27 printFn ??= print;
26 ArgResults argResults; 28 ArgResults argResults;
27 var declaredVars = <String, String>{}; 29 var declaredVars = <String, String>{};
28 try { 30 try {
29 argResults = _argParser().parse(parseDeclaredVariables(args, declaredVars)); 31 args = extractDefinedVariables(args, declaredVars);
32 argResults = _argParser().parse(args);
30 _verbose = argResults['verbose']; 33 _verbose = argResults['verbose'];
31 } on FormatException catch (error) { 34 } on FormatException catch (error) {
32 printFn('$error\n\n$_usageMessage'); 35 printFn('$error\n\n$_usageMessage');
33 return 64; 36 return 64;
34 } 37 }
35 try { 38 try {
36 _compile(argResults, declaredVars, printFn); 39 _compile(argResults, declaredVars, printFn);
37 return 0; 40 return 0;
38 } on UsageException catch (error) { 41 } on UsageException catch (error) {
39 // Incorrect usage, input file not found, etc. 42 // Incorrect usage, input file not found, etc.
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after
211 '\n\n${_argParser(hide: !_verbose).usage}'; 214 '\n\n${_argParser(hide: !_verbose).usage}';
212 215
213 void _usageException(String message) { 216 void _usageException(String message) {
214 throw new UsageException(message, _usageMessage); 217 throw new UsageException(message, _usageMessage);
215 } 218 }
216 219
217 /// Thrown when the input source code has errors. 220 /// Thrown when the input source code has errors.
218 class CompileErrorException implements Exception { 221 class CompileErrorException implements Exception {
219 toString() => '\nPlease fix all errors before compiling (warnings are okay).'; 222 toString() => '\nPlease fix all errors before compiling (warnings are okay).';
220 } 223 }
OLDNEW
« no previous file with comments | « pkg/dev_compiler/lib/src/analyzer/context.dart ('k') | pkg/dev_compiler/test/codegen_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698