@@ -31,8 +31,8 @@ final class CorrectionUtils {
3131 String ? _endOfLine;
3232
3333 CorrectionUtils (ParsedUnitResult result)
34- : _unit = result.unit,
35- _buffer = result.content;
34+ : _unit = result.unit,
35+ _buffer = result.content;
3636
3737 /// The EOL sequence to use for this [CompilationUnit] .
3838 String get endOfLine {
@@ -131,8 +131,10 @@ final class CorrectionUtils {
131131
132132 /// Returns a [SourceRange] that covers [sourceRange] and extends (if
133133 /// possible) to cover whole lines.
134- SourceRange getLinesRange (SourceRange sourceRange,
135- {bool skipLeadingEmptyLines = false }) {
134+ SourceRange getLinesRange (
135+ SourceRange sourceRange, {
136+ bool skipLeadingEmptyLines = false ,
137+ }) {
136138 // Calculate the start:
137139 var startOffset = sourceRange.offset;
138140 var startLineOffset = getLineContentStart (startOffset);
@@ -143,8 +145,9 @@ final class CorrectionUtils {
143145 var endOffset = sourceRange.end;
144146 var afterEndLineOffset = endOffset;
145147 var lineInfo = _unit.lineInfo;
146- var lineStart = lineInfo
147- .getOffsetOfLine (lineInfo.getLocation (startLineOffset).lineNumber - 1 );
148+ var lineStart = lineInfo.getOffsetOfLine (
149+ lineInfo.getLocation (startLineOffset).lineNumber - 1 ,
150+ );
148151 if (lineStart == startLineOffset) {
149152 // Only consume line endings after the end of the range if there is
150153 // nothing else on the line containing the beginning of the range.
@@ -184,10 +187,7 @@ final class CorrectionUtils {
184187
185188 /// Returns the text of the given [AstNode] in the unit, including preceding
186189 /// comments.
187- String getNodeText (
188- AstNode node, {
189- bool withLeadingComments = false ,
190- }) {
190+ String getNodeText (AstNode node, {bool withLeadingComments = false }) {
191191 var firstToken = withLeadingComments
192192 ? node.beginToken.precedingComments ?? node.beginToken
193193 : node.beginToken;
@@ -252,8 +252,13 @@ final class CorrectionUtils {
252252 /// Usually [includeLeading] and [ensureTrailingNewline] are set together,
253253 /// when indenting a set of statements to go inside a block (as opposed to
254254 /// just wrapping a nested expression that might span multiple lines).
255- String replaceSourceIndent (String source, String oldIndent, String newIndent,
256- {bool includeLeading = false , bool ensureTrailingNewline = false }) {
255+ String replaceSourceIndent (
256+ String source,
257+ String oldIndent,
258+ String newIndent, {
259+ bool includeLeading = false ,
260+ bool ensureTrailingNewline = false ,
261+ }) {
257262 // Prepare token ranges.
258263 var lineRanges = < SourceRange > [];
259264 {
@@ -323,12 +328,20 @@ final class CorrectionUtils {
323328 /// when indenting a set of statements to go inside a block (as opposed to
324329 /// just wrapping a nested expression that might span multiple lines).
325330 String replaceSourceRangeIndent (
326- SourceRange range, String oldIndent, String newIndent,
327- {bool includeLeading = false , bool ensureTrailingNewline = false }) {
331+ SourceRange range,
332+ String oldIndent,
333+ String newIndent, {
334+ bool includeLeading = false ,
335+ bool ensureTrailingNewline = false ,
336+ }) {
328337 var oldSource = getRangeText (range);
329- return replaceSourceIndent (oldSource, oldIndent, newIndent,
330- includeLeading: includeLeading,
331- ensureTrailingNewline: ensureTrailingNewline);
338+ return replaceSourceIndent (
339+ oldSource,
340+ oldIndent,
341+ newIndent,
342+ includeLeading: includeLeading,
343+ ensureTrailingNewline: ensureTrailingNewline,
344+ );
332345 }
333346
334347 /// Returns the [_InvertedCondition] for the given logical expression.
@@ -367,13 +380,21 @@ final class CorrectionUtils {
367380 ls = _invertCondition0 (le);
368381 rs = _invertCondition0 (re);
369382 return _InvertedCondition ._binary (
370- TokenType .BAR_BAR .precedence, ls, ' || ' , rs);
383+ TokenType .BAR_BAR .precedence,
384+ ls,
385+ ' || ' ,
386+ rs,
387+ );
371388 }
372389 if (operator == TokenType .BAR_BAR ) {
373390 ls = _invertCondition0 (le);
374391 rs = _invertCondition0 (re);
375392 return _InvertedCondition ._binary (
376- TokenType .AMPERSAND_AMPERSAND .precedence, ls, ' && ' , rs);
393+ TokenType .AMPERSAND_AMPERSAND .precedence,
394+ ls,
395+ ' && ' ,
396+ rs,
397+ );
377398 }
378399 } else if (expression is IsExpression ) {
379400 var expressionSource = getNodeText (expression.expression);
@@ -432,14 +453,15 @@ class TokenUtils {
432453 static List <Token > getTokens (String s, FeatureSet featureSet) {
433454 try {
434455 var tokens = < Token > [];
435- var scanner = Scanner (
436- _SourceMock (),
437- CharSequenceReader (s),
438- DiagnosticListener .nullListener,
439- )..configureFeatures (
440- featureSetForOverriding: featureSet,
441- featureSet: featureSet,
442- );
456+ var scanner =
457+ Scanner (
458+ _SourceMock (),
459+ CharSequenceReader (s),
460+ DiagnosticListener .nullListener,
461+ )..configureFeatures (
462+ featureSetForOverriding: featureSet,
463+ featureSet: featureSet,
464+ );
443465 var token = scanner.tokenize ();
444466 while (! token.isEof) {
445467 tokens.add (token);
@@ -460,25 +482,37 @@ class _InvertedCondition {
460482
461483 _InvertedCondition (this ._precedence, this ._source);
462484
463- static _InvertedCondition _binary (int precedence, _InvertedCondition left,
464- String operation, _InvertedCondition right) {
465- var src = _parenthesizeIfRequired (left, precedence) +
485+ static _InvertedCondition _binary (
486+ int precedence,
487+ _InvertedCondition left,
488+ String operation,
489+ _InvertedCondition right,
490+ ) {
491+ var src =
492+ _parenthesizeIfRequired (left, precedence) +
466493 operation +
467494 _parenthesizeIfRequired (right, precedence);
468495 return _InvertedCondition (precedence, src);
469496 }
470497
471498 static _InvertedCondition _binary2 (
472- _InvertedCondition left, String operation, _InvertedCondition right) {
499+ _InvertedCondition left,
500+ String operation,
501+ _InvertedCondition right,
502+ ) {
473503 // TODO(scheglov): consider merging with "_binary()" after testing
474504 return _InvertedCondition (
475- 1 << 20 , '${left ._source }$operation ${right ._source }' );
505+ 1 << 20 ,
506+ '${left ._source }$operation ${right ._source }' ,
507+ );
476508 }
477509
478510 /// Adds enclosing parenthesis if the precedence of the [_InvertedCondition]
479511 /// if less than the precedence of the expression we are going it to use in.
480512 static String _parenthesizeIfRequired (
481- _InvertedCondition expr, int newOperatorPrecedence) {
513+ _InvertedCondition expr,
514+ int newOperatorPrecedence,
515+ ) {
482516 if (expr._precedence < newOperatorPrecedence) {
483517 return '(${expr ._source })' ;
484518 }
0 commit comments