Chromium Code Reviews| OLD | NEW |
|---|---|
| 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:collection' show HashSet; | 5 import 'dart:collection' show HashSet; |
| 6 import 'package:args/args.dart' show ArgParser, ArgResults; | 6 import 'package:args/args.dart' show ArgParser, ArgResults; |
| 7 import 'package:args/src/usage_exception.dart' show UsageException; | |
| 7 import 'package:analyzer/analyzer.dart' | 8 import 'package:analyzer/analyzer.dart' |
| 8 show | 9 show |
| 9 AnalysisError, | 10 AnalysisError, |
| 10 CompilationUnit, | 11 CompilationUnit, |
| 11 CompileTimeErrorCode, | 12 CompileTimeErrorCode, |
| 12 ErrorSeverity, | 13 ErrorSeverity, |
| 13 StaticWarningCode; | 14 StaticWarningCode; |
| 14 import 'package:analyzer/src/generated/engine.dart' show AnalysisContext; | 15 import 'package:analyzer/src/generated/engine.dart' show AnalysisContext; |
| 15 import 'package:analyzer/src/generated/java_engine.dart' show AnalysisException; | 16 import 'package:analyzer/src/generated/java_engine.dart' show AnalysisException; |
| 16 import 'package:analyzer/src/generated/source_io.dart' show Source, SourceKind; | 17 import 'package:analyzer/src/generated/source_io.dart' show Source, SourceKind; |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 71 // If not, it's an error. | 72 // If not, it's an error. |
| 72 var explicitParts = new HashSet<Source>(); | 73 var explicitParts = new HashSet<Source>(); |
| 73 var usedParts = new HashSet<Source>(); | 74 var usedParts = new HashSet<Source>(); |
| 74 for (var sourcePath in unit.sources) { | 75 for (var sourcePath in unit.sources) { |
| 75 var sourceUri = Uri.parse(sourcePath); | 76 var sourceUri = Uri.parse(sourcePath); |
| 76 if (sourceUri.scheme == '') { | 77 if (sourceUri.scheme == '') { |
| 77 sourceUri = path.toUri(path.absolute(sourcePath)); | 78 sourceUri = path.toUri(path.absolute(sourcePath)); |
| 78 } | 79 } |
| 79 Source source = context.sourceFactory.forUri2(sourceUri); | 80 Source source = context.sourceFactory.forUri2(sourceUri); |
| 80 if (source == null) { | 81 if (source == null) { |
| 81 throw new AnalysisException('could not create a source for $sourcePath.' | 82 throw new AnalysisException('could not create a source for $sourcePath.' |
|
Jennifer Messerly
2016/07/18 19:22:01
do you mind fixing this one too?
throw new UsageE
stanm
2016/07/18 21:37:29
Done.
| |
| 82 ' The file name is in the wrong format or was not found.'); | 83 ' The file name is in the wrong format or was not found.'); |
| 83 } | 84 } |
| 84 | 85 |
| 86 if (!source.exists()) { | |
| 87 throw new UsageException('Given file "$sourcePath" does not exist.', | |
| 88 'You need to pass at least one existing .dart file as an argument.') ; | |
|
Jennifer Messerly
2016/07/18 19:22:01
long line
stanm
2016/07/18 21:37:29
Thanks, I noticed that, but the formatter seems to
| |
| 89 } | |
| 90 | |
| 85 // Ignore parts. They need to be handled in the context of their library. | 91 // Ignore parts. They need to be handled in the context of their library. |
| 86 if (context.computeKindOf(source) == SourceKind.PART) { | 92 if (context.computeKindOf(source) == SourceKind.PART) { |
| 87 explicitParts.add(source); | 93 explicitParts.add(source); |
| 88 continue; | 94 continue; |
| 89 } | 95 } |
| 90 | 96 |
| 91 var resolvedTree = context.resolveCompilationUnit2(source, source); | 97 var resolvedTree = context.resolveCompilationUnit2(source, source); |
| 92 trees.add(resolvedTree); | 98 trees.add(resolvedTree); |
| 93 errors.addAll(context.computeErrors(source)); | 99 errors.addAll(context.computeErrors(source)); |
| 94 | 100 |
| (...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 342 } | 348 } |
| 343 } | 349 } |
| 344 | 350 |
| 345 /// (Public for tests) the error code used when a part is missing. | 351 /// (Public for tests) the error code used when a part is missing. |
| 346 final missingPartErrorCode = const CompileTimeErrorCode( | 352 final missingPartErrorCode = const CompileTimeErrorCode( |
| 347 'MISSING_PART', 'The part was not supplied as an input to the compiler.'); | 353 'MISSING_PART', 'The part was not supplied as an input to the compiler.'); |
| 348 | 354 |
| 349 /// (Public for tests) the error code used when a part is unused. | 355 /// (Public for tests) the error code used when a part is unused. |
| 350 final unusedPartWarningCode = const StaticWarningCode( | 356 final unusedPartWarningCode = const StaticWarningCode( |
| 351 'UNUSED_PART', 'The part was not used by any libraries being compiled.'); | 357 'UNUSED_PART', 'The part was not used by any libraries being compiled.'); |
| OLD | NEW |