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

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

Issue 806473007: Add support for completion of case labels. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 5 years, 11 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
Index: pkg/analysis_server/lib/src/services/completion/local_computer.dart
diff --git a/pkg/analysis_server/lib/src/services/completion/local_computer.dart b/pkg/analysis_server/lib/src/services/completion/local_computer.dart
index bc8cf39cd5b927a9002eb43dadb2c0dfa47cd3c5..186f54b172ba9f45f1e3dc1a90cd1fca4fbebbad 100644
--- a/pkg/analysis_server/lib/src/services/completion/local_computer.dart
+++ b/pkg/analysis_server/lib/src/services/completion/local_computer.dart
@@ -35,8 +35,12 @@ class LocalComputer extends DartCompletionComputer {
// the completion offset and all of its parents recursively.
request.node.accept(localVisitor);
}
- if (optype.includeStatementLabelSuggestions) {
- _LabelVisitor labelVisitor = new _LabelVisitor(request);
+ if (optype.includeStatementLabelSuggestions ||
+ optype.includeCaseLabelSuggestions) {
+ _LabelVisitor labelVisitor = new _LabelVisitor(
+ request,
+ optype.includeStatementLabelSuggestions,
+ optype.includeCaseLabelSuggestions);
request.node.accept(labelVisitor);
}
@@ -61,7 +65,18 @@ class LocalComputer extends DartCompletionComputer {
class _LabelVisitor extends LocalDeclarationVisitor {
final DartCompletionRequest request;
- _LabelVisitor(DartCompletionRequest request)
+ /**
+ * True if statement labels should be included as suggestions.
+ */
+ final bool includeStatementLabels;
+
+ /**
+ * True if case labels should be included as suggestions.
+ */
+ final bool includeCaseLabels;
+
+ _LabelVisitor(DartCompletionRequest request, this.includeStatementLabels,
+ this.includeCaseLabels)
: super(request.offset),
request = request;
@@ -91,11 +106,13 @@ class _LabelVisitor extends LocalDeclarationVisitor {
}
@override
- void declaredLabel(Label label) {
- CompletionSuggestion suggestion = _addSuggestion(label.label);
- if (suggestion != null) {
- suggestion.element =
- _createElement(protocol.ElementKind.LABEL, label.label);
+ void declaredLabel(Label label, bool isCaseLabel) {
+ if (isCaseLabel ? includeCaseLabels : includeStatementLabels) {
+ CompletionSuggestion suggestion = _addSuggestion(label.label);
+ if (suggestion != null) {
+ suggestion.element =
+ _createElement(protocol.ElementKind.LABEL, label.label);
+ }
}
}
@@ -286,7 +303,7 @@ class _LocalVisitor extends LocalDeclarationVisitor {
}
@override
- void declaredLabel(Label label) {
+ void declaredLabel(Label label, bool isCaseLabel) {
// ignored
}

Powered by Google App Engine
This is Rietveld 408576698