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); |
+ } |
+ } |
} |
} |
} |