mirror of
https://github.com/dart-lang/sdk
synced 2024-10-14 18:49:37 +00:00
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>
This commit is contained in:
parent
ff06d233aa
commit
3154bb0d37
|
@ -658,7 +658,7 @@ void writeString(Uri uri, String text) {
|
|||
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();
|
||||
}
|
||||
|
|
|
@ -9,8 +9,5 @@ analyzer:
|
|||
# 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
|
||||
|
|
|
@ -87,7 +87,7 @@ bool _computeEnableColors() {
|
|||
}
|
||||
|
||||
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)}.");
|
||||
|
|
|
@ -174,7 +174,7 @@ bool computeEnableColors(CompilerContext context) {
|
|||
}
|
||||
|
||||
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)}.");
|
||||
|
|
|
@ -93,7 +93,7 @@ Future<T> reportCrash<T>(error, StackTrace trace,
|
|||
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(".");
|
||||
|
|
|
@ -140,7 +140,7 @@ class NoTypeInfoTest {
|
|||
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 @@ class NoTypeInfoTest {
|
|||
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 expectNestedInfo(expectedInfo, String source) {
|
|||
}
|
||||
|
||||
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 @@ ComplexTypeInfo computeComplex(
|
|||
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 @@ void expectComplexTypeArg(String source,
|
|||
Token start = scan(source);
|
||||
int expectedGtGtAndNullEndCount = countGtGtAndNullEnd(start);
|
||||
ComplexTypeParamOrArgInfo typeVarInfo = computeVar(
|
||||
const isInstanceOf<ComplexTypeParamOrArgInfo>(),
|
||||
const TypeMatcher<ComplexTypeParamOrArgInfo>(),
|
||||
source,
|
||||
start,
|
||||
inDeclaration);
|
||||
|
@ -2564,7 +2564,7 @@ void expectComplexTypeParam(String source,
|
|||
Token start = scan(source);
|
||||
int expectedGtGtAndNullEndCount = countGtGtAndNullEnd(start);
|
||||
ComplexTypeParamOrArgInfo typeVarInfo = computeVar(
|
||||
const isInstanceOf<ComplexTypeParamOrArgInfo>(),
|
||||
const TypeMatcher<ComplexTypeParamOrArgInfo>(),
|
||||
source,
|
||||
start,
|
||||
inDeclaration);
|
||||
|
|
|
@ -220,7 +220,7 @@ class InterfaceResolverTest {
|
|||
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 @@ class InterfaceResolverTest {
|
|||
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);
|
||||
|
|
|
@ -25,8 +25,8 @@ main() {
|
|||
});
|
||||
}
|
||||
|
||||
const Matcher _throwsFileSystemException =
|
||||
const Throws(const isInstanceOf<FileSystemException>());
|
||||
final Matcher _throwsFileSystemException =
|
||||
throwsA(const TypeMatcher<FileSystemException>());
|
||||
|
||||
@reflectiveTest
|
||||
class FileTest extends _BaseTestNative {
|
||||
|
@ -233,7 +233,7 @@ abstract class MemoryFileSystemTestMixin implements _BaseTest {
|
|||
]) {
|
||||
if (!uri.path.startsWith('/')) {
|
||||
expect(() => fileSystem.entityForUri(uri),
|
||||
throwsA(new isInstanceOf<Error>()));
|
||||
throwsA(const TypeMatcher<Error>()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -242,7 +242,7 @@ class ScannerTest_Replacement extends ScannerTestBase {
|
|||
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;
|
||||
|
|
|
@ -113,7 +113,7 @@ abstract class ScannerTestBase {
|
|||
if (lessThan is BeginToken) {
|
||||
expect(lessThan.endToken, greaterThan);
|
||||
}
|
||||
expect(greaterThan, isNot(new isInstanceOf<BeginToken>()));
|
||||
expect(greaterThan, isNot(const TypeMatcher<BeginToken>()));
|
||||
}
|
||||
|
||||
void test_async_star() {
|
||||
|
|
|
@ -25,8 +25,8 @@ main() {
|
|||
});
|
||||
}
|
||||
|
||||
const Matcher _throwsFileSystemException =
|
||||
const Throws(const isInstanceOf<FileSystemException>());
|
||||
final Matcher _throwsFileSystemException =
|
||||
throwsA(const TypeMatcher<FileSystemException>());
|
||||
|
||||
@reflectiveTest
|
||||
class DirectoryTest extends _BaseTest {
|
||||
|
@ -197,7 +197,7 @@ class StandardFileSystemTest extends _BaseTest {
|
|||
]) {
|
||||
if (!uri.path.startsWith('/')) {
|
||||
expect(() => StandardFileSystem.instance.entityForUri(uri),
|
||||
throwsA(new isInstanceOf<Error>()));
|
||||
throwsA(const TypeMatcher<Error>()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -46,22 +46,22 @@ class Foo {
|
|||
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() {
|
||||
|
|
|
@ -182,10 +182,11 @@ class ParsedArguments {
|
|||
}
|
||||
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;
|
||||
|
|
|
@ -38,14 +38,14 @@ collectLog(DateTime time, HttpRequest request) async {
|
|||
} 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 @@ main(List<String> arguments) async {
|
|||
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);
|
||||
|
|
|
@ -22,8 +22,9 @@ main() {
|
|||
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');
|
||||
|
|
|
@ -22,13 +22,13 @@ import 'package:analyzer/dart/ast/ast.dart';
|
|||
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';
|
||||
|
|
|
@ -114,9 +114,7 @@ CompilerImpl compilerFor(
|
|||
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
|
||||
|
|
|
@ -12,7 +12,11 @@ import 'dart:async';
|
|||
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;
|
||||
|
|
Loading…
Reference in a new issue