From 77d67c9d306a81012a527f51e6db0538aa9de83f Mon Sep 17 00:00:00 2001 From: Ian Hickson Date: Fri, 19 May 2017 08:46:34 -0700 Subject: [PATCH] fix flutter analyze --dartdocs (#10182) --- .analysis_options_repo | 2 +- packages/flutter_tools/lib/src/base/logger.dart | 1 - packages/flutter_tools/lib/src/commands/analyze.dart | 2 +- .../lib/src/commands/analyze_continuously.dart | 7 +++++-- packages/flutter_tools/lib/src/commands/analyze_once.dart | 6 +++--- .../lib/src/runner/flutter_command_runner.dart | 1 + 6 files changed, 11 insertions(+), 8 deletions(-) diff --git a/.analysis_options_repo b/.analysis_options_repo index 3fbde2cf40..52e4ffae02 100644 --- a/.analysis_options_repo +++ b/.analysis_options_repo @@ -116,7 +116,7 @@ linter: # - prefer_interpolation_to_compose_strings # not yet tested - prefer_is_empty - prefer_is_not_empty - # - public_member_api_docs # this is the only difference from .analysis_options_repo + - public_member_api_docs # this is the only difference from .analysis_options_repo # - recursive_getters # https://github.com/dart-lang/linter/issues/452 - slash_for_doc_comments - sort_constructors_first diff --git a/packages/flutter_tools/lib/src/base/logger.dart b/packages/flutter_tools/lib/src/base/logger.dart index 08c9228bdf..f5f297cd15 100644 --- a/packages/flutter_tools/lib/src/base/logger.dart +++ b/packages/flutter_tools/lib/src/base/logger.dart @@ -148,7 +148,6 @@ class BufferLogger extends Logger { _error.writeln(message); } - @override void printStatus( String message, diff --git a/packages/flutter_tools/lib/src/commands/analyze.dart b/packages/flutter_tools/lib/src/commands/analyze.dart index 5459eab121..afa01c951e 100644 --- a/packages/flutter_tools/lib/src/commands/analyze.dart +++ b/packages/flutter_tools/lib/src/commands/analyze.dart @@ -17,7 +17,7 @@ class AnalyzeCommand extends FlutterCommand { AnalyzeCommand({ bool verboseHelp: false, this.workingDirectory }) { argParser.addFlag('flutter-repo', help: 'Include all the examples and tests from the Flutter repository.', defaultsTo: false); 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('dartdocs', help: 'List every public member that is lacking documentation (only works with --flutter-repo and without --watch).', defaultsTo: false, hide: !verboseHelp); 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); diff --git a/packages/flutter_tools/lib/src/commands/analyze_continuously.dart b/packages/flutter_tools/lib/src/commands/analyze_continuously.dart index f94c9d7d6c..8a170bf5d5 100644 --- a/packages/flutter_tools/lib/src/commands/analyze_continuously.dart +++ b/packages/flutter_tools/lib/src/commands/analyze_continuously.dart @@ -20,10 +20,10 @@ import '../globals.dart'; import 'analyze_base.dart'; class AnalyzeContinuously extends AnalyzeBase { - final List repoAnalysisEntryPoints; - AnalyzeContinuously(ArgResults argResults, this.repoAnalysisEntryPoints) : super(argResults); + final List repoAnalysisEntryPoints; + String analysisTarget; bool firstAnalysis = true; Set analyzedPaths = new Set(); @@ -36,6 +36,9 @@ class AnalyzeContinuously extends AnalyzeBase { Future analyze() async { List directories; + if (argResults['dartdocs']) + throwToolExit('The --dartdocs option is currently not supported when using --watch.'); + if (argResults['flutter-repo']) { directories = repoAnalysisEntryPoints.map((Directory dir) => dir.path).toList(); analysisTarget = 'Flutter repository'; diff --git a/packages/flutter_tools/lib/src/commands/analyze_once.dart b/packages/flutter_tools/lib/src/commands/analyze_once.dart index c413a70c2d..fe514479f1 100644 --- a/packages/flutter_tools/lib/src/commands/analyze_once.dart +++ b/packages/flutter_tools/lib/src/commands/analyze_once.dart @@ -36,7 +36,6 @@ class AnalyzeOnce extends AnalyzeBase { final Stopwatch stopwatch = new Stopwatch()..start(); final Set pubSpecDirectories = new HashSet(); final List dartFiles = []; - for (String file in argResults.rest.toList()) { file = fs.path.normalize(fs.path.absolute(file)); final String root = fs.path.rootPrefix(file); @@ -58,6 +57,9 @@ class AnalyzeOnce extends AnalyzeBase { // currently supports (e.g. missing member dartdoc summary). // TODO(danrubel): enhance dartanalyzer to provide this type of summary if (!flutterRepo) { + if (argResults['dartdocs']) + throwToolExit('The --dartdocs option is currently only supported with --flutter-repo.'); + final List arguments = []; arguments.addAll(dartFiles.map((FileSystemEntity f) => f.path)); @@ -124,8 +126,6 @@ class AnalyzeOnce extends AnalyzeBase { return; } - //TODO (pq): revisit package and directory defaults - for (Directory dir in repoPackages) { _collectDartFiles(dir, dartFiles); pubSpecDirectories.add(dir); diff --git a/packages/flutter_tools/lib/src/runner/flutter_command_runner.dart b/packages/flutter_tools/lib/src/runner/flutter_command_runner.dart index 9b98340dc0..605451f736 100644 --- a/packages/flutter_tools/lib/src/runner/flutter_command_runner.dart +++ b/packages/flutter_tools/lib/src/runner/flutter_command_runner.dart @@ -150,6 +150,7 @@ class FlutterCommandRunner extends CommandRunner { @override Future run(Iterable args) { // Have an invocation of 'build' print out it's sub-commands. + // TODO(ianh): Move this to the Build command itself somehow. if (args.length == 1 && args.first == 'build') args = ['build', '-h'];