| 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 library protocol; | 5 library protocol; |
| 6 | 6 |
| 7 import 'dart:collection'; | 7 import 'dart:collection'; |
| 8 import 'dart:convert'; | 8 import 'dart:convert'; |
| 9 | 9 |
| 10 part 'generated_protocol.dart'; | 10 part 'generated_protocol.dart'; |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 66 | 66 |
| 67 | 67 |
| 68 /** | 68 /** |
| 69 * Get the result of applying the edit to the given [code]. Access via | 69 * Get the result of applying the edit to the given [code]. Access via |
| 70 * SourceEdit.apply(). | 70 * SourceEdit.apply(). |
| 71 */ | 71 */ |
| 72 String _applyEdit(String code, SourceEdit edit) { | 72 String _applyEdit(String code, SourceEdit edit) { |
| 73 if (edit.length < 0) { | 73 if (edit.length < 0) { |
| 74 throw new RangeError('length is negative'); | 74 throw new RangeError('length is negative'); |
| 75 } | 75 } |
| 76 return code.substring(0, edit.offset) + | 76 return code.replaceRange(edit.offset, edit.end, edit.replacement); |
| 77 edit.replacement + | |
| 78 code.substring(edit.end); | |
| 79 } | 77 } |
| 80 | 78 |
| 81 /** | 79 /** |
| 82 * Get the result of applying a set of [edits] to the given [code]. Edits | 80 * Get the result of applying a set of [edits] to the given [code]. Edits |
| 83 * are applied in the order they appear in [edits]. Access via | 81 * are applied in the order they appear in [edits]. Access via |
| 84 * SourceEdit.applySequence(). | 82 * SourceEdit.applySequence(). |
| 85 */ | 83 */ |
| 86 String _applySequence(String code, Iterable<SourceEdit> edits) { | 84 String _applySequence(String code, Iterable<SourceEdit> edits) { |
| 87 edits.forEach((SourceEdit edit) { | 85 edits.forEach((SourceEdit edit) { |
| 88 code = edit.apply(code); | 86 code = edit.apply(code); |
| (...skipping 844 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 933 hash = 0x1fffffff & (hash + ((0x03ffffff & hash) << 3)); | 931 hash = 0x1fffffff & (hash + ((0x03ffffff & hash) << 3)); |
| 934 hash = hash ^ (hash >> 11); | 932 hash = hash ^ (hash >> 11); |
| 935 return 0x1fffffff & (hash + ((0x00003fff & hash) << 15)); | 933 return 0x1fffffff & (hash + ((0x00003fff & hash) << 15)); |
| 936 } | 934 } |
| 937 | 935 |
| 938 static int hash2(a, b) => finish(combine(combine(0, a), b)); | 936 static int hash2(a, b) => finish(combine(combine(0, a), b)); |
| 939 | 937 |
| 940 static int hash4(a, b, c, d) => | 938 static int hash4(a, b, c, d) => |
| 941 finish(combine(combine(combine(combine(0, a), b), c), d)); | 939 finish(combine(combine(combine(combine(0, a), b), c), d)); |
| 942 } | 940 } |
| OLD | NEW |