argParser.addFlag('flutter-repo',help:'Include all the examples and tests from the Flutter repository.',defaultsTo:false);
argParser.addFlag('current-directory',help:'Include all the Dart files in the current directory, if any.',defaultsTo:true);
argParser.addFlag('current-package',help:'Include the lib/main.dart file from the current directory, if any.',defaultsTo:true);
argParser.addFlag('dartdocs',help:'List every public member that is lacking documentation (only examines files in the Flutter repository).',defaultsTo:false);
argParser.addFlag('watch',help:'Run analysis continuously, watching the filesystem for changes.',negatable:false);
argParser.addOption('write',valueHelp:'file',help:'Also output the results to a file. This is useful with --watch if you want a file to always contain the latest results.');
argParser.addOption('dart-sdk',valueHelp:'path-to-sdk',help:'The path to the Dart SDK.',hide:!verboseHelp);
// Hidden option to enable a benchmarking mode.
argParser.addFlag('benchmark',negatable:false,hide:!verboseHelp,help:'Also output the analysis time');
usesPubOption();
// Not used by analyze --watch
argParser.addFlag('congratulate',help:'Show output even when there are no errors, warnings, hints, or lints.',defaultsTo:true);
argParser.addFlag('preamble',help:'Display the number of files that will be analyzed.',defaultsTo:true);
}
...
...
@@ -31,318 +40,24 @@ class AnalyzeCommand extends AnalysisCommand {
Stringgetdescription=>'Analyze the project\'s Dart code.';
printError('Make sure you have run "pub upgrade" in all the directories mentioned above.');
if(dependencies.hasConflictsAffectingFlutterRepo)
printError('For packages in the flutter repository, try using "flutter update-packages --upgrade" to do all of them at once.');
printError('If this does not help, to track down the conflict you can use "pub deps --style=list" and "pub upgrade --verbosity=solver" in the affected directories.');
argParser.addFlag('flutter-repo',help:'Include all the examples and tests from the Flutter repository.',defaultsTo:false);
argParser.addFlag('current-directory',help:'Include all the Dart files in the current directory, if any.',defaultsTo:true);
argParser.addFlag('current-package',help:'Include the lib/main.dart file from the current directory, if any.',defaultsTo:true);
argParser.addFlag('dartdocs',help:'List every public member that is lacking documentation (only examines files in the Flutter repository).',defaultsTo:false);
argParser.addOption('write',valueHelp:'file',help:'Also output the results to a file.');
argParser.addOption('dart-sdk',valueHelp:'path-to-sdk',help:'The path to the Dart SDK.',hide:!verboseHelp);
// Hidden option to enable a benchmarking mode.
argParser.addFlag('benchmark',negatable:false,hide:!verboseHelp,help:'Also output the analysis time');
usesPubOption();
}
@override
boolgetshouldRunPub{
// If they're not analyzing the current project.
if(!argResults['current-package'])
returnfalse;
/// Common behavior for `flutter analyze` and `flutter analyze --watch`
abstractclassAnalyzeBase{
/// The parsed argument results for execution.
finalArgResultsargResults;
// Or we're not in a project directory.
if(!newFile('pubspec.yaml').existsSync())
returnfalse;
AnalyzeBase(this.argResults);
returnsuper.shouldRunPub;
}
/// Called by [AnalyzeCommand] to start the analysis process.
Future<int>analyze();
voiddumpErrors(Iterable<String>errors){
if(argResults['write']!=null){
...
...
@@ -66,3 +51,18 @@ abstract class AnalysisCommand extends FlutterCommand {
boolgetisBenchmarking=>argResults['benchmark'];
}
/// Return `true` if [fileList] contains a path that resides inside the Flutter repository.
/// If [fileList] is empty, then return `true` if the current directory resides inside the Flutter repository.
printError('Make sure you have run "pub upgrade" in all the directories mentioned above.');
if(dependencies.hasConflictsAffectingFlutterRepo)
printError('For packages in the flutter repository, try using "flutter update-packages --upgrade" to do all of them at once.');
printError('If this does not help, to track down the conflict you can use "pub deps --style=list" and "pub upgrade --verbosity=solver" in the affected directories.');