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

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

Issue 635043002: show only type names in is expression RHS (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: merge Created 6 years, 2 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/lib/src/services/completion/local_computer.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/imported_computer.dart
diff --git a/pkg/analysis_server/lib/src/services/completion/imported_computer.dart b/pkg/analysis_server/lib/src/services/completion/imported_computer.dart
index 3c0ffeaaef7049768491d13316317e759a5635e6..b159ea8053664ff5daadc86985a2a50588f9c117 100644
--- a/pkg/analysis_server/lib/src/services/completion/imported_computer.dart
+++ b/pkg/analysis_server/lib/src/services/completion/imported_computer.dart
@@ -52,6 +52,17 @@ class _ImportedVisitor extends GeneralizingAstVisitor<Future<bool>> {
}
@override
+ Future<bool> visitCascadeExpression(CascadeExpression node) {
+ // Make suggestions for the target, but not for the selector
+ // InvocationComputer makes selector suggestions
+ Expression target = node.target;
+ if (target != null && request.offset <= target.end) {
+ return _addImportedElementSuggestions();
+ }
+ return new Future.value(false);
+ }
+
+ @override
Future<bool> visitCombinator(Combinator node) {
return _addCombinatorSuggestions(node);
}
@@ -83,19 +94,13 @@ class _ImportedVisitor extends GeneralizingAstVisitor<Future<bool>> {
}
@override
- Future<bool> visitCascadeExpression(CascadeExpression node) {
- // Make suggestions for the target, but not for the selector
- // InvocationComputer makes selector suggestions
- Expression target = node.target;
- if (target != null && request.offset <= target.end) {
- return _addImportedElementSuggestions();
- }
- return new Future.value(false);
+ Future<bool> visitSimpleIdentifier(SimpleIdentifier node) {
+ return node.parent.accept(this);
}
@override
- Future<bool> visitSimpleIdentifier(SimpleIdentifier node) {
- return node.parent.accept(this);
+ Future<bool> visitTypeName(TypeName node) {
+ return _addImportedElementSuggestions(typesOnly: true);
}
Future _addCombinatorSuggestions(Combinator node) {
@@ -143,7 +148,7 @@ class _ImportedVisitor extends GeneralizingAstVisitor<Future<bool>> {
request.suggestions.add(suggestion);
}
- Future<bool> _addImportedElementSuggestions() {
+ Future<bool> _addImportedElementSuggestions({bool typesOnly: false}) {
// Exclude elements from local library
// because they are provided by LocalComputer
@@ -159,7 +164,9 @@ class _ImportedVisitor extends GeneralizingAstVisitor<Future<bool>> {
Namespace importNamespace =
new NamespaceBuilder().createImportNamespaceForDirective(importElem);
importNamespace.definedNames.forEach((_, Element element) {
- _addElementSuggestion(element, CompletionRelevance.DEFAULT);
+ if (!typesOnly || element is ClassElement) {
+ _addElementSuggestion(element, CompletionRelevance.DEFAULT);
+ }
});
} else {
// Exclude elements from prefixed imports
@@ -177,7 +184,9 @@ class _ImportedVisitor extends GeneralizingAstVisitor<Future<bool>> {
Namespace coreNamespace =
new NamespaceBuilder().createPublicNamespaceForLibrary(coreLib);
coreNamespace.definedNames.forEach((_, Element element) {
- _addElementSuggestion(element, CompletionRelevance.DEFAULT);
+ if (!typesOnly || element is ClassElement) {
+ _addElementSuggestion(element, CompletionRelevance.DEFAULT);
+ }
});
// Add non-imported elements as low relevance
@@ -193,7 +202,9 @@ class _ImportedVisitor extends GeneralizingAstVisitor<Future<bool>> {
if (element.isPublic &&
!excludedLibs.contains(element.library) &&
!completionSet.contains(element.displayName)) {
- _addElementSuggestion(element, CompletionRelevance.LOW);
+ if (!typesOnly || element is ClassElement) {
+ _addElementSuggestion(element, CompletionRelevance.LOW);
+ }
}
}
});
« no previous file with comments | « no previous file | pkg/analysis_server/lib/src/services/completion/local_computer.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698