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

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

Issue 1117963002: add import file uri suggestions (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: merge Created 5 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 | pkg/analysis_server/test/operation/operation_queue_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/import_uri_contributor.dart
diff --git a/pkg/analysis_server/lib/src/services/completion/import_uri_contributor.dart b/pkg/analysis_server/lib/src/services/completion/import_uri_contributor.dart
index 891a36594e07b1db184d7894aa2566235d4caf80..6398b3f53577f3c9f111bef47707d420b1f21b31 100644
--- a/pkg/analysis_server/lib/src/services/completion/import_uri_contributor.dart
+++ b/pkg/analysis_server/lib/src/services/completion/import_uri_contributor.dart
@@ -12,6 +12,7 @@ import 'package:analyzer/file_system/file_system.dart';
import 'package:analyzer/src/generated/ast.dart';
import 'package:analyzer/src/generated/sdk.dart';
import 'package:analyzer/src/generated/source.dart';
+import 'package:path/path.dart';
import '../../protocol_server.dart'
show CompletionSuggestion, CompletionSuggestionKind;
@@ -73,7 +74,33 @@ class _ImportUriSuggestionBuilder extends SimpleAstVisitor {
}
void _addFileSuggestions(String partial) {
- // TODO(danrubel) implement
+ Source source = request.source;
+ String sourceFullName = source.fullName;
+ String sourceShortName = source.shortName;
+ String dirPath = partial.endsWith('/') ? partial : dirname(partial);
+ String prefix = dirPath == '.' ? '' : dirPath;
+ if (isRelative(dirPath)) {
+ String sourceDir = dirname(sourceFullName);
+ if (isAbsolute(sourceDir)) {
+ dirPath = join(sourceDir, dirPath);
+ } else {
+ return;
+ }
+ }
+ Resource dir = request.resourceProvider.getResource(dirPath);
+ if (dir is Folder) {
+ for (Resource child in dir.getChildren()) {
+ String completion;
+ if (child is Folder) {
+ completion = '$prefix${child.shortName}$separator';
+ } else {
+ completion = '$prefix${child.shortName}';
+ }
+ if (completion != sourceShortName && completion != sourceFullName) {
+ _addSuggestion(completion);
+ }
+ }
+ }
}
void _addFolderSuggestions(String partial, String prefix, Folder folder) {
« no previous file with comments | « no previous file | pkg/analysis_server/test/operation/operation_queue_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698