diff --git a/pkg/analysis_server/lib/src/computer/computer_highlights.dart b/pkg/analysis_server/lib/src/computer/computer_highlights.dart index 01274279120..084f22e3513 100644 --- a/pkg/analysis_server/lib/src/computer/computer_highlights.dart +++ b/pkg/analysis_server/lib/src/computer/computer_highlights.dart @@ -1144,11 +1144,7 @@ class _DartUnitHighlightsComputerVisitor extends RecursiveAstVisitor { @override void visitMixinDeclaration(MixinDeclaration node) { - computer._addRegion_token(node.sealedKeyword, HighlightRegionType.BUILT_IN); computer._addRegion_token(node.baseKeyword, HighlightRegionType.BUILT_IN); - computer._addRegion_token( - node.interfaceKeyword, HighlightRegionType.BUILT_IN); - computer._addRegion_token(node.finalKeyword, HighlightRegionType.BUILT_IN); computer._addRegion_token(node.mixinKeyword, HighlightRegionType.BUILT_IN); super.visitMixinDeclaration(node); } diff --git a/pkg/analysis_server/lib/src/services/completion/dart/local_library_contributor.dart b/pkg/analysis_server/lib/src/services/completion/dart/local_library_contributor.dart index 46e43cd8b3d..902da6b8ffc 100644 --- a/pkg/analysis_server/lib/src/services/completion/dart/local_library_contributor.dart +++ b/pkg/analysis_server/lib/src/services/completion/dart/local_library_contributor.dart @@ -120,9 +120,6 @@ class LibraryElementSuggestionBuilder extends GeneralizingElementVisitor { if (node is ImplementsClause && !element.isImplementableIn(request.libraryElement)) { return; - } else if (node is WithClause && - !element.isMixableIn(request.libraryElement)) { - return; } _visitInterfaceElement(element); } diff --git a/pkg/analysis_server/lib/src/services/correction/dart/convert_class_to_mixin.dart b/pkg/analysis_server/lib/src/services/correction/dart/convert_class_to_mixin.dart index f587413f56f..7789b37f7d1 100644 --- a/pkg/analysis_server/lib/src/services/correction/dart/convert_class_to_mixin.dart +++ b/pkg/analysis_server/lib/src/services/correction/dart/convert_class_to_mixin.dart @@ -30,6 +30,11 @@ class ConvertClassToMixin extends CorrectionProducer { .any((member) => member is ConstructorDeclaration)) { return; } + if (classDeclaration.finalKeyword != null || + classDeclaration.interfaceKeyword != null || + classDeclaration.sealedKeyword != null) { + return; + } var finder = _SuperclassReferenceFinder(); classDeclaration.accept(finder); var referencedClasses = finder.referencedClasses; diff --git a/pkg/analysis_server/lib/src/services/refactoring/move_top_level_to_file.dart b/pkg/analysis_server/lib/src/services/refactoring/move_top_level_to_file.dart index 035e759285c..e24e9862ffe 100644 --- a/pkg/analysis_server/lib/src/services/refactoring/move_top_level_to_file.dart +++ b/pkg/analysis_server/lib/src/services/refactoring/move_top_level_to_file.dart @@ -225,9 +225,6 @@ class MoveTopLevelToFile extends RefactoringProducer { validSelection(node.name)) { name = node.name.lexeme; } else if (node is MixinDeclaration && validSelection(node.name)) { - if (node.sealedKeyword != null) { - sealedDeclarations.add(node); - } name = node.name.lexeme; } else if (node is TopLevelVariableDeclaration) { var variables = node.variables.variables; @@ -410,7 +407,7 @@ class _MembersToMove { } } -/// A helper to for matching sealed classes/mixins to their subclasses. +/// A helper to for matching sealed classes to their subclasses. class _SealedSubclassIndex { final CompilationUnit unit; @@ -499,9 +496,6 @@ class _SealedSubclassIndex { return const []; } - bool _isSealed(Element element) { - var isSealedClass = element is ClassElement && element.isSealed; - var isSealedMixin = element is MixinElement && element.isSealed; - return isSealedClass || isSealedMixin; - } + bool _isSealed(Element element) => + element is ClassElement && element.isSealed; } diff --git a/pkg/analysis_server/test/analysis/get_hover_test.dart b/pkg/analysis_server/test/analysis/get_hover_test.dart index 1cdb6f44d8b..5c363d98e1f 100644 --- a/pkg/analysis_server/test/analysis/get_hover_test.dart +++ b/pkg/analysis_server/test/analysis/get_hover_test.dart @@ -1229,26 +1229,6 @@ base mixin A {} expect(hover.propagatedType, isNull); } - Future test_mixin_declaration_final() async { - newFile(testFilePath, ''' -final mixin A {} -'''); - var hover = await prepareHover('A'); - expect(hover.elementDescription, 'final mixin A on Object'); - expect(hover.staticType, isNull); - expect(hover.propagatedType, isNull); - } - - Future test_mixin_declaration_interface() async { - newFile(testFilePath, ''' -interface mixin A {} -'''); - var hover = await prepareHover('A'); - expect(hover.elementDescription, 'interface mixin A on Object'); - expect(hover.staticType, isNull); - expect(hover.propagatedType, isNull); - } - @failingTest Future test_mixin_reference() async { newFile(testFilePath, ''' diff --git a/pkg/analysis_server/test/analysis/notification_highlights2_test.dart b/pkg/analysis_server/test/analysis/notification_highlights2_test.dart index e97caea095a..f42b259185c 100644 --- a/pkg/analysis_server/test/analysis/notification_highlights2_test.dart +++ b/pkg/analysis_server/test/analysis/notification_highlights2_test.dart @@ -242,7 +242,6 @@ void f() { Future test_BUILT_IN_final() async { addTestFile(''' final class A {} -final mixin M {} final class B = Object with M; void f() { var final = 42; @@ -250,7 +249,6 @@ void f() { '''); await prepareHighlights(); assertHasRegion(HighlightRegionType.BUILT_IN, 'final class A'); - assertHasRegion(HighlightRegionType.BUILT_IN, 'final mixin M'); assertHasRegion(HighlightRegionType.BUILT_IN, 'final class B'); assertNoRegion(HighlightRegionType.BUILT_IN, 'final = 42'); } @@ -319,7 +317,6 @@ void f() { Future test_BUILT_IN_interface() async { addTestFile(''' interface class A {} -interface mixin M {} interface class B = Object with M; void f() { var interface = 42; @@ -327,7 +324,6 @@ void f() { '''); await prepareHighlights(); assertHasRegion(HighlightRegionType.BUILT_IN, 'interface class A'); - assertHasRegion(HighlightRegionType.BUILT_IN, 'interface mixin M'); assertHasRegion(HighlightRegionType.BUILT_IN, 'interface class B'); assertNoRegion(HighlightRegionType.BUILT_IN, 'interface = 42'); } @@ -437,7 +433,6 @@ void f() { Future test_BUILT_IN_sealed() async { addTestFile(''' sealed class A {} -sealed mixin M {} sealed class B = Object with M; void f() { var sealed = 42; @@ -445,7 +440,6 @@ void f() { '''); await prepareHighlights(); assertHasRegion(HighlightRegionType.BUILT_IN, 'sealed class A'); - assertHasRegion(HighlightRegionType.BUILT_IN, 'sealed mixin M'); assertHasRegion(HighlightRegionType.BUILT_IN, 'sealed class B'); assertNoRegion(HighlightRegionType.BUILT_IN, 'sealed = 42'); } diff --git a/pkg/analysis_server/test/services/completion/dart/location/implements_clause_test.dart b/pkg/analysis_server/test/services/completion/dart/location/implements_clause_test.dart index 6bc2c04d7a1..b97bb13eebd 100644 --- a/pkg/analysis_server/test/services/completion/dart/location/implements_clause_test.dart +++ b/pkg/analysis_server/test/services/completion/dart/location/implements_clause_test.dart @@ -143,9 +143,6 @@ suggestions Future test_mixin_inside() async { await computeSuggestions(''' base mixin FooBase {} -interface mixin FooInterface {} -final mixin FooFinal {} -sealed mixin FooSealed {} class A implements ^ '''); @@ -153,12 +150,6 @@ class A implements ^ suggestions FooBase kind: mixin - FooFinal - kind: mixin - FooInterface - kind: mixin - FooSealed - kind: mixin '''); } @@ -178,63 +169,6 @@ suggestions } else { assertResponse(''' suggestions -'''); - } - } - - Future test_mixin_outside_final() async { - newFile('$testPackageLibPath/a.dart', 'final mixin Foo {}'); - await computeSuggestions(''' -lib B; -import 'a.dart'; -class A implements ^ -'''); - - if (isProtocolVersion1) { - assertResponse(''' -suggestions - Foo - kind: mixin -'''); - } else { - assertResponse(''' -suggestions -'''); - } - } - - Future test_mixin_outside_interface() async { - newFile('$testPackageLibPath/a.dart', 'interface mixin Foo {}'); - await computeSuggestions(''' -lib B; -import 'a.dart'; -class A implements ^ -'''); - - assertResponse(''' -suggestions - Foo - kind: mixin -'''); - } - - Future test_mixin_outside_sealed() async { - newFile('$testPackageLibPath/a.dart', 'sealed mixin Foo {}'); - await computeSuggestions(''' -lib B; -import 'a.dart'; -class A implements ^ -'''); - - if (isProtocolVersion1) { - assertResponse(''' -suggestions - Foo - kind: mixin -'''); - } else { - assertResponse(''' -suggestions '''); } } diff --git a/pkg/analysis_server/test/services/completion/dart/location/with_clause_test.dart b/pkg/analysis_server/test/services/completion/dart/location/with_clause_test.dart index 06046c45bf8..1dde2d27aec 100644 --- a/pkg/analysis_server/test/services/completion/dart/location/with_clause_test.dart +++ b/pkg/analysis_server/test/services/completion/dart/location/with_clause_test.dart @@ -94,12 +94,9 @@ suggestions } } - Future test_mixin_inside() async { + Future test_mixin_base_inside() async { await computeSuggestions(''' base mixin FooBase {} -interface mixin FooInterface {} -final mixin FooFinal {} -sealed mixin FooSealed {} class A with ^ '''); @@ -107,16 +104,10 @@ class A with ^ suggestions FooBase kind: mixin - FooFinal - kind: mixin - FooInterface - kind: mixin - FooSealed - kind: mixin '''); } - Future test_mixin_outside_base() async { + Future test_mixin_base_outside() async { newFile('$testPackageLibPath/a.dart', 'base mixin Foo {}'); await computeSuggestions(''' import 'a.dart'; @@ -130,70 +121,7 @@ suggestions '''); } - Future test_mixin_outside_final() async { - newFile('$testPackageLibPath/a.dart', 'final mixin Foo {}'); - await computeSuggestions(''' -lib B; -import 'a.dart'; -class A with ^ -'''); - - if (isProtocolVersion1) { - assertResponse(''' -suggestions - Foo - kind: mixin -'''); - } else { - assertResponse(''' -suggestions -'''); - } - } - - Future test_mixin_outside_interface() async { - newFile('$testPackageLibPath/a.dart', 'interface mixin Foo {}'); - await computeSuggestions(''' -lib B; -import 'a.dart'; -class A with ^ -'''); - - if (isProtocolVersion1) { - assertResponse(''' -suggestions - Foo - kind: mixin -'''); - } else { - assertResponse(''' -suggestions -'''); - } - } - - Future test_mixin_outside_sealed() async { - newFile('$testPackageLibPath/a.dart', 'sealed mixin Foo {}'); - await computeSuggestions(''' -lib B; -import 'a.dart'; -class A with ^ -'''); - - if (isProtocolVersion1) { - assertResponse(''' -suggestions - Foo - kind: mixin -'''); - } else { - assertResponse(''' -suggestions -'''); - } - } - - Future test_mixinClass_inside() async { + Future test_mixinClass_base_inside() async { await computeSuggestions(''' base mixin class FooBaseMixinClass {} mixin class FooMixinClass {} @@ -209,7 +137,7 @@ suggestions '''); } - Future test_mixinClass_outside() async { + Future test_mixinClass_base_outside() async { newFile('$testPackageLibPath/a.dart', ''' base mixin class FooBaseMixinClass {} mixin class FooMixinClass {} diff --git a/pkg/analysis_server/test/src/services/correction/assist/convert_class_to_mixin_test.dart b/pkg/analysis_server/test/src/services/correction/assist/convert_class_to_mixin_test.dart index 59c1bea883c..9693592fc50 100644 --- a/pkg/analysis_server/test/src/services/correction/assist/convert_class_to_mixin_test.dart +++ b/pkg/analysis_server/test/src/services/correction/assist/convert_class_to_mixin_test.dart @@ -375,10 +375,7 @@ mixin D on B implements A, C { class A {} final class B implements A {} '''); - await assertHasAssistAt('B', ''' -class A {} -final mixin B implements A {} -'''); + await assertNoAssistAt('B'); } Future test_implements() async { @@ -422,10 +419,7 @@ mixin A {} class A {} sealed class B extends A {} '''); - await assertHasAssistAt('B', ''' -class A {} -sealed mixin B implements A {} -'''); + await assertNoAssistAt('B'); } Future test_sealed_extendsWith_super_extends() async { @@ -442,19 +436,7 @@ sealed class C extends A with B { } } '''); - await assertHasAssistAt('C', ''' -class A { - a() {} -} -mixin class B { - b() {} -} -sealed mixin C on A implements B { - c() { - super.a(); - } -} -'''); + await assertNoAssistAt('C'); } Future test_typeParameters() async { diff --git a/pkg/analysis_server/test/src/services/refactoring/move_top_level_to_file_test.dart b/pkg/analysis_server/test/src/services/refactoring/move_top_level_to_file_test.dart index d8bae7afcef..9472e15b0d8 100644 --- a/pkg/analysis_server/test/src/services/refactoring/move_top_level_to_file_test.dart +++ b/pkg/analysis_server/test/src/services/refactoring/move_top_level_to_file_test.dart @@ -602,100 +602,6 @@ class SubSubclass extends SealedSubclass {} newFileContent: newFileContent); } - Future test_sealedMixin_implements() async { - var originalSource = ''' -sealed mixin [!Either!] {} - -class Left implements Either {} -mixin Right implements Either {} - -class Neither {} -'''; - var modifiedSource = ''' - -class Neither {} -'''; - var newFileName = 'either.dart'; - var newFileContent = ''' -sealed mixin Either {} - -class Left implements Either {} -mixin Right implements Either {} -'''; - await _multipleDeclarations( - originalSource: originalSource, - modifiedSource: modifiedSource, - count: 3, - newFileName: newFileName, - newFileContent: newFileContent); - } - - Future test_sealedMixin_on_subclass() async { - addTestSource(''' -sealed mixin SealedMixin {} - -mixin [!OtherMixin!] on SealedMixin {} -'''); - await initializeServer(); - await expectNoCodeAction(null); - } - - Future test_sealedMixin_on_superclass() async { - var originalSource = ''' -sealed mixin [!SealedMixin!] {} - -mixin MixinToMove on SealedMixin {} - -mixin MixinToStay on MixinToMove {} -'''; - var modifiedSource = ''' -import 'package:test/sealed_mixin.dart'; - - -mixin MixinToStay on MixinToMove {} -'''; - var newFileName = 'sealed_mixin.dart'; - var newFileContent = ''' -sealed mixin SealedMixin {} - -mixin MixinToMove on SealedMixin {} -'''; - await _multipleDeclarations( - originalSource: originalSource, - modifiedSource: modifiedSource, - count: 2, - newFileName: newFileName, - newFileContent: newFileContent); - } - - Future test_sealedMixin_with() async { - var originalSource = ''' -sealed mixin [!Either!] {} - -class Left with Either {} -class Right with Either {} - -class Neither {} -'''; - var modifiedSource = ''' - -class Neither {} -'''; - var newFileName = 'either.dart'; - var newFileContent = ''' -sealed mixin Either {} - -class Left with Either {} -class Right with Either {} -'''; - await _multipleDeclarations( - originalSource: originalSource, - modifiedSource: modifiedSource, - count: 3, - newFileName: newFileName, - newFileContent: newFileContent); - } - Future test_single_class_withTypeParameters() async { var originalSource = ''' class A {}