From 8785c4e000167376f57aaed7ce1d016def2b11ff Mon Sep 17 00:00:00 2001 From: Konstantin Shcheglov Date: Wed, 8 Jan 2025 14:46:17 -0800 Subject: [PATCH] Elements. Migrate lib/utilities/range_factory.dart Change-Id: I218603ef0f3a9eae8bde3889cb22fa7f59000e38 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/403623 Commit-Queue: Konstantin Shcheglov Reviewed-by: Brian Wilkerson Reviewed-by: Phil Quitslund --- .../src/services/refactoring/legacy/rename.dart | 16 ---------------- pkg/analyzer_plugin/CHANGELOG.md | 3 +++ .../analyzer_use_new_elements.txt | 2 -- .../lib/utilities/range_factory.dart | 6 ------ pkg/analyzer_plugin/pubspec.yaml | 2 +- .../test/utilities/range_factory_test.dart | 6 ------ 6 files changed, 4 insertions(+), 31 deletions(-) diff --git a/pkg/analysis_server/lib/src/services/refactoring/legacy/rename.dart b/pkg/analysis_server/lib/src/services/refactoring/legacy/rename.dart index 06790109c944..7083917b825c 100644 --- a/pkg/analysis_server/lib/src/services/refactoring/legacy/rename.dart +++ b/pkg/analysis_server/lib/src/services/refactoring/legacy/rename.dart @@ -30,14 +30,6 @@ class RenameProcessor { this.newName, ); - /// Add the edit that updates the [element] declaration. - void addDeclarationEdit(Element? element) { - if (element != null && workspace.containsElement(element)) { - var edit = newSourceEdit_range(range.elementName(element), newName); - doSourceChange_addElementEdit(change, element, edit); - } - } - /// Add the edit that updates the [element] declaration. void addDeclarationEdit2(Element2? element) { if (element == null) { @@ -72,14 +64,6 @@ class RenameProcessor { } } - /// Update the [element] declaration and reference to it. - Future renameElement(Element element) { - addDeclarationEdit(element); - return workspace.searchEngine - .searchReferences(element.asElement2!) - .then(addReferenceEdits); - } - /// Update the [element] declaration and references to it. Future renameElement2(Element2 element) async { addDeclarationEdit2(element); diff --git a/pkg/analyzer_plugin/CHANGELOG.md b/pkg/analyzer_plugin/CHANGELOG.md index 1ea0de817540..8e2ea322aec9 100644 --- a/pkg/analyzer_plugin/CHANGELOG.md +++ b/pkg/analyzer_plugin/CHANGELOG.md @@ -1,3 +1,6 @@ +## 0.13.0-dev +- Remove `elementName()` from `RangeFactory`. Use `fragmentName()` instead. + ## 0.12.0 - Breaking changes to `DartFileEditBuilder`: `convertFunctionFromSyncToAsync` and `replaceTypeWithFuture`. diff --git a/pkg/analyzer_plugin/analyzer_use_new_elements.txt b/pkg/analyzer_plugin/analyzer_use_new_elements.txt index 12cbae2cf056..4eaeceb55c45 100644 --- a/pkg/analyzer_plugin/analyzer_use_new_elements.txt +++ b/pkg/analyzer_plugin/analyzer_use_new_elements.txt @@ -11,9 +11,7 @@ lib/utilities/change_builder/change_builder_dart.dart lib/utilities/completion/inherited_reference_contributor.dart lib/utilities/completion/suggestion_builder.dart lib/utilities/completion/type_member_contributor.dart -lib/utilities/range_factory.dart test/src/utilities/change_builder/change_builder_dart_test.dart test/src/utilities/completion/completion_target_test.dart test/src/utilities/visitors/local_declaration_visitor_test.dart test/utilities/analyzer_converter_test.dart -test/utilities/range_factory_test.dart diff --git a/pkg/analyzer_plugin/lib/utilities/range_factory.dart b/pkg/analyzer_plugin/lib/utilities/range_factory.dart index 116c8cb8a564..1e3756f7b175 100644 --- a/pkg/analyzer_plugin/lib/utilities/range_factory.dart +++ b/pkg/analyzer_plugin/lib/utilities/range_factory.dart @@ -5,7 +5,6 @@ import 'package:analyzer/dart/ast/ast.dart'; import 'package:analyzer/dart/ast/syntactic_entity.dart'; import 'package:analyzer/dart/ast/token.dart'; -import 'package:analyzer/dart/element/element.dart'; import 'package:analyzer/dart/element/element2.dart'; import 'package:analyzer/error/error.dart'; import 'package:analyzer/source/source_range.dart'; @@ -96,11 +95,6 @@ class RangeFactory { return startOffsetEndOffset(startOffset, endOffset); } - /// Return a source range that covers the name of the given [element]. - SourceRange elementName(Element element) { - return SourceRange(element.nameOffset, element.nameLength); - } - /// Return a source range that starts at the end of [leftEntity] and ends at /// the end of [rightEntity]. SourceRange endEnd(SyntacticEntity leftEntity, SyntacticEntity rightEntity) { diff --git a/pkg/analyzer_plugin/pubspec.yaml b/pkg/analyzer_plugin/pubspec.yaml index e036b35c0892..bbcca2d0a90e 100644 --- a/pkg/analyzer_plugin/pubspec.yaml +++ b/pkg/analyzer_plugin/pubspec.yaml @@ -1,6 +1,6 @@ name: analyzer_plugin description: A framework and support code for building plugins for the analysis server. -version: 0.12.0 +version: 0.13.0-dev repository: https://github.com/dart-lang/sdk/tree/main/pkg/analyzer_plugin environment: diff --git a/pkg/analyzer_plugin/test/utilities/range_factory_test.dart b/pkg/analyzer_plugin/test/utilities/range_factory_test.dart index 62dc34ed25e0..58b95c965b5b 100644 --- a/pkg/analyzer_plugin/test/utilities/range_factory_test.dart +++ b/pkg/analyzer_plugin/test/utilities/range_factory_test.dart @@ -508,12 +508,6 @@ class B {} '''); } - Future test_elementName() async { - await resolveTestCode('class ABC {}'); - var element = findElement.class_('ABC'); - expect(range.elementName(element), SourceRange(6, 3)); - } - Future test_endEnd() async { await resolveTestCode('main() {}'); var mainFunction = testUnit.declarations[0] as FunctionDeclaration;