@@ -31,15 +31,20 @@ class AnalyzeContinuously extends AnalyzeBase {
3131 Stopwatch analysisTimer;
3232 int lastErrorCount = 0 ;
3333 Status analysisStatus;
34+ bool flutterRepo;
35+ bool showDartDocIssuesIndividually;
3436
3537 @override
3638 Future <Null > analyze () async {
3739 List <String > directories;
3840
39- if ( argResults['dartdocs' ])
40- throwToolExit ( 'The -- dartdocs option is currently not supported when using --watch.' ) ;
41+ flutterRepo = argResults['flutter-repo' ] || inRepo ( null );
42+ showDartDocIssuesIndividually = argResults[ ' dartdocs' ] ;
4143
42- if (argResults['flutter-repo' ]) {
44+ if (showDartDocIssuesIndividually && ! flutterRepo)
45+ throwToolExit ('The --dartdocs option is only supported when using --flutter-repo.' );
46+
47+ if (flutterRepo) {
4348 final PackageDependencyTracker dependencies = new PackageDependencyTracker ();
4449 dependencies.checkForConflictingDependencies (repoPackages, dependencies);
4550 directories = repoPackages.map ((Directory dir) => dir.path).toList ();
@@ -52,7 +57,7 @@ class AnalyzeContinuously extends AnalyzeBase {
5257 analysisTarget = fs.currentDirectory.path;
5358 }
5459
55- final AnalysisServer server = new AnalysisServer (dartSdkPath, directories);
60+ final AnalysisServer server = new AnalysisServer (dartSdkPath, directories, flutterRepo : flutterRepo );
5661 server.onAnalyzing.listen ((bool isAnalyzing) => _handleAnalysisStatus (server, isAnalyzing));
5762 server.onErrors.listen (_handleAnalysisErrors);
5863
@@ -82,29 +87,52 @@ class AnalyzeContinuously extends AnalyzeBase {
8287 logger.printStatus (terminal.clearScreen (), newline: false );
8388
8489 // Remove errors for deleted files, sort, and print errors.
85- final List <AnalysisError > errors = < AnalysisError > [];
90+ final List <AnalysisError > allErrors = < AnalysisError > [];
8691 for (String path in analysisErrors.keys.toList ()) {
8792 if (fs.isFileSync (path)) {
88- errors .addAll (analysisErrors[path]);
93+ allErrors .addAll (analysisErrors[path]);
8994 } else {
9095 analysisErrors.remove (path);
9196 }
9297 }
9398
94- errors.sort ();
99+ // Summarize dartdoc issues rather than displaying each individually
100+ int membersMissingDocumentation = 0 ;
101+ List <AnalysisError > detailErrors;
102+ if (flutterRepo && ! showDartDocIssuesIndividually) {
103+ detailErrors = allErrors.where ((AnalysisError error) {
104+ if (error.code == 'public_member_api_docs' ) {
105+ // https://github.com/dart-lang/linter/issues/208
106+ if (isFlutterLibrary (error.file))
107+ membersMissingDocumentation += 1 ;
108+ return true ;
109+ }
110+ return false ;
111+ }).toList ();
112+ } else {
113+ detailErrors = allErrors;
114+ }
115+
116+ detailErrors.sort ();
95117
96- for (AnalysisError error in errors ) {
118+ for (AnalysisError error in detailErrors ) {
97119 printStatus (error.toString ());
98120 if (error.code != null )
99121 printTrace ('error code: ${error .code }' );
100122 }
101123
102- dumpErrors (errors.map <String >((AnalysisError error) => error.toLegacyString ()));
124+ dumpErrors (detailErrors.map <String >((AnalysisError error) => error.toLegacyString ()));
125+
126+ if (membersMissingDocumentation != 0 ) {
127+ printStatus (membersMissingDocumentation == 1
128+ ? '1 public member lacks documentation'
129+ : '$membersMissingDocumentation public members lack documentation' );
130+ }
103131
104132 // Print an analysis summary.
105133 String errorsMessage;
106134
107- final int issueCount = errors .length;
135+ final int issueCount = detailErrors .length;
108136 final int issueDiff = issueCount - lastErrorCount;
109137 lastErrorCount = issueCount;
110138
@@ -150,10 +178,11 @@ class AnalyzeContinuously extends AnalyzeBase {
150178}
151179
152180class AnalysisServer {
153- AnalysisServer (this .sdk, this .directories);
181+ AnalysisServer (this .sdk, this .directories, { this .flutterRepo : false } );
154182
155183 final String sdk;
156184 final List <String > directories;
185+ final bool flutterRepo;
157186
158187 Process _process;
159188 final StreamController <bool > _analyzingController = new StreamController <bool >.broadcast ();
@@ -169,6 +198,13 @@ class AnalysisServer {
169198 '--sdk' ,
170199 sdk,
171200 ];
201+ // Let the analysis server know that the flutter repository is being analyzed
202+ // so that it can enable the public_member_api_docs lint even though
203+ // the analysis_options file does not have that lint enabled.
204+ // It is not enabled in the analysis_option file
205+ // because doing so causes too much noise in the IDE.
206+ if (flutterRepo)
207+ command.add ('--flutter-repo' );
172208
173209 printTrace ('dart ${command .skip (1 ).join (' ' )}' );
174210 _process = await processManager.start (command);
0 commit comments