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

Unified Diff: pkg/analysis_server/lib/src/services/correction/fix_internal.dart

Issue 2572013002: Fix for detecting lib/src. Sort fixes by relevance. (Closed)
Patch Set: Created 4 years 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
Index: pkg/analysis_server/lib/src/services/correction/fix_internal.dart
diff --git a/pkg/analysis_server/lib/src/services/correction/fix_internal.dart b/pkg/analysis_server/lib/src/services/correction/fix_internal.dart
index 16ac99c5af24531ecd57a5733061fcc8197e176d..52fe2130b214f9c8a3b17accfd5ff0301c77fd64 100644
--- a/pkg/analysis_server/lib/src/services/correction/fix_internal.dart
+++ b/pkg/analysis_server/lib/src/services/correction/fix_internal.dart
@@ -1580,9 +1580,7 @@ class FixProcessor {
}
// Compute the fix kind.
FixKind fixKind;
- if (resourceProvider.pathContext
- .split(librarySource.fullName)
- .contains('src')) {
+ if (_isLibSrcPath(librarySource.fullName)) {
// Bad: non-API.
fixKind = DartFixKind.IMPORT_LIBRARY_PROJECT3;
} else if (declaration.isExported) {
@@ -2809,6 +2807,16 @@ class FixProcessor {
return node is SimpleIdentifier && node.name == 'await';
}
+ bool _isLibSrcPath(String path) {
+ List<String> parts = resourceProvider.pathContext.split(path);
+ for (int i = 0; i < parts.length - 2; i++) {
+ if (parts[i] == 'lib' && parts[i + 1] == 'src') {
+ return true;
+ }
+ }
+ return false;
+ }
+
/**
* Removes any [ParenthesizedExpression] enclosing [expr].
*
« no previous file with comments | « pkg/analysis_server/lib/src/edit/edit_domain.dart ('k') | pkg/analysis_server/test/services/correction/fix_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698