Skip to content

Commit 009daa9

Browse files
authored
Library loading refactor, drop analysis error checking (#1845)
* Cleanup library creation pipeline * Library loading doesn't need to throw analysis errors, just drop that problematic feature * Crush findLibrary down some more * Disable test that verifies we stop on analysis errors * Performance changes * dartfmt * Review comments and lint
1 parent 13daf78 commit 009daa9

File tree

4 files changed

+111
-238
lines changed

4 files changed

+111
-238
lines changed

lib/dartdoc.dart

Lines changed: 0 additions & 89 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,6 @@ import 'dart:async';
1212
import 'dart:convert';
1313
import 'dart:io';
1414

15-
import 'package:analyzer/dart/analysis/results.dart';
16-
import 'package:analyzer/error/error.dart';
17-
import 'package:analyzer/src/error/codes.dart';
18-
import 'package:analyzer/src/generated/engine.dart';
19-
import 'package:analyzer/src/generated/source.dart';
2015
import 'package:dartdoc/src/dartdoc_options.dart';
2116
import 'package:dartdoc/src/generator.dart';
2217
import 'package:dartdoc/src/html/html_generator.dart';
@@ -81,54 +76,6 @@ class Dartdoc extends PackageBuilder {
8176

8277
Stream<String> get onCheckProgress => _onCheckProgress.stream;
8378

84-
@override
85-
Future<void> logAnalysisErrors(Set<Source> sources) async {
86-
List<AnalysisErrorInfo> errorInfos = [];
87-
// TODO(jcollins-g): figure out why sources can't contain includeExternals
88-
// or embedded SDK components without having spurious(?) analysis errors.
89-
// That seems wrong. dart-lang/dartdoc#1547
90-
for (Source source in sources) {
91-
ErrorsResult errorsResult = await driver.getErrors(source.fullName);
92-
AnalysisErrorInfo info =
93-
new AnalysisErrorInfoImpl(errorsResult.errors, errorsResult.lineInfo);
94-
List<_Error> errors = [info]
95-
.expand((AnalysisErrorInfo info) {
96-
return info.errors.map((error) => new _Error(
97-
error, info.lineInfo, config.topLevelPackageMeta.dir.path));
98-
})
99-
.where((_Error error) => error.isError)
100-
.toList()
101-
..sort();
102-
// TODO(jcollins-g): Why does the SDK have analysis errors? Annotations
103-
// seem correctly formed. dart-lang/dartdoc#1547
104-
if (errors.isNotEmpty && !source.uri.toString().startsWith('dart:')) {
105-
errorInfos.add(info);
106-
logWarning(
107-
'analysis errors from source: ${source.uri.toString()} (${source.toString()}');
108-
errors.forEach(logWarning);
109-
}
110-
}
111-
112-
List<_Error> errors = errorInfos
113-
.expand((AnalysisErrorInfo info) {
114-
return info.errors.map((error) => new _Error(
115-
error, info.lineInfo, config.topLevelPackageMeta.dir.path));
116-
})
117-
.where((_Error error) => error.isError)
118-
// TODO(jcollins-g): remove after conversion to analysis driver
119-
.where((_Error error) =>
120-
error.error.errorCode !=
121-
CompileTimeErrorCode.URI_HAS_NOT_BEEN_GENERATED)
122-
.toList()
123-
..sort();
124-
125-
if (errors.isNotEmpty) {
126-
int len = errors.length;
127-
throw new DartdocFailure(
128-
"encountered ${len} analysis error${len == 1 ? '' : 's'}");
129-
}
130-
}
131-
13279
PackageGraph packageGraph;
13380

13481
/// Generate Dartdoc documentation.
@@ -434,39 +381,3 @@ class DartdocResults {
434381

435382
DartdocResults(this.packageMeta, this.packageGraph, this.outDir);
436383
}
437-
438-
class _Error implements Comparable<_Error> {
439-
final AnalysisError error;
440-
final LineInfo lineInfo;
441-
final String projectPath;
442-
443-
_Error(this.error, this.lineInfo, this.projectPath);
444-
445-
String get description => '${error.message} at ${location}, line ${line}.';
446-
bool get isError => error.errorCode.errorSeverity == ErrorSeverity.ERROR;
447-
int get line => lineInfo.getLocation(error.offset).lineNumber;
448-
String get location {
449-
String path = error.source.fullName;
450-
if (path.startsWith(projectPath)) {
451-
path = path.substring(projectPath.length + 1);
452-
}
453-
return path;
454-
}
455-
456-
int get severity => error.errorCode.errorSeverity.ordinal;
457-
458-
String get severityName => error.errorCode.errorSeverity.displayName;
459-
460-
@override
461-
int compareTo(_Error other) {
462-
if (severity == other.severity) {
463-
int cmp = error.source.fullName.compareTo(other.error.source.fullName);
464-
return cmp == 0 ? line - other.line : cmp;
465-
} else {
466-
return other.severity - severity;
467-
}
468-
}
469-
470-
@override
471-
String toString() => '[${severityName}] ${description}';
472-
}

0 commit comments

Comments
 (0)