@@ -31,15 +31,20 @@ class AnalyzeContinuously extends AnalyzeBase {
31
31
Stopwatch analysisTimer;
32
32
int lastErrorCount = 0 ;
33
33
Status analysisStatus;
34
+ bool flutterRepo;
35
+ bool showDartDocIssuesIndividually;
34
36
35
37
@override
36
38
Future <Null > analyze () async {
37
39
List <String > directories;
38
40
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' ] ;
41
43
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) {
43
48
final PackageDependencyTracker dependencies = new PackageDependencyTracker ();
44
49
dependencies.checkForConflictingDependencies (repoPackages, dependencies);
45
50
directories = repoPackages.map ((Directory dir) => dir.path).toList ();
@@ -52,7 +57,7 @@ class AnalyzeContinuously extends AnalyzeBase {
52
57
analysisTarget = fs.currentDirectory.path;
53
58
}
54
59
55
- final AnalysisServer server = new AnalysisServer (dartSdkPath, directories);
60
+ final AnalysisServer server = new AnalysisServer (dartSdkPath, directories, flutterRepo : flutterRepo );
56
61
server.onAnalyzing.listen ((bool isAnalyzing) => _handleAnalysisStatus (server, isAnalyzing));
57
62
server.onErrors.listen (_handleAnalysisErrors);
58
63
@@ -82,29 +87,52 @@ class AnalyzeContinuously extends AnalyzeBase {
82
87
logger.printStatus (terminal.clearScreen (), newline: false );
83
88
84
89
// Remove errors for deleted files, sort, and print errors.
85
- final List <AnalysisError > errors = < AnalysisError > [];
90
+ final List <AnalysisError > allErrors = < AnalysisError > [];
86
91
for (String path in analysisErrors.keys.toList ()) {
87
92
if (fs.isFileSync (path)) {
88
- errors .addAll (analysisErrors[path]);
93
+ allErrors .addAll (analysisErrors[path]);
89
94
} else {
90
95
analysisErrors.remove (path);
91
96
}
92
97
}
93
98
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 ();
95
117
96
- for (AnalysisError error in errors ) {
118
+ for (AnalysisError error in detailErrors ) {
97
119
printStatus (error.toString ());
98
120
if (error.code != null )
99
121
printTrace ('error code: ${error .code }' );
100
122
}
101
123
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
+ }
103
131
104
132
// Print an analysis summary.
105
133
String errorsMessage;
106
134
107
- final int issueCount = errors .length;
135
+ final int issueCount = detailErrors .length;
108
136
final int issueDiff = issueCount - lastErrorCount;
109
137
lastErrorCount = issueCount;
110
138
@@ -150,10 +178,11 @@ class AnalyzeContinuously extends AnalyzeBase {
150
178
}
151
179
152
180
class AnalysisServer {
153
- AnalysisServer (this .sdk, this .directories);
181
+ AnalysisServer (this .sdk, this .directories, { this .flutterRepo : false } );
154
182
155
183
final String sdk;
156
184
final List <String > directories;
185
+ final bool flutterRepo;
157
186
158
187
Process _process;
159
188
final StreamController <bool > _analyzingController = new StreamController <bool >.broadcast ();
@@ -169,6 +198,13 @@ class AnalysisServer {
169
198
'--sdk' ,
170
199
sdk,
171
200
];
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' );
172
208
173
209
printTrace ('dart ${command .skip (1 ).join (' ' )}' );
174
210
_process = await processManager.start (command);
0 commit comments