| 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:collection'; | 5 import 'dart:collection'; |
| 6 | 6 |
| 7 import 'package:analysis_server/protocol/protocol_generated.dart' | 7 import 'package:analysis_server/protocol/protocol_generated.dart'; |
| 8 hide AnalysisErrorFixes; | 8 import 'package:analyzer_plugin/protocol/protocol_common.dart'; |
| 9 import 'package:analyzer_plugin/protocol/protocol_common.dart' as plugin; | |
| 10 import 'package:analyzer_plugin/protocol/protocol_generated.dart' as plugin; | 9 import 'package:analyzer_plugin/protocol/protocol_generated.dart' as plugin; |
| 11 import 'package:meta/meta.dart'; | 10 import 'package:meta/meta.dart'; |
| 12 | 11 |
| 13 /** | 12 /** |
| 14 * An object used to merge partial lists of results that were contributed by | 13 * An object used to merge partial lists of results that were contributed by |
| 15 * plugins. | 14 * plugins. |
| 16 * | 15 * |
| 17 * All of the methods in this class assume that the contributions from the | 16 * All of the methods in this class assume that the contributions from the |
| 18 * analysis server are the first partial result in the list of partial results | 17 * analysis server are the first partial result in the list of partial results |
| 19 * to be merged. | 18 * to be merged. |
| 20 */ | 19 */ |
| 21 class ResultMerger { | 20 class ResultMerger { |
| 22 /** | 21 /** |
| 23 * Return a list of fixes composed by merging the lists of fixes in the | 22 * Return a list of fixes composed by merging the lists of fixes in the |
| 24 * [partialResultList]. | 23 * [partialResultList]. |
| 25 * | 24 * |
| 26 * The resulting list of fixes will contain exactly one fix for every analysis | 25 * The resulting list of fixes will contain exactly one fix for every analysis |
| 27 * error for which there are fixes. If two or more plugins contribute the same | 26 * error for which there are fixes. If two or more plugins contribute the same |
| 28 * fix for a given error, the resulting list will contain duplications. | 27 * fix for a given error, the resulting list will contain duplications. |
| 29 */ | 28 */ |
| 30 List<plugin.AnalysisErrorFixes> mergeAnalysisErrorFixes( | 29 List<plugin.AnalysisErrorFixes> mergeAnalysisErrorFixes( |
| 31 List<List<plugin.AnalysisErrorFixes>> partialResultList) { | 30 List<List<plugin.AnalysisErrorFixes>> partialResultList) { |
| 32 /** | 31 /** |
| 33 * Return a key encoding the unique attributes of the given [error]. | 32 * Return a key encoding the unique attributes of the given [error]. |
| 34 */ | 33 */ |
| 35 String computeKey(plugin.AnalysisError error) { | 34 String computeKey(AnalysisError error) { |
| 36 StringBuffer buffer = new StringBuffer(); | 35 StringBuffer buffer = new StringBuffer(); |
| 37 buffer.write(error.location.offset); | 36 buffer.write(error.location.offset); |
| 38 buffer.write(';'); | 37 buffer.write(';'); |
| 39 buffer.write(error.code); | 38 buffer.write(error.code); |
| 40 buffer.write(';'); | 39 buffer.write(';'); |
| 41 buffer.write(error.message); | 40 buffer.write(error.message); |
| 42 buffer.write(';'); | 41 buffer.write(';'); |
| 43 buffer.write(error.correction); | 42 buffer.write(error.correction); |
| 44 return buffer.toString(); | 43 return buffer.toString(); |
| 45 } | 44 } |
| (...skipping 773 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 819 if (leftEnd < rightStart || leftStart > rightEnd) { | 818 if (leftEnd < rightStart || leftStart > rightEnd) { |
| 820 return false; | 819 return false; |
| 821 } | 820 } |
| 822 if (!allowNesting) { | 821 if (!allowNesting) { |
| 823 return true; | 822 return true; |
| 824 } | 823 } |
| 825 return !((leftStart <= rightStart && rightEnd <= leftEnd) || | 824 return !((leftStart <= rightStart && rightEnd <= leftEnd) || |
| 826 (rightStart <= leftStart && leftEnd <= rightEnd)); | 825 (rightStart <= leftStart && leftEnd <= rightEnd)); |
| 827 } | 826 } |
| 828 } | 827 } |
| OLD | NEW |