Version 2.17.0-102.0.dev
Merge commit '65d7aa3b49dbbf6738d00594682e5adfb711d5bf' into 'dev'
diff --git a/pkg/analysis_server/lib/src/computer/computer_highlights.dart b/pkg/analysis_server/lib/src/computer/computer_highlights.dart
index df18a65..0711fd6 100644
--- a/pkg/analysis_server/lib/src/computer/computer_highlights.dart
+++ b/pkg/analysis_server/lib/src/computer/computer_highlights.dart
@@ -253,8 +253,7 @@
// prepare type
HighlightRegionType? type;
if (element is FieldElement) {
- var enclosingElement = element.enclosingElement;
- if (enclosingElement is ClassElement && enclosingElement.isEnum) {
+ if (element.isEnumConstant) {
type = HighlightRegionType.ENUM_CONSTANT;
} else if (element.isStatic) {
type = HighlightRegionType.STATIC_FIELD_DECLARATION;
@@ -268,12 +267,12 @@
}
if (element is PropertyAccessorElement) {
var accessor = element;
- var enclosingElement = element.enclosingElement;
- if (accessor.variable is TopLevelVariableElement) {
+ var variable = accessor.variable;
+ if (variable is TopLevelVariableElement) {
type = accessor.isGetter
? HighlightRegionType.TOP_LEVEL_GETTER_REFERENCE
: HighlightRegionType.TOP_LEVEL_SETTER_REFERENCE;
- } else if (enclosingElement is ClassElement && enclosingElement.isEnum) {
+ } else if (variable is FieldElement && variable.isEnumConstant) {
type = HighlightRegionType.ENUM_CONSTANT;
} else if (accessor.isStatic) {
type = accessor.isGetter
@@ -698,6 +697,15 @@
}
@override
+ void visitConstructorSelector(ConstructorSelector node) {
+ computer._addRegion_node(
+ node.name,
+ HighlightRegionType.CONSTRUCTOR,
+ );
+ node.visitChildren(this);
+ }
+
+ @override
void visitContinueStatement(ContinueStatement node) {
computer._addRegion_token(node.continueKeyword, HighlightRegionType.KEYWORD,
semanticTokenModifiers: {CustomSemanticTokenModifiers.control});
@@ -727,6 +735,15 @@
}
@override
+ void visitEnumConstantDeclaration(EnumConstantDeclaration node) {
+ computer._addRegion_node(
+ node.name,
+ HighlightRegionType.ENUM_CONSTANT,
+ );
+ node.visitChildren(this);
+ }
+
+ @override
void visitEnumDeclaration(EnumDeclaration node) {
computer._addRegion_token(node.enumKeyword, HighlightRegionType.KEYWORD);
super.visitEnumDeclaration(node);
diff --git a/pkg/analysis_server/lib/src/services/completion/dart/keyword_contributor.dart b/pkg/analysis_server/lib/src/services/completion/dart/keyword_contributor.dart
index f7d945a..94c4ede 100644
--- a/pkg/analysis_server/lib/src/services/completion/dart/keyword_contributor.dart
+++ b/pkg/analysis_server/lib/src/services/completion/dart/keyword_contributor.dart
@@ -315,6 +315,20 @@
@override
void visitFieldDeclaration(FieldDeclaration node) {
+ if (request.opType.completionLocation == 'FieldDeclaration_static') {
+ _addSuggestion(Keyword.CONST);
+ _addSuggestion(Keyword.DYNAMIC);
+ _addSuggestion(Keyword.FINAL);
+ _addSuggestion(Keyword.LATE);
+ return;
+ }
+
+ if (request.opType.completionLocation == 'FieldDeclaration_static_late') {
+ _addSuggestion(Keyword.DYNAMIC);
+ _addSuggestion(Keyword.FINAL);
+ return;
+ }
+
var fields = node.fields;
if (entity != fields) {
return;
@@ -336,6 +350,9 @@
request.featureSet.isEnabled(Feature.non_nullable)) {
_addSuggestion(Keyword.LATE);
}
+ if (node.fields.type == null) {
+ _addSuggestion(Keyword.DYNAMIC);
+ }
if (!node.isStatic) {
_addSuggestion(Keyword.STATIC);
}
diff --git a/pkg/analysis_server/test/analysis/notification_highlights2_test.dart b/pkg/analysis_server/test/analysis/notification_highlights2_test.dart
index ed4a472..3b7c79d 100644
--- a/pkg/analysis_server/test/analysis/notification_highlights2_test.dart
+++ b/pkg/analysis_server/test/analysis/notification_highlights2_test.dart
@@ -656,9 +656,164 @@
assertHasRegion(HighlightRegionType.INSTANCE_SETTER_REFERENCE, 'f = 1');
}
- Future<void> test_ENUM() async {
+ Future<void> test_enum_constant() async {
+ addTestFile('''
+enum MyEnum {AAA, BBB}
+
+void f() {
+ MyEnum.AAA;
+ MyEnum.BBB;
+}
+''');
+ await prepareHighlights();
+ assertHasRegion(HighlightRegionType.ENUM_CONSTANT, 'AAA, ');
+ assertHasRegion(HighlightRegionType.ENUM_CONSTANT, 'BBB}');
+ assertHasRegion(HighlightRegionType.ENUM_CONSTANT, 'AAA;');
+ assertHasRegion(HighlightRegionType.ENUM_CONSTANT, 'BBB;');
+ }
+
+ Future<void> test_enum_constructor() async {
+ addTestFile('''
+const a = 0;
+
+enum E<T> {
+ v<int>.named(a); // 1
+ E.named(T a); // 2
+}
+''');
+ await prepareHighlights();
+ assertHasRegion(HighlightRegionType.ENUM_CONSTANT, 'v<');
+ assertHasRegion(HighlightRegionType.CLASS, 'int>');
+ assertHasRegion(HighlightRegionType.CONSTRUCTOR, 'named(a)');
+ assertHasRegion(HighlightRegionType.TOP_LEVEL_GETTER_REFERENCE, 'a); // 1');
+ assertHasRegion(HighlightRegionType.ENUM, 'E.named');
+ assertHasRegion(HighlightRegionType.CONSTRUCTOR, 'named(T');
+ assertHasRegion(HighlightRegionType.TYPE_PARAMETER, 'T a');
+ assertHasRegion(HighlightRegionType.PARAMETER_DECLARATION, 'a); // 2');
+ }
+
+ Future<void> test_enum_field_instance() async {
+ addTestFile('''
+enum E {
+ v;
+ final int a = 0;
+ E(this.a);
+}
+
+void f(E e) {
+ e.a;
+}
+''');
+ await prepareHighlights();
+ assertHasRegion(HighlightRegionType.CLASS, 'int ');
+ assertHasRegion(HighlightRegionType.INSTANCE_FIELD_DECLARATION, 'a = 0');
+ assertHasRegion(HighlightRegionType.PARAMETER_DECLARATION, 'a);');
+ assertHasRegion(HighlightRegionType.INSTANCE_GETTER_REFERENCE, 'a;');
+ }
+
+ Future<void> test_enum_field_static() async {
+ addTestFile('''
+enum E {
+ v;
+ static final int a = 0;
+}
+
+void f() {
+ E.a;
+}
+''');
+ await prepareHighlights();
+ assertHasRegion(HighlightRegionType.CLASS, 'int ');
+ assertHasRegion(HighlightRegionType.STATIC_FIELD_DECLARATION, 'a = 0');
+ assertHasRegion(HighlightRegionType.STATIC_GETTER_REFERENCE, 'a;');
+ }
+
+ Future<void> test_enum_getter_instance() async {
+ addTestFile('''
+enum E {
+ v;
+ int get foo => 0;
+}
+
+void f(E e) {
+ e.foo;
+}
+''');
+ await prepareHighlights();
+ assertHasRegion(HighlightRegionType.CLASS, 'int get');
+ assertHasRegion(HighlightRegionType.INSTANCE_GETTER_DECLARATION, 'foo =>');
+ assertHasRegion(HighlightRegionType.INSTANCE_GETTER_REFERENCE, 'foo;');
+ }
+
+ Future<void> test_enum_getter_static() async {
+ addTestFile('''
+enum E {
+ v;
+ static int get foo => 0;
+}
+
+void f() {
+ E.foo;
+}
+''');
+ await prepareHighlights();
+ assertHasRegion(HighlightRegionType.CLASS, 'int get');
+ assertHasRegion(HighlightRegionType.STATIC_GETTER_DECLARATION, 'foo =>');
+ assertHasRegion(HighlightRegionType.STATIC_GETTER_REFERENCE, 'foo;');
+ }
+
+ Future<void> test_enum_method_instance() async {
+ addTestFile('''
+enum E {
+ v;
+ int foo(int a) {
+ return a;
+ }
+}
+
+void f(E e) {
+ e.foo();
+ e.foo;
+}
+''');
+ await prepareHighlights();
+ assertHasRegion(HighlightRegionType.CLASS, 'int foo');
+ assertHasRegion(HighlightRegionType.INSTANCE_METHOD_DECLARATION, 'foo(int');
+ assertHasRegion(HighlightRegionType.CLASS, 'int a');
+ assertHasRegion(HighlightRegionType.PARAMETER_DECLARATION, 'a)');
+ assertHasRegion(HighlightRegionType.PARAMETER_REFERENCE, 'a;');
+ assertHasRegion(HighlightRegionType.INSTANCE_METHOD_REFERENCE, 'foo();');
+ assertHasRegion(HighlightRegionType.INSTANCE_METHOD_TEAR_OFF, 'foo;');
+ }
+
+ Future<void> test_enum_method_static() async {
+ addTestFile('''
+enum E {
+ v;
+ static int foo(int a) {
+ return a;
+ }
+}
+
+void f() {
+ E.foo();
+ E.foo;
+}
+''');
+ await prepareHighlights();
+ assertHasRegion(HighlightRegionType.CLASS, 'int foo');
+ assertHasRegion(HighlightRegionType.STATIC_METHOD_DECLARATION, 'foo(int');
+ assertHasRegion(HighlightRegionType.CLASS, 'int a');
+ assertHasRegion(HighlightRegionType.PARAMETER_DECLARATION, 'a)');
+ assertHasRegion(HighlightRegionType.PARAMETER_REFERENCE, 'a;');
+ assertHasRegion(HighlightRegionType.STATIC_METHOD_REFERENCE, 'foo();');
+ assertHasRegion(HighlightRegionType.STATIC_METHOD_TEAR_OFF, 'foo;');
+ }
+
+ Future<void> test_enum_name() async {
addTestFile('''
enum MyEnum {A, B, C}
+
MyEnum value;
''');
await prepareHighlights();
@@ -666,19 +821,50 @@
assertHasRegion(HighlightRegionType.ENUM, 'MyEnum value;');
}
- Future<void> test_ENUM_CONSTANT() async {
+ Future<void> test_enum_setter_instance() async {
addTestFile('''
-enum MyEnum {AAA, BBB}
-void f() {
- print(MyEnum.AAA);
- print(MyEnum.BBB);
+enum E {
+ v;
+ set foo(int _) {}
+}
+
+void f(E e) {
+ e.foo = 0;
}
''');
await prepareHighlights();
- assertHasRegion(HighlightRegionType.ENUM_CONSTANT, 'AAA, ');
- assertHasRegion(HighlightRegionType.ENUM_CONSTANT, 'BBB}');
- assertHasRegion(HighlightRegionType.ENUM_CONSTANT, 'AAA);');
- assertHasRegion(HighlightRegionType.ENUM_CONSTANT, 'BBB);');
+ assertHasRegion(HighlightRegionType.CLASS, 'int _');
+ assertHasRegion(HighlightRegionType.INSTANCE_SETTER_DECLARATION, 'foo(int');
+ assertHasRegion(HighlightRegionType.INSTANCE_SETTER_REFERENCE, 'foo = 0;');
+ }
+
+ Future<void> test_enum_setter_static() async {
+ addTestFile('''
+enum E {
+ v;
+ static set foo(int _) {}
+}
+
+void f() {
+ E.foo = 0;
+}
+''');
+ await prepareHighlights();
+ assertHasRegion(HighlightRegionType.CLASS, 'int _');
+ assertHasRegion(HighlightRegionType.STATIC_SETTER_DECLARATION, 'foo(int');
+ assertHasRegion(HighlightRegionType.STATIC_SETTER_REFERENCE, 'foo = 0;');
+ }
+
+ Future<void> test_enum_typeParameter() async {
+ addTestFile('''
+enum E<T> {
+ v;
+ T? foo() => null;
+}
+''');
+ await prepareHighlights();
+ assertHasRegion(HighlightRegionType.TYPE_PARAMETER, 'T>');
+ assertHasRegion(HighlightRegionType.TYPE_PARAMETER, 'T?');
}
Future<void> test_EXTENSION() async {
diff --git a/pkg/analysis_server/test/analysis/notification_navigation_test.dart b/pkg/analysis_server/test/analysis/notification_navigation_test.dart
index 8ca77d4..d25b5c0 100644
--- a/pkg/analysis_server/test/analysis/notification_navigation_test.dart
+++ b/pkg/analysis_server/test/analysis/notification_navigation_test.dart
@@ -92,6 +92,22 @@
assertHasFileTarget(testFile, offset, length);
}
+ /// TODO(scheglov) Improve target matching.
+ void assertHasTargetInDartCore(String search) {
+ var dartCoreFile = getFile('/sdk/lib/core/core.dart');
+ var dartCoreContent = dartCoreFile.readAsStringSync();
+
+ var offset = dartCoreContent.indexOf(search);
+ expect(offset, isNot(-1));
+
+ if (dartCoreContent.contains(search, offset + search.length)) {
+ fail('Not unique');
+ }
+
+ var length = findIdentifierLength(search);
+ assertHasFileTarget(dartCoreFile.path, offset, length);
+ }
+
/// Validates that there is a target in [testTargets] with [testFile], at the
/// offset of [str] in [testFile], and with the length of [str].
void assertHasTargetString(String str) {
@@ -651,7 +667,7 @@
''');
await prepareNavigation();
assertHasRegion('index');
- assertHasTarget('E {');
+ assertHasTargetInDartCore('index;');
}
Future<void> test_enum_typeParameter() async {
diff --git a/pkg/analysis_server/test/plugin/protocol_dart_test.dart b/pkg/analysis_server/test/plugin/protocol_dart_test.dart
index 708a951..130ca0d 100644
--- a/pkg/analysis_server/test/plugin/protocol_dart_test.dart
+++ b/pkg/analysis_server/test/plugin/protocol_dart_test.dart
@@ -281,24 +281,6 @@
expect(element.flags, Element.FLAG_CONST | Element.FLAG_STATIC);
}
{
- var engineElement = findElement.field('index', of: 'E2');
- // create notification Element
- var element = convertElement(engineElement, withNullability: true);
- expect(element.kind, ElementKind.FIELD);
- expect(element.name, 'index');
- {
- var location = element.location!;
- expect(location.file, testFile);
- expect(location.offset, -1);
- expect(location.length, 'index'.length);
- expect(location.startLine, 1);
- expect(location.startColumn, 0);
- }
- expect(element.parameters, isNull);
- expect(element.returnType, 'int');
- expect(element.flags, Element.FLAG_FINAL);
- }
- {
var engineElement = findElement.field('values', of: 'E2');
// create notification Element
var element = convertElement(engineElement, withNullability: true);
diff --git a/pkg/analysis_server/test/services/completion/dart/completion_check.dart b/pkg/analysis_server/test/services/completion/dart/completion_check.dart
index eeab07a..a7094e8 100644
--- a/pkg/analysis_server/test/services/completion/dart/completion_check.dart
+++ b/pkg/analysis_server/test/services/completion/dart/completion_check.dart
@@ -410,6 +410,18 @@
(selected) => 'withElementClass ${valueStr(selected)}',
);
}
+
+ @useResult
+ CheckTarget<Iterable<CompletionSuggestionForTesting>> get withKindKeyword {
+ var result = value
+ .where((suggestion) =>
+ suggestion.suggestion.kind == CompletionSuggestionKind.KEYWORD)
+ .toList();
+ return nest(
+ result,
+ (selected) => 'withKindKeyword ${valueStr(selected)}',
+ );
+ }
}
extension ElementExtension on CheckTarget<Element> {
diff --git a/pkg/analysis_server/test/services/completion/dart/keyword_contributor_test.dart b/pkg/analysis_server/test/services/completion/dart/keyword_contributor_test.dart
index c2c05ab..1918e2d 100644
--- a/pkg/analysis_server/test/services/completion/dart/keyword_contributor_test.dart
+++ b/pkg/analysis_server/test/services/completion/dart/keyword_contributor_test.dart
@@ -394,6 +394,7 @@
Keyword.ABSTRACT,
Keyword.CONST,
Keyword.COVARIANT,
+ Keyword.DYNAMIC,
Keyword.EXTERNAL,
Keyword.FINAL
];
diff --git a/pkg/analysis_server/test/services/completion/dart/location/class_body_test.dart b/pkg/analysis_server/test/services/completion/dart/location/class_body_test.dart
new file mode 100644
index 0000000..8d27610
--- /dev/null
+++ b/pkg/analysis_server/test/services/completion/dart/location/class_body_test.dart
@@ -0,0 +1,368 @@
+// Copyright (c) 2022, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+import 'package:analyzer/dart/ast/token.dart';
+import 'package:analyzer_utilities/check/check.dart';
+import 'package:test_reflective_loader/test_reflective_loader.dart';
+
+import '../../../../client/completion_driver_test.dart';
+import '../completion_check.dart';
+
+void main() {
+ defineReflectiveSuite(() {
+ defineReflectiveTests(ClassBodyTest1);
+ defineReflectiveTests(ClassBodyTest2);
+ });
+}
+
+@reflectiveTest
+class ClassBodyTest1 extends AbstractCompletionDriverTest
+ with ClassBodyTestCases {
+ @override
+ TestingCompletionProtocol get protocol => TestingCompletionProtocol.version1;
+}
+
+@reflectiveTest
+class ClassBodyTest2 extends AbstractCompletionDriverTest
+ with ClassBodyTestCases {
+ @override
+ TestingCompletionProtocol get protocol => TestingCompletionProtocol.version2;
+}
+
+mixin ClassBodyTestCases on AbstractCompletionDriverTest {
+ /// It does not really matter which classes we list here, in this test
+ /// suite we only need to know that we suggest classes at all.
+ List<CompletionSuggestionChecker> get sampleClassChecks {
+ return const {
+ 'Object',
+ }.map((name) {
+ return (CompletionSuggestionTarget suggestion) {
+ suggestion
+ ..completion.isEqualTo(name)
+ ..isClass;
+ };
+ }).toList();
+ }
+
+ @override
+ bool get supportsAvailableSuggestions => true;
+
+ Future<void> test_nothing_x() async {
+ await _checkContainers(
+ line: '^',
+ validator: (
+ response, {
+ required bool isClass,
+ required bool isMixin,
+ }) {
+ check(response).suggestions
+ ..withKindKeyword.matchesInAnyOrder(
+ {
+ // TODO(scheglov) Not quite right, without static.
+ Keyword.CONST,
+ if (isClass || isMixin) Keyword.COVARIANT,
+ Keyword.DYNAMIC,
+ // TODO(scheglov) This does not look right, mixin.
+ if (isClass || isMixin) Keyword.FACTORY,
+ Keyword.FINAL,
+ Keyword.GET,
+ Keyword.LATE,
+ Keyword.OPERATOR,
+ Keyword.SET,
+ Keyword.STATIC,
+ Keyword.VAR,
+ Keyword.VOID,
+ }.asKeywordChecks,
+ )
+ ..includesAll(sampleClassChecks);
+ },
+ );
+ }
+
+ Future<void> test_static_const_x() async {
+ await _checkContainers(
+ line: 'static const ^',
+ validator: (
+ response, {
+ required bool isClass,
+ required bool isMixin,
+ }) {
+ check(response).suggestions
+ ..withKindKeyword.matchesInAnyOrder(
+ {
+ Keyword.DYNAMIC,
+ Keyword.VOID,
+ }.asKeywordChecks,
+ )
+ ..includesAll(sampleClassChecks);
+ },
+ );
+ }
+
+ Future<void> test_static_final_Ox() async {
+ await _checkContainers(
+ line: 'static final O^',
+ validator: (
+ response, {
+ required bool isClass,
+ required bool isMixin,
+ }) {
+ if (isProtocolVersion2) {
+ check(response).suggestions
+ ..withKindKeyword.isEmpty
+ ..includesAll(sampleClassChecks);
+ } else {
+ check(response).suggestions
+ ..withKindKeyword.matchesInAnyOrder(
+ {
+ Keyword.DYNAMIC,
+ Keyword.VOID,
+ }.asKeywordChecks,
+ )
+ ..includesAll(sampleClassChecks);
+ }
+ },
+ );
+ }
+
+ Future<void> test_static_final_x() async {
+ await _checkContainers(
+ line: 'static final ^',
+ validator: (
+ response, {
+ required bool isClass,
+ required bool isMixin,
+ }) {
+ check(response).suggestions
+ ..withKindKeyword.matchesInAnyOrder(
+ {
+ Keyword.DYNAMIC,
+ Keyword.VOID,
+ }.asKeywordChecks,
+ )
+ ..includesAll(sampleClassChecks);
+ },
+ );
+ }
+
+ Future<void> test_static_fx() async {
+ await _checkContainers(
+ line: 'static f^',
+ validator: (
+ response, {
+ required bool isClass,
+ required bool isMixin,
+ }) {
+ if (isProtocolVersion2) {
+ check(response).suggestions
+ ..withKindKeyword.matchesInAnyOrder(
+ {
+ Keyword.FINAL,
+ }.asKeywordChecks,
+ )
+ ..includesAll([
+ (suggestion) => suggestion
+ ..completion.isEqualTo('FutureOr')
+ ..isClass,
+ ]);
+ } else {
+ check(response).suggestions
+ ..withKindKeyword.matchesInAnyOrder(
+ {
+ Keyword.ABSTRACT,
+ Keyword.CONST,
+ Keyword.COVARIANT,
+ Keyword.DYNAMIC,
+ Keyword.EXTERNAL,
+ Keyword.FINAL,
+ Keyword.LATE,
+ }.asKeywordChecks,
+ )
+ ..includesAll(sampleClassChecks);
+ }
+ },
+ );
+ }
+
+ Future<void> test_static_late_x() async {
+ await _checkContainers(
+ line: 'static late ^',
+ validator: (
+ response, {
+ required bool isClass,
+ required bool isMixin,
+ }) {
+ check(response).suggestions
+ ..withKindKeyword.matchesInAnyOrder(
+ {
+ Keyword.DYNAMIC,
+ Keyword.FINAL,
+ }.asKeywordChecks,
+ )
+ ..includesAll(sampleClassChecks);
+ },
+ );
+ }
+
+ Future<void> test_static_x() async {
+ await _checkContainers(
+ line: 'static ^',
+ validator: (
+ response, {
+ required bool isClass,
+ required bool isMixin,
+ }) {
+ check(response).suggestions
+ ..withKindKeyword.matchesInAnyOrder(
+ {
+ Keyword.CONST,
+ Keyword.DYNAMIC,
+ Keyword.FINAL,
+ Keyword.LATE,
+ }.asKeywordChecks,
+ )
+ ..includesAll(sampleClassChecks);
+ },
+ );
+ }
+
+ Future<void> test_static_x_name_eq() async {
+ await _checkContainers(
+ line: 'static ^ name = 0;',
+ validator: (
+ response, {
+ required bool isClass,
+ required bool isMixin,
+ }) {
+ check(response).suggestions
+ ..withKindKeyword.matchesInAnyOrder(
+ {
+ // TODO(scheglov) This does not look right.
+ Keyword.ABSTRACT,
+ Keyword.CONST,
+ // TODO(scheglov) This does not look right.
+ Keyword.COVARIANT,
+ Keyword.DYNAMIC,
+ // TODO(scheglov) This does not look right.
+ Keyword.EXTERNAL,
+ Keyword.FINAL,
+ Keyword.LATE,
+ }.asKeywordChecks,
+ )
+ ..includesAll(sampleClassChecks);
+ },
+ );
+ }
+
+ Future<void> test_sx() async {
+ await _checkContainers(
+ line: 's^',
+ validator: (
+ response, {
+ required bool isClass,
+ required bool isMixin,
+ }) {
+ if (isProtocolVersion2) {
+ check(response).suggestions
+ ..withKindKeyword.matchesInAnyOrder(
+ {
+ Keyword.SET,
+ Keyword.STATIC,
+ }.asKeywordChecks,
+ )
+ ..includesAll([
+ (suggestion) => suggestion
+ ..completion.isEqualTo('String')
+ ..isClass,
+ ]);
+ } else {
+ check(response).suggestions
+ ..withKindKeyword.matchesInAnyOrder(
+ {
+ // TODO(scheglov) Not quite right, without static.
+ Keyword.CONST,
+ if (isClass || isMixin) Keyword.COVARIANT,
+ Keyword.DYNAMIC,
+ // TODO(scheglov) This does not look right, mixin.
+ if (isClass || isMixin) Keyword.FACTORY,
+ Keyword.FINAL,
+ Keyword.GET,
+ Keyword.LATE,
+ Keyword.OPERATOR,
+ Keyword.SET,
+ Keyword.STATIC,
+ Keyword.VAR,
+ Keyword.VOID,
+ }.asKeywordChecks,
+ )
+ ..includesAll(sampleClassChecks);
+ }
+ },
+ );
+ }
+
+ Future<void> _checkContainers({
+ required String line,
+ required void Function(
+ CompletionResponseForTesting response, {
+ required bool isClass,
+ required bool isMixin,
+ })
+ validator,
+ }) async {
+ // class
+ {
+ var response = await getTestCodeSuggestions('''
+class A {
+ $line
+}
+''');
+ validator(
+ response,
+ isClass: true,
+ isMixin: false,
+ );
+ }
+ // enum
+ {
+ var response = await getTestCodeSuggestions('''
+enum E {
+ v;
+ $line
+}
+''');
+ validator(
+ response,
+ isClass: false,
+ isMixin: false,
+ );
+ }
+ // extension
+ {
+ var response = await getTestCodeSuggestions('''
+extension on Object {
+ $line
+}
+''');
+ validator(
+ response,
+ isClass: false,
+ isMixin: false,
+ );
+ }
+ // mixin
+ {
+ var response = await getTestCodeSuggestions('''
+mixin M {
+ $line
+}
+''');
+ validator(
+ response,
+ isClass: false,
+ isMixin: true,
+ );
+ }
+ }
+}
diff --git a/pkg/analysis_server/test/services/completion/dart/location/enum_test.dart b/pkg/analysis_server/test/services/completion/dart/location/enum_test.dart
index ad76948..89bc1b5 100644
--- a/pkg/analysis_server/test/services/completion/dart/location/enum_test.dart
+++ b/pkg/analysis_server/test/services/completion/dart/location/enum_test.dart
@@ -38,28 +38,14 @@
''');
check(response).suggestions.matchesInAnyOrder([
- (suggestion) => suggestion.isKeyword(Keyword.WITH),
+ ...{
+ Keyword.WITH,
+ }.asKeywordChecks,
]);
}
}
mixin EnumDeclarationTestCases on AbstractCompletionDriverTest {
- static List<CompletionSuggestionChecker> get _bodyKeywords {
- const keywords = [
- Keyword.CONST,
- Keyword.DYNAMIC,
- Keyword.FINAL,
- Keyword.GET,
- Keyword.LATE,
- Keyword.OPERATOR,
- Keyword.SET,
- Keyword.STATIC,
- Keyword.VAR,
- Keyword.VOID
- ];
- return keywords.asKeywordChecks;
- }
-
@override
bool get supportsAvailableSuggestions => true;
@@ -81,13 +67,11 @@
''');
check(response).suggestions
+ ..withKindKeyword.isEmpty
..includesAll([
(suggestion) => suggestion
..completion.isEqualTo('Object')
..isClass,
- ])
- ..excludesAll([
- (suggestion) => suggestion.isKeywordAny,
]);
}
@@ -99,7 +83,9 @@
''');
check(response).suggestions.matchesInAnyOrder([
- (suggestion) => suggestion.isKeyword(Keyword.WITH),
+ ...{
+ Keyword.WITH,
+ }.asKeywordChecks,
]);
}
@@ -111,8 +97,10 @@
''');
check(response).suggestions.matchesInAnyOrder([
- (suggestion) => suggestion.isKeyword(Keyword.IMPLEMENTS),
- (suggestion) => suggestion.isKeyword(Keyword.WITH),
+ ...{
+ Keyword.IMPLEMENTS,
+ Keyword.WITH,
+ }.asKeywordChecks,
]);
}
@@ -134,8 +122,10 @@
''');
check(response).suggestions.matchesInAnyOrder([
- (suggestion) => suggestion.isKeyword(Keyword.IMPLEMENTS),
- (suggestion) => suggestion.isKeyword(Keyword.WITH),
+ ...{
+ Keyword.IMPLEMENTS,
+ Keyword.WITH,
+ }.asKeywordChecks,
]);
}
@@ -147,7 +137,9 @@
''');
check(response).suggestions.matchesInAnyOrder([
- (suggestion) => suggestion.isKeyword(Keyword.WITH),
+ ...{
+ Keyword.WITH,
+ }.asKeywordChecks,
]);
}
@@ -172,37 +164,6 @@
check(response).suggestions.isEmpty;
}
- Future<void> test_afterSemicolon() async {
- var response = await getTestCodeSuggestions('''
-enum E {
- v;^
-}
-''');
-
- check(response).suggestions.includesAll([
- (suggestion) => suggestion
- ..completion.isEqualTo('Object')
- ..isClass,
- ..._bodyKeywords,
- ]);
- }
-
- Future<void> test_afterSemicolon_beforeVoid() async {
- var response = await getTestCodeSuggestions('''
-enum E {
- v;
- ^void foo() {}
-}
-''');
-
- check(response).suggestions.includesAll([
- (suggestion) => suggestion
- ..completion.isEqualTo('Object')
- ..isClass,
- ..._bodyKeywords,
- ]);
- }
-
Future<void> test_afterWith() async {
var response = await getTestCodeSuggestions('''
enum E with ^ {
@@ -211,13 +172,11 @@
''');
check(response).suggestions
+ ..withKindKeyword.isEmpty
..includesAll([
(suggestion) => suggestion
..completion.isEqualTo('Object')
..isClass,
- ])
- ..excludesAll([
- (suggestion) => suggestion.isKeywordAny,
]);
}
@@ -229,7 +188,9 @@
''');
check(response).suggestions.matchesInAnyOrder([
- (suggestion) => suggestion.isKeyword(Keyword.IMPLEMENTS),
+ ...{
+ Keyword.IMPLEMENTS,
+ }.asKeywordChecks,
]);
}
diff --git a/pkg/analysis_server/test/services/completion/dart/location/test_all.dart b/pkg/analysis_server/test/services/completion/dart/location/test_all.dart
index bd42780..5fc5401 100644
--- a/pkg/analysis_server/test/services/completion/dart/location/test_all.dart
+++ b/pkg/analysis_server/test/services/completion/dart/location/test_all.dart
@@ -4,6 +4,7 @@
import 'package:test_reflective_loader/test_reflective_loader.dart';
+import 'class_body_test.dart' as class_body;
import 'enum_constant_test.dart' as enum_constant;
import 'enum_test.dart' as enum_;
import 'field_formal_parameter_test.dart' as field_formal_parameter;
@@ -13,6 +14,7 @@
/// Tests suggestions produced at specific locations.
void main() {
defineReflectiveSuite(() {
+ class_body.main();
enum_constant.main();
enum_.main();
field_formal_parameter.main();
diff --git a/pkg/analysis_server/test/services/completion/dart/type_member_contributor_test.dart b/pkg/analysis_server/test/services/completion/dart/type_member_contributor_test.dart
index 47000b2..a5d53f4 100644
--- a/pkg/analysis_server/test/services/completion/dart/type_member_contributor_test.dart
+++ b/pkg/analysis_server/test/services/completion/dart/type_member_contributor_test.dart
@@ -1674,6 +1674,8 @@
assertNotSuggested('values');
}
+ /// TODO(scheglov) move this test into contributor independent suite
+ @FailingTest(reason: 'No index, not local anymore')
Future<void> test_enumConst_index() async {
addTestSource('enum E { one, two } void f() {E.one.^}');
await computeSuggestions();
@@ -1684,6 +1686,8 @@
assertNotSuggested('values');
}
+ /// TODO(scheglov) move this test into contributor independent suite
+ @FailingTest(reason: 'No index, not local anymore')
Future<void> test_enumConst_index2() async {
addTestSource('enum E { one, two } void f() {E.one.i^}');
await computeSuggestions();
@@ -1694,6 +1698,8 @@
assertNotSuggested('values');
}
+ /// TODO(scheglov) move this test into contributor independent suite
+ @FailingTest(reason: 'No index, not local anymore')
Future<void> test_enumConst_index3() async {
addTestSource('enum E { one, two } void f() {E.one.^ int g;}');
await computeSuggestions();
diff --git a/pkg/analyzer/lib/src/dart/analysis/driver.dart b/pkg/analyzer/lib/src/dart/analysis/driver.dart
index 2b44892..92e0825 100644
--- a/pkg/analyzer/lib/src/dart/analysis/driver.dart
+++ b/pkg/analyzer/lib/src/dart/analysis/driver.dart
@@ -82,7 +82,7 @@
/// TODO(scheglov) Clean up the list of implicitly analyzed files.
class AnalysisDriver implements AnalysisDriverGeneric {
/// The version of data format, should be incremented on every format change.
- static const int DATA_VERSION = 205;
+ static const int DATA_VERSION = 206;
/// The number of exception contexts allowed to write. Once this field is
/// zero, we stop writing any new exception contexts in this process.
diff --git a/pkg/analyzer/lib/src/dart/element/element.dart b/pkg/analyzer/lib/src/dart/element/element.dart
index 7179b60..e57f2658 100644
--- a/pkg/analyzer/lib/src/dart/element/element.dart
+++ b/pkg/analyzer/lib/src/dart/element/element.dart
@@ -5238,6 +5238,7 @@
Element get nonSynthetic {
if (isSynthetic) {
if (enclosingElement is EnumElementImpl) {
+ // TODO(scheglov) remove 'index'?
if (name == 'index' || name == 'values') {
return enclosingElement;
}
diff --git a/pkg/analyzer/lib/src/summary2/element_builder.dart b/pkg/analyzer/lib/src/summary2/element_builder.dart
index c4deaa9..e159199 100644
--- a/pkg/analyzer/lib/src/summary2/element_builder.dart
+++ b/pkg/analyzer/lib/src/summary2/element_builder.dart
@@ -339,12 +339,6 @@
node.withClause?.accept(this);
node.implementsClause?.accept(this);
- // Build the 'index' field.
- var indexField = ConstFieldElementImpl('index', -1)
- ..isFinal = true
- ..isSynthetic = true;
- holder.addNonSyntheticField(indexField);
-
_withEnclosing(holder, () {
node.typeParameters?.accept(this);
_visitPropertyFirst<FieldDeclaration>(node.members);
@@ -365,7 +359,6 @@
_libraryBuilder.implicitEnumNodes.add(
ImplicitEnumNodes(
element: element,
- indexField: indexField,
valuesTypeNode: valuesTypeNode,
valuesField: valuesField,
),
@@ -808,6 +801,14 @@
element.isGetter = true;
element.isStatic = node.isStatic;
+ // `class Enum {}` in `dart:core` declares `int get index` as abstract.
+ // But the specification says that practically a different class
+ // implementing `Enum` is used as a superclass, so `index` should be
+ // considered to have non-abstract implementation.
+ if (_enclosingContext.isDartCoreEnum && name == 'index') {
+ element.isAbstract = false;
+ }
+
reference = _enclosingContext.addGetter(name, element);
executableElement = element;
@@ -1367,6 +1368,11 @@
this.hasConstConstructor = false,
});
+ bool get isDartCoreEnum {
+ final element = this.element;
+ return element is ClassElementImpl && element.isDartCoreEnum;
+ }
+
Reference addClass(String name, ClassElementImpl element) {
classes.add(element);
return _bindReference('@class', name, element);
diff --git a/pkg/analyzer/lib/src/summary2/library_builder.dart b/pkg/analyzer/lib/src/summary2/library_builder.dart
index 048cdaf..36f7c25 100644
--- a/pkg/analyzer/lib/src/summary2/library_builder.dart
+++ b/pkg/analyzer/lib/src/summary2/library_builder.dart
@@ -22,13 +22,11 @@
class ImplicitEnumNodes {
final EnumElementImpl element;
- final FieldElementImpl indexField;
final ast.NamedTypeImpl valuesTypeNode;
final ConstFieldElementImpl valuesField;
ImplicitEnumNodes({
required this.element,
- required this.indexField,
required this.valuesTypeNode,
required this.valuesField,
});
@@ -134,7 +132,6 @@
for (var enum_ in implicitEnumNodes) {
enum_.element.supertype =
typeProvider.enumType ?? typeProvider.objectType;
- enum_.indexField.type = typeProvider.intType;
var valuesType = typeProvider.listType(
element.typeSystem.instantiateToBounds2(
classElement: enum_.element,
diff --git a/pkg/analyzer/test/src/dart/analysis/index_test.dart b/pkg/analyzer/test/src/dart/analysis/index_test.dart
index 215d184..568de01 100644
--- a/pkg/analyzer/test/src/dart/analysis/index_test.dart
+++ b/pkg/analyzer/test/src/dart/analysis/index_test.dart
@@ -1172,7 +1172,7 @@
ClassElement enumElement = findElement.enum_('MyEnum');
assertThat(enumElement.getGetter('values')!)
..isReferencedAt('values);', true);
- assertThat(enumElement.getGetter('index')!)
+ assertThat(typeProvider.enumElement!.getGetter('index')!)
..isReferencedAt('index);', true);
assertThat(enumElement.getGetter('A')!)..isReferencedAt('A);', true);
assertThat(enumElement.getGetter('B')!)..isReferencedAt('B);', true);
diff --git a/pkg/analyzer/test/src/dart/analysis/search_test.dart b/pkg/analyzer/test/src/dart/analysis/search_test.dart
index 4e4f016..55dc51f 100644
--- a/pkg/analyzer/test/src/dart/analysis/search_test.dart
+++ b/pkg/analyzer/test/src/dart/analysis/search_test.dart
@@ -973,7 +973,7 @@
''');
var enumElement = findElement.enum_('MyEnum');
var main = findElement.function('main');
- await _verifyReferences(enumElement.getField('index')!,
+ await _verifyReferences(typeProvider.enumElement!.getField('index')!,
[_expectIdQ(main, SearchResultKind.READ, 'index);')]);
await _verifyReferences(enumElement.getField('values')!,
[_expectIdQ(main, SearchResultKind.READ, 'values);')]);
diff --git a/pkg/analyzer/test/src/dart/element/element_test.dart b/pkg/analyzer/test/src/dart/element/element_test.dart
index 2b46b93..e39414a 100644
--- a/pkg/analyzer/test/src/dart/element/element_test.dart
+++ b/pkg/analyzer/test/src/dart/element/element_test.dart
@@ -692,8 +692,8 @@
FieldElement b2Element = B.getField('B2')!;
expect(b2Element.isEnumConstant, isTrue);
- FieldElement indexElement = B.getField('index')!;
- expect(indexElement.isEnumConstant, isFalse);
+ FieldElement valuesElement = B.getField('values')!;
+ expect(valuesElement.isEnumConstant, isFalse);
}
}
diff --git a/pkg/analyzer/test/src/dart/resolution/enum_test.dart b/pkg/analyzer/test/src/dart/resolution/enum_test.dart
index edad25c..81e03b3 100644
--- a/pkg/analyzer/test/src/dart/resolution/enum_test.dart
+++ b/pkg/analyzer/test/src/dart/resolution/enum_test.dart
@@ -295,7 +295,6 @@
expect(findElement.field('a').isEnumConstant, isTrue);
expect(findElement.field('b').isEnumConstant, isTrue);
- expect(findElement.field('index').isEnumConstant, isFalse);
expect(findElement.field('values').isEnumConstant, isFalse);
}
@@ -417,7 +416,7 @@
assertPropertyAccess2(
findNode.propertyAccess('index'),
- element: findElement.getter('index', of: 'E'),
+ element: typeProvider.enumElement!.getGetter('index')!,
type: 'int',
);
}
diff --git a/pkg/analyzer/test/src/diagnostics/mixin_application_no_concrete_super_invoked_member_test.dart b/pkg/analyzer/test/src/diagnostics/mixin_application_no_concrete_super_invoked_member_test.dart
index 115f527..77c785a 100644
--- a/pkg/analyzer/test/src/diagnostics/mixin_application_no_concrete_super_invoked_member_test.dart
+++ b/pkg/analyzer/test/src/diagnostics/mixin_application_no_concrete_super_invoked_member_test.dart
@@ -273,6 +273,38 @@
]);
}
+ test_enum_getter_exists() async {
+ await assertNoErrorsInCode(r'''
+mixin M1 {
+ int get foo => 0;
+}
+
+mixin M2 on M1 {
+ void bar() {
+ super.foo;
+ }
+}
+
+enum E with M1, M2 {
+ v
+}
+''');
+ }
+
+ test_enum_getter_index() async {
+ await assertNoErrorsInCode(r'''
+mixin M on Enum {
+ void foo() {
+ super.index;
+ }
+}
+
+enum E with M {
+ v
+}
+''');
+ }
+
test_enum_method() async {
await assertErrorsInCode(r'''
mixin M1 {
@@ -298,6 +330,24 @@
]);
}
+ test_enum_method_exists() async {
+ await assertNoErrorsInCode(r'''
+mixin M1 {
+ void foo() {}
+}
+
+mixin M2 on M1 {
+ void bar() {
+ super.foo();
+ }
+}
+
+enum E with M1, M2 {
+ v
+}
+''');
+ }
+
test_enum_OK_getter_inPreviousMixin() async {
await assertNoErrorsInCode(r'''
mixin M1 {
diff --git a/pkg/analyzer/test/src/summary/resynthesize_common.dart b/pkg/analyzer/test/src/summary/resynthesize_common.dart
index 64ba014..085c1c1 100644
--- a/pkg/analyzer/test/src/summary/resynthesize_common.dart
+++ b/pkg/analyzer/test/src/summary/resynthesize_common.dart
@@ -8390,8 +8390,6 @@
leftBracket: [ @0
rightBracket: ] @0
staticType: List<E>
- synthetic final index @-1
- type: int
constructors
synthetic const @-1
accessors
@@ -8403,8 +8401,6 @@
returnType: E
synthetic static get values @-1
returnType: List<E>
- synthetic get index @-1
- returnType: int
''',
withCodeRanges: true);
}
@@ -13633,8 +13629,6 @@
leftBracket: [ @0
rightBracket: ] @0
staticType: List<E>
- synthetic final index @-1
- type: int
constructors
synthetic const @-1
accessors
@@ -13646,8 +13640,6 @@
returnType: E
synthetic static get values @-1
returnType: List<E>
- synthetic get index @-1
- returnType: int
typeAliases
functionTypeAliasBased F @50
aliasedType: dynamic Function(int, String)
@@ -15925,8 +15917,6 @@
leftBracket: [ @0
rightBracket: ] @0
staticType: List<E>
- synthetic final index @-1
- type: int
constructors
synthetic const @-1
accessors
@@ -15938,8 +15928,6 @@
returnType: E
synthetic static get values @-1
returnType: List<E>
- synthetic get index @-1
- returnType: int
topLevelVariables
static final vValue @23
type: E
@@ -16002,8 +15990,6 @@
leftBracket: [ @0
rightBracket: ] @0
staticType: List<E>
- synthetic final index @-1
- type: int
constructors
synthetic const @-1
accessors
@@ -16011,8 +15997,6 @@
returnType: E
synthetic static get values @-1
returnType: List<E>
- synthetic get index @-1
- returnType: int
topLevelVariables
static final vToString @17
type: String
@@ -17025,8 +17009,6 @@
leftBracket: [ @0
rightBracket: ] @0
staticType: List<E>
- synthetic final index @-1
- type: int
constructors
synthetic const @-1
accessors
@@ -17036,8 +17018,6 @@
returnType: E
synthetic static get values @-1
returnType: List<E>
- synthetic get index @-1
- returnType: int
enum E @19
supertype: Enum
fields
@@ -17124,8 +17104,6 @@
leftBracket: [ @0
rightBracket: ] @0
staticType: List<E>
- synthetic final index @-1
- type: int
constructors
synthetic const @-1
accessors
@@ -17137,8 +17115,6 @@
returnType: E
synthetic static get values @-1
returnType: List<E>
- synthetic get index @-1
- returnType: int
''');
}
@@ -17447,8 +17423,6 @@
leftBracket: [ @0
rightBracket: ] @0
staticType: List<E<dynamic>>
- synthetic final index @-1
- type: int
constructors
const @43
parameters
@@ -17461,8 +17435,6 @@
returnType: E<String>
synthetic static get values @-1
returnType: List<E<dynamic>>
- synthetic get index @-1
- returnType: int
''');
}
@@ -17513,8 +17485,6 @@
leftBracket: [ @0
rightBracket: ] @0
staticType: List<E>
- synthetic final index @-1
- type: int
constructors
synthetic const @-1
accessors
@@ -17522,8 +17492,6 @@
returnType: E
synthetic static get values @-1
returnType: List<E>
- synthetic get index @-1
- returnType: int
''');
}
@@ -17595,8 +17563,6 @@
leftBracket: [ @0
rightBracket: ] @0
staticType: List<E<dynamic>>
- synthetic final index @-1
- type: int
constructors
const @37
parameters
@@ -17607,8 +17573,6 @@
returnType: E<double>
synthetic static get values @-1
returnType: List<E<dynamic>>
- synthetic get index @-1
- returnType: int
''');
}
@@ -17658,8 +17622,6 @@
leftBracket: [ @0
rightBracket: ] @0
staticType: List<E>
- synthetic final index @-1
- type: int
constructors
synthetic const @-1
accessors
@@ -17667,8 +17629,6 @@
returnType: E
synthetic static get values @-1
returnType: List<E>
- synthetic get index @-1
- returnType: int
''');
}
@@ -17719,8 +17679,6 @@
leftBracket: [ @0
rightBracket: ] @0
staticType: List<E>
- synthetic final index @-1
- type: int
constructors
factory named @26
periodOffset: 25
@@ -17731,8 +17689,6 @@
returnType: E
synthetic static get values @-1
returnType: List<E>
- synthetic get index @-1
- returnType: int
''');
}
@@ -17783,8 +17739,6 @@
leftBracket: [ @0
rightBracket: ] @0
staticType: List<E>
- synthetic final index @-1
- type: int
constructors
factory @24
accessors
@@ -17792,8 +17746,6 @@
returnType: E
synthetic static get values @-1
returnType: List<E>
- synthetic get index @-1
- returnType: int
''');
}
@@ -17845,8 +17797,6 @@
leftBracket: [ @0
rightBracket: ] @0
staticType: List<E>
- synthetic final index @-1
- type: int
final x @22
type: dynamic
constructors
@@ -17863,8 +17813,6 @@
returnType: E
synthetic static get values @-1
returnType: List<E>
- synthetic get index @-1
- returnType: int
synthetic get x @-1
returnType: dynamic
''');
@@ -17919,8 +17867,6 @@
leftBracket: [ @0
rightBracket: ] @0
staticType: List<E>
- synthetic final index @-1
- type: int
final x @26
type: int
final x @44
@@ -17936,8 +17882,6 @@
returnType: E
synthetic static get values @-1
returnType: List<E>
- synthetic get index @-1
- returnType: int
synthetic get x @-1
returnType: int
synthetic get x @-1
@@ -17992,8 +17936,6 @@
leftBracket: [ @0
rightBracket: ] @0
staticType: List<E>
- synthetic final index @-1
- type: int
constructors
const @22
parameters
@@ -18005,8 +17947,6 @@
returnType: E
synthetic static get values @-1
returnType: List<E>
- synthetic get index @-1
- returnType: int
''');
}
@@ -18058,8 +17998,6 @@
leftBracket: [ @0
rightBracket: ] @0
staticType: List<E>
- synthetic final index @-1
- type: int
final x @26
type: num
constructors
@@ -18073,8 +18011,6 @@
returnType: E
synthetic static get values @-1
returnType: List<E>
- synthetic get index @-1
- returnType: int
synthetic get x @-1
returnType: num
''');
@@ -18128,8 +18064,6 @@
leftBracket: [ @0
rightBracket: ] @0
staticType: List<E>
- synthetic final index @-1
- type: int
final x @22
type: dynamic
constructors
@@ -18143,8 +18077,6 @@
returnType: E
synthetic static get values @-1
returnType: List<E>
- synthetic get index @-1
- returnType: int
synthetic get x @-1
returnType: dynamic
''');
@@ -18198,8 +18130,6 @@
leftBracket: [ @0
rightBracket: ] @0
staticType: List<E>
- synthetic final index @-1
- type: int
final x @22
type: dynamic
constructors
@@ -18213,8 +18143,6 @@
returnType: E
synthetic static get values @-1
returnType: List<E>
- synthetic get index @-1
- returnType: int
synthetic get x @-1
returnType: dynamic
''');
@@ -18271,8 +18199,6 @@
leftBracket: [ @0
rightBracket: ] @0
staticType: List<E>
- synthetic final index @-1
- type: int
constructors
const named @34
periodOffset: 33
@@ -18285,8 +18211,6 @@
returnType: E
synthetic static get values @-1
returnType: List<E>
- synthetic get index @-1
- returnType: int
''');
}
@@ -18341,8 +18265,6 @@
leftBracket: [ @0
rightBracket: ] @0
staticType: List<E>
- synthetic final index @-1
- type: int
constructors
const @26
parameters
@@ -18353,8 +18275,6 @@
returnType: E
synthetic static get values @-1
returnType: List<E>
- synthetic get index @-1
- returnType: int
''');
}
@@ -18406,8 +18326,6 @@
leftBracket: [ @0
rightBracket: ] @0
staticType: List<E>
- synthetic final index @-1
- type: int
constructors
synthetic const @-1
accessors
@@ -18415,8 +18333,6 @@
returnType: E
synthetic static get values @-1
returnType: List<E>
- synthetic get index @-1
- returnType: int
''');
}
@@ -18467,8 +18383,6 @@
leftBracket: [ @0
rightBracket: ] @0
staticType: List<E>
- synthetic final index @-1
- type: int
final foo @22
type: int
constantInitializer
@@ -18482,8 +18396,6 @@
returnType: E
synthetic static get values @-1
returnType: List<E>
- synthetic get index @-1
- returnType: int
synthetic get foo @-1
returnType: int
''');
@@ -18536,8 +18448,6 @@
leftBracket: [ @0
rightBracket: ] @0
staticType: List<E>
- synthetic final index @-1
- type: int
synthetic foo @-1
type: int
constructors
@@ -18547,8 +18457,6 @@
returnType: E
synthetic static get values @-1
returnType: List<E>
- synthetic get index @-1
- returnType: int
get foo @23
returnType: int
''');
@@ -18607,8 +18515,6 @@
leftBracket: [ @0
rightBracket: ] @0
staticType: List<E>
- synthetic final index @-1
- type: int
constructors
synthetic const @-1
accessors
@@ -18616,8 +18522,6 @@
returnType: E
synthetic static get values @-1
returnType: List<E>
- synthetic get index @-1
- returnType: int
''');
}
@@ -18684,8 +18588,6 @@
leftBracket: [ @0
rightBracket: ] @0
staticType: List<E<dynamic>>
- synthetic final index @-1
- type: int
constructors
synthetic const @-1
accessors
@@ -18693,8 +18595,6 @@
returnType: E<dynamic>
synthetic static get values @-1
returnType: List<E<dynamic>>
- synthetic get index @-1
- returnType: int
''');
}
@@ -18756,8 +18656,6 @@
leftBracket: [ @0
rightBracket: ] @0
staticType: List<E>
- synthetic final index @-1
- type: int
constructors
synthetic const @-1
accessors
@@ -18765,8 +18663,6 @@
returnType: E
synthetic static get values @-1
returnType: List<E>
- synthetic get index @-1
- returnType: int
''');
}
@@ -18824,8 +18720,6 @@
leftBracket: [ @0
rightBracket: ] @0
staticType: List<E<dynamic>>
- synthetic final index @-1
- type: int
constructors
synthetic const @-1
accessors
@@ -18833,8 +18727,6 @@
returnType: E<dynamic>
synthetic static get values @-1
returnType: List<E<dynamic>>
- synthetic get index @-1
- returnType: int
methods
foo @23
typeParameters
@@ -18895,8 +18787,6 @@
leftBracket: [ @0
rightBracket: ] @0
staticType: List<E>
- synthetic final index @-1
- type: int
constructors
synthetic const @-1
accessors
@@ -18904,8 +18794,6 @@
returnType: E
synthetic static get values @-1
returnType: List<E>
- synthetic get index @-1
- returnType: int
methods
toString @23
returnType: String
@@ -18961,8 +18849,6 @@
leftBracket: [ @0
rightBracket: ] @0
staticType: List<E>
- synthetic final index @-1
- type: int
constructors
synthetic const @-1
accessors
@@ -18970,8 +18856,6 @@
returnType: E
synthetic static get values @-1
returnType: List<E>
- synthetic get index @-1
- returnType: int
mixins
mixin M @6
superclassConstraints
@@ -19032,8 +18916,6 @@
leftBracket: [ @0
rightBracket: ] @0
staticType: List<E>
- synthetic final index @-1
- type: int
constructors
synthetic const @-1
accessors
@@ -19041,8 +18923,6 @@
returnType: E
synthetic static get values @-1
returnType: List<E>
- synthetic get index @-1
- returnType: int
mixins
mixin M1 @6
typeParameters
@@ -19110,8 +18990,6 @@
leftBracket: [ @0
rightBracket: ] @0
staticType: List<E>
- synthetic final index @-1
- type: int
synthetic foo @-1
type: int
constructors
@@ -19121,8 +18999,6 @@
returnType: E
synthetic static get values @-1
returnType: List<E>
- synthetic get index @-1
- returnType: int
set foo @19
parameters
requiredPositional _ @27
@@ -19184,8 +19060,6 @@
leftBracket: [ @0
rightBracket: ] @0
staticType: List<E<dynamic>>
- synthetic final index @-1
- type: int
constructors
synthetic const @-1
accessors
@@ -19193,8 +19067,6 @@
returnType: E<dynamic>
synthetic static get values @-1
returnType: List<E<dynamic>>
- synthetic get index @-1
- returnType: int
''');
}
@@ -19255,8 +19127,6 @@
leftBracket: [ @0
rightBracket: ] @0
staticType: List<E<num, num>>
- synthetic final index @-1
- type: int
constructors
synthetic const @-1
accessors
@@ -19264,8 +19134,6 @@
returnType: E<num, num>
synthetic static get values @-1
returnType: List<E<num, num>>
- synthetic get index @-1
- returnType: int
''');
}
@@ -19291,15 +19159,11 @@
leftBracket: [ @0
rightBracket: ] @0
staticType: List<E<dynamic>>
- synthetic final index @-1
- type: int
constructors
synthetic const @-1
accessors
synthetic static get values @-1
returnType: List<E<dynamic>>
- synthetic get index @-1
- returnType: int
''');
}
@@ -19331,15 +19195,11 @@
leftBracket: [ @0
rightBracket: ] @0
staticType: List<E<dynamic, num, dynamic>>
- synthetic final index @-1
- type: int
constructors
synthetic const @-1
accessors
synthetic static get values @-1
returnType: List<E<dynamic, num, dynamic>>
- synthetic get index @-1
- returnType: int
''');
}
@@ -19365,15 +19225,11 @@
leftBracket: [ @0
rightBracket: ] @0
staticType: List<E<dynamic>>
- synthetic final index @-1
- type: int
constructors
synthetic const @-1
accessors
synthetic static get values @-1
returnType: List<E<dynamic>>
- synthetic get index @-1
- returnType: int
''');
}
@@ -19398,15 +19254,11 @@
leftBracket: [ @0
rightBracket: ] @0
staticType: List<E<dynamic>>
- synthetic final index @-1
- type: int
constructors
synthetic const @-1
accessors
synthetic static get values @-1
returnType: List<E<dynamic>>
- synthetic get index @-1
- returnType: int
''');
}
@@ -19431,15 +19283,11 @@
leftBracket: [ @0
rightBracket: ] @0
staticType: List<E<dynamic>>
- synthetic final index @-1
- type: int
constructors
synthetic const @-1
accessors
synthetic static get values @-1
returnType: List<E<dynamic>>
- synthetic get index @-1
- returnType: int
''');
}
@@ -19464,15 +19312,11 @@
leftBracket: [ @0
rightBracket: ] @0
staticType: List<E<dynamic>>
- synthetic final index @-1
- type: int
constructors
synthetic const @-1
accessors
synthetic static get values @-1
returnType: List<E<dynamic>>
- synthetic get index @-1
- returnType: int
''');
}
@@ -19501,15 +19345,11 @@
leftBracket: [ @0
rightBracket: ] @0
staticType: List<E<dynamic, dynamic, dynamic>>
- synthetic final index @-1
- type: int
constructors
synthetic const @-1
accessors
synthetic static get values @-1
returnType: List<E<dynamic, dynamic, dynamic>>
- synthetic get index @-1
- returnType: int
''');
}
@@ -19590,8 +19430,6 @@
leftBracket: [ @0
rightBracket: ] @0
staticType: List<E>
- synthetic final index @-1
- type: int
constructors
synthetic const @-1
accessors
@@ -19601,8 +19439,6 @@
returnType: E
synthetic static get values @-1
returnType: List<E>
- synthetic get index @-1
- returnType: int
''');
}
@@ -19704,8 +19540,6 @@
leftBracket: [ @0
rightBracket: ] @0
staticType: List<E>
- synthetic final index @-1
- type: int
constructors
synthetic const @-1
accessors
@@ -19715,8 +19549,6 @@
returnType: E
synthetic static get values @-1
returnType: List<E>
- synthetic get index @-1
- returnType: int
topLevelVariables
static const annotation @91
type: int
@@ -19797,8 +19629,6 @@
leftBracket: [ @0
rightBracket: ] @0
staticType: List<E>
- synthetic final index @-1
- type: int
constructors
synthetic const @-1
accessors
@@ -19808,8 +19638,6 @@
returnType: E
synthetic static get values @-1
returnType: List<E>
- synthetic get index @-1
- returnType: int
''');
}
@@ -19855,8 +19683,6 @@
leftBracket: [ @0
rightBracket: ] @0
staticType: List<E1>
- synthetic final index @-1
- type: int
constructors
synthetic const @-1
accessors
@@ -19864,8 +19690,6 @@
returnType: E1
synthetic static get values @-1
returnType: List<E1>
- synthetic get index @-1
- returnType: int
enum E2 @20
supertype: Enum
fields
@@ -19902,8 +19726,6 @@
leftBracket: [ @0
rightBracket: ] @0
staticType: List<E2>
- synthetic final index @-1
- type: int
constructors
synthetic const @-1
accessors
@@ -19911,8 +19733,6 @@
returnType: E2
synthetic static get values @-1
returnType: List<E2>
- synthetic get index @-1
- returnType: int
''');
}
@@ -20066,8 +19886,6 @@
leftBracket: [ @0
rightBracket: ] @0
staticType: List<E>
- synthetic final index @-1
- type: int
constructors
synthetic const @-1
accessors
@@ -20079,8 +19897,6 @@
returnType: E
synthetic static get values @-1
returnType: List<E>
- synthetic get index @-1
- returnType: int
''');
}
@@ -26957,8 +26773,6 @@
leftBracket: [ @0
rightBracket: ] @0
staticType: List<E>
- synthetic final index @-1
- type: int
constructors
synthetic const @-1
accessors
@@ -26966,8 +26780,6 @@
returnType: E
synthetic static get values @-1
returnType: List<E>
- synthetic get index @-1
- returnType: int
topLevelVariables
static const a @6
type: int
@@ -27128,8 +26940,6 @@
leftBracket: [ @0
rightBracket: ] @0
staticType: List<E>
- synthetic final index @-1
- type: int
constructors
synthetic const @-1
accessors
@@ -27141,8 +26951,6 @@
returnType: E
synthetic static get values @-1
returnType: List<E>
- synthetic get index @-1
- returnType: int
''');
}
@@ -27196,8 +27004,6 @@
leftBracket: [ @0
rightBracket: ] @0
staticType: List<E>
- synthetic final index @-1
- type: int
constructors
synthetic const @-1
accessors
@@ -27205,8 +27011,6 @@
returnType: E
synthetic static get values @-1
returnType: List<E>
- synthetic get index @-1
- returnType: int
topLevelVariables
static const a @6
type: int
@@ -28789,8 +28593,6 @@
leftBracket: [ @0
rightBracket: ] @0
staticType: List<E>
- synthetic final index @-1
- type: int
constructors
synthetic const @-1
accessors
@@ -28802,8 +28604,6 @@
returnType: E
synthetic static get values @-1
returnType: List<E>
- synthetic get index @-1
- returnType: int
topLevelVariables
static const foo @6
type: int
@@ -29879,8 +29679,6 @@
leftBracket: [ @0
rightBracket: ] @0
staticType: List<E<dynamic>>
- synthetic final index @-1
- type: int
constructors
synthetic const @-1
accessors
@@ -29888,8 +29686,6 @@
returnType: E<dynamic>
synthetic static get values @-1
returnType: List<E<dynamic>>
- synthetic get index @-1
- returnType: int
topLevelVariables
static const a @6
type: int
@@ -30177,8 +29973,6 @@
leftBracket: [ @0
rightBracket: ] @0
staticType: List<E>
- synthetic final index @-1
- type: int
constructors
synthetic const @-1
accessors
@@ -30190,8 +29984,6 @@
returnType: E
synthetic static get values @-1
returnType: List<E>
- synthetic get index @-1
- returnType: int
''');
}
@@ -31540,9 +31332,6 @@
rightBracket: ] @0
staticType: List<E>
nonSynthetic: self::@enum::E
- synthetic final index @-1
- type: int
- nonSynthetic: self::@enum::E
constructors
synthetic const @-1
nonSynthetic: self::@enum::E
@@ -31556,9 +31345,6 @@
synthetic static get values @-1
returnType: List<E>
nonSynthetic: self::@enum::E
- synthetic get index @-1
- returnType: int
- nonSynthetic: self::@enum::E
''',
withNonSynthetic: true);
}
@@ -33564,8 +33350,6 @@
leftBracket: [ @0
rightBracket: ] @0
staticType: List<E>
- synthetic final index @-1
- type: int
constructors
synthetic const @-1
accessors
@@ -33573,8 +33357,6 @@
returnType: E
synthetic static get values @-1
returnType: List<E>
- synthetic get index @-1
- returnType: int
typeAliases
functionTypeAliasBased F @32
aliasedType: dynamic Function()
@@ -33699,8 +33481,6 @@
leftBracket: [ @0
rightBracket: ] @0
staticType: List<E>
- synthetic final index @-1
- type: int
constructors
synthetic const @-1
accessors
@@ -33708,8 +33488,6 @@
returnType: E
synthetic static get values @-1
returnType: List<E>
- synthetic get index @-1
- returnType: int
typeAliases
functionTypeAliasBased F @43
aliasedType: dynamic Function()
@@ -33768,8 +33546,6 @@
leftBracket: [ @0
rightBracket: ] @0
staticType: List<E>
- synthetic final index @-1
- type: int
constructors
synthetic const @-1
accessors
@@ -33777,8 +33553,6 @@
returnType: E
synthetic static get values @-1
returnType: List<E>
- synthetic get index @-1
- returnType: int
typeAliases
functionTypeAliasBased F @58
aliasedType: dynamic Function()
@@ -33874,8 +33648,6 @@
leftBracket: [ @0
rightBracket: ] @0
staticType: List<E>
- synthetic final index @-1
- type: int
constructors
synthetic const @-1
accessors
@@ -33883,8 +33655,6 @@
returnType: E
synthetic static get values @-1
returnType: List<E>
- synthetic get index @-1
- returnType: int
typeAliases
functionTypeAliasBased F @43
aliasedType: dynamic Function()
@@ -33978,8 +33748,6 @@
leftBracket: [ @0
rightBracket: ] @0
staticType: List<E>
- synthetic final index @-1
- type: int
constructors
synthetic const @-1
accessors
@@ -33987,8 +33755,6 @@
returnType: E
synthetic static get values @-1
returnType: List<E>
- synthetic get index @-1
- returnType: int
typeAliases
functionTypeAliasBased F @43
aliasedType: dynamic Function()
@@ -34150,8 +33916,6 @@
leftBracket: [ @0
rightBracket: ] @0
staticType: List<E>
- synthetic final index @-1
- type: int
constructors
synthetic const @-1
accessors
@@ -34159,8 +33923,6 @@
returnType: E
synthetic static get values @-1
returnType: List<E>
- synthetic get index @-1
- returnType: int
topLevelVariables
static e @15
type: E
diff --git a/pkg/analyzer_plugin/lib/src/utilities/completion/optype.dart b/pkg/analyzer_plugin/lib/src/utilities/completion/optype.dart
index f54edf3..9d6bce2 100644
--- a/pkg/analyzer_plugin/lib/src/utilities/completion/optype.dart
+++ b/pkg/analyzer_plugin/lib/src/utilities/completion/optype.dart
@@ -596,6 +596,29 @@
if (entity == node.fields) {
optype.completionLocation = 'FieldDeclaration_fields';
}
+
+ // Incomplete code looks like a "field" declaration.
+ if (node.fields.type == null) {
+ var variables = node.fields.variables;
+ // class A { static late ^ }
+ if (node.staticKeyword != null &&
+ variables.length == 1 &&
+ variables[0].name.name == 'late') {
+ optype.completionLocation = 'FieldDeclaration_static_late';
+ optype.includeTypeNameSuggestions = true;
+ return;
+ }
+ // class A { static ^ }
+ if (node.staticKeyword == null &&
+ offset <= node.semicolon.offset &&
+ variables.length == 1 &&
+ variables[0].name.name == 'static') {
+ optype.completionLocation = 'FieldDeclaration_static';
+ optype.includeTypeNameSuggestions = true;
+ return;
+ }
+ }
+
if (offset <= node.semicolon.offset) {
optype.includeVarNameSuggestions = true;
}
diff --git a/pkg/analyzer_plugin/test/utilities/analyzer_converter_test.dart b/pkg/analyzer_plugin/test/utilities/analyzer_converter_test.dart
index 38487ab..ab3e77a 100644
--- a/pkg/analyzer_plugin/test/utilities/analyzer_converter_test.dart
+++ b/pkg/analyzer_plugin/test/utilities/analyzer_converter_test.dart
@@ -352,24 +352,6 @@
plugin.Element.FLAG_CONST | plugin.Element.FLAG_STATIC);
}
{
- var engineElement = findElement.field('index', of: 'E2');
- // create notification Element
- var element = converter.convertElement(engineElement);
- expect(element.kind, plugin.ElementKind.FIELD);
- expect(element.name, 'index');
- {
- var location = element.location!;
- expect(location.file, testFile);
- expect(location.offset, -1);
- expect(location.length, 'index'.length);
- expect(location.startLine, 1);
- expect(location.startColumn, 0);
- }
- expect(element.parameters, isNull);
- expect(element.returnType, 'int');
- expect(element.flags, plugin.Element.FLAG_FINAL);
- }
- {
var engineElement = findElement.field('values', of: 'E2');
// create notification Element
diff --git a/pkg/analyzer_plugin/test/utilities/completion/type_member_contributor_test.dart b/pkg/analyzer_plugin/test/utilities/completion/type_member_contributor_test.dart
index 4f20366..327ebfe 100644
--- a/pkg/analyzer_plugin/test/utilities/completion/type_member_contributor_test.dart
+++ b/pkg/analyzer_plugin/test/utilities/completion/type_member_contributor_test.dart
@@ -1681,6 +1681,8 @@
assertNotSuggested('values');
}
+ /// TODO(scheglov) move this test into contributor independent suite
+ @FailingTest(reason: 'No index, not local anymore')
Future<void> test_enumConst_index() async {
addTestSource('enum E { one, two } main() {E.one.^}');
await computeSuggestions();
@@ -1691,6 +1693,8 @@
assertNotSuggested('values');
}
+ /// TODO(scheglov) move this test into contributor independent suite
+ @FailingTest(reason: 'No index, not local anymore')
Future<void> test_enumConst_index2() async {
addTestSource('enum E { one, two } main() {E.one.i^}');
await computeSuggestions();
@@ -1701,6 +1705,8 @@
assertNotSuggested('values');
}
+ /// TODO(scheglov) move this test into contributor independent suite
+ @FailingTest(reason: 'No index, not local anymore')
Future<void> test_enumConst_index3() async {
addTestSource('enum E { one, two } main() {E.one.^ int g;}');
await computeSuggestions();
diff --git a/pkg/compiler/lib/src/compiler.dart b/pkg/compiler/lib/src/compiler.dart
index 7928a2b..ad4f8c8 100644
--- a/pkg/compiler/lib/src/compiler.dart
+++ b/pkg/compiler/lib/src/compiler.dart
@@ -40,7 +40,7 @@
show GlobalTypeInferenceResults, GlobalTypeInferenceTask;
import 'io/source_information.dart' show SourceInformation;
import 'ir/modular.dart';
-import 'js_backend/backend.dart' show CodegenInputs, JavaScriptImpactStrategy;
+import 'js_backend/backend.dart' show CodegenInputs;
import 'js_backend/inferred_data.dart';
import 'js_model/js_strategy.dart';
import 'js_model/js_world.dart';
@@ -57,8 +57,7 @@
import 'universe/selector.dart' show Selector;
import 'universe/codegen_world_builder.dart';
import 'universe/resolution_world_builder.dart';
-import 'universe/world_impact.dart'
- show ImpactStrategy, WorldImpact, WorldImpactBuilderImpl;
+import 'universe/world_impact.dart' show WorldImpact, WorldImpactBuilderImpl;
import 'world.dart' show JClosedWorld, KClosedWorld;
typedef MakeReporterFunction = CompilerDiagnosticReporter Function(
@@ -74,8 +73,6 @@
CompilerDiagnosticReporter _reporter;
Map<Entity, WorldImpact> _impactCache;
- ImpactStrategy impactStrategy = const ImpactStrategy();
-
/// Options provided from command-line arguments.
final CompilerOptions options;
@@ -434,10 +431,6 @@
// this until after the resolution queue is processed.
deferredLoadTask.beforeResolution(rootLibraryUri, libraries);
- impactStrategy = JavaScriptImpactStrategy(dumpInfoTask,
- supportDeferredLoad: deferredLoadTask.isProgramSplit,
- supportDumpInfo: options.dumpInfo);
-
phase = PHASE_RESOLVING;
resolutionEnqueuer.applyImpact(mainImpact);
if (options.showInternalProgress) reporter.log('Computing closed world');
@@ -466,8 +459,6 @@
_userCodeLocations
.addAll(result.moduleLibraries.map((module) => CodeLocation(module)));
selfTask.measureSubtask('runModularAnalysis', () {
- impactStrategy = JavaScriptImpactStrategy(dumpInfoTask,
- supportDeferredLoad: true, supportDumpInfo: true);
var included = result.moduleLibraries.toSet();
var elementMap = (frontendStrategy as KernelFrontendStrategy).elementMap;
var moduleData = computeModuleData(result.component, included, options,
@@ -607,8 +598,7 @@
work.element,
() => selfTask.measureSubtask("applyImpact", () {
enqueuer.applyImpact(
- selfTask.measureSubtask("work.run", () => work.run()),
- impactSource: work.element);
+ selfTask.measureSubtask("work.run", () => work.run()));
}));
});
});
@@ -619,7 +609,6 @@
{void onProgress(Enqueuer enqueuer)}) {
selfTask.measureSubtask("processQueue", () {
enqueuer.open(
- impactStrategy,
mainMethod,
elementEnvironment.libraries
.map((LibraryEntity library) => library.canonicalUri));
diff --git a/pkg/compiler/lib/src/deferred_load/deferred_load.dart b/pkg/compiler/lib/src/deferred_load/deferred_load.dart
index d99d431..405738c 100644
--- a/pkg/compiler/lib/src/deferred_load/deferred_load.dart
+++ b/pkg/compiler/lib/src/deferred_load/deferred_load.dart
@@ -286,7 +286,6 @@
import '../elements/types.dart';
import '../elements/entities.dart';
import '../kernel/element_map.dart';
-import '../universe/world_impact.dart' show ImpactUseCase;
import '../util/util.dart' show makeUnique;
import '../world.dart' show KClosedWorld;
@@ -325,8 +324,6 @@
/// Will be `true` if the program contains deferred libraries.
bool isProgramSplit = false;
- static const ImpactUseCase IMPACT_USE = ImpactUseCase('Deferred load');
-
/// A cache of the result of calling `computeImportDeferName` on the keys of
/// this map.
final Map<ImportEntity, String> importDeferName = {};
diff --git a/pkg/compiler/lib/src/deferred_load/entity_data_info.dart b/pkg/compiler/lib/src/deferred_load/entity_data_info.dart
index d61c350..b601c6c 100644
--- a/pkg/compiler/lib/src/deferred_load/entity_data_info.dart
+++ b/pkg/compiler/lib/src/deferred_load/entity_data_info.dart
@@ -5,7 +5,6 @@
import 'package:kernel/ast.dart' as ir;
import 'package:kernel/type_environment.dart' as ir;
-import 'deferred_load.dart';
import 'entity_data.dart';
import '../common.dart';
@@ -19,8 +18,7 @@
import '../kernel/kelements.dart' show KLocalFunction;
import '../kernel/element_map.dart';
import '../universe/use.dart';
-import '../universe/world_impact.dart'
- show ImpactStrategy, WorldImpact, WorldImpactVisitorImpl;
+import '../universe/world_impact.dart' show WorldImpact, WorldImpactVisitorImpl;
import '../world.dart' show KClosedWorld;
/// [EntityDataInfo] is meta data about [EntityData] for a given compilation
@@ -63,7 +61,6 @@
this.closedWorld, this.elementMap, this.compiler, this.registry);
Map<Entity, WorldImpact> get impactCache => compiler.impactCache;
- ImpactStrategy get impactStrategy => compiler.impactStrategy;
KElementEnvironment get elementEnvironment =>
compiler.frontendStrategy.elementEnvironment;
CommonElements get commonElements => compiler.frontendStrategy.commonElements;
@@ -242,20 +239,16 @@
/// Extract any dependencies that are known from the impact of [element].
void _addDependenciesFromImpact(MemberEntity element) {
WorldImpact worldImpact = impactCache[element];
- impactStrategy.visitImpact(
- element,
- worldImpact,
- WorldImpactVisitorImpl(
- visitStaticUse: (MemberEntity member, StaticUse staticUse) {
- _addFromStaticUse(element, staticUse);
- }, visitTypeUse: (MemberEntity member, TypeUse typeUse) {
- _addFromTypeUse(element, typeUse);
- }, visitDynamicUse: (MemberEntity member, DynamicUse dynamicUse) {
- // TODO(johnniwinther): Use rti need data to skip unneeded type
- // arguments.
- addTypeListDependencies(dynamicUse.typeArguments);
- }),
- DeferredLoadTask.IMPACT_USE);
+ worldImpact.apply(WorldImpactVisitorImpl(
+ visitStaticUse: (MemberEntity member, StaticUse staticUse) {
+ _addFromStaticUse(element, staticUse);
+ }, visitTypeUse: (MemberEntity member, TypeUse typeUse) {
+ _addFromTypeUse(element, typeUse);
+ }, visitDynamicUse: (MemberEntity member, DynamicUse dynamicUse) {
+ // TODO(johnniwinther): Use rti need data to skip unneeded type
+ // arguments.
+ addTypeListDependencies(dynamicUse.typeArguments);
+ }));
}
}
diff --git a/pkg/compiler/lib/src/dump_info.dart b/pkg/compiler/lib/src/dump_info.dart
index e0b9941..9832432 100644
--- a/pkg/compiler/lib/src/dump_info.dart
+++ b/pkg/compiler/lib/src/dump_info.dart
@@ -27,8 +27,7 @@
import 'js/js.dart' as jsAst;
import 'js_backend/field_analysis.dart';
import 'universe/codegen_world_builder.dart';
-import 'universe/world_impact.dart'
- show ImpactUseCase, WorldImpact, WorldImpactVisitorImpl;
+import 'universe/world_impact.dart' show WorldImpact, WorldImpactVisitorImpl;
import 'util/sink_adapter.dart';
import 'world.dart' show JClosedWorld;
@@ -427,7 +426,6 @@
}
class DumpInfoTask extends CompilerTask implements InfoReporter {
- static const ImpactUseCase IMPACT_USE = ImpactUseCase('Dump info');
final Compiler compiler;
final bool useBinaryFormat;
@@ -493,20 +491,17 @@
if (impact == null) return const <Selection>[];
var selections = <Selection>[];
- compiler.impactStrategy.visitImpact(
- entity,
- impact,
- WorldImpactVisitorImpl(visitDynamicUse: (member, dynamicUse) {
- AbstractValue mask = dynamicUse.receiverConstraint;
- selections.addAll(closedWorld
- // TODO(het): Handle `call` on `Closure` through
- // `world.includesClosureCall`.
- .locateMembers(dynamicUse.selector, mask)
- .map((MemberEntity e) => Selection(e, mask)));
- }, visitStaticUse: (member, staticUse) {
- selections.add(Selection(staticUse.element, null));
- }),
- IMPACT_USE);
+ impact.apply(WorldImpactVisitorImpl(visitDynamicUse: (member, dynamicUse) {
+ AbstractValue mask = dynamicUse.receiverConstraint;
+ selections.addAll(closedWorld
+ // TODO(het): Handle `call` on `Closure` through
+ // `world.includesClosureCall`.
+ .locateMembers(dynamicUse.selector, mask)
+ .map((MemberEntity e) => Selection(e, mask)));
+ }, visitStaticUse: (member, staticUse) {
+ selections.add(Selection(staticUse.element, null));
+ }));
+ unregisterImpact(entity);
return selections;
}
diff --git a/pkg/compiler/lib/src/enqueue.dart b/pkg/compiler/lib/src/enqueue.dart
index 6c53667..de9afc0 100644
--- a/pkg/compiler/lib/src/enqueue.dart
+++ b/pkg/compiler/lib/src/enqueue.dart
@@ -30,8 +30,7 @@
StaticUseKind,
TypeUse,
TypeUseKind;
-import 'universe/world_impact.dart'
- show ImpactStrategy, ImpactUseCase, WorldImpact, WorldImpactVisitor;
+import 'universe/world_impact.dart' show WorldImpact, WorldImpactVisitor;
import 'util/enumset.dart';
import 'util/util.dart' show Setlet;
import 'world.dart' show JClosedWorld;
@@ -144,6 +143,7 @@
static bool skipEnqueuerCheckForTesting = false;
WorldBuilder get worldBuilder;
+ WorldImpactVisitor get impactVisitor;
/// Returns [:true:] if this enqueuer is the resolution enqueuer.
bool get isResolutionQueue;
@@ -152,14 +152,14 @@
bool get queueIsEmpty;
- ImpactUseCase get impactUse;
-
void forEach(void f(WorkItem work));
- /// Apply the [worldImpact] to this enqueuer. If the [impactSource] is
- /// provided the impact strategy will remove it from the element impact cache,
- /// if it is no longer needed.
- void applyImpact(WorldImpact worldImpact, {var impactSource});
+ /// Apply the [worldImpact] to this enqueuer.
+ void applyImpact(WorldImpact worldImpact) {
+ if (worldImpact.isEmpty) return;
+ worldImpact.apply(impactVisitor);
+ }
+
bool checkNoEnqueuedInvokedInstanceMethods(
ElementEnvironment elementEnvironment);
@@ -179,21 +179,11 @@
void processConstantUse(ConstantUse constantUse);
EnqueuerListener get listener;
- // TODO(johnniwinther): Initialize [_impactStrategy] to `null`.
- ImpactStrategy _impactStrategy = const ImpactStrategy();
-
- ImpactStrategy get impactStrategy => _impactStrategy;
-
- void open(ImpactStrategy impactStrategy, FunctionEntity mainMethod,
- Iterable<Uri> libraries) {
- _impactStrategy = impactStrategy;
+ void open(FunctionEntity mainMethod, Iterable<Uri> libraries) {
listener.onQueueOpen(this, mainMethod, libraries);
}
void close() {
- // TODO(johnniwinther): Set [_impactStrategy] to `null` and [queueIsClosed]
- // to `true` here.
- _impactStrategy = const ImpactStrategy();
listener.onQueueClosed();
}
@@ -216,8 +206,6 @@
/// [Enqueuer] which is specific to resolution.
class ResolutionEnqueuer extends Enqueuer {
- static const ImpactUseCase IMPACT_USE = ImpactUseCase('ResolutionEnqueuer');
-
@override
final CompilerTask task;
final String name;
@@ -234,7 +222,8 @@
@override
bool queueIsClosed = false;
- WorldImpactVisitor _impactVisitor;
+ @override
+ WorldImpactVisitor impactVisitor;
final Queue<WorkItem> _queue = Queue<WorkItem>();
@@ -245,7 +234,7 @@
ResolutionEnqueuer(this.task, this._reporter, this.listener,
this._worldBuilder, this._workItemBuilder, this._annotationsData,
[this.name = 'resolution enqueuer']) {
- _impactVisitor = EnqueuerImpactVisitor(this);
+ impactVisitor = EnqueuerImpactVisitor(this);
}
@override
@@ -264,13 +253,6 @@
@override
Iterable<ClassEntity> get processedClasses => _worldBuilder.processedClasses;
- @override
- void applyImpact(WorldImpact worldImpact, {var impactSource}) {
- if (worldImpact.isEmpty) return;
- impactStrategy.visitImpact(
- impactSource, worldImpact, _impactVisitor, impactUse);
- }
-
void _registerInstantiatedType(InterfaceType type,
{ConstructorEntity constructor,
bool nativeUsage = false,
@@ -310,8 +292,7 @@
_registerClosurizedMember(member);
}
if (useSet.contains(MemberUse.CLOSURIZE_STATIC)) {
- applyImpact(listener.registerGetOfStaticFunction(),
- impactSource: 'get of static function');
+ applyImpact(listener.registerGetOfStaticFunction());
}
}
@@ -323,12 +304,10 @@
// We only tell the backend once that [cls] was instantiated, so
// any additional dependencies must be treated as global
// dependencies.
- applyImpact(listener.registerInstantiatedClass(cls),
- impactSource: 'instantiated class');
+ applyImpact(listener.registerInstantiatedClass(cls));
}
if (useSet.contains(ClassUse.IMPLEMENTED)) {
- applyImpact(listener.registerImplementedClass(cls),
- impactSource: 'implemented class');
+ applyImpact(listener.registerImplementedClass(cls));
}
}
@@ -343,8 +322,7 @@
void processConstantUse(ConstantUse constantUse) {
task.measureSubtask('resolution.constantUse', () {
if (_worldBuilder.registerConstantUse(constantUse)) {
- applyImpact(listener.registerUsedConstant(constantUse.value),
- impactSource: 'constant use');
+ applyImpact(listener.registerUsedConstant(constantUse.value));
_recentConstants = true;
}
});
@@ -427,8 +405,7 @@
void _registerClosurizedMember(MemberEntity element) {
assert(element.isInstanceMember);
- applyImpact(listener.registerClosurizedMember(element),
- impactSource: 'closurized member');
+ applyImpact(listener.registerClosurizedMember(element));
_worldBuilder.registerClosurizedMember(element);
}
@@ -475,9 +452,6 @@
_worldBuilder.processedMembers;
@override
- ImpactUseCase get impactUse => IMPACT_USE;
-
- @override
bool get isResolutionQueue => true;
@override
@@ -506,8 +480,7 @@
entity, "Resolution work list is closed. Trying to add $entity.");
}
- applyImpact(listener.registerUsedElement(entity),
- impactSource: 'used element');
+ applyImpact(listener.registerUsedElement(entity));
_worldBuilder.registerUsedElement(entity);
_queue.add(workItem);
}
diff --git a/pkg/compiler/lib/src/js_backend/backend.dart b/pkg/compiler/lib/src/js_backend/backend.dart
index f9e007c..3c01756 100644
--- a/pkg/compiler/lib/src/js_backend/backend.dart
+++ b/pkg/compiler/lib/src/js_backend/backend.dart
@@ -6,15 +6,10 @@
import '../common.dart';
import '../common/codegen.dart';
-import '../deferred_load/deferred_load.dart' show DeferredLoadTask;
-import '../dump_info.dart' show DumpInfoTask;
import '../elements/entities.dart';
-import '../enqueue.dart' show ResolutionEnqueuer;
import '../inferrer/types.dart';
import '../js_model/elements.dart';
import '../tracer.dart';
-import '../universe/world_impact.dart'
- show ImpactStrategy, ImpactUseCase, WorldImpact, WorldImpactVisitor;
import 'annotations.dart';
import 'checked_mode_helpers.dart';
import 'namer.dart';
@@ -261,36 +256,6 @@
}
}
-class JavaScriptImpactStrategy extends ImpactStrategy {
- final DumpInfoTask dumpInfoTask;
- final bool supportDeferredLoad;
- final bool supportDumpInfo;
-
- JavaScriptImpactStrategy(this.dumpInfoTask,
- {this.supportDeferredLoad, this.supportDumpInfo});
-
- @override
- void visitImpact(var impactSource, WorldImpact impact,
- WorldImpactVisitor visitor, ImpactUseCase impactUse) {
- // TODO(johnniwinther): Compute the application strategy once for each use.
- if (impactUse == ResolutionEnqueuer.IMPACT_USE) {
- if (supportDeferredLoad) {
- impact.apply(visitor);
- } else {
- impact.apply(visitor);
- }
- } else if (impactUse == DeferredLoadTask.IMPACT_USE) {
- impact.apply(visitor);
- // Impacts are uncached globally in [onImpactUsed].
- } else if (impactUse == DumpInfoTask.IMPACT_USE) {
- impact.apply(visitor);
- dumpInfoTask.unregisterImpact(impactSource);
- } else {
- impact.apply(visitor);
- }
- }
-}
-
/// Interface for resources only used during code generation.
abstract class CodegenInputs {
CheckedModeHelpers get checkedModeHelpers;
diff --git a/pkg/compiler/lib/src/js_backend/enqueuer.dart b/pkg/compiler/lib/src/js_backend/enqueuer.dart
index 768a940..e8abbfb 100644
--- a/pkg/compiler/lib/src/js_backend/enqueuer.dart
+++ b/pkg/compiler/lib/src/js_backend/enqueuer.dart
@@ -24,8 +24,7 @@
StaticUseKind,
TypeUse,
TypeUseKind;
-import '../universe/world_impact.dart'
- show ImpactUseCase, WorldImpact, WorldImpactVisitor;
+import '../universe/world_impact.dart' show WorldImpactVisitor;
import '../util/enumset.dart';
import '../util/util.dart' show Setlet;
@@ -45,7 +44,8 @@
final EnqueuerListener listener;
final AnnotationsData _annotationsData;
- WorldImpactVisitor _impactVisitor;
+ @override
+ WorldImpactVisitor impactVisitor;
final Queue<WorkItem> _queue = Queue<WorkItem>();
@@ -56,12 +56,10 @@
// applying additional impacts before re-emptying the queue.
void Function() onEmptyForTesting;
- static const ImpactUseCase IMPACT_USE = ImpactUseCase('CodegenEnqueuer');
-
CodegenEnqueuer(this.task, this._worldBuilder, this._workItemBuilder,
this.listener, this._annotationsData)
: this.name = 'codegen enqueuer' {
- _impactVisitor = EnqueuerImpactVisitor(this);
+ impactVisitor = EnqueuerImpactVisitor(this);
}
@override
@@ -97,13 +95,6 @@
_queue.add(workItem);
}
- @override
- void applyImpact(WorldImpact worldImpact, {var impactSource}) {
- if (worldImpact.isEmpty) return;
- impactStrategy.visitImpact(
- impactSource, worldImpact, _impactVisitor, impactUse);
- }
-
void _registerInstantiatedType(InterfaceType type,
{bool nativeUsage = false}) {
task.measureSubtask('codegen.typeUse', () {
@@ -308,9 +299,6 @@
String toString() => 'Enqueuer($name)';
@override
- ImpactUseCase get impactUse => IMPACT_USE;
-
- @override
Iterable<MemberEntity> get processedEntities => _processedEntities;
@override
diff --git a/pkg/compiler/lib/src/js_backend/resolution_listener.dart b/pkg/compiler/lib/src/js_backend/resolution_listener.dart
index 36f9598..ca26e30 100644
--- a/pkg/compiler/lib/src/js_backend/resolution_listener.dart
+++ b/pkg/compiler/lib/src/js_backend/resolution_listener.dart
@@ -137,18 +137,15 @@
void onQueueOpen(
Enqueuer enqueuer, FunctionEntity mainMethod, Iterable<Uri> libraries) {
if (_deferredLoadTask.isProgramSplit) {
- enqueuer.applyImpact(_computeDeferredLoadingImpact(),
- impactSource: 'deferred load');
+ enqueuer.applyImpact(_computeDeferredLoadingImpact());
}
- enqueuer.applyImpact(_nativeEnqueuer.processNativeClasses(libraries),
- impactSource: 'native classes');
+ enqueuer.applyImpact(_nativeEnqueuer.processNativeClasses(libraries));
if (mainMethod != null) {
- enqueuer.applyImpact(_computeMainImpact(mainMethod),
- impactSource: 'main impact');
+ enqueuer.applyImpact(_computeMainImpact(mainMethod));
}
// Elements required by enqueueHelpers are global dependencies
// that are not pulled in by a particular element.
- enqueuer.applyImpact(computeHelpersImpact(), impactSource: 'helpers');
+ enqueuer.applyImpact(computeHelpersImpact());
}
@override
@@ -158,8 +155,7 @@
//
// Return early if any elements are added to avoid counting the elements as
// due to mirrors.
- enqueuer.applyImpact(_customElementsAnalysis.flush(),
- impactSource: _customElementsAnalysis);
+ enqueuer.applyImpact(_customElementsAnalysis.flush());
for (ClassEntity cls in recentClasses) {
MemberEntity element = _elementEnvironment.lookupLocalClassMember(
diff --git a/pkg/compiler/lib/src/universe/world_impact.dart b/pkg/compiler/lib/src/universe/world_impact.dart
index 7368e456..f23105a 100644
--- a/pkg/compiler/lib/src/universe/world_impact.dart
+++ b/pkg/compiler/lib/src/universe/world_impact.dart
@@ -303,28 +303,6 @@
}
}
-/// Constant used to denote a specific use of a [WorldImpact].
-class ImpactUseCase {
- final String name;
-
- const ImpactUseCase(this.name);
-
- @override
- String toString() => 'ImpactUseCase($name)';
-}
-
-/// Strategy used for processing [WorldImpact] object in various use cases.
-class ImpactStrategy {
- const ImpactStrategy();
-
- /// Applies [impact] to [visitor] for the [impactUseCase] of [impactSource].
- void visitImpact(var impactSource, WorldImpact impact,
- WorldImpactVisitor visitor, ImpactUseCase impactUseCase) {
- // Apply unconditionally.
- impact.apply(visitor);
- }
-}
-
/// Visitor used to process the uses of a [WorldImpact].
abstract class WorldImpactVisitor {
void visitStaticUse(MemberEntity member, StaticUse staticUse);
diff --git a/pkg/compiler/pubspec.yaml b/pkg/compiler/pubspec.yaml
index bbee8a4..ba75211 100644
--- a/pkg/compiler/pubspec.yaml
+++ b/pkg/compiler/pubspec.yaml
@@ -38,7 +38,6 @@
package_config: any
path: any
source_maps: any
- cli_util: any
# Unpublished packages that can be used via path dependency
async_helper:
path: ../async_helper
diff --git a/pkg/compiler/tool/kernel_visitor/test/info_visitor_test.dart b/pkg/compiler/tool/kernel_visitor/test/info_visitor_test.dart
index e5fc258..885ecb4 100644
--- a/pkg/compiler/tool/kernel_visitor/test/info_visitor_test.dart
+++ b/pkg/compiler/tool/kernel_visitor/test/info_visitor_test.dart
@@ -1,45 +1,17 @@
// Copyright (c) 2021, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
-import "package:kernel/kernel.dart";
-import "package:expect/expect.dart";
-import "package:expect/minitest.dart";
-import "../dart_html_metrics_visitor.dart";
-import "package:cli_util/cli_util.dart";
-import "package:path/path.dart" as path;
+
import "dart:io";
-main() async {
- // Compile Dill
- var sdkPath = getSdkPath();
- if (!sdkPath.contains("ReleaseX64"))
- sdkPath = path.join(sdkPath, "ReleaseX64", "dart-sdk");
- var scriptPath = Platform.script.path;
- var pkgPath = path.dirname(
- path.dirname(path.dirname(path.dirname(path.dirname(scriptPath)))));
- var compilePath = path.canonicalize(
- path.join(pkgPath, "front_end", "tool", "_fasta", "compile.dart"));
- var testClassesPath = path
- .canonicalize(path.join(path.dirname(scriptPath), "test_classes.dart"));
- var ddcOutlinePath =
- path.canonicalize(path.join(sdkPath, "lib", "_internal", "ddc_sdk.dill"));
- var dillPath = path
- .canonicalize(path.join(path.dirname(scriptPath), "test_classes.dill"));
+import "package:expect/expect.dart";
+import "package:expect/minitest.dart";
+import "package:kernel/kernel.dart";
+import "package:path/path.dart" as path;
- await Process.run(path.join(sdkPath, "bin", "dart"), [
- compilePath,
- "--target=dartdevc",
- "--platform=${ddcOutlinePath}",
- "-o=${dillPath}",
- testClassesPath
- ]);
+import "../dart_html_metrics_visitor.dart";
- // Dill compiled from test_classes.dart using ddc.
- var component = loadComponentFromBinary(dillPath);
- var visitor = MetricsVisitor(["file:${testClassesPath}"]);
-
- component.accept(visitor);
-
+void runTests(MetricsVisitor visitor) {
test("Class A does not call super", () {
Expect.equals(visitor.classInfo["A"].invokesSuper, false);
});
@@ -95,3 +67,42 @@
visitor.classInfo["G"].notOverriddenMethods.contains("getValue"), true);
});
}
+
+void main() async {
+ // Compile Dill
+ var sdkPath = path.dirname(path.dirname(Platform.resolvedExecutable));
+ if (!sdkPath.contains("ReleaseX64"))
+ sdkPath = path.join(sdkPath, "ReleaseX64", "dart-sdk");
+ var scriptPath = Platform.script.path;
+ var pkgPath = path.dirname(
+ path.dirname(path.dirname(path.dirname(path.dirname(scriptPath)))));
+ var compilePath = path.canonicalize(
+ path.join(pkgPath, "front_end", "tool", "_fasta", "compile.dart"));
+ var testClassesPath = path
+ .canonicalize(path.join(path.dirname(scriptPath), "test_classes.dart"));
+ var ddcOutlinePath =
+ path.canonicalize(path.join(sdkPath, "lib", "_internal", "ddc_sdk.dill"));
+ var dillPath = path
+ .canonicalize(path.join(path.dirname(scriptPath), "test_classes.dill"));
+
+ await Process.run(path.join(sdkPath, "bin", "dart"), [
+ compilePath,
+ "--target=dartdevc",
+ "--platform=${ddcOutlinePath}",
+ "-o=${dillPath}",
+ testClassesPath
+ ]);
+
+ // Dill compiled from test_classes.dart using ddc.
+ var component = loadComponentFromBinary(dillPath);
+ var visitor = MetricsVisitor(["file:${testClassesPath}"]);
+
+ component.accept(visitor);
+
+ try {
+ runTests(visitor);
+ } finally {
+ // Cleanup.
+ File(dillPath).deleteSync();
+ }
+}
diff --git a/pkg/nnbd_migration/lib/src/node_builder.dart b/pkg/nnbd_migration/lib/src/node_builder.dart
index 2e7fa25..ac2cf60 100644
--- a/pkg/nnbd_migration/lib/src/node_builder.dart
+++ b/pkg/nnbd_migration/lib/src/node_builder.dart
@@ -283,13 +283,6 @@
DecoratedType(classElement.thisType,
makeNonNullNode(valuesTarget.typeArgument(0)))
])));
- final indexGetter = classElement.getGetter('index')!;
- var indexTarget = NullabilityNodeTarget.element(indexGetter, _getLineInfo);
- _variables!.recordDecoratedElementType(
- indexGetter,
- DecoratedType(indexGetter.type, makeNonNullNode(indexTarget),
- returnType: DecoratedType(indexGetter.returnType,
- makeNonNullNode(indexTarget.returnType()))));
return null;
}
diff --git a/runtime/tests/concurrency/stress_test_list.json b/runtime/tests/concurrency/stress_test_list.json
index 9922f32..843350b 100644
--- a/runtime/tests/concurrency/stress_test_list.json
+++ b/runtime/tests/concurrency/stress_test_list.json
@@ -3325,7 +3325,6 @@
"../../../tests/standalone/io/process_path_environment_test.dart",
"../../../tests/standalone/io/process_path_test.dart",
"../../../tests/standalone/io/process_pid_test.dart",
- "../../../tests/standalone/io/process_run_test.dart",
"../../../tests/standalone/io/process_segfault_test.dart",
"../../../tests/standalone/io/process_start_exception_test.dart",
"../../../tests/standalone/io/raw_datagram_read_all_test.dart",
@@ -6650,7 +6649,6 @@
"../../../tests/standalone_2/io/process_path_environment_test.dart",
"../../../tests/standalone_2/io/process_path_test.dart",
"../../../tests/standalone_2/io/process_pid_test.dart",
- "../../../tests/standalone_2/io/process_run_test.dart",
"../../../tests/standalone_2/io/process_segfault_test.dart",
"../../../tests/standalone_2/io/process_start_exception_test.dart",
"../../../tests/standalone_2/io/raw_datagram_read_all_test.dart",
diff --git a/tools/VERSION b/tools/VERSION
index 499468e..a9db075 100644
--- a/tools/VERSION
+++ b/tools/VERSION
@@ -27,5 +27,5 @@
MAJOR 2
MINOR 17
PATCH 0
-PRERELEASE 101
+PRERELEASE 102
PRERELEASE_PATCH 0
\ No newline at end of file