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

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

Issue 967643002: throw exception to stop visiting (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 5 years, 9 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 library services.completion.computer.dart.local; 5 library services.completion.computer.dart.local;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 8
9 import 'package:analysis_server/src/protocol.dart' as protocol show Element, 9 import 'package:analysis_server/src/protocol.dart' as protocol show Element,
10 ElementKind; 10 ElementKind;
(...skipping 16 matching lines...) Expand all
27 OpType optype = request.optype; 27 OpType optype = request.optype;
28 if (optype.includeTopLevelSuggestions) { 28 if (optype.includeTopLevelSuggestions) {
29 _LocalVisitor localVisitor = new _LocalVisitor( 29 _LocalVisitor localVisitor = new _LocalVisitor(
30 request, 30 request,
31 request.offset, 31 request.offset,
32 optype.includeOnlyTypeNameSuggestions, 32 optype.includeOnlyTypeNameSuggestions,
33 !optype.includeVoidReturnSuggestions); 33 !optype.includeVoidReturnSuggestions);
34 34
35 // Collect suggestions from the specific child [AstNode] that contains 35 // Collect suggestions from the specific child [AstNode] that contains
36 // the completion offset and all of its parents recursively. 36 // the completion offset and all of its parents recursively.
37 request.node.accept(localVisitor); 37 localVisitor.visit(request.node);
38 } 38 }
39 if (optype.includeStatementLabelSuggestions || 39 if (optype.includeStatementLabelSuggestions ||
40 optype.includeCaseLabelSuggestions) { 40 optype.includeCaseLabelSuggestions) {
41 _LabelVisitor labelVisitor = new _LabelVisitor( 41 _LabelVisitor labelVisitor = new _LabelVisitor(
42 request, 42 request,
43 optype.includeStatementLabelSuggestions, 43 optype.includeStatementLabelSuggestions,
44 optype.includeCaseLabelSuggestions); 44 optype.includeCaseLabelSuggestions);
45 request.node.accept(labelVisitor); 45 labelVisitor.visit(request.node);
46 } 46 }
47 47
48 // If the unit is not a part and does not reference any parts 48 // If the unit is not a part and does not reference any parts
49 // then work is complete 49 // then work is complete
50 return !request.unit.directives.any( 50 return !request.unit.directives.any(
51 (Directive directive) => 51 (Directive directive) =>
52 directive is PartOfDirective || directive is PartDirective); 52 directive is PartOfDirective || directive is PartDirective);
53 } 53 }
54 54
55 @override 55 @override
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
132 // ignored 132 // ignored
133 } 133 }
134 134
135 @override 135 @override
136 void declaredTopLevelVar(VariableDeclarationList varList, 136 void declaredTopLevelVar(VariableDeclarationList varList,
137 VariableDeclaration varDecl) { 137 VariableDeclaration varDecl) {
138 // ignored 138 // ignored
139 } 139 }
140 140
141 @override 141 @override
142 bool visitFunctionExpression(FunctionExpression node) { 142 void visitFunctionExpression(FunctionExpression node) {
143 // Labels are only accessible within the local function, so stop visiting 143 // Labels are only accessible within the local function, so stop visiting
144 // once we reach a function boundary. 144 // once we reach a function boundary.
145 finished = true; 145 finished();
146 return true;
147 } 146 }
148 147
149 @override 148 @override
150 bool visitMethodDeclaration(MethodDeclaration node) { 149 void visitMethodDeclaration(MethodDeclaration node) {
151 // Labels are only accessible within the local function, so stop visiting 150 // Labels are only accessible within the local function, so stop visiting
152 // once we reach a function boundary. 151 // once we reach a function boundary.
153 finished = true; 152 finished();
154 return true;
155 } 153 }
156 154
157 CompletionSuggestion _addSuggestion(SimpleIdentifier id) { 155 CompletionSuggestion _addSuggestion(SimpleIdentifier id) {
158 if (id != null) { 156 if (id != null) {
159 String completion = id.name; 157 String completion = id.name;
160 if (completion != null && completion.length > 0 && completion != '_') { 158 if (completion != null && completion.length > 0 && completion != '_') {
161 CompletionSuggestion suggestion = new CompletionSuggestion( 159 CompletionSuggestion suggestion = new CompletionSuggestion(
162 CompletionSuggestionKind.IDENTIFIER, 160 CompletionSuggestionKind.IDENTIFIER,
163 DART_RELEVANCE_DEFAULT, 161 DART_RELEVANCE_DEFAULT,
164 completion, 162 completion,
(...skipping 393 matching lines...) Expand 10 before | Expand all | Expand 10 after
558 if (name == null || name.length <= 0) { 556 if (name == null || name.length <= 0) {
559 return DYNAMIC; 557 return DYNAMIC;
560 } 558 }
561 TypeArgumentList typeArgs = type.typeArguments; 559 TypeArgumentList typeArgs = type.typeArguments;
562 if (typeArgs != null) { 560 if (typeArgs != null) {
563 //TODO (danrubel) include type arguments 561 //TODO (danrubel) include type arguments
564 } 562 }
565 return name; 563 return name;
566 } 564 }
567 } 565 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698