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

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

Issue 1872073002: Code completion improvement in the DAS- only suggest completions on the RHS of an as-expression tha… (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: rebase with bleeding_edge Created 4 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/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/optype.dart
diff --git a/pkg/analysis_server/lib/src/services/completion/dart/optype.dart b/pkg/analysis_server/lib/src/services/completion/dart/optype.dart
index 274609926f9f239edc898acd9946c09bf3805bfb..d5f206c75454081d628fce18a86115759bd56dd9 100644
--- a/pkg/analysis_server/lib/src/services/completion/dart/optype.dart
+++ b/pkg/analysis_server/lib/src/services/completion/dart/optype.dart
@@ -181,10 +181,11 @@ class _OpTypeAstVisitor extends GeneralizingAstVisitor {
void visitAsExpression(AsExpression node) {
if (identical(entity, node.type)) {
optype.includeTypeNameSuggestions = true;
- // TODO (danrubel) Possible future improvement:
- // on the RHS of an "is" or "as" expression, don't suggest types that are
- // guaranteed to pass or guaranteed to fail the cast.
- // See dartbug.com/18860
+ optype.typeNameSuggestionsFilter = (DartType dartType) {
+ DartType staticType = node.expression.staticType;
+ return staticType.isDynamic ||
+ (dartType.isSubtypeOf(staticType) && dartType != staticType);
+ };
}
}
@@ -503,9 +504,9 @@ class _OpTypeAstVisitor extends GeneralizingAstVisitor {
if (identical(entity, node.type)) {
optype.includeTypeNameSuggestions = true;
optype.typeNameSuggestionsFilter = (DartType dartType) {
- DartType bestType = node.expression.bestType;
- return bestType.isDynamic ||
- (dartType.isSubtypeOf(bestType) && dartType != bestType);
+ DartType staticType = node.expression.staticType;
+ return staticType.isDynamic ||
+ (dartType.isSubtypeOf(staticType) && dartType != staticType);
};
}
}
« 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