Skip to content

Commit

Permalink
[element model] migrate abstract_single_unit
Browse files Browse the repository at this point in the history
Change-Id: I6d717985cb6d8ddafb0f7d8b9e1428f1c5f1fa21
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/403484
Commit-Queue: Phil Quitslund <[email protected]>
Reviewed-by: Konstantin Shcheglov <[email protected]>
  • Loading branch information
pq authored and Commit Queue committed Jan 7, 2025
1 parent 057426e commit a1f5ee9
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 10 deletions.
1 change: 0 additions & 1 deletion pkg/analysis_server/analyzer_use_new_elements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,5 @@ lib/src/services/refactoring/legacy/refactoring_manager.dart
lib/src/services/refactoring/legacy/rename.dart
lib/src/services/refactoring/legacy/rename_import.dart
lib/src/services/search/element_visitors.dart
test/abstract_single_unit.dart
test/services/refactoring/legacy/abstract_rename.dart
test/services/search/element_visitors_test.dart
10 changes: 3 additions & 7 deletions pkg/analysis_server/test/abstract_single_unit.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

import 'package:analyzer/dart/analysis/results.dart';
import 'package:analyzer/dart/ast/ast.dart';
import 'package:analyzer/dart/element/element.dart';
import 'package:analyzer/dart/element/element2.dart';
import 'package:analyzer/error/error.dart';
import 'package:analyzer/file_system/file_system.dart';
Expand All @@ -13,7 +12,6 @@ import 'package:analyzer/src/test_utilities/find_element.dart';
import 'package:analyzer/src/test_utilities/find_element2.dart';
import 'package:analyzer/src/test_utilities/find_node.dart';
import 'package:analyzer/src/utilities/extensions/analysis_session.dart';
import 'package:analyzer/src/utilities/extensions/element.dart';
import 'package:test/test.dart';

import 'abstract_context.dart';
Expand All @@ -26,13 +24,11 @@ class AbstractSingleUnitTest extends AbstractContextTest {
late ResolvedLibraryResult? testLibraryResult;
late ResolvedUnitResult testAnalysisResult;
late CompilationUnit testUnit;
late CompilationUnitElement testUnitElement;
late LibraryElement testLibraryElement;
late FindNode findNode;
late FindElement findElement;
late FindElement2 findElement2;

LibraryElement2 get testLibraryElement2 => testLibraryElement.asElement2;
late LibraryElement2 testLibraryElement;

void addTestSource(String code) {
testCode = code;
Expand Down Expand Up @@ -84,8 +80,8 @@ class AbstractSingleUnitTest extends AbstractContextTest {
isEmpty,
);
}
testUnitElement = testUnit.declaredElement!;
testLibraryElement = testUnitElement.library;

testLibraryElement = testUnit.declaredFragment!.element;
findNode = FindNode(testCode, testUnit);
findElement = FindElement(testUnit);
findElement2 = FindElement2(testUnit);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,7 @@ import 'package:ddd/ddd.dart';
await addLibraryImports(
testAnalysisResult.session,
change,
testLibraryElement2,
testLibraryElement,
newLibraries.toSet(),
);
var testEdit = change.getFileEdit(testFile.path);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,6 @@ part of the.new.name;
}

void _createRenameRefactoring() {
createRenameRefactoringForElement2(testLibraryElement2);
createRenameRefactoringForElement2(testLibraryElement);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

import 'package:analysis_server/src/services/search/element_visitors.dart';
import 'package:analyzer/dart/element/element.dart';
import 'package:analyzer/src/utilities/extensions/element.dart';
import 'package:test/test.dart';
import 'package:test_reflective_loader/test_reflective_loader.dart';

Expand All @@ -17,6 +18,8 @@ void main() {

@reflectiveTest
class FindElementByNameOffsetTest extends AbstractSingleUnitTest {
Element get testUnitElement => testLibraryElement.asElement;

Future<void> test_class() async {
await resolveTestCode(r'''
class AAA {}
Expand Down

0 comments on commit a1f5ee9

Please sign in to comment.