fix flutter analyze --dartdocs (#10182)

This commit is contained in:
Ian Hickson 2017-05-19 08:46:34 -07:00 committed by GitHub
parent cd6e3b1ac2
commit 77d67c9d30
6 changed files with 11 additions and 8 deletions

View file

@ -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

View file

@ -148,7 +148,6 @@ class BufferLogger extends Logger {
_error.writeln(message);
}
@override
void printStatus(
String message,

View file

@ -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);

View file

@ -20,10 +20,10 @@ import '../globals.dart';
import 'analyze_base.dart';
class AnalyzeContinuously extends AnalyzeBase {
final List<Directory> repoAnalysisEntryPoints;
AnalyzeContinuously(ArgResults argResults, this.repoAnalysisEntryPoints) : super(argResults);
final List<Directory> repoAnalysisEntryPoints;
String analysisTarget;
bool firstAnalysis = true;
Set<String> analyzedPaths = new Set<String>();
@ -36,6 +36,9 @@ class AnalyzeContinuously extends AnalyzeBase {
Future<Null> analyze() async {
List<String> 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';

View file

@ -36,7 +36,6 @@ class AnalyzeOnce extends AnalyzeBase {
final Stopwatch stopwatch = new Stopwatch()..start();
final Set<Directory> pubSpecDirectories = new HashSet<Directory>();
final List<File> dartFiles = <File>[];
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<String> arguments = <String>[];
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);

View file

@ -150,6 +150,7 @@ class FlutterCommandRunner extends CommandRunner<Null> {
@override
Future<Null> run(Iterable<String> 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 = <String>['build', '-h'];