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

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

Issue 531243002: improve keyword suggestions when completing partial keyword (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: merge Created 6 years, 3 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 4187b61228014780e793c8f87a774ca536f3e135..4137c7d99f4b1e6a980e1e3fdb29b7e2d1514349 100644
--- a/pkg/analysis_server/lib/src/services/completion/keyword_computer.dart
+++ b/pkg/analysis_server/lib/src/services/completion/keyword_computer.dart
@@ -62,6 +62,13 @@ class _KeywordVisitor extends GeneralizingAstVisitor {
int startOfDeclarations = node.end;
if (node.declarations.length > 0) {
startOfDeclarations = node.declarations[0].offset;
+ // If the first token is a simple identifier
+ // and cursor position in within that first token
+ // then consider cursor to be before the first declaration
+ Token token = node.declarations[0].firstTokenAfterCommentAndMetadata;
+ if (token.offset <= request.offset && request.offset <= token.end) {
+ startOfDeclarations = token.end;
+ }
}
// Simplistic check for library as first directive
@@ -103,6 +110,20 @@ class _KeywordVisitor extends GeneralizingAstVisitor {
}
}
+ visitSimpleIdentifier(SimpleIdentifier node) {
+ AstNode parent =
+ node.getAncestor((n) => n is TopLevelVariableDeclaration);
+ if (parent is TopLevelVariableDeclaration) {
+ if (parent.variables != null && parent.variables.type != null
+ && parent.variables.type.name == node) {
+ AstNode unit = node.getAncestor((n) => n is CompilationUnit);
+ if (unit is CompilationUnit) {
+ visitCompilationUnit(unit);
+ }
+ }
+ }
+ }
+
void _addSuggestion(Keyword keyword) {
String completion = keyword.syntax;
request.suggestions.add(
« 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