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

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

Issue 1888583002: Disable computing errors for .pub-cache sources. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 8 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 | no next file » | 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 7314a20729a2ae4001e7021484d81af35b9bfc31..b3e9398204828aed0b8450529f2c6499f8691f43 100644
--- a/pkg/analyzer_cli/lib/src/analyzer_impl.dart
+++ b/pkg/analyzer_cli/lib/src/analyzer_impl.dart
@@ -20,6 +20,7 @@ import 'package:analyzer/src/generated/utilities_general.dart';
import 'package:analyzer_cli/src/driver.dart';
import 'package:analyzer_cli/src/error_formatter.dart';
import 'package:analyzer_cli/src/options.dart';
+import 'package:path/path.dart' as pathos;
/// The maximum number of sources for which AST structures should be kept in the cache.
const int _maxCacheSize = 512;
@@ -179,11 +180,15 @@ class AnalyzerImpl {
/// Returns true if we want to report diagnostics for this library.
bool _isAnalyzedLibrary(LibraryElement library) {
- switch (library.source.uriKind) {
+ Source source = library.source;
+ switch (source.uriKind) {
case UriKind.DART_URI:
return options.showSdkWarnings;
case UriKind.PACKAGE_URI:
- return _isAnalyzedPackage(library.source.uri);
+ if (_isPathInPubCache(source.fullName)) {
+ return false;
+ }
+ return _isAnalyzedPackage(source.uri);
default:
return true;
}
@@ -194,7 +199,6 @@ class AnalyzerImpl {
if (uri.scheme != 'package' || uri.pathSegments.isEmpty) {
return false;
}
-
String packageName = uri.pathSegments.first;
if (packageName == _selfPackageName) {
return true;
@@ -328,6 +332,20 @@ class AnalyzerImpl {
return new ProcessedSeverity(severity, isOverridden);
}
+
+ /// Return `true` if the given [path] is in the Pub cache.
+ static bool _isPathInPubCache(String path) {
+ List<String> parts = pathos.split(path);
+ if (parts.contains('.pub-cache')) {
+ return true;
+ }
+ for (int i = 0; i < parts.length - 2; i++) {
+ if (parts[i] == 'Pub' && parts[i + 1] == 'Cache') {
+ return true;
+ }
+ }
+ return false;
+ }
}
/// This [Logger] prints out information comments to [outSink] and error messages
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698