| Index: pkg/analysis_server/lib/src/services/correction/util.dart
|
| diff --git a/pkg/analysis_server/lib/src/services/correction/util.dart b/pkg/analysis_server/lib/src/services/correction/util.dart
|
| index 91956794c516aa42a74571a54437fa65c3f684c0..ea5770b93ac1584264333723d8d75201b1edbc3e 100644
|
| --- a/pkg/analysis_server/lib/src/services/correction/util.dart
|
| +++ b/pkg/analysis_server/lib/src/services/correction/util.dart
|
| @@ -10,7 +10,6 @@ import 'package:analysis_server/protocol/protocol_generated.dart'
|
| show SourceChange, SourceEdit;
|
| import 'package:analysis_server/src/protocol_server.dart'
|
| show doSourceChange_addElementEdit;
|
| -import 'package:analysis_server/src/services/correction/source_range.dart';
|
| import 'package:analysis_server/src/services/correction/strings.dart';
|
| import 'package:analyzer/dart/ast/ast.dart';
|
| import 'package:analyzer/dart/ast/token.dart';
|
| @@ -23,6 +22,7 @@ import 'package:analyzer/src/dart/scanner/scanner.dart';
|
| import 'package:analyzer/src/generated/engine.dart';
|
| import 'package:analyzer/src/generated/resolver.dart';
|
| import 'package:analyzer/src/generated/source.dart';
|
| +import 'package:analyzer_plugin/utilities/range_factory.dart';
|
| import 'package:path/path.dart';
|
|
|
| /**
|
| @@ -178,7 +178,7 @@ List<SourceRange> getCommentRanges(CompilationUnit unit) {
|
| while (token != null && token.type != TokenType.EOF) {
|
| Token commentToken = token.precedingComments;
|
| while (commentToken != null) {
|
| - ranges.add(rangeToken(commentToken));
|
| + ranges.add(range.token(commentToken));
|
| commentToken = commentToken.next;
|
| }
|
| token = token.next;
|
| @@ -972,30 +972,29 @@ class CorrectionUtils {
|
| }
|
|
|
| /**
|
| - * Returns a [SourceRange] that covers [range] and extends (if possible) to
|
| - * cover whole lines.
|
| + * Returns a [SourceRange] that covers [sourceRange] and extends (if possible)
|
| + * to cover whole lines.
|
| */
|
| - SourceRange getLinesRange(SourceRange range,
|
| + SourceRange getLinesRange(SourceRange sourceRange,
|
| {bool skipLeadingEmptyLines: false}) {
|
| // start
|
| - int startOffset = range.offset;
|
| + int startOffset = sourceRange.offset;
|
| int startLineOffset = getLineContentStart(startOffset);
|
| if (skipLeadingEmptyLines) {
|
| startLineOffset = skipEmptyLinesLeft(startLineOffset);
|
| }
|
| // end
|
| - int endOffset = range.end;
|
| + int endOffset = sourceRange.end;
|
| int afterEndLineOffset = getLineContentEnd(endOffset);
|
| // range
|
| - return rangeStartEnd(startLineOffset, afterEndLineOffset);
|
| + return range.offsetEndIndex(startLineOffset, afterEndLineOffset);
|
| }
|
|
|
| /**
|
| * Returns a [SourceRange] that covers all the given [Statement]s.
|
| */
|
| SourceRange getLinesRangeStatements(List<Statement> statements) {
|
| - SourceRange range = rangeNodes(statements);
|
| - return getLinesRange(range);
|
| + return getLinesRange(range.nodes(statements));
|
| }
|
|
|
| /**
|
| @@ -1322,7 +1321,7 @@ class CorrectionUtils {
|
| List<Token> tokens = TokenUtils.getTokens(source);
|
| for (Token token in tokens) {
|
| if (token.type == TokenType.STRING) {
|
| - lineRanges.add(rangeToken(token));
|
| + lineRanges.add(range.token(token));
|
| }
|
| token = token.next;
|
| }
|
| @@ -1378,7 +1377,7 @@ class CorrectionUtils {
|
| bool selectionIncludesNonWhitespaceOutsideNode(
|
| SourceRange selection, AstNode node) {
|
| return _selectionIncludesNonWhitespaceOutsideRange(
|
| - selection, rangeNode(node));
|
| + selection, range.node(node));
|
| }
|
|
|
| /**
|
| @@ -1501,17 +1500,19 @@ class CorrectionUtils {
|
| * between "selection" and "range" start/end.
|
| */
|
| bool _selectionIncludesNonWhitespaceOutsideRange(
|
| - SourceRange selection, SourceRange range) {
|
| + SourceRange selection, SourceRange sourceRange) {
|
| // selection should cover range
|
| - if (!selection.covers(range)) {
|
| + if (!selection.covers(sourceRange)) {
|
| return false;
|
| }
|
| // non-whitespace between selection start and range start
|
| - if (!isJustWhitespaceOrComment(rangeStartStart(selection, range))) {
|
| + if (!isJustWhitespaceOrComment(
|
| + range.offsetEndIndex(selection.offset, sourceRange.offset))) {
|
| return true;
|
| }
|
| // non-whitespace after range
|
| - if (!isJustWhitespaceOrComment(rangeEndEnd(range, selection))) {
|
| + if (!isJustWhitespaceOrComment(
|
| + range.offsetEndIndex(sourceRange.end, selection.end))) {
|
| return true;
|
| }
|
| // only whitespace in selection around range
|
|
|