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

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

Issue 2250873002: fix completion in switch case (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: merge Created 4 years, 4 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/dart/local_reference_contributor_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/local_declaration_visitor.dart
diff --git a/pkg/analysis_server/lib/src/services/completion/dart/local_declaration_visitor.dart b/pkg/analysis_server/lib/src/services/completion/dart/local_declaration_visitor.dart
index e46b7e52478f6dd22da3f316e9c35acb1c3d861a..f0c2b3a11928a83f495f154e2c8bd84be57bd222 100644
--- a/pkg/analysis_server/lib/src/services/completion/dart/local_declaration_visitor.dart
+++ b/pkg/analysis_server/lib/src/services/completion/dart/local_declaration_visitor.dart
@@ -71,31 +71,7 @@ abstract class LocalDeclarationVisitor extends GeneralizingAstVisitor {
@override
void visitBlock(Block node) {
- for (Statement stmt in node.statements) {
- if (stmt.offset < offset) {
- if (stmt is VariableDeclarationStatement) {
- VariableDeclarationList varList = stmt.variables;
- if (varList != null) {
- for (VariableDeclaration varDecl in varList.variables) {
- if (varDecl.end < offset) {
- declaredLocalVar(varDecl.name, varList.type);
- }
- }
- }
- } else if (stmt is FunctionDeclarationStatement) {
- FunctionDeclaration declaration = stmt.functionDeclaration;
- if (declaration != null && declaration.offset < offset) {
- SimpleIdentifier id = declaration.name;
- if (id != null) {
- String name = id.name;
- if (name != null && name.length > 0) {
- declaredFunction(declaration);
- }
- }
- }
- }
- }
- }
+ _visitStatements(node.statements);
visitNode(node);
}
@@ -220,6 +196,12 @@ abstract class LocalDeclarationVisitor extends GeneralizingAstVisitor {
}
@override
+ void visitSwitchMember(SwitchMember node) {
+ _visitStatements(node.statements);
+ visitNode(node);
+ }
+
+ @override
void visitSwitchStatement(SwitchStatement node) {
for (SwitchMember member in node.members) {
for (Label label in member.labels) {
@@ -263,6 +245,34 @@ abstract class LocalDeclarationVisitor extends GeneralizingAstVisitor {
});
}
}
+
+ _visitStatements(NodeList<Statement> statements) {
+ for (Statement stmt in statements) {
+ if (stmt.offset < offset) {
+ if (stmt is VariableDeclarationStatement) {
+ VariableDeclarationList varList = stmt.variables;
+ if (varList != null) {
+ for (VariableDeclaration varDecl in varList.variables) {
+ if (varDecl.end < offset) {
+ declaredLocalVar(varDecl.name, varList.type);
+ }
+ }
+ }
+ } else if (stmt is FunctionDeclarationStatement) {
+ FunctionDeclaration declaration = stmt.functionDeclaration;
+ if (declaration != null && declaration.offset < offset) {
+ SimpleIdentifier id = declaration.name;
+ if (id != null) {
+ String name = id.name;
+ if (name != null && name.length > 0) {
+ declaredFunction(declaration);
+ }
+ }
+ }
+ }
+ }
+ }
+ }
}
/**
« no previous file with comments | « no previous file | pkg/analysis_server/test/services/completion/dart/local_reference_contributor_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698