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

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

Issue 2342473002: improve import URI completions at EOF (Closed)
Patch Set: update tests Created 4 years, 3 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/analysis_server/test/completion_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 01176aaef2ce148ac05fdda984e0353d8f7575db..7b9935384685799efecf07717207beabd6271ed0 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
@@ -55,11 +55,39 @@ class _UriSuggestionBuilder extends SimpleAstVisitor {
StringLiteral uri = node.uri;
if (uri is SimpleStringLiteral) {
int offset = request.offset;
- if (uri.offset < offset &&
- (offset < uri.end || offset == uri.offset + 1)) {
- // Handle degenerate case where import or export is only line in file
- // and there is no semicolon
- visitSimpleStringLiteral(uri);
+ int start = uri.offset;
+ int end = uri.end;
+ if (offset > start) {
+ if (offset < end) {
+ // Quoted non-empty string
+ visitSimpleStringLiteral(uri);
+ } else if (offset == end) {
+ if (end == start + 1) {
+ // Quoted empty string
+ visitSimpleStringLiteral(uri);
+ } else {
+ String data = request.source.contents.data;
+ if (end == data.length) {
+ String ch = data[end - 1];
+ if (ch != '"' && ch != "'") {
+ // Insertion point at end of file
+ // and missing closing quote on non-empty string
+ visitSimpleStringLiteral(uri);
+ }
+ }
+ }
+ }
+ }
+ else if (offset == start && offset == end) {
+ String data = request.source.contents.data;
+ if (end == data.length) {
+ String ch = data[end - 1];
+ if (ch == '"' || ch == "'") {
+ // Insertion point at end of file
+ // and missing closing quote on empty string
+ visitSimpleStringLiteral(uri);
+ }
+ }
}
}
}
« no previous file with comments | « no previous file | pkg/analysis_server/test/completion_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698