Skip to content

Commit 8785c4e

Browse files
scheglovCommit Queue
authored andcommitted
Elements. Migrate lib/utilities/range_factory.dart
Change-Id: I218603ef0f3a9eae8bde3889cb22fa7f59000e38 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/403623 Commit-Queue: Konstantin Shcheglov <[email protected]> Reviewed-by: Brian Wilkerson <[email protected]> Reviewed-by: Phil Quitslund <[email protected]>
1 parent 8121b02 commit 8785c4e

File tree

6 files changed

+4
-31
lines changed

6 files changed

+4
-31
lines changed

pkg/analysis_server/lib/src/services/refactoring/legacy/rename.dart

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,6 @@ class RenameProcessor {
3030
this.newName,
3131
);
3232

33-
/// Add the edit that updates the [element] declaration.
34-
void addDeclarationEdit(Element? element) {
35-
if (element != null && workspace.containsElement(element)) {
36-
var edit = newSourceEdit_range(range.elementName(element), newName);
37-
doSourceChange_addElementEdit(change, element, edit);
38-
}
39-
}
40-
4133
/// Add the edit that updates the [element] declaration.
4234
void addDeclarationEdit2(Element2? element) {
4335
if (element == null) {
@@ -72,14 +64,6 @@ class RenameProcessor {
7264
}
7365
}
7466

75-
/// Update the [element] declaration and reference to it.
76-
Future<void> renameElement(Element element) {
77-
addDeclarationEdit(element);
78-
return workspace.searchEngine
79-
.searchReferences(element.asElement2!)
80-
.then(addReferenceEdits);
81-
}
82-
8367
/// Update the [element] declaration and references to it.
8468
Future<void> renameElement2(Element2 element) async {
8569
addDeclarationEdit2(element);

pkg/analyzer_plugin/CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
## 0.13.0-dev
2+
- Remove `elementName()` from `RangeFactory`. Use `fragmentName()` instead.
3+
14
## 0.12.0
25
- Breaking changes to `DartFileEditBuilder`: `convertFunctionFromSyncToAsync`
36
and `replaceTypeWithFuture`.

pkg/analyzer_plugin/analyzer_use_new_elements.txt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,7 @@ lib/utilities/change_builder/change_builder_dart.dart
1111
lib/utilities/completion/inherited_reference_contributor.dart
1212
lib/utilities/completion/suggestion_builder.dart
1313
lib/utilities/completion/type_member_contributor.dart
14-
lib/utilities/range_factory.dart
1514
test/src/utilities/change_builder/change_builder_dart_test.dart
1615
test/src/utilities/completion/completion_target_test.dart
1716
test/src/utilities/visitors/local_declaration_visitor_test.dart
1817
test/utilities/analyzer_converter_test.dart
19-
test/utilities/range_factory_test.dart

pkg/analyzer_plugin/lib/utilities/range_factory.dart

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
import 'package:analyzer/dart/ast/ast.dart';
66
import 'package:analyzer/dart/ast/syntactic_entity.dart';
77
import 'package:analyzer/dart/ast/token.dart';
8-
import 'package:analyzer/dart/element/element.dart';
98
import 'package:analyzer/dart/element/element2.dart';
109
import 'package:analyzer/error/error.dart';
1110
import 'package:analyzer/source/source_range.dart';
@@ -96,11 +95,6 @@ class RangeFactory {
9695
return startOffsetEndOffset(startOffset, endOffset);
9796
}
9897

99-
/// Return a source range that covers the name of the given [element].
100-
SourceRange elementName(Element element) {
101-
return SourceRange(element.nameOffset, element.nameLength);
102-
}
103-
10498
/// Return a source range that starts at the end of [leftEntity] and ends at
10599
/// the end of [rightEntity].
106100
SourceRange endEnd(SyntacticEntity leftEntity, SyntacticEntity rightEntity) {

pkg/analyzer_plugin/pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: analyzer_plugin
22
description: A framework and support code for building plugins for the analysis server.
3-
version: 0.12.0
3+
version: 0.13.0-dev
44
repository: https://github.com/dart-lang/sdk/tree/main/pkg/analyzer_plugin
55

66
environment:

pkg/analyzer_plugin/test/utilities/range_factory_test.dart

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -508,12 +508,6 @@ class B {}
508508
''');
509509
}
510510

511-
Future<void> test_elementName() async {
512-
await resolveTestCode('class ABC {}');
513-
var element = findElement.class_('ABC');
514-
expect(range.elementName(element), SourceRange(6, 3));
515-
}
516-
517511
Future<void> test_endEnd() async {
518512
await resolveTestCode('main() {}');
519513
var mainFunction = testUnit.declarations[0] as FunctionDeclaration;

0 commit comments

Comments
 (0)