Files
sdk/pkg/analysis_server/test/utils/test_code_extensions.dart
T
Danny Tuppeny 1b38b7bb7b [analysis_server] Move TestCode from analysis_server to analyzer
Change-Id: I81333240d7693b66416ce6bb308f980b264a2238
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/264920
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2022-10-19 19:58:47 +00:00

23 lines
952 B
Dart

// Copyright (c) 2022, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
import 'package:analysis_server/lsp_protocol/protocol.dart'
show Position, Range;
import 'package:analysis_server/src/lsp/mapping.dart';
import 'package:analyzer/src/test_utilities/test_code_format.dart';
extension TestCodePositionExtension on TestCodePosition {
/// Return the LSP [Position] of the marker.
///
/// Positions are based on [TestCode.code], with all parsed markers removed.
Position get position => toPosition(lineInfo.getLocation(offset));
}
extension TestCodeRangeExtension on TestCodeRange {
/// The LSP [Range] indicated by the markers.
///
/// Ranges are based on [TestCode.code], with all parsed markers removed.
Range get range => toRange(lineInfo, sourceRange.offset, sourceRange.length);
}