Remove dart2jsHint option, verifier, and tests.

R=brianwilkerson@google.com, devoncarew@google.com

Change-Id: I95b88940c862d463af03e85fcdf0f4bf81c2fbd5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/157641
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
This commit is contained in:
Konstantin Shcheglov 2020-08-10 19:19:43 +00:00 committed by commit-bot@chromium.org
parent 1af388c521
commit 8405d7c8e3
14 changed files with 1 additions and 272 deletions

View file

@ -443,11 +443,6 @@ class AnalysisDomainHandler extends AbstractRequestHandler {
var params = AnalysisUpdateOptionsParams.fromRequest(request);
var newOptions = params.options;
var updaters = <OptionUpdater>[];
if (newOptions.generateDart2jsHints != null) {
updaters.add((engine.AnalysisOptionsImpl options) {
options.dart2jsHint = newOptions.generateDart2jsHints;
});
}
if (newOptions.generateHints != null) {
updaters.add((engine.AnalysisOptionsImpl options) {
options.hint = newOptions.generateHints;

View file

@ -446,7 +446,6 @@ class ContextsPage extends DiagnosticPageWithNav {
b.write(writeOption('Feature set', options.contextFeatures.toString()));
b.write('<br>');
b.write(writeOption('Generate dart2js hints', options.dart2jsHint));
b.write(writeOption('Generate hints', options.hint));
return b.toString();

View file

@ -509,10 +509,6 @@ const List<ErrorCode> errorCodeValues = [
HintCode.INVALID_USE_OF_VISIBLE_FOR_TEMPLATE_MEMBER,
HintCode.INVALID_USE_OF_VISIBLE_FOR_TESTING_MEMBER,
HintCode.INVALID_VISIBILITY_ANNOTATION,
HintCode.IS_DOUBLE,
HintCode.IS_INT,
HintCode.IS_NOT_DOUBLE,
HintCode.IS_NOT_INT,
HintCode.MISSING_JS_LIB_ANNOTATION,
HintCode.MISSING_REQUIRED_PARAM,
HintCode.MISSING_REQUIRED_PARAM_WITH_DETAILS,

View file

@ -26,7 +26,6 @@ import 'package:analyzer/src/dart/resolver/legacy_type_asserter.dart';
import 'package:analyzer/src/dart/resolver/resolution_visitor.dart';
import 'package:analyzer/src/error/best_practices_verifier.dart';
import 'package:analyzer/src/error/codes.dart';
import 'package:analyzer/src/error/dart2js_verifier.dart';
import 'package:analyzer/src/error/dead_code_verifier.dart';
import 'package:analyzer/src/error/imports_verifier.dart';
import 'package:analyzer/src/error/inheritance_override.dart';
@ -272,11 +271,6 @@ class LibraryAnalyzer {
unit.accept(DeadCodeVerifier(errorReporter));
// Dart2js analysis.
if (_analysisOptions.dart2jsHint) {
unit.accept(Dart2JSVerifier(errorReporter));
}
unit.accept(
BestPracticesVerifier(
errorReporter,

View file

@ -994,46 +994,6 @@ class HintCode extends AnalyzerErrorCode {
"meaningful on declarations of public members.",
hasPublishedDocs: true);
/**
* Hint for the `x is double` type checks.
*/
static const HintCode IS_DOUBLE = HintCode(
'IS_DOUBLE',
"When compiled to JS, this test might return true when the left hand "
"side is an int.",
correction: "Try testing for 'num' instead.");
/**
* Hint for the `x is int` type checks.
*/
// TODO(brianwilkerson) This hint isn't being generated. Decide whether to
// generate it or remove it.
static const HintCode IS_INT = HintCode(
'IS_INT',
"When compiled to JS, this test might return true when the left hand "
"side is a double.",
correction: "Try testing for 'num' instead.");
/**
* Hint for the `x is! double` type checks.
*/
static const HintCode IS_NOT_DOUBLE = HintCode(
'IS_NOT_DOUBLE',
"When compiled to JS, this test might return false when the left hand "
"side is an int.",
correction: "Try testing for 'num' instead.");
/**
* Hint for the `x is! int` type checks.
*/
// TODO(brianwilkerson) This hint isn't being generated. Decide whether to
// generate it or remove it.
static const HintCode IS_NOT_INT = HintCode(
'IS_NOT_INT',
"When compiled to JS, this test might return false when the left hand "
"side is a double.",
correction: "Try testing for 'num' instead.");
/**
* Generate a hint for an element that is annotated with `@JS(...)` whose
* library declaration is not similarly annotated.

View file

@ -26,7 +26,6 @@ import 'package:analyzer/src/dart/resolver/legacy_type_asserter.dart';
import 'package:analyzer/src/dart/resolver/resolution_visitor.dart';
import 'package:analyzer/src/error/best_practices_verifier.dart';
import 'package:analyzer/src/error/codes.dart';
import 'package:analyzer/src/error/dart2js_verifier.dart';
import 'package:analyzer/src/error/dead_code_verifier.dart';
import 'package:analyzer/src/error/imports_verifier.dart';
import 'package:analyzer/src/error/inheritance_override.dart';
@ -266,11 +265,6 @@ class LibraryAnalyzer {
unit.accept(DeadCodeVerifier(errorReporter));
// Dart2js analysis.
if (_analysisOptions.dart2jsHint) {
unit.accept(Dart2JSVerifier(errorReporter));
}
var content = getFileContent(file);
unit.accept(
BestPracticesVerifier(

View file

@ -1,70 +0,0 @@
// Copyright (c) 2019, the Dart project authors. Please see the AUTHORS file
// 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.
import 'package:analyzer/dart/ast/ast.dart';
import 'package:analyzer/dart/ast/visitor.dart';
import 'package:analyzer/dart/element/element.dart';
import 'package:analyzer/dart/element/type.dart';
import 'package:analyzer/error/listener.dart';
import 'package:analyzer/src/error/codes.dart';
/// Instances of the class `Dart2JSVerifier` traverse an AST structure looking
/// for hints for code that will be compiled to JS, such as
/// [HintCode.IS_DOUBLE].
class Dart2JSVerifier extends RecursiveAstVisitor<void> {
/// The name of the `double` type.
static const String _DOUBLE_TYPE_NAME = "double";
/// The error reporter by which errors will be reported.
final ErrorReporter _errorReporter;
/// Create a new instance of the [Dart2JSVerifier].
///
/// @param errorReporter the error reporter
Dart2JSVerifier(this._errorReporter);
@override
void visitIsExpression(IsExpression node) {
_checkForIsDoubleHints(node);
super.visitIsExpression(node);
}
/// Check for instances of `x is double`, `x is int`, `x is! double` and
/// `x is! int`.
///
/// @param node the is expression to check
/// @return `true` if and only if a hint code is generated on the passed node
/// See [HintCode.IS_DOUBLE],
/// [HintCode.IS_INT],
/// [HintCode.IS_NOT_DOUBLE], and
/// [HintCode.IS_NOT_INT].
bool _checkForIsDoubleHints(IsExpression node) {
DartType type = node.type.type;
Element element = type?.element;
if (element != null) {
String typeNameStr = element.name;
LibraryElement libraryElement = element.library;
// if (typeNameStr.equals(INT_TYPE_NAME) && libraryElement != null
// && libraryElement.isDartCore()) {
// if (node.getNotOperator() == null) {
// errorReporter.reportError(HintCode.IS_INT, node);
// } else {
// errorReporter.reportError(HintCode.IS_NOT_INT, node);
// }
// return true;
// } else
if (typeNameStr == _DOUBLE_TYPE_NAME &&
libraryElement != null &&
libraryElement.isDartCore) {
if (node.notOperator == null) {
_errorReporter.reportErrorForNode(HintCode.IS_DOUBLE, node);
} else {
_errorReporter.reportErrorForNode(HintCode.IS_NOT_DOUBLE, node);
}
return true;
}
}
return false;
}
}

View file

@ -235,9 +235,6 @@ abstract class AnalysisOptions {
/// The set of features that are globally enabled for this context.
FeatureSet get contextFeatures;
/// Return `true` if analysis is to generate dart2js related hint results.
bool get dart2jsHint;
/// Return `true` if cache flushing should be disabled. Setting this option to
/// `true` can improve analysis speed at the expense of memory usage. It may
/// also be useful for working around bugs.
@ -429,9 +426,6 @@ class AnalysisOptionsImpl implements AnalysisOptions {
@deprecated
int cacheSize = 64;
@override
bool dart2jsHint = false;
ExperimentStatus _contextFeatures = ExperimentStatus();
/// The set of features to use for libraries that are not in a package.
@ -535,7 +529,6 @@ class AnalysisOptionsImpl implements AnalysisOptions {
AnalysisOptionsImpl.from(AnalysisOptions options) {
// ignore: deprecated_member_use_from_same_package
analyzeFunctionBodiesPredicate = options.analyzeFunctionBodiesPredicate;
dart2jsHint = options.dart2jsHint;
contextFeatures = options.contextFeatures;
enabledPluginNames = options.enabledPluginNames;
// ignore: deprecated_member_use_from_same_package
@ -832,7 +825,6 @@ class AnalysisOptionsImpl implements AnalysisOptions {
@override
void resetToDefaults() {
contextFeatures = ExperimentStatus();
dart2jsHint = false;
disableCacheFlushing = false;
enabledPluginNames = const <String>[];
enableLazyAssignmentOperators = false;

View file

@ -214,7 +214,7 @@ linter:
// Invert a subset of the options to ensure that the default options are
// being returned.
AnalysisOptionsImpl defaultOptions = AnalysisOptionsImpl();
defaultOptions.dart2jsHint = !defaultOptions.dart2jsHint;
defaultOptions.implicitCasts = !defaultOptions.implicitCasts;
builderOptions.defaultOptions = defaultOptions;
AnalysisOptions options = builder.createDefaultOptions();
_expectEqualOptions(options, defaultOptions);
@ -759,7 +759,6 @@ environment:
void _expectEqualOptions(
AnalysisOptionsImpl actual, AnalysisOptionsImpl expected) {
// TODO(brianwilkerson) Consider moving this to AnalysisOptionsImpl.==.
expect(actual.dart2jsHint, expected.dart2jsHint);
expect(actual.enableTiming, expected.enableTiming);
expect(actual.hint, expected.hint);
expect(actual.lint, expected.lint);

View file

@ -1,30 +0,0 @@
// Copyright (c) 2019, the Dart project authors. Please see the AUTHORS file
// 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.
import 'package:analyzer/src/dart/error/hint_codes.dart';
import 'package:analyzer/src/generated/engine.dart';
import 'package:test_reflective_loader/test_reflective_loader.dart';
import '../dart/resolution/driver_resolution.dart';
main() {
defineReflectiveSuite(() {
defineReflectiveTests(IsDoubleTest);
});
}
@reflectiveTest
class IsDoubleTest extends DriverResolutionTest {
@override
AnalysisOptionsImpl get analysisOptions =>
AnalysisOptionsImpl()..dart2jsHint = true;
test_use() async {
await assertErrorsInCode('''
var v = 1 is double;
''', [
error(HintCode.IS_DOUBLE, 8, 11),
]);
}
}

View file

@ -1,31 +0,0 @@
// Copyright (c) 2019, the Dart project authors. Please see the AUTHORS file
// 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.
import 'package:analyzer/src/dart/error/hint_codes.dart';
import 'package:analyzer/src/generated/engine.dart';
import 'package:test_reflective_loader/test_reflective_loader.dart';
import '../dart/resolution/driver_resolution.dart';
main() {
defineReflectiveSuite(() {
defineReflectiveTests(IsIntTest);
});
}
@reflectiveTest
class IsIntTest extends DriverResolutionTest {
@override
AnalysisOptionsImpl get analysisOptions =>
AnalysisOptionsImpl()..dart2jsHint = true;
@failingTest
test_use() async {
await assertErrorsInCode('''
var v = 1 is int;
''', [
error(HintCode.IS_INT, 8, 8),
]);
}
}

View file

@ -1,30 +0,0 @@
// Copyright (c) 2019, the Dart project authors. Please see the AUTHORS file
// 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.
import 'package:analyzer/src/dart/error/hint_codes.dart';
import 'package:analyzer/src/generated/engine.dart';
import 'package:test_reflective_loader/test_reflective_loader.dart';
import '../dart/resolution/driver_resolution.dart';
main() {
defineReflectiveSuite(() {
defineReflectiveTests(IsNotDoubleTest);
});
}
@reflectiveTest
class IsNotDoubleTest extends DriverResolutionTest {
@override
AnalysisOptionsImpl get analysisOptions =>
AnalysisOptionsImpl()..dart2jsHint = true;
test_use() async {
await assertErrorsInCode('''
var v = 1 is! double;
''', [
error(HintCode.IS_NOT_DOUBLE, 8, 12),
]);
}
}

View file

@ -1,31 +0,0 @@
// Copyright (c) 2019, the Dart project authors. Please see the AUTHORS file
// 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.
import 'package:analyzer/src/dart/error/hint_codes.dart';
import 'package:analyzer/src/generated/engine.dart';
import 'package:test_reflective_loader/test_reflective_loader.dart';
import '../dart/resolution/driver_resolution.dart';
main() {
defineReflectiveSuite(() {
defineReflectiveTests(IsNotIntTest);
});
}
@reflectiveTest
class IsNotIntTest extends DriverResolutionTest {
@override
AnalysisOptionsImpl get analysisOptions =>
AnalysisOptionsImpl()..dart2jsHint = true;
@failingTest
test_use() async {
await assertErrorsInCode('''
var v = 1 is! int;
''', [
error(HintCode.IS_NOT_INT, 8, 9),
]);
}
}

View file

@ -324,10 +324,6 @@ import 'invocation_of_extension_without_call_test.dart'
as invocation_of_extension_without_call;
import 'invocation_of_non_function_expression_test.dart'
as invocation_of_non_function_expression;
import 'is_double_test.dart' as is_double;
import 'is_int_test.dart' as is_int;
import 'is_not_double_test.dart' as is_not_double;
import 'is_not_int_test.dart' as is_not_int;
import 'label_in_outer_scope_test.dart' as label_in_outer_scope;
import 'label_undefined_test.dart' as label_undefined;
import 'late_final_field_with_const_constructor_test.dart'
@ -844,10 +840,6 @@ main() {
invalid_visibility_annotation.main();
invocation_of_extension_without_call.main();
invocation_of_non_function_expression.main();
is_double.main();
is_int.main();
is_not_double.main();
is_not_int.main();
label_in_outer_scope.main();
label_undefined.main();
late_final_field_with_const_constructor.main();