Skip to content

Commit c0bca2c

Browse files
committed
Elements. Build all fragments first, then build elements.
Main changes: 1. Separating `FragmentBuilder` and `ElementBuilder`. I removed `augmentation.dart` and its builders, because now it is implemented in the new `ElementBuilder`. 2. Fragments are not given actual `Reference` objects anymore, there might be some in the current state, but I will go over this in the future and remove them completely. 3. Writing and reading elements also happens in two stages: first fragments, then elements. Each fragment in the summary is given unique ID, and during writing / reading elements we use these ID to locate fragments and create elements around them. 4. Lazy loading of `ClassElement` members is simplified and generalized, could be potentially applied to any `InstanceElement`. Maybe use also in mixins, which are used somewhat often in Flutter. 5. There are slight changes to tests, mostly to the better, sometime a bit reordering, a couple of new tests. There is some dirty code added, especially around patching types for getters, setters, and their fragments. I plan to clean this in future CLs as I move toward better implementation, and from using fragments where this is wrong. Change-Id: I1e4bf2a3b7ff45f1dba133797e85cd70aa729c11 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/433180 Reviewed-by: Brian Wilkerson <[email protected]> Reviewed-by: Paul Berry <[email protected]> Commit-Queue: Konstantin Shcheglov <[email protected]>
1 parent eff3522 commit c0bca2c

File tree

74 files changed

+4566
-3991
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

74 files changed

+4566
-3991
lines changed

pkg/analysis_server/lib/src/status/utilities/element_writer.dart

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,13 +52,14 @@ class ElementWriter with TreeWriter {
5252
properties['isValidMixin'] = element.isValidMixin;
5353
}
5454
}
55-
if (firstFragment is ConstFieldFragmentImpl) {
55+
if (firstFragment is FieldFragmentImpl) {
5656
properties['evaluationResult'] = firstFragment.evaluationResult;
5757
}
58-
if (firstFragment is ConstLocalVariableFragmentImpl) {
58+
if (firstFragment is ConstLocalVariableFragmentImpl &&
59+
firstFragment.constantInitializer != null) {
5960
properties['evaluationResult'] = firstFragment.evaluationResult;
6061
}
61-
if (firstFragment is ConstTopLevelVariableFragmentImpl) {
62+
if (firstFragment is TopLevelVariableFragmentImpl) {
6263
properties['evaluationResult'] = firstFragment.evaluationResult;
6364
}
6465
if (element is ConstructorElement) {

pkg/analysis_server/test/analysis/get_hover_test.dart

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -897,6 +897,7 @@ void f(A a) {
897897
expect(hover.propagatedType, isNull);
898898
}
899899

900+
@FailingTest() // TODO(scheglov): implement augmentation
900901
Future<void>
901902
test_constructorInvocation_referenceFromAugmentation_default() async {
902903
var file = newFile('$testPackageLibPath/a.dart', '''
@@ -926,6 +927,7 @@ class C {
926927
expect(hover.staticType, isNull);
927928
}
928929

930+
@FailingTest() // TODO(scheglov): implement augmentation
929931
Future<void>
930932
test_constructorInvocation_referenceFromAugmentation_named() async {
931933
var file = newFile('$testPackageLibPath/a.dart', '''

pkg/analysis_server/test/analysis/notification_implemented_test.dart

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -472,7 +472,6 @@ class B extends A {}
472472
assertHasImplementedMember('m()');
473473
}
474474

475-
@FailingTest() // TODO(scheglov): implement augmentation
476475
Future<void> test_ofClass_byClass_method_inAugmented() async {
477476
newFile('$testPackageLibPath/b.dart', '''
478477
part 'test.dart';

pkg/analysis_server/test/analysis/notification_navigation_test.dart

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -446,7 +446,6 @@ class A {
446446
assertHasTarget('bar', targetFile: aFile);
447447
}
448448

449-
@FailingTest() // TODO(scheglov): implement augmentation
450449
Future<void> test_augmentation_within_augment() async {
451450
addTestFile(r'''
452451
part of 'a.dart';
@@ -497,7 +496,6 @@ void f() {
497496
assertHasTarget('named', targetFile: aFile);
498497
}
499498

500-
@FailingTest() // TODO(scheglov): implement augmentation
501499
Future<void> test_class_augmentation_method() async {
502500
var aFile = newFile(augmentFilePath, r'''
503501
part of 'test.dart';

pkg/analysis_server/test/analysis/notification_overrides_test.dart

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -540,7 +540,6 @@ class C extends B {
540540
assertNoInterfaceMembers();
541541
}
542542

543-
@FailingTest() // TODO(scheglov): implement augmentation
544543
Future<void> test_class_super_method_overriddenFromAugmentation() async {
545544
var augmentation = newFile('$testPackageLibPath/a.dart', '''
546545
part of 'test.dart';

pkg/analysis_server/test/lsp/augmentation_test.dart

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ augment class [!A!] {}
6262
''');
6363
}
6464

65+
@SkippedTest() // TODO(scheglov): implement augmentation
6566
Future<void> test_constructor_body_augmentationToAugmentation() async {
6667
await verifyGoToAugmentation('''
6768
class A {
@@ -80,6 +81,7 @@ augment class A {
8081
''');
8182
}
8283

84+
@SkippedTest() // TODO(scheglov): implement augmentation
8385
Future<void> test_constructor_body_declarationToAugmentation() async {
8486
await verifyGoToAugmentation('''
8587
class A {
@@ -94,6 +96,7 @@ augment class A {
9496
''');
9597
}
9698

99+
@SkippedTest() // TODO(scheglov): implement augmentation
97100
Future<void> test_constructor_name_augmentationToAugmentation() async {
98101
await verifyGoToAugmentation('''
99102
class A {
@@ -110,6 +113,7 @@ augment class A {
110113
''');
111114
}
112115

116+
@SkippedTest() // TODO(scheglov): implement augmentation
113117
Future<void> test_constructor_name_declarationToAugmentation() async {
114118
await verifyGoToAugmentation('''
115119
class A {

pkg/analysis_server/test/lsp/signature_help_test.dart

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -337,7 +337,6 @@ void f(int a, int b) {
337337
);
338338
}
339339

340-
@FailingTest() // TODO(scheglov): implement augmentation
341340
Future<void> test_augmentation_method() async {
342341
var content = '''
343342
part 'a.dart';

pkg/analysis_server/test/lsp/super_test.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ class B^ extends A {}
3131
);
3232
}
3333

34+
@SkippedTest() // TODO(scheglov): implement augmentation
3435
Future<void> test_augmentation_constructor() async {
3536
await verifyGoToSuper(
3637
TestCode.parse('''

pkg/analysis_server/test/src/computer/call_hierarchy_computer_test.dart

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -764,7 +764,6 @@ class Foo {
764764
);
765765
}
766766

767-
@FailingTest() // TODO(scheglov): implement augmentation
768767
Future<void> test_methodCall_to_augmentation() async {
769768
var code = TestCode.parse('''
770769
part 'other.dart';
@@ -2544,7 +2543,6 @@ class Foo {
25442543
);
25452544
}
25462545

2547-
@FailingTest() // TODO(scheglov): implement augmentation
25482546
Future<void> test_method_from_augmentation() async {
25492547
var code = TestCode.parse('''
25502548
part 'other.dart';

pkg/analyzer/lib/src/dart/analysis/driver.dart

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ testFineAfterLibraryAnalyzerHook;
110110
// TODO(scheglov): Clean up the list of implicitly analyzed files.
111111
class AnalysisDriver {
112112
/// The version of data format, should be incremented on every format change.
113-
static const int DATA_VERSION = 475;
113+
static const int DATA_VERSION = 476;
114114

115115
/// The number of exception contexts allowed to write. Once this field is
116116
/// zero, we stop writing any new exception contexts in this process.
@@ -604,9 +604,7 @@ class AnalysisDriver {
604604
required List<Uri> uriList,
605605
PackageBundleSdk? packageBundleSdk,
606606
}) async {
607-
var elementFactory = libraryContext.elementFactory;
608-
609-
var bundleWriter = BundleWriter(elementFactory.dynamicRef);
607+
var bundleWriter = BundleWriter();
610608
var packageBundleBuilder = PackageBundleBuilder();
611609

612610
for (var uri in uriList) {

0 commit comments

Comments
 (0)