OLD | NEW |
---|---|
1 // Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2017, 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 import 'dart:async'; | 5 import 'dart:async'; |
6 | 6 |
7 import 'package:analyzer/dart/analysis/results.dart'; | 7 import 'package:analyzer/dart/analysis/results.dart'; |
8 import 'package:analyzer/file_system/file_system.dart'; | 8 import 'package:analyzer/file_system/file_system.dart'; |
9 import 'package:analyzer_plugin/protocol/protocol.dart'; | 9 import 'package:analyzer_plugin/protocol/protocol.dart'; |
10 import 'package:analyzer_plugin/protocol/protocol_common.dart'; | 10 import 'package:analyzer_plugin/protocol/protocol_common.dart'; |
(...skipping 28 matching lines...) Expand all Loading... | |
39 * Set the offset of the region of text that should be replaced by the | 39 * Set the offset of the region of text that should be replaced by the |
40 * selected completion suggestion. | 40 * selected completion suggestion. |
41 * | 41 * |
42 * The offset can only be set once and applies to all of the suggestions. | 42 * The offset can only be set once and applies to all of the suggestions. |
43 * Hence, this setter throws a [StateError] if the offset has already been | 43 * Hence, this setter throws a [StateError] if the offset has already been |
44 * set. | 44 * set. |
45 */ | 45 */ |
46 void set offset(int offset); | 46 void set offset(int offset); |
47 | 47 |
48 /** | 48 /** |
49 * Indicates if the collector's offset has been set (and ultimately the | |
50 * length too). | |
51 */ | |
52 bool get offsetIsSet; | |
53 | |
54 /** | |
55 * Returns length of suggestions currently held. | |
56 */ | |
57 int get suggestionsLength; | |
58 | |
59 /** | |
49 * Record the given completion [suggestion]. | 60 * Record the given completion [suggestion]. |
50 */ | 61 */ |
51 void addSuggestion(CompletionSuggestion suggestion); | 62 void addSuggestion(CompletionSuggestion suggestion); |
52 } | 63 } |
53 | 64 |
54 /** | 65 /** |
55 * An object used to produce completion suggestions. | 66 * An object used to produce completion suggestions. |
56 * | 67 * |
57 * Clients may implement this class when implementing plugins. | 68 * Clients may implement this class when implementing plugins. |
58 */ | 69 */ |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
97 await contributor.computeSuggestions(request, collector); | 108 await contributor.computeSuggestions(request, collector); |
98 } catch (exception, stackTrace) { | 109 } catch (exception, stackTrace) { |
99 notifications.add(new PluginErrorParams( | 110 notifications.add(new PluginErrorParams( |
100 false, exception.toString(), stackTrace.toString()) | 111 false, exception.toString(), stackTrace.toString()) |
101 .toNotification()); | 112 .toNotification()); |
102 } | 113 } |
103 } | 114 } |
104 } on AbortCompletion { | 115 } on AbortCompletion { |
105 return new GeneratorResult(null, notifications); | 116 return new GeneratorResult(null, notifications); |
106 } | 117 } |
118 if (collector.suggestions.isEmpty) { | |
mfairhurst
2017/06/13 20:31:39
Should this instead check 'offsetIsSet'? And, what
maxkim
2017/06/13 20:49:21
Ah that's right, I added this block before adding
| |
119 collector | |
120 ..offset = request.offset | |
121 ..length = 0; | |
122 } | |
107 CompletionGetSuggestionsResult result = new CompletionGetSuggestionsResult( | 123 CompletionGetSuggestionsResult result = new CompletionGetSuggestionsResult( |
108 collector.offset, collector.length, collector.suggestions); | 124 collector.offset, collector.length, collector.suggestions); |
Brian Wilkerson
2017/06/13 20:50:19
I don't understand what the length of the suggesti
maxkim
2017/06/13 21:11:40
This is following the assumption that if suggestio
| |
109 return new GeneratorResult(result, notifications); | 125 return new GeneratorResult(result, notifications); |
110 } | 126 } |
111 } | 127 } |
112 | 128 |
113 /** | 129 /** |
114 * The information about a requested list of completions. | 130 * The information about a requested list of completions. |
115 * | 131 * |
116 * Clients may not extend, implement or mix-in this class. | 132 * Clients may not extend, implement or mix-in this class. |
117 */ | 133 */ |
118 abstract class CompletionRequest { | 134 abstract class CompletionRequest { |
(...skipping 12 matching lines...) Expand all Loading... | |
131 * The analysis result for the file in which the completion is being | 147 * The analysis result for the file in which the completion is being |
132 * requested. | 148 * requested. |
133 */ | 149 */ |
134 ResolveResult get result; | 150 ResolveResult get result; |
135 | 151 |
136 /** | 152 /** |
137 * Throw an [AbortCompletion] if the completion request has been aborted. | 153 * Throw an [AbortCompletion] if the completion request has been aborted. |
138 */ | 154 */ |
139 void checkAborted(); | 155 void checkAborted(); |
140 } | 156 } |
OLD | NEW |