diff --git a/pkg/analysis_server/lib/src/services/completion/dart/static_member_contributor.dart b/pkg/analysis_server/lib/src/services/completion/dart/static_member_contributor.dart index 593de242e5c..8239f37c20d 100644 --- a/pkg/analysis_server/lib/src/services/completion/dart/static_member_contributor.dart +++ b/pkg/analysis_server/lib/src/services/completion/dart/static_member_contributor.dart @@ -67,13 +67,6 @@ class _SuggestionBuilder extends GeneralizingElementVisitor { // ignored } - @override - visitConstructorElement(ConstructorElement element) { - if (element.context.analysisOptions.previewDart2) { - _addSuggestion(element); - } - } - @override visitFieldElement(FieldElement element) { if (element.isStatic) { diff --git a/pkg/analysis_server/lib/src/services/correction/assist_internal.dart b/pkg/analysis_server/lib/src/services/correction/assist_internal.dart index 15b360008de..d7b5b782afb 100644 --- a/pkg/analysis_server/lib/src/services/correction/assist_internal.dart +++ b/pkg/analysis_server/lib/src/services/correction/assist_internal.dart @@ -1676,9 +1676,7 @@ class AssistProcessor { DartChangeBuilder changeBuilder = new DartChangeBuilder(session); await changeBuilder.addFileEdit(file, (DartFileEditBuilder builder) { builder.addReplacement(range.node(widgetExpr), (DartEditBuilder builder) { - if (!driver.analysisOptions.previewDart2) { - builder.write('new '); - } + builder.write('new '); if (parentClassElement == null) { builder.addSimpleLinkedEdit('WIDGET', 'widget'); } else { @@ -1757,9 +1755,7 @@ class AssistProcessor { DartChangeBuilder changeBuilder = new DartChangeBuilder(session); await changeBuilder.addFileEdit(file, (DartFileEditBuilder builder) { builder.addReplacement(selectedRange, (DartEditBuilder builder) { - if (!driver.analysisOptions.previewDart2) { - builder.write('new '); - } + builder.write('new '); builder.writeType(parentClassElement.type); builder.write('('); diff --git a/pkg/analysis_server/test/completion_test.dart b/pkg/analysis_server/test/completion_test.dart index d4029b3aa62..4a2270c1d20 100644 --- a/pkg/analysis_server/test/completion_test.dart +++ b/pkg/analysis_server/test/completion_test.dart @@ -732,17 +732,21 @@ main() { ["1+fooConst", "1-fooNotConst", "1-bar"], failingTests: '1'); - buildTests('testCompletion_annotation_type', ''' + buildTests( + 'testCompletion_annotation_type', + ''' class AAA { const AAA({int a, int b}); const AAA.nnn(int c, int d); } @AAA!1 main() { -}''', [ - "1+AAA" /*":" + ProposalKind.CONSTRUCTOR*/, - "1+AAA.nnn" /*":" + ProposalKind.CONSTRUCTOR*/ - ]); +}''', + [ + "1+AAA" /*":" + ProposalKind.CONSTRUCTOR*/, + "1+AAA.nnn" /*":" + ProposalKind.CONSTRUCTOR*/ + ], + failingTests: '1'); buildTests('testCompletion_annotation_type_inClass_withoutMember', ''' class AAA { diff --git a/pkg/analysis_server/test/domain_completion_test.dart b/pkg/analysis_server/test/domain_completion_test.dart index 07c23fa4079..078a2bb399e 100644 --- a/pkg/analysis_server/test/domain_completion_test.dart +++ b/pkg/analysis_server/test/domain_completion_test.dart @@ -619,11 +619,8 @@ main() { assertHasResult(CompletionSuggestionKind.INVOCATION, 'A', elementKind: ElementKind.CLASS); - // Both constructors - default and named, are suggested. - assertHasResult(CompletionSuggestionKind.INVOCATION, 'A', - elementKind: ElementKind.CONSTRUCTOR); - assertHasResult(CompletionSuggestionKind.INVOCATION, 'A.named', - elementKind: ElementKind.CONSTRUCTOR); + // No constructors suggested. + assertNoResult('A.named'); } test_local_named_constructor() { diff --git a/pkg/analysis_server/test/services/completion/dart/imported_reference_contributor_test.dart b/pkg/analysis_server/test/services/completion/dart/imported_reference_contributor_test.dart index 41feab87f10..a72473f49cf 100644 --- a/pkg/analysis_server/test/services/completion/dart/imported_reference_contributor_test.dart +++ b/pkg/analysis_server/test/services/completion/dart/imported_reference_contributor_test.dart @@ -2449,12 +2449,12 @@ main() { await computeSuggestions(); assertSuggestClass('A'); - assertSuggestConstructor('A.a1'); - assertSuggestConstructor('A.a2'); + assertNotSuggested('A.a1'); + assertNotSuggested('A.a2'); assertSuggestClass('B'); - assertSuggestConstructor('B.b1'); - assertSuggestConstructor('B.b2'); + assertNotSuggested('B.b1'); + assertNotSuggested('B.b2'); } test_ImportDirective_dart() async { diff --git a/pkg/analysis_server/test/services/completion/dart/static_member_contributor_test.dart b/pkg/analysis_server/test/services/completion/dart/static_member_contributor_test.dart index 29877107c38..8aebb553ed0 100644 --- a/pkg/analysis_server/test/services/completion/dart/static_member_contributor_test.dart +++ b/pkg/analysis_server/test/services/completion/dart/static_member_contributor_test.dart @@ -114,8 +114,8 @@ main() { '''); await computeSuggestions(); - assertSuggestConstructor('foo', elementName: 'foo'); - assertSuggestConstructor('bar', elementName: 'bar'); + assertNotSuggested('foo'); + assertNotSuggested('bar'); } test_keyword() async { diff --git a/pkg/analysis_server/test/services/correction/assist_test.dart b/pkg/analysis_server/test/services/correction/assist_test.dart index 7567e4b90cd..cb974b3f98e 100644 --- a/pkg/analysis_server/test/services/correction/assist_test.dart +++ b/pkg/analysis_server/test/services/correction/assist_test.dart @@ -3541,7 +3541,7 @@ class FakeFlutter { import 'package:flutter/widgets.dart'; class FakeFlutter { main() { - return /*caret*/Container(); + return /*caret*/new Container(); } } '''); @@ -3550,7 +3550,7 @@ class FakeFlutter { import 'package:flutter/widgets.dart'; class FakeFlutter { main() { - return /*caret*/Center(child: Container()); + return /*caret*/new Center(child: new Container()); } } '''); @@ -3677,7 +3677,7 @@ import 'package:flutter/widgets.dart'; main() { return Container( - child: /*caret*/Text('aaa'), + child: /*caret*/new Text('aaa'), ); } '''); @@ -3687,9 +3687,9 @@ import 'package:flutter/widgets.dart'; main() { return Container( - child: /*caret*/Column( + child: /*caret*/new Column( children: [ - Text('aaa'), + new Text('aaa'), ], ), ); diff --git a/pkg/analyzer_plugin/lib/src/utilities/completion/optype.dart b/pkg/analyzer_plugin/lib/src/utilities/completion/optype.dart index acc3c4147c6..15f728433e9 100644 --- a/pkg/analyzer_plugin/lib/src/utilities/completion/optype.dart +++ b/pkg/analyzer_plugin/lib/src/utilities/completion/optype.dart @@ -130,16 +130,6 @@ class OpType { optype.inStaticMethodBody = mthDecl is MethodDeclaration && mthDecl.isStatic; - // If a value should be suggested, suggest also constructors. - if (optype.includeReturnValueSuggestions) { - // Careful: in angular plugin, `target.unit` may be null! - CompilationUnitElement unitElement = target.unit?.element; - if (unitElement != null && - unitElement.context.analysisOptions.previewDart2) { - optype.includeConstructorSuggestions = true; - } - } - // Compute the type required by the context and set filters. optype._computeRequiredTypeAndFilters(target);