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

Unified Diff: pkg/analysis_server/lib/src/services/completion/dart/uri_contributor.dart

Issue 1509373005: do not suggest import uri reaching out of lib (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: merge Created 5 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
« no previous file with comments | « no previous file | pkg/analysis_server/test/services/completion/dart/uri_contributor_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analysis_server/lib/src/services/completion/dart/uri_contributor.dart
diff --git a/pkg/analysis_server/lib/src/services/completion/dart/uri_contributor.dart b/pkg/analysis_server/lib/src/services/completion/dart/uri_contributor.dart
index 13282c2fdb2eef21b13aeb648d1dd02fdafe0d06..7e849b148930d4f3aad760b920dfeb42e0ea6f71 100644
--- a/pkg/analysis_server/lib/src/services/completion/dart/uri_contributor.dart
+++ b/pkg/analysis_server/lib/src/services/completion/dart/uri_contributor.dart
@@ -116,10 +116,16 @@ class _UriSuggestionBuilder extends SimpleAstVisitor {
if (resContext.isRelative(dirPath)) {
String sourceDirPath = resContext.dirname(source.fullName);
if (resContext.isAbsolute(sourceDirPath)) {
- dirPath = resContext.join(sourceDirPath, dirPath);
+ dirPath = resContext.normalize(resContext.join(sourceDirPath, dirPath));
} else {
return;
}
+ // Do not suggest relative paths reaching outside the 'lib' directory.
+ bool srcInLib = resContext.split(sourceDirPath).contains('lib');
+ bool dstInLib = resContext.split(dirPath).contains('lib');
+ if (srcInLib && !dstInLib) {
+ return;
+ }
}
if (dirPath.endsWith('\\.')) {
dirPath = dirPath.substring(0, dirPath.length - 1);
« no previous file with comments | « no previous file | pkg/analysis_server/test/services/completion/dart/uri_contributor_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698