@@ -393,14 +393,14 @@ final class CorrectionUtils {
393
393
394
394
static const String _twoIndents = _oneIndent + _oneIndent;
395
395
396
- final CompilationUnit unit ;
396
+ final CompilationUnit _unit ;
397
397
398
398
final String _buffer;
399
399
400
400
String ? _endOfLine;
401
401
402
402
CorrectionUtils (ParsedUnitResult result)
403
- : unit = result.unit,
403
+ : _unit = result.unit,
404
404
_buffer = result.content;
405
405
406
406
/// The EOL sequence to use for this [CompilationUnit] .
@@ -426,7 +426,7 @@ final class CorrectionUtils {
426
426
String get twoIndents => _twoIndents;
427
427
428
428
/// Returns the [AstNode] that encloses the given offset.
429
- AstNode ? findNode (int offset) => NodeLocator (offset).searchWithin (unit );
429
+ AstNode ? findNode (int offset) => NodeLocator (offset).searchWithin (_unit );
430
430
431
431
/// Skips whitespace characters and single EOL on the right from [index] .
432
432
///
@@ -524,7 +524,7 @@ final class CorrectionUtils {
524
524
// end
525
525
var endOffset = sourceRange.end;
526
526
var afterEndLineOffset = endOffset;
527
- var lineInfo = unit .lineInfo;
527
+ var lineInfo = _unit .lineInfo;
528
528
var lineStart = lineInfo
529
529
.getOffsetOfLine (lineInfo.getLocation (startLineOffset).lineNumber - 1 );
530
530
if (lineStart == startLineOffset) {
@@ -597,43 +597,6 @@ final class CorrectionUtils {
597
597
return _buffer.substring (offset, offset + length);
598
598
}
599
599
600
- /// Splits [text] into lines, and removes one level of indent from each line.
601
- /// Lines that don't start with indentation are left as is.
602
- String indentLeft (String text) {
603
- var buffer = StringBuffer ();
604
- var indent = oneIndent;
605
- var eol = endOfLine;
606
- var lines = text.split (eol);
607
- for (var line in lines) {
608
- if (buffer.isNotEmpty) {
609
- buffer.write (eol);
610
- }
611
- String updatedLine;
612
- if (line.startsWith (indent)) {
613
- updatedLine = line.substring (indent.length);
614
- } else {
615
- updatedLine = line;
616
- }
617
- buffer.write (updatedLine);
618
- }
619
- return buffer.toString ();
620
- }
621
-
622
- /// Adds [level] indents to each line.
623
- String indentRight (String text, {int level = 1 }) {
624
- var buffer = StringBuffer ();
625
- var indent = _oneIndent * level;
626
- var eol = endOfLine;
627
- var lines = text.split (eol);
628
- for (var line in lines) {
629
- if (buffer.isNotEmpty) {
630
- buffer.write (eol);
631
- }
632
- buffer.write ('$indent $line ' );
633
- }
634
- return buffer.toString ();
635
- }
636
-
637
600
/// Indents given source left or right.
638
601
String indentSourceLeftRight (String source, {bool indentLeft = true }) {
639
602
var sb = StringBuffer ();
@@ -682,7 +645,7 @@ final class CorrectionUtils {
682
645
// prepare STRING token ranges
683
646
var lineRanges = < SourceRange > [];
684
647
{
685
- var tokens = TokenUtils .getTokens (source, unit .featureSet);
648
+ var tokens = TokenUtils .getTokens (source, _unit .featureSet);
686
649
for (var token in tokens) {
687
650
if (token.type == TokenType .STRING ) {
688
651
lineRanges.add (range.token (token));
@@ -838,7 +801,7 @@ final class CorrectionUtils {
838
801
return true ;
839
802
}
840
803
// may be comment
841
- return TokenUtils .getTokens (trimmedText, unit .featureSet).isEmpty;
804
+ return TokenUtils .getTokens (trimmedText, _unit .featureSet).isEmpty;
842
805
}
843
806
844
807
/// Return `true` if [selection] covers [range] and there are any
0 commit comments