Skip to content

Commit

Permalink
[element model] migrate ``session_helper_test
Browse files Browse the repository at this point in the history
Change-Id: I04cc518df418d5203a5c2f9a3f55f919ccf1b6a9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/401942
Reviewed-by: Konstantin Shcheglov <[email protected]>
Commit-Queue: Phil Quitslund <[email protected]>
  • Loading branch information
pq authored and Commit Queue committed Dec 19, 2024
1 parent 3b58e14 commit dcfdeb9
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 16 deletions.
1 change: 0 additions & 1 deletion pkg/analyzer/analyzer_use_new_elements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,6 @@ test/id_tests/type_constraint_generation_test.dart
test/src/dart/analysis/index_test.dart
test/src/dart/analysis/result_printer.dart
test/src/dart/analysis/results/get_element_declaration_test.dart
test/src/dart/analysis/session_helper_test.dart
test/src/dart/analysis/session_test.dart
test/src/dart/ast/element_locator_test.dart
test/src/dart/constant/evaluation_test.dart
Expand Down
30 changes: 15 additions & 15 deletions pkg/analyzer/test/src/dart/analysis/session_helper_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ int v = 0;
''');
String uri = file.toUri().toString();

var element = (await helper.getClass(uri, 'C'))!;
var element = (await helper.getClass2(uri, 'C'))!;
expect(element.displayName, 'C');
}

Expand All @@ -44,7 +44,7 @@ int v = 0;
''');
String uri = file.toUri().toString();

var element = await helper.getClass(uri, 'v');
var element = await helper.getClass2(uri, 'v');
expect(element, isNull);
}

Expand All @@ -57,7 +57,7 @@ export 'a.dart';
''');
String bUri = bFile.toUri().toString();

var element = (await helper.getClass(bUri, 'A'))!;
var element = (await helper.getClass2(bUri, 'A'))!;
expect(element.displayName, 'A');
}

Expand All @@ -70,16 +70,16 @@ import 'a.dart';
''');
String bUri = bFile.toUri().toString();

var element = await helper.getClass(bUri, 'A');
var element = await helper.getClass2(bUri, 'A');
expect(element, isNull);
}

test_getElementDeclaration_class() async {
await resolveTestCode(r'''
class A {}
''');
var element = findElement.class_('A');
var result = (await helper.getElementDeclaration(element))!;
var element = findElement2.class_('A');
var result = (await helper.getElementDeclaration2(element.firstFragment))!;
var node = result.node as ClassDeclaration;
expect(node.name.lexeme, 'A');
}
Expand All @@ -89,8 +89,8 @@ class A {}
class A {}
class B {}
''');
var element = findNode.classDeclaration('A').declaredElement!;
var resolvedUnit = (await helper.getResolvedUnitByElement(element))!;
var element = findNode.classDeclaration('A').declaredFragment!.element;
var resolvedUnit = (await helper.getResolvedUnitByElement2(element))!;
expect(resolvedUnit.unit.declarations, hasLength(2));
}

Expand All @@ -100,7 +100,7 @@ int get a => 0;
''');
String uri = file.toUri().toString();

var element = (await helper.getTopLevelPropertyAccessor(uri, 'a'))!;
var element = (await helper.getTopLevelPropertyAccessor2(uri, 'a'))!;
expect(element.kind, ElementKind.GETTER);
expect(element.displayName, 'a');
}
Expand All @@ -111,7 +111,7 @@ set a(_) {}
''');
String uri = file.toUri().toString();

var element = (await helper.getTopLevelPropertyAccessor(uri, 'a='))!;
var element = (await helper.getTopLevelPropertyAccessor2(uri, 'a='))!;
expect(element.kind, ElementKind.SETTER);
expect(element.displayName, 'a');
}
Expand All @@ -122,7 +122,7 @@ int a;
''');
String uri = file.toUri().toString();

var element = (await helper.getTopLevelPropertyAccessor(uri, 'a'))!;
var element = (await helper.getTopLevelPropertyAccessor2(uri, 'a'))!;
expect(element.kind, ElementKind.GETTER);
expect(element.displayName, 'a');
}
Expand All @@ -136,7 +136,7 @@ export 'a.dart';
''');
String bUri = bFile.toUri().toString();

var element = (await helper.getTopLevelPropertyAccessor(bUri, 'a'))!;
var element = (await helper.getTopLevelPropertyAccessor2(bUri, 'a'))!;
expect(element.kind, ElementKind.GETTER);
expect(element.displayName, 'a');
}
Expand All @@ -150,7 +150,7 @@ import 'a.dart';
''');
String bUri = bFile.toUri().toString();

var element = await helper.getTopLevelPropertyAccessor(bUri, 'a');
var element = await helper.getTopLevelPropertyAccessor2(bUri, 'a');
expect(element, isNull);
}

Expand All @@ -160,7 +160,7 @@ int a;
''');
String uri = file.toUri().toString();

var element = await helper.getTopLevelPropertyAccessor(uri, 'b');
var element = await helper.getTopLevelPropertyAccessor2(uri, 'b');
expect(element, isNull);
}

Expand All @@ -170,7 +170,7 @@ int a() {}
''');
String uri = file.toUri().toString();

var element = await helper.getTopLevelPropertyAccessor(uri, 'a');
var element = await helper.getTopLevelPropertyAccessor2(uri, 'a');
expect(element, isNull);
}
}

0 comments on commit dcfdeb9

Please sign in to comment.