| OLD | NEW |
| 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 import 'dart:async'; | 5 import 'dart:async'; |
| 6 | 6 |
| 7 import 'package:analysis_server/protocol/protocol.dart'; | 7 import 'package:analysis_server/protocol/protocol.dart'; |
| 8 import 'package:analysis_server/protocol/protocol_generated.dart'; | 8 import 'package:analysis_server/protocol/protocol_generated.dart'; |
| 9 import 'package:analysis_server/src/analysis_server.dart'; | 9 import 'package:analysis_server/src/analysis_server.dart'; |
| 10 import 'package:analysis_server/src/constants.dart'; | 10 import 'package:analysis_server/src/constants.dart'; |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 114 | 114 |
| 115 // | 115 // |
| 116 // Add the fixes produced by plugins to the server-generated fixes. | 116 // Add the fixes produced by plugins to the server-generated fixes. |
| 117 // | 117 // |
| 118 if (pluginFutures != null) { | 118 if (pluginFutures != null) { |
| 119 List<plugin.Response> responses = await waitForResponses(pluginFutures, | 119 List<plugin.Response> responses = await waitForResponses(pluginFutures, |
| 120 requestParameters: requestParams); | 120 requestParameters: requestParams); |
| 121 for (plugin.Response response in responses) { | 121 for (plugin.Response response in responses) { |
| 122 plugin.CompletionGetSuggestionsResult result = | 122 plugin.CompletionGetSuggestionsResult result = |
| 123 new plugin.CompletionGetSuggestionsResult.fromResponse(response); | 123 new plugin.CompletionGetSuggestionsResult.fromResponse(response); |
| 124 suggestions.addAll(result.results); | 124 if (result.results != null && result.results.isNotEmpty) { |
| 125 if (suggestions.isEmpty) { |
| 126 request.replacementOffset = result.replacementOffset; |
| 127 request.replacementLength = result.replacementLength; |
| 128 } else if (request.replacementOffset != result.replacementOffset && |
| 129 request.replacementLength != result.replacementLength) { |
| 130 server.instrumentationService |
| 131 .logError('Plugin completion-results dropped due to conflicting' |
| 132 ' replacement offset/length: ${result.toJson()}'); |
| 133 continue; |
| 134 } |
| 135 suggestions.addAll(result.results); |
| 136 } |
| 125 } | 137 } |
| 126 } | 138 } |
| 127 // | 139 // |
| 128 // Return the result. | 140 // Return the result. |
| 129 // | 141 // |
| 130 return new CompletionResult( | 142 return new CompletionResult( |
| 131 request.replacementOffset, request.replacementLength, suggestions); | 143 request.replacementOffset, request.replacementLength, suggestions); |
| 132 } | 144 } |
| 133 | 145 |
| 134 @override | 146 @override |
| (...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 288 final int replacementOffset; | 300 final int replacementOffset; |
| 289 | 301 |
| 290 /** | 302 /** |
| 291 * The suggested completions. | 303 * The suggested completions. |
| 292 */ | 304 */ |
| 293 final List<CompletionSuggestion> suggestions; | 305 final List<CompletionSuggestion> suggestions; |
| 294 | 306 |
| 295 CompletionResult( | 307 CompletionResult( |
| 296 this.replacementOffset, this.replacementLength, this.suggestions); | 308 this.replacementOffset, this.replacementLength, this.suggestions); |
| 297 } | 309 } |
| OLD | NEW |