Stop using external deprecated members in front_end

Change-Id: I3fa03de568f72bfc3adb46efcfa2b61b781c706b
Reviewed-on: https://dart-review.googlesource.com/c/89020
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Reviewed-by: Peter von der Ahé <ahe@google.com>
diff --git a/pkg/compiler/lib/src/dart2js.dart b/pkg/compiler/lib/src/dart2js.dart
index dbfe890..50b8aeb 100644
--- a/pkg/compiler/lib/src/dart2js.dart
+++ b/pkg/compiler/lib/src/dart2js.dart
@@ -658,7 +658,7 @@
   if (uri.scheme != 'file') {
     fail('Unhandled scheme ${uri.scheme}.');
   }
-  var file = new File(uri.toFilePath()).openSync(mode: FileMode.WRITE);
+  var file = new File(uri.toFilePath()).openSync(mode: FileMode.write);
   file.writeStringSync(text);
   file.closeSync();
 }
diff --git a/pkg/front_end/analysis_options.yaml b/pkg/front_end/analysis_options.yaml
index ae13d06..0fb6ccc 100644
--- a/pkg/front_end/analysis_options.yaml
+++ b/pkg/front_end/analysis_options.yaml
@@ -9,8 +9,5 @@
     # Allow having TODOs in the code
     todo: ignore
 
-    # Allow cross-package deprecated calls
-    # TODO(srawlins): clean these up and remove this "ignore."
-    deprecated_member_use: ignore
     # Allow deprecated calls from within the same package
     deprecated_member_use_from_same_package: ignore
diff --git a/pkg/front_end/lib/src/api_prototype/terminal_color_support.dart b/pkg/front_end/lib/src/api_prototype/terminal_color_support.dart
index 4d866f3..e0e3ebc 100644
--- a/pkg/front_end/lib/src/api_prototype/terminal_color_support.dart
+++ b/pkg/front_end/lib/src/api_prototype/terminal_color_support.dart
@@ -87,7 +87,7 @@
   }
 
   String numberOfColors = lines[0];
-  if (int.parse(numberOfColors, onError: (_) => -1) < 8) {
+  if (int.tryParse(numberOfColors) ?? -1 < 8) {
     if (debug) {
       print("Not enabling colors, less than 8 colors supported: "
           "${jsonEncode(numberOfColors)}.");
diff --git a/pkg/front_end/lib/src/fasta/colors.dart b/pkg/front_end/lib/src/fasta/colors.dart
index 65b2e79..edde5bb 100644
--- a/pkg/front_end/lib/src/fasta/colors.dart
+++ b/pkg/front_end/lib/src/fasta/colors.dart
@@ -174,7 +174,7 @@
   }
 
   String numberOfColors = lines[0];
-  if (int.parse(numberOfColors, onError: (_) => -1) < 8) {
+  if (int.tryParse(numberOfColors) ?? -1 < 8) {
     if (context.options.verbose) {
       print("Not enabling colors, less than 8 colors supported: "
           "${jsonEncode(numberOfColors)}.");
diff --git a/pkg/front_end/lib/src/fasta/crash.dart b/pkg/front_end/lib/src/fasta/crash.dart
index f4745d5..8498da9 100644
--- a/pkg/front_end/lib/src/fasta/crash.dart
+++ b/pkg/front_end/lib/src/fasta/crash.dart
@@ -93,7 +93,7 @@
       int port = request?.connectionInfo?.remotePort;
       await note(" to $host:$port");
       await request
-        ..headers.contentType = ContentType.JSON
+        ..headers.contentType = ContentType.json
         ..write(json);
       await request.close();
       await note(".");
diff --git a/pkg/front_end/test/fasta/parser/type_info_test.dart b/pkg/front_end/test/fasta/parser/type_info_test.dart
index 2f13cfe..eced64d 100644
--- a/pkg/front_end/test/fasta/parser/type_info_test.dart
+++ b/pkg/front_end/test/fasta/parser/type_info_test.dart
@@ -140,7 +140,7 @@
     final TypeInfoListener listener = new TypeInfoListener();
 
     expect(noType.ensureTypeNotVoid(start, new Parser(listener)),
-        new isInstanceOf<SyntheticStringToken>());
+        const TypeMatcher<SyntheticStringToken>());
     expect(listener.calls, [
       'handleIdentifier  typeReference',
       'handleNoTypeArguments ;',
@@ -154,7 +154,7 @@
     final TypeInfoListener listener = new TypeInfoListener();
 
     expect(noType.ensureTypeOrVoid(start, new Parser(listener)),
-        new isInstanceOf<SyntheticStringToken>());
+        const TypeMatcher<SyntheticStringToken>());
     expect(listener.calls, [
       'handleIdentifier  typeReference',
       'handleNoTypeArguments ;',
@@ -2478,7 +2478,7 @@
 }
 
 void expectNestedComplexInfo(String source) {
-  expectNestedInfo(const isInstanceOf<ComplexTypeInfo>(), source);
+  expectNestedInfo(const TypeMatcher<ComplexTypeInfo>(), source);
 }
 
 TypeInfo compute(expectedInfo, String source, Token start, bool required,
@@ -2502,7 +2502,7 @@
     List<ExpectedError> expectedErrors) {
   int expectedGtGtAndNullEndCount = countGtGtAndNullEnd(start);
   ComplexTypeInfo typeInfo = compute(
-      const isInstanceOf<ComplexTypeInfo>(), source, start, required,
+      const TypeMatcher<ComplexTypeInfo>(), source, start, required,
       inDeclaration: inDeclaration);
   expect(typeInfo.start, start.next, reason: source);
   expect(typeInfo.couldBeExpression, couldBeExpression);
@@ -2530,7 +2530,7 @@
   Token start = scan(source);
   int expectedGtGtAndNullEndCount = countGtGtAndNullEnd(start);
   ComplexTypeParamOrArgInfo typeVarInfo = computeVar(
-      const isInstanceOf<ComplexTypeParamOrArgInfo>(),
+      const TypeMatcher<ComplexTypeParamOrArgInfo>(),
       source,
       start,
       inDeclaration);
@@ -2564,7 +2564,7 @@
   Token start = scan(source);
   int expectedGtGtAndNullEndCount = countGtGtAndNullEnd(start);
   ComplexTypeParamOrArgInfo typeVarInfo = computeVar(
-      const isInstanceOf<ComplexTypeParamOrArgInfo>(),
+      const TypeMatcher<ComplexTypeParamOrArgInfo>(),
       source,
       start,
       inDeclaration);
diff --git a/pkg/front_end/test/fasta/type_inference/interface_resolver_test.dart b/pkg/front_end/test/fasta/type_inference/interface_resolver_test.dart
index d34cb01..0b6ee37 100644
--- a/pkg/front_end/test/fasta/type_inference/interface_resolver_test.dart
+++ b/pkg/front_end/test/fasta/type_inference/interface_resolver_test.dart
@@ -220,7 +220,7 @@
     var field = makeField();
     var class_ = makeClass(fields: [field]);
     var candidate = getCandidate(class_, false);
-    expect(candidate, new isInstanceOf<SyntheticAccessor>());
+    expect(candidate, const TypeMatcher<SyntheticAccessor>());
     expect(candidate.parent, same(class_));
     expect(candidate.name, field.name);
     expect(candidate.kind, ProcedureKind.Getter);
@@ -233,7 +233,7 @@
     var field = makeField();
     var class_ = makeClass(fields: [field]);
     var candidate = getCandidate(class_, true);
-    expect(candidate, new isInstanceOf<SyntheticAccessor>());
+    expect(candidate, const TypeMatcher<SyntheticAccessor>());
     expect(candidate.parent, same(class_));
     expect(candidate.name, field.name);
     expect(candidate.kind, ProcedureKind.Setter);
diff --git a/pkg/front_end/test/memory_file_system_test.dart b/pkg/front_end/test/memory_file_system_test.dart
index 366d2a1..c62dbc3 100644
--- a/pkg/front_end/test/memory_file_system_test.dart
+++ b/pkg/front_end/test/memory_file_system_test.dart
@@ -25,8 +25,8 @@
   });
 }
 
-const Matcher _throwsFileSystemException =
-    const Throws(const isInstanceOf<FileSystemException>());
+final Matcher _throwsFileSystemException =
+    throwsA(const TypeMatcher<FileSystemException>());
 
 @reflectiveTest
 class FileTest extends _BaseTestNative {
@@ -233,7 +233,7 @@
     ]) {
       if (!uri.path.startsWith('/')) {
         expect(() => fileSystem.entityForUri(uri),
-            throwsA(new isInstanceOf<Error>()));
+            throwsA(const TypeMatcher<Error>()));
       }
     }
   }
diff --git a/pkg/front_end/test/scanner_replacement_test.dart b/pkg/front_end/test/scanner_replacement_test.dart
index a9f0b70..aa227f1 100644
--- a/pkg/front_end/test/scanner_replacement_test.dart
+++ b/pkg/front_end/test/scanner_replacement_test.dart
@@ -242,7 +242,7 @@
         token = token.next;
       }
     }
-    var isNotErrorToken = isNot(new isInstanceOf<fasta.ErrorToken>());
+    var isNotErrorToken = isNot(const TypeMatcher<fasta.ErrorToken>());
     while (!token.isEof) {
       if (errorsFirst) expect(token, isNotErrorToken);
       previous = token;
diff --git a/pkg/front_end/test/scanner_test.dart b/pkg/front_end/test/scanner_test.dart
index 936ad38..67a212b 100644
--- a/pkg/front_end/test/scanner_test.dart
+++ b/pkg/front_end/test/scanner_test.dart
@@ -113,7 +113,7 @@
     if (lessThan is BeginToken) {
       expect(lessThan.endToken, greaterThan);
     }
-    expect(greaterThan, isNot(new isInstanceOf<BeginToken>()));
+    expect(greaterThan, isNot(const TypeMatcher<BeginToken>()));
   }
 
   void test_async_star() {
diff --git a/pkg/front_end/test/standard_file_system_test.dart b/pkg/front_end/test/standard_file_system_test.dart
index bd67f3b..5644c98 100644
--- a/pkg/front_end/test/standard_file_system_test.dart
+++ b/pkg/front_end/test/standard_file_system_test.dart
@@ -25,8 +25,8 @@
   });
 }
 
-const Matcher _throwsFileSystemException =
-    const Throws(const isInstanceOf<FileSystemException>());
+final Matcher _throwsFileSystemException =
+    throwsA(const TypeMatcher<FileSystemException>());
 
 @reflectiveTest
 class DirectoryTest extends _BaseTest {
@@ -197,7 +197,7 @@
     ]) {
       if (!uri.path.startsWith('/')) {
         expect(() => StandardFileSystem.instance.entityForUri(uri),
-            throwsA(new isInstanceOf<Error>()));
+            throwsA(const TypeMatcher<Error>()));
       }
     }
   }
diff --git a/pkg/front_end/test/token_test.dart b/pkg/front_end/test/token_test.dart
index 4b39e62..686c789 100644
--- a/pkg/front_end/test/token_test.dart
+++ b/pkg/front_end/test/token_test.dart
@@ -46,22 +46,22 @@
     Token comment = nextComment();
     expect(comment.lexeme, contains('Single line dartdoc comment'));
     expect(comment.type, TokenType.SINGLE_LINE_COMMENT);
-    expect(comment, new isInstanceOf<DocumentationCommentToken>());
+    expect(comment, const TypeMatcher<DocumentationCommentToken>());
 
     comment = nextComment();
     expect(comment.lexeme, contains('Multi-line dartdoc comment'));
     expect(comment.type, TokenType.MULTI_LINE_COMMENT);
-    expect(comment, new isInstanceOf<DocumentationCommentToken>());
+    expect(comment, const TypeMatcher<DocumentationCommentToken>());
 
     comment = nextComment();
     expect(comment.lexeme, contains('Single line comment'));
     expect(comment.type, TokenType.SINGLE_LINE_COMMENT);
-    expect(comment, new isInstanceOf<CommentToken>());
+    expect(comment, const TypeMatcher<CommentToken>());
 
     comment = nextComment();
     expect(comment.lexeme, contains('Multi-line comment'));
     expect(comment.type, TokenType.MULTI_LINE_COMMENT);
-    expect(comment, new isInstanceOf<CommentToken>());
+    expect(comment, const TypeMatcher<CommentToken>());
   }
 
   void test_isSynthetic() {
diff --git a/pkg/front_end/tool/_fasta/command_line.dart b/pkg/front_end/tool/_fasta/command_line.dart
index d4ccb3a..e4c2dff 100644
--- a/pkg/front_end/tool/_fasta/command_line.dart
+++ b/pkg/front_end/tool/_fasta/command_line.dart
@@ -182,10 +182,11 @@
             }
             var parsedValue;
             if (valueSpecification == int) {
-              parsedValue = int.parse(value, onError: (_) {
+              parsedValue = int.tryParse(value);
+              if (parsedValue == null) {
                 return throw new CommandLineProblem.deprecated(
                     "Value for '$argument', '$value', isn't an int.");
-              });
+              }
             } else if (valueSpecification == bool) {
               if (value == null || value == "true" || value == "yes") {
                 parsedValue = true;
diff --git a/pkg/front_end/tool/_fasta/log_collector.dart b/pkg/front_end/tool/_fasta/log_collector.dart
index 5f3e184..f95564c 100644
--- a/pkg/front_end/tool/_fasta/log_collector.dart
+++ b/pkg/front_end/tool/_fasta/log_collector.dart
@@ -38,14 +38,14 @@
   } on FormatException catch (e) {
     print(e);
     return badRequest(
-        request, HttpStatus.BAD_REQUEST, "Malformed JSON data: ${e.message}.");
+        request, HttpStatus.badRequest, "Malformed JSON data: ${e.message}.");
   }
   if (data is! Map) {
     return badRequest(
-        request, HttpStatus.BAD_REQUEST, "Malformed JSON data: not a map.");
+        request, HttpStatus.badRequest, "Malformed JSON data: not a map.");
   }
   if (data["type"] != "crash") {
-    return badRequest(request, HttpStatus.BAD_REQUEST,
+    return badRequest(request, HttpStatus.badRequest,
         "Malformed JSON data: type should be 'crash'.");
   }
   request.response.close();
@@ -92,16 +92,16 @@
     throw "Unexpected arguments: ${arguments.join(' ')}.";
   }
   int port = uri.hasPort ? uri.port : 0;
-  var host = uri.host.isEmpty ? InternetAddress.LOOPBACK_IP_V4 : uri.host;
+  var host = uri.host.isEmpty ? InternetAddress.loopbackIPv4 : uri.host;
   HttpServer server = await HttpServer.bind(host, port);
   print("Listening on http://${server.address.host}:${server.port}/");
   await for (HttpRequest request in server) {
     if (request.method != "POST") {
-      badRequest(request, HttpStatus.METHOD_NOT_ALLOWED, "Not allowed.");
+      badRequest(request, HttpStatus.methodNotAllowed, "Not allowed.");
       continue;
     }
     if (request.uri.path != "/") {
-      badRequest(request, HttpStatus.NOT_FOUND, "Not found.");
+      badRequest(request, HttpStatus.notFound, "Not found.");
       continue;
     }
     collectLog(new DateTime.now(), request);
diff --git a/pkg/front_end/tool/_fasta/resolve_input_uri_test.dart b/pkg/front_end/tool/_fasta/resolve_input_uri_test.dart
index d644f92..9e499db 100644
--- a/pkg/front_end/tool/_fasta/resolve_input_uri_test.dart
+++ b/pkg/front_end/tool/_fasta/resolve_input_uri_test.dart
@@ -22,8 +22,9 @@
     expect(resolveInputUri('c:/foo').scheme, 'file');
     if (Platform.isWindows) {
       /// : is an invalid path character in windows.
-      expect(() => resolveInputUri('test:foo').scheme, throws);
-      expect(() => resolveInputUri('org-dartlang-foo:bar').scheme, throws);
+      expect(() => resolveInputUri('test:foo').scheme, throwsFormatException);
+      expect(() => resolveInputUri('org-dartlang-foo:bar').scheme,
+          throwsFormatException);
     } else {
       expect(resolveInputUri('test:foo').scheme, 'file');
       expect(resolveInputUri('org-dartlang-foo:bar').scheme, 'file');
diff --git a/pkg/front_end/tool/perf.dart b/pkg/front_end/tool/perf.dart
index 582d65a..553ffc6 100644
--- a/pkg/front_end/tool/perf.dart
+++ b/pkg/front_end/tool/perf.dart
@@ -22,13 +22,13 @@
 import 'package:analyzer/error/listener.dart';
 import 'package:analyzer/file_system/physical_file_system.dart'
     show PhysicalResourceProvider;
-import 'package:analyzer/source/package_map_resolver.dart';
 import 'package:analyzer/src/context/builder.dart';
 import 'package:analyzer/src/dart/sdk/sdk.dart' show FolderBasedDartSdk;
 import 'package:analyzer/src/file_system/file_system.dart';
 import 'package:analyzer/src/generated/parser.dart';
 import 'package:analyzer/src/generated/source.dart';
 import 'package:analyzer/src/generated/source_io.dart';
+import 'package:analyzer/src/source/package_map_resolver.dart';
 import 'package:front_end/src/fasta/scanner.dart';
 import 'package:front_end/src/scanner/token.dart';
 import 'package:package_config/discovery.dart';
diff --git a/tests/compiler/dart2js/helpers/memory_compiler.dart b/tests/compiler/dart2js/helpers/memory_compiler.dart
index 6062660..ce4eda7 100644
--- a/tests/compiler/dart2js/helpers/memory_compiler.dart
+++ b/tests/compiler/dart2js/helpers/memory_compiler.dart
@@ -114,9 +114,7 @@
   Uri platformBinaries = computePlatformBinariesLocation();
 
   if (packageRoot == null && packageConfig == null) {
-    if (Platform.packageRoot != null) {
-      packageRoot = Uri.base.resolve(Platform.packageRoot);
-    } else if (Platform.packageConfig != null) {
+    if (Platform.packageConfig != null) {
       packageConfig = Uri.base.resolve(Platform.packageConfig);
     } else {
       // The tests are run with the base directory as the SDK root
diff --git a/tools/patch_sdk.dart b/tools/patch_sdk.dart
index 458ee6b..b0ef7d7 100644
--- a/tools/patch_sdk.dart
+++ b/tools/patch_sdk.dart
@@ -12,7 +12,11 @@
 import 'dart:math' as math;
 import 'dart:convert' show jsonEncode;
 
-import 'package:analyzer/analyzer.dart';
+// ignore: deprecated_member_use
+import 'package:analyzer/analyzer.dart'
+    show parseCompilationUnit, parseDirectives;
+import 'package:analyzer/dart/ast/ast.dart';
+import 'package:analyzer/dart/ast/visitor.dart';
 import 'package:analyzer/src/generated/sdk.dart';
 import 'package:compiler/src/kernel/dart2js_target.dart' show Dart2jsTarget;
 import 'package:path/path.dart' as path;