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

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

Issue 2862793002: Fix a completion exception during import suggestions. (Closed)
Patch Set: Created 3 years, 7 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 | « pkg/analysis_server/analysis_server.iml ('k') | pkg/analyzer/analyzer.iml » ('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 b2b624df2ae4e1064e51b0ddcc5c039fefd38081..d299a8ff560b803402bd5da97da7020f26924c3c 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
@@ -7,6 +7,8 @@ library services.completion.contributor.dart.importuri;
import 'dart:async';
import 'dart:core';
+import 'package:analysis_server/src/protocol_server.dart'
+ show CompletionSuggestion, CompletionSuggestionKind;
import 'package:analysis_server/src/provisional/completion/dart/completion_dart.dart';
import 'package:analyzer/dart/ast/ast.dart';
import 'package:analyzer/dart/ast/visitor.dart';
@@ -16,9 +18,6 @@ import 'package:analyzer/src/generated/source.dart';
import 'package:path/path.dart' show posix;
import 'package:path/src/context.dart';
-import '../../../protocol_server.dart'
- show CompletionSuggestion, CompletionSuggestionKind;
-
/**
* A contributor for calculating uri suggestions
* for import and part directives.
@@ -161,32 +160,41 @@ class _UriSuggestionBuilder extends SimpleAstVisitor {
Resource dir = resProvider.getResource(dirPath);
if (dir is Folder) {
- for (Resource child in dir.getChildren()) {
- String completion;
- if (child is Folder) {
- completion = '$uriPrefix${child.shortName}/';
- } else {
- completion = '$uriPrefix${child.shortName}';
- }
- if (completion != source.shortName) {
- _addSuggestion(completion);
+ try {
+ for (Resource child in dir.getChildren()) {
+ String completion;
+ if (child is Folder) {
+ completion = '$uriPrefix${child.shortName}/';
+ } else {
+ completion = '$uriPrefix${child.shortName}';
+ }
+ if (completion != source.shortName) {
+ _addSuggestion(completion);
+ }
}
+ } on FileSystemException {
+ // Guard against I/O exceptions.
}
}
}
void _addPackageFolderSuggestions(
String partial, String prefix, Folder folder) {
- for (Resource child in folder.getChildren()) {
- if (child is Folder) {
- String childPrefix = '$prefix${child.shortName}/';
- _addSuggestion(childPrefix);
- if (partial.startsWith(childPrefix)) {
- _addPackageFolderSuggestions(partial, childPrefix, child);
+ try {
+ for (Resource child in folder.getChildren()) {
+ if (child is Folder) {
+ String childPrefix = '$prefix${child.shortName}/';
+ _addSuggestion(childPrefix);
+ if (partial.startsWith(childPrefix)) {
+ _addPackageFolderSuggestions(partial, childPrefix, child);
+ }
+ } else {
+ _addSuggestion('$prefix${child.shortName}');
}
- } else {
- _addSuggestion('$prefix${child.shortName}');
}
+ } on FileSystemException {
+ // Guard against I/O exceptions.
+ return;
}
}
« no previous file with comments | « pkg/analysis_server/analysis_server.iml ('k') | pkg/analyzer/analyzer.iml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698