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

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

Issue 935123002: Issue 21879. Don't include 'this' and 'super' keywords if not in a method/constructor body. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 5 years, 10 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/services/completion/keyword_computer_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/keyword_computer.dart
diff --git a/pkg/analysis_server/lib/src/services/completion/keyword_computer.dart b/pkg/analysis_server/lib/src/services/completion/keyword_computer.dart
index b9588be40469dad2a070651fd668d949d93eb22b..baaef7bd84cc59f95c7e75979e5513e8369bbb30 100644
--- a/pkg/analysis_server/lib/src/services/completion/keyword_computer.dart
+++ b/pkg/analysis_server/lib/src/services/completion/keyword_computer.dart
@@ -44,27 +44,47 @@ class _KeywordVisitor extends GeneralizingAstVisitor {
@override
visitBlock(Block node) {
- _addSuggestions(
- [
- Keyword.ASSERT,
- Keyword.CASE,
- Keyword.CONTINUE,
- Keyword.DO,
- Keyword.FACTORY,
- Keyword.FINAL,
- Keyword.FOR,
- Keyword.IF,
- Keyword.NEW,
- Keyword.RETHROW,
- Keyword.RETURN,
- Keyword.SUPER,
- Keyword.SWITCH,
- Keyword.THIS,
- Keyword.THROW,
- Keyword.TRY,
- Keyword.VAR,
- Keyword.VOID,
- Keyword.WHILE]);
+ if (_isInClassMemberBody(node)) {
+ _addSuggestions(
+ [
+ Keyword.ASSERT,
+ Keyword.CASE,
+ Keyword.CONTINUE,
+ Keyword.DO,
+ Keyword.FINAL,
+ Keyword.FOR,
+ Keyword.IF,
+ Keyword.NEW,
+ Keyword.RETHROW,
+ Keyword.RETURN,
+ Keyword.SUPER,
+ Keyword.SWITCH,
+ Keyword.THIS,
+ Keyword.THROW,
+ Keyword.TRY,
+ Keyword.VAR,
+ Keyword.VOID,
+ Keyword.WHILE]);
+ } else {
+ _addSuggestions(
+ [
+ Keyword.ASSERT,
+ Keyword.CASE,
+ Keyword.CONTINUE,
+ Keyword.DO,
+ Keyword.FINAL,
+ Keyword.FOR,
+ Keyword.IF,
+ Keyword.NEW,
+ Keyword.RETHROW,
+ Keyword.RETURN,
+ Keyword.SWITCH,
+ Keyword.THROW,
+ Keyword.TRY,
+ Keyword.VAR,
+ Keyword.VOID,
+ Keyword.WHILE]);
+ }
}
@override
@@ -231,4 +251,18 @@ class _KeywordVisitor extends GeneralizingAstVisitor {
}
return false;
}
+
+ static bool _isInClassMemberBody(AstNode node) {
+ while (true) {
+ AstNode body = node.getAncestor((n) => n is FunctionBody);
+ if (body == null) {
+ return false;
+ }
+ AstNode parent = body.parent;
+ if (parent is ConstructorDeclaration || parent is MethodDeclaration) {
+ return true;
+ }
+ node = parent;
+ }
+ }
}
« no previous file with comments | « no previous file | pkg/analysis_server/test/services/completion/keyword_computer_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698