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

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

Issue 1514263004: extract LabelContributor from local reference contributor (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: merge Created 5 years 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_reference_contributor.dart
diff --git a/pkg/analysis_server/lib/src/services/completion/local_reference_contributor.dart b/pkg/analysis_server/lib/src/services/completion/local_reference_contributor.dart
index 6753a400f85c1ec0fec3f1daa767a0ed1483d165..23282d04bc9c3618cfa390b95a6aad850a90e350 100644
--- a/pkg/analysis_server/lib/src/services/completion/local_reference_contributor.dart
+++ b/pkg/analysis_server/lib/src/services/completion/local_reference_contributor.dart
@@ -41,14 +41,6 @@ class LocalReferenceContributor extends DartCompletionContributor {
new _LocalVisitor(request, request.offset, optype);
localVisitor.visit(request.target.containingNode);
}
- if (optype.includeStatementLabelSuggestions ||
- optype.includeCaseLabelSuggestions) {
- _LabelVisitor labelVisitor = new _LabelVisitor(
- request,
- optype.includeStatementLabelSuggestions,
- optype.includeCaseLabelSuggestions);
- labelVisitor.visit(request.target.containingNode);
- }
if (optype.includeConstructorSuggestions) {
new _ConstructorVisitor(request).visit(request.target.containingNode);
}
@@ -238,119 +230,6 @@ class _ConstructorVisitor extends LocalDeclarationVisitor {
}
/**
- * A visitor for collecting suggestions for break and continue labels.
- */
-class _LabelVisitor extends LocalDeclarationVisitor {
- final 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;
-
- @override
- void declaredClass(ClassDeclaration declaration) {
- // ignored
- }
-
- @override
- void declaredClassTypeAlias(ClassTypeAlias declaration) {
- // ignored
- }
-
- @override
- void declaredField(FieldDeclaration fieldDecl, VariableDeclaration varDecl) {
- // ignored
- }
-
- @override
- void declaredFunction(FunctionDeclaration declaration) {
- // ignored
- }
-
- @override
- void declaredFunctionTypeAlias(FunctionTypeAlias declaration) {
- // ignored
- }
-
- @override
- void declaredLabel(Label label, bool isCaseLabel) {
- if (isCaseLabel ? includeCaseLabels : includeStatementLabels) {
- CompletionSuggestion suggestion = _addSuggestion(label.label);
- if (suggestion != null) {
- suggestion.element = createElement(
- request.source, protocol.ElementKind.LABEL, label.label,
- returnType: NO_RETURN_TYPE);
- }
- }
- }
-
- @override
- void declaredLocalVar(SimpleIdentifier name, TypeName type) {
- // ignored
- }
-
- @override
- void declaredMethod(MethodDeclaration declaration) {
- // ignored
- }
-
- @override
- void declaredParam(SimpleIdentifier name, TypeName type) {
- // ignored
- }
-
- @override
- void declaredTopLevelVar(
- VariableDeclarationList varList, VariableDeclaration varDecl) {
- // ignored
- }
-
- @override
- void visitFunctionExpression(FunctionExpression node) {
- // Labels are only accessible within the local function, so stop visiting
- // once we reach a function boundary.
- finished();
- }
-
- @override
- void visitMethodDeclaration(MethodDeclaration node) {
- // Labels are only accessible within the local function, so stop visiting
- // once we reach a function boundary.
- finished();
- }
-
- CompletionSuggestion _addSuggestion(SimpleIdentifier id) {
- if (id != null) {
- String completion = id.name;
- if (completion != null && completion.length > 0 && completion != '_') {
- CompletionSuggestion suggestion = new CompletionSuggestion(
- CompletionSuggestionKind.IDENTIFIER,
- DART_RELEVANCE_DEFAULT,
- completion,
- completion.length,
- 0,
- false,
- false);
- request.addSuggestion(suggestion);
- return suggestion;
- }
- }
- return null;
- }
-}
-
-/**
* A visitor for collecting suggestions from the most specific child [AstNode]
* that contains the completion offset to the [CompilationUnit].
*/

Powered by Google App Engine
This is Rietveld 408576698