diff --git a/pkg/analysis_server/test/plugin/protocol_dart_test.dart b/pkg/analysis_server/test/plugin/protocol_dart_test.dart index da9514dbcaa..e8028635b7f 100644 --- a/pkg/analysis_server/test/plugin/protocol_dart_test.dart +++ b/pkg/analysis_server/test/plugin/protocol_dart_test.dart @@ -2,8 +2,6 @@ // 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. -// @dart = 2.9 - import 'package:analysis_server/plugin/protocol/protocol_dart.dart'; import 'package:analyzer/dart/element/element.dart' as engine; import 'package:analyzer/src/dart/element/element.dart' as engine; @@ -88,7 +86,7 @@ class B {}'''); expect(element.name, '_A'); expect(element.typeParameters, isNull); { - var location = element.location; + var location = element.location!; expect(location.file, testFile); expect(location.offset, 27); expect(location.length, '_A'.length); @@ -125,7 +123,7 @@ class A { expect(element.name, 'myConstructor'); expect(element.typeParameters, isNull); { - var location = element.location; + var location = element.location!; expect(location.file, testFile); expect(location.offset, 20); expect(location.length, 'myConstructor'.length); @@ -210,7 +208,7 @@ enum E2 { three, four }'''); expect(element.name, '_E1'); expect(element.typeParameters, isNull); { - var location = element.location; + var location = element.location!; expect(location.file, testFile); expect(location.offset, 17); expect(location.length, '_E1'.length); @@ -246,7 +244,7 @@ enum E2 { three, four }'''); expect(element.kind, ElementKind.ENUM_CONSTANT); expect(element.name, 'one'); { - var location = element.location; + var location = element.location!; expect(location.file, testFile); expect(location.offset, 23); expect(location.length, 'one'.length); @@ -270,7 +268,7 @@ enum E2 { three, four }'''); expect(element.kind, ElementKind.ENUM_CONSTANT); expect(element.name, 'three'); { - var location = element.location; + var location = element.location!; expect(location.file, testFile); expect(location.offset, 44); expect(location.length, 'three'.length); @@ -288,7 +286,7 @@ enum E2 { three, four }'''); expect(element.kind, ElementKind.FIELD); expect(element.name, 'index'); { - var location = element.location; + var location = element.location!; expect(location.file, testFile); expect(location.offset, -1); expect(location.length, 'index'.length); @@ -306,7 +304,7 @@ enum E2 { three, four }'''); expect(element.kind, ElementKind.FIELD); expect(element.name, 'values'); { - var location = element.location; + var location = element.location!; expect(location.file, testFile); expect(location.offset, -1); expect(location.length, 'values'.length); @@ -330,7 +328,7 @@ class A { expect(element.kind, ElementKind.FIELD); expect(element.name, 'myField'); { - var location = element.location; + var location = element.location!; expect(location.file, testFile); expect(location.offset, 25); expect(location.length, 'myField'.length); @@ -353,7 +351,7 @@ typedef F = int Function(String x); expect(element.name, 'F'); expect(element.typeParameters, ''); { - var location = element.location; + var location = element.location!; expect(location.file, testFile); expect(location.offset, 8); expect(location.length, 'F'.length); @@ -376,7 +374,7 @@ typedef F = Map; expect(element.name, 'F'); expect(element.typeParameters, ''); { - var location = element.location; + var location = element.location!; expect(location.file, testFile); expect(location.offset, 8); expect(location.length, 'F'.length); @@ -400,7 +398,7 @@ typedef int F(String x); expect(element.name, 'F'); expect(element.typeParameters, ''); { - var location = element.location; + var location = element.location!; expect(location.file, testFile); expect(location.offset, 12); expect(location.length, 'F'.length); @@ -424,7 +422,7 @@ class A { expect(element.kind, ElementKind.GETTER); expect(element.name, 'myGetter'); { - var location = element.location; + var location = element.location!; expect(location.file, testFile); expect(location.offset, 23); expect(location.length, 'myGetter'.length); @@ -450,7 +448,7 @@ myLabel: expect(element.kind, ElementKind.LABEL); expect(element.name, 'myLabel'); { - var location = element.location; + var location = element.location!; expect(location.file, testFile); expect(location.offset, 9); expect(location.length, 'myLabel'.length); @@ -475,7 +473,7 @@ class A { expect(element.kind, ElementKind.METHOD); expect(element.name, 'myMethod'); { - var location = element.location; + var location = element.location!; expect(location.file, testFile); expect(location.offset, 32); expect(location.length, 'myGetter'.length); @@ -499,7 +497,7 @@ mixin A {} expect(element.name, 'A'); expect(element.typeParameters, isNull); { - var location = element.location; + var location = element.location!; expect(location.file, testFile); expect(location.offset, 6); expect(location.length, 'A'.length); @@ -522,7 +520,7 @@ class A { expect(element.kind, ElementKind.SETTER); expect(element.name, 'mySetter'); { - var location = element.location; + var location = element.location!; expect(location.file, testFile); expect(location.offset, 16); expect(location.length, 'mySetter'.length); diff --git a/pkg/analysis_server/test/search/search_result_test.dart b/pkg/analysis_server/test/search/search_result_test.dart index 978f0ec8cae..25308ca234c 100644 --- a/pkg/analysis_server/test/search/search_result_test.dart +++ b/pkg/analysis_server/test/search/search_result_test.dart @@ -2,8 +2,6 @@ // 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. -// @dart = 2.9 - import 'package:analysis_server/src/protocol_server.dart'; import 'package:analysis_server/src/services/search/search_engine.dart'; import 'package:test/test.dart'; @@ -30,7 +28,6 @@ class SearchResultKindTest { SearchResultKind.REFERENCE); expect(newSearchResultKind_fromEngine(MatchKind.INVOCATION), SearchResultKind.INVOCATION); - expect(newSearchResultKind_fromEngine(null), SearchResultKind.UNKNOWN); } void test_fromName() { diff --git a/pkg/analysis_server/test/services/correction/change_test.dart b/pkg/analysis_server/test/services/correction/change_test.dart index 8616a2ce359..dead4df124a 100644 --- a/pkg/analysis_server/test/services/correction/change_test.dart +++ b/pkg/analysis_server/test/services/correction/change_test.dart @@ -2,8 +2,6 @@ // 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. -// @dart = 2.9 - import 'package:analysis_server/src/protocol_server.dart'; import 'package:analyzer/src/generated/source.dart'; import 'package:test/test.dart'; @@ -34,8 +32,7 @@ class ChangeTest { change.addEdit('/a.dart', 0, edit2); expect(change.edits, hasLength(1)); { - var fileEdit = change.getFileEdit('/a.dart'); - expect(fileEdit, isNotNull); + var fileEdit = change.getFileEdit('/a.dart')!; expect(fileEdit.edits, unorderedEquals([edit1, edit2])); } } diff --git a/pkg/analysis_server/test/services/correction/status_test.dart b/pkg/analysis_server/test/services/correction/status_test.dart index 3bcc7a9847d..41c0eec44bd 100644 --- a/pkg/analysis_server/test/services/correction/status_test.dart +++ b/pkg/analysis_server/test/services/correction/status_test.dart @@ -2,8 +2,6 @@ // 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. -// @dart = 2.9 - import 'package:analysis_server/src/protocol_server.dart' hide Element; import 'package:analysis_server/src/services/correction/status.dart'; import 'package:analysis_server/src/services/search/search_engine.dart'; @@ -28,7 +26,7 @@ class RefactoringLocationTest extends AbstractSingleUnitTest { await resolveTestCode('class MyClass {}'); var element = findElement.class_('MyClass'); // check - var location = newLocation_fromElement(element); + var location = newLocation_fromElement(element)!; expect(location.file, testFile); expect(location.offset, 6); expect(location.length, 7); @@ -114,9 +112,10 @@ class RefactoringStatusTest { var problems = refactoringStatus.problems; expect(problems, hasLength(1)); expect(problems[0].message, 'msg'); - expect(problems[0].location.file, '/test.dart'); - expect(problems[0].location.offset, 1); - expect(problems[0].location.length, 2); + var problemLocation = problems[0].location!; + expect(problemLocation.file, '/test.dart'); + expect(problemLocation.offset, 1); + expect(problemLocation.length, 2); // add WARNING, resulting severity is still FATAL refactoringStatus.addWarning('warning'); expect(refactoringStatus.severity, RefactoringProblemSeverity.FATAL); @@ -202,22 +201,22 @@ class RefactoringStatusTest { refactoringStatus.addError('msgError'); refactoringStatus.addWarning('msgWarning'); refactoringStatus.addFatalError('msgFatalError'); + var problem = refactoringStatus.problem!; // get entry - { - var problem = refactoringStatus.problem; - expect(problem.severity, RefactoringProblemSeverity.FATAL); - expect(problem.message, 'msgFatalError'); - } + expect(problem.severity, RefactoringProblemSeverity.FATAL); + expect(problem.message, 'msgFatalError'); // get message - expect(refactoringStatus.problem.message, 'msgFatalError'); + expect(problem.message, 'msgFatalError'); } void test_newError() { var location = Location('/test.dart', 1, 2, 3, 4, 5, 6); var refactoringStatus = RefactoringStatus.error('msg', location); + var problem = refactoringStatus.problem!; + var problemLocation = problem.location!; expect(refactoringStatus.severity, RefactoringProblemSeverity.ERROR); - expect(refactoringStatus.problem.message, 'msg'); - expect(refactoringStatus.problem.location.file, '/test.dart'); + expect(problem.message, 'msg'); + expect(problemLocation.file, '/test.dart'); } void test_newFatalError() {