Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(39)

Unified Diff: pkg/analyzer_cli/lib/src/analyzer_impl.dart

Issue 1806263004: add --x-package-warnings-prefix option to dartanalyzer (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: oops, check in all the test files Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | pkg/analyzer_cli/lib/src/driver.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analyzer_cli/lib/src/analyzer_impl.dart
diff --git a/pkg/analyzer_cli/lib/src/analyzer_impl.dart b/pkg/analyzer_cli/lib/src/analyzer_impl.dart
index 71115e0c255774684c37d17dd1d5e0de71f2d6dd..95bed116bb1268ec3be74e75f2464ba1e772ca3a 100644
--- a/pkg/analyzer_cli/lib/src/analyzer_impl.dart
+++ b/pkg/analyzer_cli/lib/src/analyzer_impl.dart
@@ -80,8 +80,8 @@ class AnalyzerImpl {
return status;
}
- void addCompilationUnitSource(CompilationUnitElement unit,
- Set<LibraryElement> libraries, Set<CompilationUnitElement> units) {
+ void addCompilationUnitSource(
+ CompilationUnitElement unit, Set<CompilationUnitElement> units) {
if (unit == null || units.contains(unit)) {
return;
}
@@ -95,21 +95,13 @@ class AnalyzerImpl {
return;
}
// Maybe skip library.
- {
- UriKind uriKind = library.source.uriKind;
- // Optionally skip package: libraries.
- if (!options.showPackageWarnings && _isOtherPackage(library.source.uri)) {
- return;
- }
- // Optionally skip SDK libraries.
- if (!options.showSdkWarnings && uriKind == UriKind.DART_URI) {
- return;
- }
+ if (!_isAnalyzedLibrary(library)) {
+ return;
}
// Add compilation units.
- addCompilationUnitSource(library.definingCompilationUnit, libraries, units);
+ addCompilationUnitSource(library.definingCompilationUnit, units);
for (CompilationUnitElement child in library.parts) {
- addCompilationUnitSource(child, libraries, units);
+ addCompilationUnitSource(child, units);
}
// Add referenced libraries.
for (LibraryElement child in library.importedLibraries) {
@@ -185,18 +177,34 @@ class AnalyzerImpl {
return status;
}
- /// Determine whether the given URI refers to a package other than the package
- /// being analyzed.
- bool _isOtherPackage(Uri uri) {
- if (uri.scheme != 'package') {
+ /// Returns true if we want to report diagnostics for this library.
+ bool _isAnalyzedLibrary(LibraryElement library) {
+ switch (library.source.uriKind) {
+ case UriKind.DART_URI:
+ return options.showSdkWarnings;
+ case UriKind.PACKAGE_URI:
+ return _isAnalyzedPackage(library.source.uri);
+ default:
+ return true;
+ }
+ }
+
+ /// Determine whether the given URI refers to a package being analyzed.
+ bool _isAnalyzedPackage(Uri uri) {
+ if (uri.scheme != 'package' || uri.pathSegments.isEmpty) {
return false;
}
- if (_selfPackageName != null &&
- uri.pathSegments.length > 0 &&
- uri.pathSegments[0] == _selfPackageName) {
+
+ String packageName = uri.pathSegments.first;
+ if (packageName == _selfPackageName) {
+ return true;
+ } else if (!options.showPackageWarnings) {
return false;
+ } else if (options.showPackageWarningsPrefix == null) {
+ return true;
+ } else {
+ return packageName.startsWith(options.showPackageWarningsPrefix);
}
- return true;
}
_printColdPerf() {
« no previous file with comments | « no previous file | pkg/analyzer_cli/lib/src/driver.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698