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

Side by Side Diff: pkg/source_maps/lib/refactor.dart

Issue 402843003: Deprecate the source_maps span classes. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 5 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) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, 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 /// Tools to help implement refactoring like transformations to Dart code. 5 /// Tools to help implement refactoring like transformations to Dart code.
6 /// 6 ///
7 /// [TextEditTransaction] supports making a series of changes to a text buffer. 7 /// [TextEditTransaction] supports making a series of changes to a text buffer.
8 /// [guessIndent] helps to guess the appropriate indentiation for the new code. 8 /// [guessIndent] helps to guess the appropriate indentiation for the new code.
9 library source_maps.refactor; 9 library source_maps.refactor;
10 10
11 import 'span.dart'; 11 import 'span.dart';
12 import 'printer.dart'; 12 import 'printer.dart';
13 import 'src/span_wrapper.dart';
13 14
14 /// Editable text transaction. 15 /// Editable text transaction.
15 /// 16 ///
16 /// Applies a series of edits using original location 17 /// Applies a series of edits using original location
17 /// information, and composes them into the edited string. 18 /// information, and composes them into the edited string.
18 class TextEditTransaction { 19 class TextEditTransaction {
Siggi Cherem (dart-lang) 2014/07/18 01:40:53 FYI - I'd like to move this file to code_transform
nweiz 2014/07/23 23:17:18 Sure; I'll leave the version number as 0.9.4-dev,
19 final SourceFile file; 20 final SourceFile file;
20 final String original; 21 final String original;
21 final _edits = <_TextEdit>[]; 22 final _edits = <_TextEdit>[];
22 23
23 TextEditTransaction(this.original, this.file); 24 /// Creates a new transaction.
25 ///
26 /// [file] can be either a `source_map` [SourceFile] or a `source_span`
27 /// `SourceFile`. Using a `source_map` [SourceFile] is deprecated and will be
28 /// unsupported in version 0.10.0.
29 TextEditTransaction(this.original, file)
30 : file = SourceFileWrapper.wrap(file);
24 31
25 bool get hasEdits => _edits.length > 0; 32 bool get hasEdits => _edits.length > 0;
26 33
27 /// Edit the original text, replacing text on the range [begin] and [end] 34 /// Edit the original text, replacing text on the range [begin] and [end]
28 /// with the [replacement]. [replacement] can be either a string or a 35 /// with the [replacement]. [replacement] can be either a string or a
29 /// [NestedPrinter]. 36 /// [NestedPrinter].
30 void edit(int begin, int end, replacement) { 37 void edit(int begin, int end, replacement) {
31 _edits.add(new _TextEdit(begin, end, replacement)); 38 _edits.add(new _TextEdit(begin, end, replacement));
32 } 39 }
33 40
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
122 } 129 }
123 } 130 }
124 131
125 return code.substring(lineStart, whitespaceEnd); 132 return code.substring(lineStart, whitespaceEnd);
126 } 133 }
127 134
128 const int _CR = 13; 135 const int _CR = 13;
129 const int _LF = 10; 136 const int _LF = 10;
130 const int _TAB = 9; 137 const int _TAB = 9;
131 const int _SPACE = 32; 138 const int _SPACE = 32;
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698