mirror of
https://github.com/dart-lang/sdk
synced 2024-09-19 15:21:31 +00:00
Replace and remove JavaException(s).
R=brianwilkerson@google.com BUG= Review URL: https://codereview.chromium.org/2326813002 .
This commit is contained in:
parent
6137d020b9
commit
e976e692be
|
@ -151,18 +151,18 @@ class LocationSpec {
|
||||||
modifiedSource.substring(index + n);
|
modifiedSource.substring(index + n);
|
||||||
}
|
}
|
||||||
if (modifiedSource == originalSource) {
|
if (modifiedSource == originalSource) {
|
||||||
throw new IllegalStateException("No tests in source: " + originalSource);
|
throw new StateError("No tests in source: " + originalSource);
|
||||||
}
|
}
|
||||||
for (String result in validationStrings) {
|
for (String result in validationStrings) {
|
||||||
if (result.length < 3) {
|
if (result.length < 3) {
|
||||||
throw new IllegalStateException("Invalid location result: " + result);
|
throw new StateError("Invalid location result: " + result);
|
||||||
}
|
}
|
||||||
String id = result.substring(0, 1);
|
String id = result.substring(0, 1);
|
||||||
String sign = result.substring(1, 2);
|
String sign = result.substring(1, 2);
|
||||||
String value = result.substring(2);
|
String value = result.substring(2);
|
||||||
LocationSpec test = tests[id];
|
LocationSpec test = tests[id];
|
||||||
if (test == null) {
|
if (test == null) {
|
||||||
throw new IllegalStateException(
|
throw new StateError(
|
||||||
"Invalid location result id: $id for: $result");
|
"Invalid location result id: $id for: $result");
|
||||||
}
|
}
|
||||||
test.source = modifiedSource;
|
test.source = modifiedSource;
|
||||||
|
@ -172,7 +172,7 @@ class LocationSpec {
|
||||||
test.negativeResults.add(value);
|
test.negativeResults.add(value);
|
||||||
} else {
|
} else {
|
||||||
String err = "Invalid location result sign: $sign for: $result";
|
String err = "Invalid location result sign: $sign for: $result";
|
||||||
throw new IllegalStateException(err);
|
throw new StateError(err);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
List<String> badPoints = <String>[];
|
List<String> badPoints = <String>[];
|
||||||
|
@ -200,7 +200,7 @@ class LocationSpec {
|
||||||
err..write(' ')..write(ch);
|
err..write(' ')..write(ch);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
throw new IllegalStateException(err.toString());
|
throw new StateError(err.toString());
|
||||||
}
|
}
|
||||||
return tests.values.toList();
|
return tests.values.toList();
|
||||||
}
|
}
|
||||||
|
|
|
@ -473,7 +473,7 @@ class AnalysisContextImpl implements InternalAnalysisContext {
|
||||||
if (identical(_sourceFactory, factory)) {
|
if (identical(_sourceFactory, factory)) {
|
||||||
return;
|
return;
|
||||||
} else if (factory.context != null) {
|
} else if (factory.context != null) {
|
||||||
throw new IllegalStateException(
|
throw new StateError(
|
||||||
"Source factories cannot be shared between contexts");
|
"Source factories cannot be shared between contexts");
|
||||||
}
|
}
|
||||||
if (_sourceFactory != null) {
|
if (_sourceFactory != null) {
|
||||||
|
@ -2307,7 +2307,7 @@ class SdkAnalysisContext extends AnalysisContextImpl {
|
||||||
}
|
}
|
||||||
DartSdk sdk = factory.dartSdk;
|
DartSdk sdk = factory.dartSdk;
|
||||||
if (sdk == null) {
|
if (sdk == null) {
|
||||||
throw new IllegalArgumentException(
|
throw new ArgumentError(
|
||||||
"The source factory for an SDK analysis context must have a DartUriResolver");
|
"The source factory for an SDK analysis context must have a DartUriResolver");
|
||||||
}
|
}
|
||||||
return new AnalysisCache(
|
return new AnalysisCache(
|
||||||
|
|
|
@ -143,8 +143,7 @@ class SourceFactoryImpl implements SourceFactory {
|
||||||
Source fromEncoding(String encoding) {
|
Source fromEncoding(String encoding) {
|
||||||
Source source = forUri(encoding);
|
Source source = forUri(encoding);
|
||||||
if (source == null) {
|
if (source == null) {
|
||||||
throw new IllegalArgumentException(
|
throw new ArgumentError("Invalid source encoding: '$encoding'");
|
||||||
"Invalid source encoding: '$encoding'");
|
|
||||||
}
|
}
|
||||||
return source;
|
return source;
|
||||||
}
|
}
|
||||||
|
|
|
@ -399,7 +399,7 @@ class ArgumentListImpl extends AstNodeImpl implements ArgumentList {
|
||||||
void set correspondingPropagatedParameters(
|
void set correspondingPropagatedParameters(
|
||||||
List<ParameterElement> parameters) {
|
List<ParameterElement> parameters) {
|
||||||
if (parameters != null && parameters.length != _arguments.length) {
|
if (parameters != null && parameters.length != _arguments.length) {
|
||||||
throw new IllegalArgumentException(
|
throw new ArgumentError(
|
||||||
"Expected ${_arguments.length} parameters, not ${parameters.length}");
|
"Expected ${_arguments.length} parameters, not ${parameters.length}");
|
||||||
}
|
}
|
||||||
_correspondingPropagatedParameters = parameters;
|
_correspondingPropagatedParameters = parameters;
|
||||||
|
@ -411,7 +411,7 @@ class ArgumentListImpl extends AstNodeImpl implements ArgumentList {
|
||||||
@override
|
@override
|
||||||
void set correspondingStaticParameters(List<ParameterElement> parameters) {
|
void set correspondingStaticParameters(List<ParameterElement> parameters) {
|
||||||
if (parameters != null && parameters.length != _arguments.length) {
|
if (parameters != null && parameters.length != _arguments.length) {
|
||||||
throw new IllegalArgumentException(
|
throw new ArgumentError(
|
||||||
"Expected ${_arguments.length} parameters, not ${parameters.length}");
|
"Expected ${_arguments.length} parameters, not ${parameters.length}");
|
||||||
}
|
}
|
||||||
_correspondingStaticParameters = parameters;
|
_correspondingStaticParameters = parameters;
|
||||||
|
@ -5177,7 +5177,7 @@ class FunctionExpressionImpl extends ExpressionImpl
|
||||||
}
|
}
|
||||||
// This should never be reached because external functions must be named,
|
// This should never be reached because external functions must be named,
|
||||||
// hence either the body or the name should be non-null.
|
// hence either the body or the name should be non-null.
|
||||||
throw new IllegalStateException("Non-external functions must have a body");
|
throw new StateError("Non-external functions must have a body");
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
|
@ -5201,7 +5201,7 @@ class FunctionExpressionImpl extends ExpressionImpl
|
||||||
}
|
}
|
||||||
// This should never be reached because external functions must be named,
|
// This should never be reached because external functions must be named,
|
||||||
// hence either the body or the name should be non-null.
|
// hence either the body or the name should be non-null.
|
||||||
throw new IllegalStateException("Non-external functions must have a body");
|
throw new StateError("Non-external functions must have a body");
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
|
@ -9297,7 +9297,7 @@ class StringInterpolationImpl extends SingleStringLiteralImpl
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void _appendStringValue(StringBuffer buffer) {
|
void _appendStringValue(StringBuffer buffer) {
|
||||||
throw new IllegalArgumentException();
|
throw new ArgumentError();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -9410,7 +9410,7 @@ abstract class StringLiteralImpl extends LiteralImpl implements StringLiteral {
|
||||||
StringBuffer buffer = new StringBuffer();
|
StringBuffer buffer = new StringBuffer();
|
||||||
try {
|
try {
|
||||||
_appendStringValue(buffer);
|
_appendStringValue(buffer);
|
||||||
} on IllegalArgumentException {
|
} on ArgumentError {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
return buffer.toString();
|
return buffer.toString();
|
||||||
|
@ -9418,8 +9418,8 @@ abstract class StringLiteralImpl extends LiteralImpl implements StringLiteral {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Append the value of this string literal to the given [buffer]. Throw an
|
* Append the value of this string literal to the given [buffer]. Throw an
|
||||||
* [IllegalArgumentException] if the string is not a constant string without
|
* [ArgumentError] if the string is not a constant string without any
|
||||||
* any string interpolation.
|
* string interpolation.
|
||||||
*/
|
*/
|
||||||
void _appendStringValue(StringBuffer buffer);
|
void _appendStringValue(StringBuffer buffer);
|
||||||
}
|
}
|
||||||
|
|
|
@ -71,8 +71,7 @@ class AstCloner implements AstVisitor<AstNode> {
|
||||||
* Return a list containing cloned versions of the nodes in the given list of
|
* Return a list containing cloned versions of the nodes in the given list of
|
||||||
* [nodes].
|
* [nodes].
|
||||||
*/
|
*/
|
||||||
List<AstNode/*=E*/ > cloneNodeList/*<E extends AstNode>*/(
|
List<AstNode/*=E*/ > cloneNodeList/*<E extends AstNode>*/(List/*<E>*/ nodes) {
|
||||||
List/*<E>*/ nodes) {
|
|
||||||
int count = nodes.length;
|
int count = nodes.length;
|
||||||
List/*<E>*/ clonedNodes = new List/*<E>*/();
|
List/*<E>*/ clonedNodes = new List/*<E>*/();
|
||||||
for (int i = 0; i < count; i++) {
|
for (int i = 0; i < count; i++) {
|
||||||
|
@ -936,6 +935,7 @@ class AstCloner implements AstVisitor<AstNode> {
|
||||||
Token nonComment(Token token) {
|
Token nonComment(Token token) {
|
||||||
return token is CommentToken ? token.parent : token;
|
return token is CommentToken ? token.parent : token;
|
||||||
}
|
}
|
||||||
|
|
||||||
token = nonComment(token);
|
token = nonComment(token);
|
||||||
if (_lastCloned == null) {
|
if (_lastCloned == null) {
|
||||||
_lastCloned = new Token(TokenType.EOF, -1);
|
_lastCloned = new Token(TokenType.EOF, -1);
|
||||||
|
@ -4706,8 +4706,7 @@ class NodeReplacer implements AstVisitor<bool> {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool visitNode(AstNode node) {
|
bool visitNode(AstNode node) {
|
||||||
throw new IllegalArgumentException(
|
throw new ArgumentError("The old node is not a child of it's parent");
|
||||||
"The old node is not a child of it's parent");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool visitNormalFormalParameter(NormalFormalParameter node) {
|
bool visitNormalFormalParameter(NormalFormalParameter node) {
|
||||||
|
@ -5065,21 +5064,18 @@ class NodeReplacer implements AstVisitor<bool> {
|
||||||
* Replace the [oldNode] with the [newNode] in the AST structure containing
|
* Replace the [oldNode] with the [newNode] in the AST structure containing
|
||||||
* the old node. Return `true` if the replacement was successful.
|
* the old node. Return `true` if the replacement was successful.
|
||||||
*
|
*
|
||||||
* Throws an [IllegalArgumentException] if either node is `null`, if the old
|
* Throws an [ArgumentError] if either node is `null`, if the old node does
|
||||||
* node does not have a parent node, or if the AST structure has been
|
* not have a parent node, or if the AST structure has been corrupted.
|
||||||
* corrupted.
|
|
||||||
*/
|
*/
|
||||||
static bool replace(AstNode oldNode, AstNode newNode) {
|
static bool replace(AstNode oldNode, AstNode newNode) {
|
||||||
if (oldNode == null || newNode == null) {
|
if (oldNode == null || newNode == null) {
|
||||||
throw new IllegalArgumentException(
|
throw new ArgumentError("The old and new nodes must be non-null");
|
||||||
"The old and new nodes must be non-null");
|
|
||||||
} else if (identical(oldNode, newNode)) {
|
} else if (identical(oldNode, newNode)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
AstNode parent = oldNode.parent;
|
AstNode parent = oldNode.parent;
|
||||||
if (parent == null) {
|
if (parent == null) {
|
||||||
throw new IllegalArgumentException(
|
throw new ArgumentError("The old node is not a child of another node");
|
||||||
"The old node is not a child of another node");
|
|
||||||
}
|
}
|
||||||
NodeReplacer replacer = new NodeReplacer(oldNode, newNode);
|
NodeReplacer replacer = new NodeReplacer(oldNode, newNode);
|
||||||
return parent.accept(replacer);
|
return parent.accept(replacer);
|
||||||
|
|
|
@ -13,7 +13,6 @@ import 'package:analyzer/dart/constant/value.dart';
|
||||||
import 'package:analyzer/dart/element/element.dart';
|
import 'package:analyzer/dart/element/element.dart';
|
||||||
import 'package:analyzer/dart/element/type.dart';
|
import 'package:analyzer/dart/element/type.dart';
|
||||||
import 'package:analyzer/src/generated/error.dart';
|
import 'package:analyzer/src/generated/error.dart';
|
||||||
import 'package:analyzer/src/generated/java_core.dart';
|
|
||||||
import 'package:analyzer/src/generated/resolver.dart' show TypeProvider;
|
import 'package:analyzer/src/generated/resolver.dart' show TypeProvider;
|
||||||
import 'package:analyzer/src/generated/utilities_general.dart';
|
import 'package:analyzer/src/generated/utilities_general.dart';
|
||||||
|
|
||||||
|
@ -240,7 +239,7 @@ class DartObjectImpl implements DartObject {
|
||||||
return new DartObjectImpl(typeProvider.stringType, result);
|
return new DartObjectImpl(typeProvider.stringType, result);
|
||||||
}
|
}
|
||||||
// We should never get here.
|
// We should never get here.
|
||||||
throw new IllegalStateException("add returned a ${result.runtimeType}");
|
throw new StateError("add returned a ${result.runtimeType}");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -339,7 +338,7 @@ class DartObjectImpl implements DartObject {
|
||||||
return new DartObjectImpl(typeProvider.numType, result);
|
return new DartObjectImpl(typeProvider.numType, result);
|
||||||
}
|
}
|
||||||
// We should never get here.
|
// We should never get here.
|
||||||
throw new IllegalStateException("divide returned a ${result.runtimeType}");
|
throw new StateError("divide returned a ${result.runtimeType}");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -508,7 +507,7 @@ class DartObjectImpl implements DartObject {
|
||||||
return new DartObjectImpl(typeProvider.numType, result);
|
return new DartObjectImpl(typeProvider.numType, result);
|
||||||
}
|
}
|
||||||
// We should never get here.
|
// We should never get here.
|
||||||
throw new IllegalStateException("minus returned a ${result.runtimeType}");
|
throw new StateError("minus returned a ${result.runtimeType}");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -528,7 +527,7 @@ class DartObjectImpl implements DartObject {
|
||||||
return new DartObjectImpl(typeProvider.numType, result);
|
return new DartObjectImpl(typeProvider.numType, result);
|
||||||
}
|
}
|
||||||
// We should never get here.
|
// We should never get here.
|
||||||
throw new IllegalStateException("negated returned a ${result.runtimeType}");
|
throw new StateError("negated returned a ${result.runtimeType}");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -589,8 +588,7 @@ class DartObjectImpl implements DartObject {
|
||||||
return new DartObjectImpl(typeProvider.numType, result);
|
return new DartObjectImpl(typeProvider.numType, result);
|
||||||
}
|
}
|
||||||
// We should never get here.
|
// We should never get here.
|
||||||
throw new IllegalStateException(
|
throw new StateError("remainder returned a ${result.runtimeType}");
|
||||||
"remainder returned a ${result.runtimeType}");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -647,7 +645,7 @@ class DartObjectImpl implements DartObject {
|
||||||
return new DartObjectImpl(typeProvider.numType, result);
|
return new DartObjectImpl(typeProvider.numType, result);
|
||||||
}
|
}
|
||||||
// We should never get here.
|
// We should never get here.
|
||||||
throw new IllegalStateException("times returned a ${result.runtimeType}");
|
throw new StateError("times returned a ${result.runtimeType}");
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
|
@ -1231,9 +1229,9 @@ class DynamicState extends InstanceState {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A run-time exception that would be thrown during the evaluation of Dart code.
|
* Exception that would be thrown during the evaluation of Dart code.
|
||||||
*/
|
*/
|
||||||
class EvaluationException extends JavaException {
|
class EvaluationException {
|
||||||
/**
|
/**
|
||||||
* The error code associated with the exception.
|
* The error code associated with the exception.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -8414,7 +8414,7 @@ abstract class VariableElementImpl extends ElementImpl
|
||||||
* constant expression to the given [result].
|
* constant expression to the given [result].
|
||||||
*/
|
*/
|
||||||
void set evaluationResult(EvaluationResultImpl result) {
|
void set evaluationResult(EvaluationResultImpl result) {
|
||||||
throw new IllegalStateException(
|
throw new StateError(
|
||||||
"Invalid attempt to set a compile-time constant result");
|
"Invalid attempt to set a compile-time constant result");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -149,7 +149,7 @@ abstract class ExecutableMember extends Member implements ExecutableElement {
|
||||||
// Elements within this element should have type parameters substituted,
|
// Elements within this element should have type parameters substituted,
|
||||||
// just like this element.
|
// just like this element.
|
||||||
//
|
//
|
||||||
throw new UnsupportedOperationException();
|
throw new UnsupportedError('functions');
|
||||||
// return getBaseElement().getFunctions();
|
// return getBaseElement().getFunctions();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -186,7 +186,7 @@ abstract class ExecutableMember extends Member implements ExecutableElement {
|
||||||
// Elements within this element should have type parameters substituted,
|
// Elements within this element should have type parameters substituted,
|
||||||
// just like this element.
|
// just like this element.
|
||||||
//
|
//
|
||||||
throw new UnsupportedOperationException();
|
throw new UnsupportedError('localVariables');
|
||||||
// return getBaseElement().getLocalVariables();
|
// return getBaseElement().getLocalVariables();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -952,21 +952,21 @@ class TypeParameterMember extends Member implements TypeParameterElement {
|
||||||
@override
|
@override
|
||||||
Element get enclosingElement => baseElement.enclosingElement;
|
Element get enclosingElement => baseElement.enclosingElement;
|
||||||
|
|
||||||
@override
|
|
||||||
TypeParameterType get type => _type;
|
|
||||||
|
|
||||||
@override
|
|
||||||
accept(ElementVisitor visitor) => visitor.visitTypeParameterElement(this);
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
int get hashCode => baseElement.hashCode;
|
int get hashCode => baseElement.hashCode;
|
||||||
|
|
||||||
|
@override
|
||||||
|
TypeParameterType get type => _type;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
bool operator ==(obj) =>
|
bool operator ==(obj) =>
|
||||||
// TODO(jmesserly): this equality should consider the bound, see:
|
// TODO(jmesserly): this equality should consider the bound, see:
|
||||||
// https://github.com/dart-lang/sdk/issues/27210
|
// https://github.com/dart-lang/sdk/issues/27210
|
||||||
obj is TypeParameterMember && obj.baseElement == baseElement;
|
obj is TypeParameterMember && obj.baseElement == baseElement;
|
||||||
|
|
||||||
|
@override
|
||||||
|
accept(ElementVisitor visitor) => visitor.visitTypeParameterElement(this);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* If the given [parameter]'s type is different when any type parameters from
|
* If the given [parameter]'s type is different when any type parameters from
|
||||||
* the defining type's declaration are replaced with the actual type
|
* the defining type's declaration are replaced with the actual type
|
||||||
|
@ -1033,7 +1033,7 @@ abstract class VariableMember extends Member implements VariableElement {
|
||||||
// Elements within this element should have type parameters substituted,
|
// Elements within this element should have type parameters substituted,
|
||||||
// just like this element.
|
// just like this element.
|
||||||
//
|
//
|
||||||
throw new UnsupportedOperationException();
|
throw new UnsupportedError('initializer');
|
||||||
// return getBaseElement().getInitializer();
|
// return getBaseElement().getInitializer();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -711,6 +711,7 @@ class FunctionTypeImpl extends TypeImpl implements FunctionType {
|
||||||
needsComma = true;
|
needsComma = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void startOptionalParameters() {
|
void startOptionalParameters() {
|
||||||
if (needsComma) {
|
if (needsComma) {
|
||||||
buffer.write(", ");
|
buffer.write(", ");
|
||||||
|
@ -759,7 +760,7 @@ class FunctionTypeImpl extends TypeImpl implements FunctionType {
|
||||||
@override
|
@override
|
||||||
FunctionTypeImpl instantiate(List<DartType> argumentTypes) {
|
FunctionTypeImpl instantiate(List<DartType> argumentTypes) {
|
||||||
if (argumentTypes.length != typeFormals.length) {
|
if (argumentTypes.length != typeFormals.length) {
|
||||||
throw new IllegalArgumentException(
|
throw new ArgumentError(
|
||||||
"argumentTypes.length (${argumentTypes.length}) != "
|
"argumentTypes.length (${argumentTypes.length}) != "
|
||||||
"typeFormals.length (${typeFormals.length})");
|
"typeFormals.length (${typeFormals.length})");
|
||||||
}
|
}
|
||||||
|
@ -838,7 +839,7 @@ class FunctionTypeImpl extends TypeImpl implements FunctionType {
|
||||||
// substituting once.
|
// substituting once.
|
||||||
assert(this.prunedTypedefs == null);
|
assert(this.prunedTypedefs == null);
|
||||||
if (argumentTypes.length != parameterTypes.length) {
|
if (argumentTypes.length != parameterTypes.length) {
|
||||||
throw new IllegalArgumentException(
|
throw new ArgumentError(
|
||||||
"argumentTypes.length (${argumentTypes.length}) != parameterTypes.length (${parameterTypes.length})");
|
"argumentTypes.length (${argumentTypes.length}) != parameterTypes.length (${parameterTypes.length})");
|
||||||
}
|
}
|
||||||
Element element = this.element;
|
Element element = this.element;
|
||||||
|
@ -1849,7 +1850,7 @@ class InterfaceTypeImpl extends TypeImpl implements InterfaceType {
|
||||||
List<DartType> argumentTypes, List<DartType> parameterTypes,
|
List<DartType> argumentTypes, List<DartType> parameterTypes,
|
||||||
[List<FunctionTypeAliasElement> prune]) {
|
[List<FunctionTypeAliasElement> prune]) {
|
||||||
if (argumentTypes.length != parameterTypes.length) {
|
if (argumentTypes.length != parameterTypes.length) {
|
||||||
throw new IllegalArgumentException(
|
throw new ArgumentError(
|
||||||
"argumentTypes.length (${argumentTypes.length}) != parameterTypes.length (${parameterTypes.length})");
|
"argumentTypes.length (${argumentTypes.length}) != parameterTypes.length (${parameterTypes.length})");
|
||||||
}
|
}
|
||||||
if (argumentTypes.length == 0 || typeArguments.length == 0) {
|
if (argumentTypes.length == 0 || typeArguments.length == 0) {
|
||||||
|
@ -1936,6 +1937,7 @@ class InterfaceTypeImpl extends TypeImpl implements InterfaceType {
|
||||||
visitedClasses.remove(type.element);
|
visitedClasses.remove(type.element);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
recurse(this);
|
recurse(this);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -1959,7 +1961,25 @@ class InterfaceTypeImpl extends TypeImpl implements InterfaceType {
|
||||||
List<InterfaceType> s = _intersection(si, sj);
|
List<InterfaceType> s = _intersection(si, sj);
|
||||||
return computeTypeAtMaxUniqueDepth(s);
|
return computeTypeAtMaxUniqueDepth(s);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return the length of the longest inheritance path from the given [type] to
|
||||||
|
* Object.
|
||||||
|
*
|
||||||
|
* See [computeLeastUpperBound].
|
||||||
|
*/
|
||||||
|
static int computeLongestInheritancePathToObject(InterfaceType type) =>
|
||||||
|
_computeLongestInheritancePathToObject(
|
||||||
|
type, 0, new HashSet<ClassElement>());
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the set of all superinterfaces of the given [type].
|
||||||
|
*
|
||||||
|
* See [computeLeastUpperBound].
|
||||||
|
*/
|
||||||
|
static Set<InterfaceType> computeSuperinterfaceSet(InterfaceType type) =>
|
||||||
|
_computeSuperinterfaceSet(type, new HashSet<InterfaceType>());
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the type from the [types] list that has the longest inheritence path
|
* Return the type from the [types] list that has the longest inheritence path
|
||||||
* to Object of unique length.
|
* to Object of unique length.
|
||||||
|
@ -1995,24 +2015,6 @@ class InterfaceTypeImpl extends TypeImpl implements InterfaceType {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Return the length of the longest inheritance path from the given [type] to
|
|
||||||
* Object.
|
|
||||||
*
|
|
||||||
* See [computeLeastUpperBound].
|
|
||||||
*/
|
|
||||||
static int computeLongestInheritancePathToObject(InterfaceType type) =>
|
|
||||||
_computeLongestInheritancePathToObject(
|
|
||||||
type, 0, new HashSet<ClassElement>());
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the set of all superinterfaces of the given [type].
|
|
||||||
*
|
|
||||||
* See [computeLeastUpperBound].
|
|
||||||
*/
|
|
||||||
static Set<InterfaceType> computeSuperinterfaceSet(InterfaceType type) =>
|
|
||||||
_computeSuperinterfaceSet(type, new HashSet<InterfaceType>());
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* If there is a single type which is at least as specific as all of the
|
* If there is a single type which is at least as specific as all of the
|
||||||
* types in [types], return it. Otherwise return `null`.
|
* types in [types], return it. Otherwise return `null`.
|
||||||
|
@ -2187,7 +2189,7 @@ class InterfaceTypeImpl extends TypeImpl implements InterfaceType {
|
||||||
ClassElement firstElement = firstType.element;
|
ClassElement firstElement = firstType.element;
|
||||||
ClassElement secondElement = secondType.element;
|
ClassElement secondElement = secondType.element;
|
||||||
if (firstElement != secondElement) {
|
if (firstElement != secondElement) {
|
||||||
throw new IllegalArgumentException('The same elements expected, but '
|
throw new ArgumentError('The same elements expected, but '
|
||||||
'$firstElement and $secondElement are given.');
|
'$firstElement and $secondElement are given.');
|
||||||
}
|
}
|
||||||
if (firstType == secondType) {
|
if (firstType == secondType) {
|
||||||
|
|
|
@ -25,7 +25,7 @@ class BlockScope extends EnclosedScope {
|
||||||
*/
|
*/
|
||||||
BlockScope(Scope enclosingScope, Block block) : super(enclosingScope) {
|
BlockScope(Scope enclosingScope, Block block) : super(enclosingScope) {
|
||||||
if (block == null) {
|
if (block == null) {
|
||||||
throw new IllegalArgumentException("block cannot be null");
|
throw new ArgumentError("block cannot be null");
|
||||||
}
|
}
|
||||||
_defineElements(block);
|
_defineElements(block);
|
||||||
}
|
}
|
||||||
|
@ -69,7 +69,7 @@ class ClassScope extends EnclosedScope {
|
||||||
ClassScope(Scope enclosingScope, ClassElement classElement)
|
ClassScope(Scope enclosingScope, ClassElement classElement)
|
||||||
: super(enclosingScope) {
|
: super(enclosingScope) {
|
||||||
if (classElement == null) {
|
if (classElement == null) {
|
||||||
throw new IllegalArgumentException("class element cannot be null");
|
throw new ArgumentError("class element cannot be null");
|
||||||
}
|
}
|
||||||
_defineMembers(classElement);
|
_defineMembers(classElement);
|
||||||
}
|
}
|
||||||
|
@ -173,7 +173,7 @@ class FunctionScope extends EnclosedScope {
|
||||||
FunctionScope(Scope enclosingScope, this._functionElement)
|
FunctionScope(Scope enclosingScope, this._functionElement)
|
||||||
: super(new EnclosedScope(new EnclosedScope(enclosingScope))) {
|
: super(new EnclosedScope(new EnclosedScope(enclosingScope))) {
|
||||||
if (_functionElement == null) {
|
if (_functionElement == null) {
|
||||||
throw new IllegalArgumentException("function element cannot be null");
|
throw new ArgumentError("function element cannot be null");
|
||||||
}
|
}
|
||||||
_defineTypeParameters();
|
_defineTypeParameters();
|
||||||
}
|
}
|
||||||
|
@ -1154,7 +1154,7 @@ class TypeParameterScope extends EnclosedScope {
|
||||||
TypeParameterScope(Scope enclosingScope, ClassElement classElement)
|
TypeParameterScope(Scope enclosingScope, ClassElement classElement)
|
||||||
: super(enclosingScope) {
|
: super(enclosingScope) {
|
||||||
if (classElement == null) {
|
if (classElement == null) {
|
||||||
throw new IllegalArgumentException("class element cannot be null");
|
throw new ArgumentError("class element cannot be null");
|
||||||
}
|
}
|
||||||
_defineTypeParameters(classElement);
|
_defineTypeParameters(classElement);
|
||||||
}
|
}
|
||||||
|
|
|
@ -3202,9 +3202,9 @@ class ErrorReporter {
|
||||||
*/
|
*/
|
||||||
ErrorReporter(this._errorListener, this._defaultSource) {
|
ErrorReporter(this._errorListener, this._defaultSource) {
|
||||||
if (_errorListener == null) {
|
if (_errorListener == null) {
|
||||||
throw new IllegalArgumentException("An error listener must be provided");
|
throw new ArgumentError("An error listener must be provided");
|
||||||
} else if (_defaultSource == null) {
|
} else if (_defaultSource == null) {
|
||||||
throw new IllegalArgumentException("A default source must be provided");
|
throw new ArgumentError("A default source must be provided");
|
||||||
}
|
}
|
||||||
this._source = _defaultSource;
|
this._source = _defaultSource;
|
||||||
}
|
}
|
||||||
|
|
|
@ -86,8 +86,7 @@ String _printf(String fmt, List args) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
// unknown
|
// unknown
|
||||||
throw new IllegalArgumentException(
|
throw new ArgumentError('[$fmt][$i] = 0x${c.toRadixString(16)}');
|
||||||
'[$fmt][$i] = 0x${c.toRadixString(16)}');
|
|
||||||
} else {
|
} else {
|
||||||
sb.writeCharCode(c);
|
sb.writeCharCode(c);
|
||||||
}
|
}
|
||||||
|
@ -130,7 +129,7 @@ class Character {
|
||||||
|
|
||||||
static String toChars(int codePoint) {
|
static String toChars(int codePoint) {
|
||||||
if (codePoint < 0 || codePoint > MAX_CODE_POINT) {
|
if (codePoint < 0 || codePoint > MAX_CODE_POINT) {
|
||||||
throw new IllegalArgumentException();
|
throw new ArgumentError();
|
||||||
}
|
}
|
||||||
if (codePoint < MIN_SUPPLEMENTARY_CODE_POINT) {
|
if (codePoint < MIN_SUPPLEMENTARY_CODE_POINT) {
|
||||||
return new String.fromCharCode(codePoint);
|
return new String.fromCharCode(codePoint);
|
||||||
|
@ -154,15 +153,6 @@ abstract class Enum<E extends Enum> implements Comparable<E> {
|
||||||
String toString() => name;
|
String toString() => name;
|
||||||
}
|
}
|
||||||
|
|
||||||
class IllegalArgumentException extends JavaException {
|
|
||||||
IllegalArgumentException([message = "", cause = null])
|
|
||||||
: super(message, cause);
|
|
||||||
}
|
|
||||||
|
|
||||||
class IllegalStateException extends JavaException {
|
|
||||||
IllegalStateException([message = ""]) : super(message);
|
|
||||||
}
|
|
||||||
|
|
||||||
class JavaArrays {
|
class JavaArrays {
|
||||||
static int makeHashCode(List a) {
|
static int makeHashCode(List a) {
|
||||||
// TODO(rnystrom): This is not used by analyzer, but is called by
|
// TODO(rnystrom): This is not used by analyzer, but is called by
|
||||||
|
@ -178,18 +168,6 @@ class JavaArrays {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class JavaException implements Exception {
|
|
||||||
final String message;
|
|
||||||
final Object cause;
|
|
||||||
JavaException([this.message = "", this.cause = null]);
|
|
||||||
JavaException.withCause(this.cause) : message = null;
|
|
||||||
String toString() => "$runtimeType: $message $cause";
|
|
||||||
}
|
|
||||||
|
|
||||||
class JavaIOException extends JavaException {
|
|
||||||
JavaIOException([message = "", cause = null]) : super(message, cause);
|
|
||||||
}
|
|
||||||
|
|
||||||
class JavaPatternMatcher {
|
class JavaPatternMatcher {
|
||||||
Iterator<Match> _matches;
|
Iterator<Match> _matches;
|
||||||
Match _match;
|
Match _match;
|
||||||
|
@ -237,26 +215,6 @@ class JavaSystem {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class MissingFormatArgumentException implements Exception {
|
|
||||||
final String s;
|
|
||||||
|
|
||||||
MissingFormatArgumentException(this.s);
|
|
||||||
|
|
||||||
String toString() => "MissingFormatArgumentException: $s";
|
|
||||||
}
|
|
||||||
|
|
||||||
class NoSuchElementException extends JavaException {
|
|
||||||
String toString() => "NoSuchElementException";
|
|
||||||
}
|
|
||||||
|
|
||||||
class NotImplementedException extends JavaException {
|
|
||||||
NotImplementedException(message) : super(message);
|
|
||||||
}
|
|
||||||
|
|
||||||
class NumberFormatException extends JavaException {
|
|
||||||
String toString() => "NumberFormatException";
|
|
||||||
}
|
|
||||||
|
|
||||||
class PrintStringWriter extends PrintWriter {
|
class PrintStringWriter extends PrintWriter {
|
||||||
final StringBuffer _sb = new StringBuffer();
|
final StringBuffer _sb = new StringBuffer();
|
||||||
|
|
||||||
|
@ -284,19 +242,6 @@ abstract class PrintWriter {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class RuntimeException extends JavaException {
|
|
||||||
RuntimeException({String message: "", Exception cause: null})
|
|
||||||
: super(message, cause);
|
|
||||||
}
|
|
||||||
|
|
||||||
class StringIndexOutOfBoundsException extends JavaException {
|
|
||||||
StringIndexOutOfBoundsException(int index) : super('$index');
|
|
||||||
}
|
|
||||||
|
|
||||||
class UnsupportedOperationException extends JavaException {
|
|
||||||
UnsupportedOperationException([message = ""]) : super(message);
|
|
||||||
}
|
|
||||||
|
|
||||||
class URISyntaxException implements Exception {
|
class URISyntaxException implements Exception {
|
||||||
final String message;
|
final String message;
|
||||||
URISyntaxException(this.message);
|
URISyntaxException(this.message);
|
||||||
|
|
|
@ -275,12 +275,11 @@ class StringUtilities {
|
||||||
*/
|
*/
|
||||||
static String printListOfQuotedNames(List<String> names) {
|
static String printListOfQuotedNames(List<String> names) {
|
||||||
if (names == null) {
|
if (names == null) {
|
||||||
throw new IllegalArgumentException("The list must not be null");
|
throw new ArgumentError("The list must not be null");
|
||||||
}
|
}
|
||||||
int count = names.length;
|
int count = names.length;
|
||||||
if (count < 2) {
|
if (count < 2) {
|
||||||
throw new IllegalArgumentException(
|
throw new ArgumentError("The list must contain at least two names");
|
||||||
"The list must contain at least two names");
|
|
||||||
}
|
}
|
||||||
StringBuffer buffer = new StringBuffer();
|
StringBuffer buffer = new StringBuffer();
|
||||||
buffer.write("'");
|
buffer.write("'");
|
||||||
|
|
|
@ -6,7 +6,6 @@ library analyzer.src.generated.java_io;
|
||||||
|
|
||||||
import "dart:io";
|
import "dart:io";
|
||||||
|
|
||||||
import 'package:analyzer/src/generated/java_core.dart' show JavaIOException;
|
|
||||||
import 'package:path/path.dart' as path;
|
import 'package:path/path.dart' as path;
|
||||||
|
|
||||||
class JavaFile {
|
class JavaFile {
|
||||||
|
@ -51,11 +50,7 @@ class JavaFile {
|
||||||
|
|
||||||
JavaFile getCanonicalFile() => new JavaFile(getCanonicalPath());
|
JavaFile getCanonicalFile() => new JavaFile(getCanonicalPath());
|
||||||
String getCanonicalPath() {
|
String getCanonicalPath() {
|
||||||
try {
|
return _newFile().resolveSymbolicLinksSync();
|
||||||
return _newFile().resolveSymbolicLinksSync();
|
|
||||||
} catch (e) {
|
|
||||||
throw new JavaIOException('IOException', e);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
String getName() => pathContext.basename(_path);
|
String getName() => pathContext.basename(_path);
|
||||||
|
|
|
@ -483,7 +483,7 @@ Object invokeParserMethodImpl(
|
||||||
MethodTrampoline method =
|
MethodTrampoline method =
|
||||||
methodTable_Parser['${methodName}_${objects.length}'];
|
methodTable_Parser['${methodName}_${objects.length}'];
|
||||||
if (method == null) {
|
if (method == null) {
|
||||||
throw new IllegalArgumentException('There is no method named $methodName');
|
throw new ArgumentError('There is no method named $methodName');
|
||||||
}
|
}
|
||||||
return method.invoke(parser, objects);
|
return method.invoke(parser, objects);
|
||||||
}
|
}
|
||||||
|
@ -1670,7 +1670,7 @@ class IncrementalParseDispatcher implements AstVisitor<AstNode> {
|
||||||
* the node to be replaced.
|
* the node to be replaced.
|
||||||
*/
|
*/
|
||||||
AstNode _notAChild(AstNode node) {
|
AstNode _notAChild(AstNode node) {
|
||||||
throw new IncrementalParseException.con1(
|
throw new IncrementalParseException(
|
||||||
"Internal error: the visited node (a ${node.runtimeType}) was not the parent of the node to be replaced (a ${_oldNode.runtimeType})");
|
"Internal error: the visited node (a ${node.runtimeType}) was not the parent of the node to be replaced (a ${_oldNode.runtimeType})");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1680,24 +1680,10 @@ class IncrementalParseDispatcher implements AstVisitor<AstNode> {
|
||||||
* specified node in an existing AST structure.
|
* specified node in an existing AST structure.
|
||||||
*/
|
*/
|
||||||
@deprecated
|
@deprecated
|
||||||
class IncrementalParseException extends RuntimeException {
|
class IncrementalParseException {
|
||||||
/**
|
final String message;
|
||||||
* Initialize a newly created exception to have no message and to be its own
|
IncrementalParseException([this.message = '']);
|
||||||
* cause.
|
String toString() => '$runtimeType: $message';
|
||||||
*/
|
|
||||||
IncrementalParseException() : super();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Initialize a newly created exception to have the given [message] and to be
|
|
||||||
* its own cause.
|
|
||||||
*/
|
|
||||||
IncrementalParseException.con1(String message) : super(message: message);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Initialize a newly created exception to have no message and to have the
|
|
||||||
* given [cause].
|
|
||||||
*/
|
|
||||||
IncrementalParseException.con2(Exception cause) : super(cause: cause);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1970,23 +1956,7 @@ class IncrementalParseStateBuilder extends SimpleAstVisitor {
|
||||||
*/
|
*/
|
||||||
@deprecated
|
@deprecated
|
||||||
class InsufficientContextException extends IncrementalParseException {
|
class InsufficientContextException extends IncrementalParseException {
|
||||||
/**
|
InsufficientContextException([String message = '']) : super(message);
|
||||||
* Initialize a newly created exception to have no message and to be its own
|
|
||||||
* cause.
|
|
||||||
*/
|
|
||||||
InsufficientContextException() : super();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Initialize a newly created exception to have the given [message] and to be
|
|
||||||
* its own cause.
|
|
||||||
*/
|
|
||||||
InsufficientContextException.con1(String message) : super.con1(message);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Initialize a newly created exception to have no message and to have the
|
|
||||||
* given [cause].
|
|
||||||
*/
|
|
||||||
InsufficientContextException.con2(Exception cause) : super.con2(cause);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1999,8 +1969,7 @@ class MethodTrampoline {
|
||||||
MethodTrampoline(this.parameterCount, this.trampoline);
|
MethodTrampoline(this.parameterCount, this.trampoline);
|
||||||
Object invoke(target, List arguments) {
|
Object invoke(target, List arguments) {
|
||||||
if (arguments.length != parameterCount) {
|
if (arguments.length != parameterCount) {
|
||||||
throw new IllegalArgumentException(
|
throw new ArgumentError("${arguments.length} != $parameterCount");
|
||||||
"${arguments.length} != $parameterCount");
|
|
||||||
}
|
}
|
||||||
switch (parameterCount) {
|
switch (parameterCount) {
|
||||||
case 0:
|
case 0:
|
||||||
|
@ -2015,7 +1984,7 @@ class MethodTrampoline {
|
||||||
return trampoline(
|
return trampoline(
|
||||||
target, arguments[0], arguments[1], arguments[2], arguments[3]);
|
target, arguments[0], arguments[1], arguments[2], arguments[3]);
|
||||||
default:
|
default:
|
||||||
throw new IllegalArgumentException("Not implemented for > 4 arguments");
|
throw new ArgumentError("Not implemented for > 4 arguments");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2878,7 +2847,7 @@ class Parser {
|
||||||
} else {
|
} else {
|
||||||
// Internal error: this method should not have been invoked if the
|
// Internal error: this method should not have been invoked if the
|
||||||
// current token was something other than one of the above.
|
// current token was something other than one of the above.
|
||||||
throw new IllegalStateException(
|
throw new StateError(
|
||||||
"parseDirective invoked in an invalid state (currentToken = $_currentToken)");
|
"parseDirective invoked in an invalid state (currentToken = $_currentToken)");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -5730,7 +5699,7 @@ class Parser {
|
||||||
} else {
|
} else {
|
||||||
// Internal error: this method should not have been invoked if the current
|
// Internal error: this method should not have been invoked if the current
|
||||||
// token was something other than one of the above.
|
// token was something other than one of the above.
|
||||||
throw new IllegalStateException(
|
throw new StateError(
|
||||||
"parseDirective invoked in an invalid state; currentToken = $_currentToken");
|
"parseDirective invoked in an invalid state; currentToken = $_currentToken");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -9599,8 +9568,7 @@ class Parser {
|
||||||
*/
|
*/
|
||||||
void _unlockErrorListener() {
|
void _unlockErrorListener() {
|
||||||
if (_errorListenerLock == 0) {
|
if (_errorListenerLock == 0) {
|
||||||
throw new IllegalStateException(
|
throw new StateError("Attempt to unlock not locked error listener.");
|
||||||
"Attempt to unlock not locked error listener.");
|
|
||||||
}
|
}
|
||||||
_errorListenerLock--;
|
_errorListenerLock--;
|
||||||
}
|
}
|
||||||
|
|
|
@ -533,8 +533,8 @@ class BestPracticesVerifier extends RecursiveAstVisitor<Object> {
|
||||||
* [identifier] is not a name of a getter or a method that exists in the
|
* [identifier] is not a name of a getter or a method that exists in the
|
||||||
* class [Null].
|
* class [Null].
|
||||||
*/
|
*/
|
||||||
void _checkForCanBeNullAfterNullAware(
|
void _checkForCanBeNullAfterNullAware(Expression target, Token operator,
|
||||||
Expression target, Token operator, SimpleIdentifier propertyName, SimpleIdentifier methodName) {
|
SimpleIdentifier propertyName, SimpleIdentifier methodName) {
|
||||||
if (operator?.type == TokenType.QUESTION_PERIOD) {
|
if (operator?.type == TokenType.QUESTION_PERIOD) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -9097,7 +9097,7 @@ class TypeOverrideManager {
|
||||||
*/
|
*/
|
||||||
void applyOverrides(Map<VariableElement, DartType> overrides) {
|
void applyOverrides(Map<VariableElement, DartType> overrides) {
|
||||||
if (currentScope == null) {
|
if (currentScope == null) {
|
||||||
throw new IllegalStateException("Cannot apply overrides without a scope");
|
throw new StateError("Cannot apply overrides without a scope");
|
||||||
}
|
}
|
||||||
currentScope.applyOverrides(overrides);
|
currentScope.applyOverrides(overrides);
|
||||||
}
|
}
|
||||||
|
@ -9110,8 +9110,7 @@ class TypeOverrideManager {
|
||||||
*/
|
*/
|
||||||
Map<VariableElement, DartType> captureLocalOverrides() {
|
Map<VariableElement, DartType> captureLocalOverrides() {
|
||||||
if (currentScope == null) {
|
if (currentScope == null) {
|
||||||
throw new IllegalStateException(
|
throw new StateError("Cannot capture local overrides without a scope");
|
||||||
"Cannot capture local overrides without a scope");
|
|
||||||
}
|
}
|
||||||
return currentScope.captureLocalOverrides();
|
return currentScope.captureLocalOverrides();
|
||||||
}
|
}
|
||||||
|
@ -9126,8 +9125,7 @@ class TypeOverrideManager {
|
||||||
Map<VariableElement, DartType> captureOverrides(
|
Map<VariableElement, DartType> captureOverrides(
|
||||||
VariableDeclarationList variableList) {
|
VariableDeclarationList variableList) {
|
||||||
if (currentScope == null) {
|
if (currentScope == null) {
|
||||||
throw new IllegalStateException(
|
throw new StateError("Cannot capture overrides without a scope");
|
||||||
"Cannot capture overrides without a scope");
|
|
||||||
}
|
}
|
||||||
return currentScope.captureOverrides(variableList);
|
return currentScope.captureOverrides(variableList);
|
||||||
}
|
}
|
||||||
|
@ -9144,7 +9142,7 @@ class TypeOverrideManager {
|
||||||
*/
|
*/
|
||||||
void exitScope() {
|
void exitScope() {
|
||||||
if (currentScope == null) {
|
if (currentScope == null) {
|
||||||
throw new IllegalStateException("No scope to exit");
|
throw new StateError("No scope to exit");
|
||||||
}
|
}
|
||||||
currentScope = currentScope._outerScope;
|
currentScope = currentScope._outerScope;
|
||||||
}
|
}
|
||||||
|
@ -9203,7 +9201,7 @@ class TypeOverrideManager {
|
||||||
*/
|
*/
|
||||||
void setType(VariableElement element, DartType type) {
|
void setType(VariableElement element, DartType type) {
|
||||||
if (currentScope == null) {
|
if (currentScope == null) {
|
||||||
throw new IllegalStateException("Cannot override without a scope");
|
throw new StateError("Cannot override without a scope");
|
||||||
}
|
}
|
||||||
currentScope.setType(element, type);
|
currentScope.setType(element, type);
|
||||||
}
|
}
|
||||||
|
@ -9405,7 +9403,7 @@ class TypePromotionManager {
|
||||||
*/
|
*/
|
||||||
void exitScope() {
|
void exitScope() {
|
||||||
if (currentScope == null) {
|
if (currentScope == null) {
|
||||||
throw new IllegalStateException("No scope to exit");
|
throw new StateError("No scope to exit");
|
||||||
}
|
}
|
||||||
currentScope = currentScope._outerScope;
|
currentScope = currentScope._outerScope;
|
||||||
}
|
}
|
||||||
|
@ -9430,7 +9428,7 @@ class TypePromotionManager {
|
||||||
*/
|
*/
|
||||||
void setType(Element element, DartType type) {
|
void setType(Element element, DartType type) {
|
||||||
if (currentScope == null) {
|
if (currentScope == null) {
|
||||||
throw new IllegalStateException("Cannot promote without a scope");
|
throw new StateError("Cannot promote without a scope");
|
||||||
}
|
}
|
||||||
currentScope.setType(element, type);
|
currentScope.setType(element, type);
|
||||||
}
|
}
|
||||||
|
|
|
@ -212,9 +212,9 @@ class LineInfo {
|
||||||
*/
|
*/
|
||||||
LineInfo._(this.lineStarts) {
|
LineInfo._(this.lineStarts) {
|
||||||
if (lineStarts == null) {
|
if (lineStarts == null) {
|
||||||
throw new IllegalArgumentException("lineStarts must be non-null");
|
throw new ArgumentError("lineStarts must be non-null");
|
||||||
} else if (lineStarts.length < 1) {
|
} else if (lineStarts.length < 1) {
|
||||||
throw new IllegalArgumentException("lineStarts must be non-empty");
|
throw new ArgumentError("lineStarts must be non-empty");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -379,7 +379,7 @@ class NonExistingSource extends Source {
|
||||||
|
|
||||||
@override
|
@override
|
||||||
TimestampedData<String> get contents {
|
TimestampedData<String> get contents {
|
||||||
throw new UnsupportedOperationException('$fullName does not exist.');
|
throw new UnsupportedError('$fullName does not exist.');
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
|
|
|
@ -376,7 +376,7 @@ class PackageUriResolver extends UriResolver {
|
||||||
*/
|
*/
|
||||||
PackageUriResolver(this._packagesDirectories) {
|
PackageUriResolver(this._packagesDirectories) {
|
||||||
if (_packagesDirectories.length < 1) {
|
if (_packagesDirectories.length < 1) {
|
||||||
throw new IllegalArgumentException(
|
throw new ArgumentError(
|
||||||
"At least one package directory must be provided");
|
"At least one package directory must be provided");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -407,7 +407,7 @@ class PackageUriResolver extends UriResolver {
|
||||||
JavaFile pkgDir = new JavaFile.relative(packagesDirectory, pkgName);
|
JavaFile pkgDir = new JavaFile.relative(packagesDirectory, pkgName);
|
||||||
try {
|
try {
|
||||||
pkgDir = pkgDir.getCanonicalFile();
|
pkgDir = pkgDir.getCanonicalFile();
|
||||||
} on JavaIOException catch (exception, stackTrace) {
|
} catch (exception, stackTrace) {
|
||||||
if (!exception.toString().contains("Required key not available")) {
|
if (!exception.toString().contains("Required key not available")) {
|
||||||
AnalysisEngine.instance.logger.logError("Canonical failed: $pkgDir",
|
AnalysisEngine.instance.logger.logError("Canonical failed: $pkgDir",
|
||||||
new CaughtException(exception, stackTrace));
|
new CaughtException(exception, stackTrace));
|
||||||
|
|
|
@ -287,7 +287,7 @@ class ElementFactory {
|
||||||
int nameCount = names == null ? 0 : names.length;
|
int nameCount = names == null ? 0 : names.length;
|
||||||
int typeCount = namedParameters == null ? 0 : namedParameters.length;
|
int typeCount = namedParameters == null ? 0 : namedParameters.length;
|
||||||
if (names != null && nameCount != typeCount) {
|
if (names != null && nameCount != typeCount) {
|
||||||
throw new IllegalStateException(
|
throw new StateError(
|
||||||
"The passed String[] and ClassElement[] arrays had different lengths.");
|
"The passed String[] and ClassElement[] arrays had different lengths.");
|
||||||
}
|
}
|
||||||
int totalCount = normalCount + nameCount;
|
int totalCount = normalCount + nameCount;
|
||||||
|
|
|
@ -203,7 +203,7 @@ class DirectedGraph<N> {
|
||||||
*/
|
*/
|
||||||
List<N> findCycleContaining(N node) {
|
List<N> findCycleContaining(N node) {
|
||||||
if (node == null) {
|
if (node == null) {
|
||||||
throw new IllegalArgumentException();
|
throw new ArgumentError();
|
||||||
}
|
}
|
||||||
DirectedGraph_SccFinder<N> finder = new DirectedGraph_SccFinder<N>(this);
|
DirectedGraph_SccFinder<N> finder = new DirectedGraph_SccFinder<N>(this);
|
||||||
return finder.componentContaining(node);
|
return finder.componentContaining(node);
|
||||||
|
@ -570,7 +570,7 @@ class MultipleMapIterator<K, V> implements MapIterator<K, V> {
|
||||||
@override
|
@override
|
||||||
K get key {
|
K get key {
|
||||||
if (_currentIterator == null) {
|
if (_currentIterator == null) {
|
||||||
throw new NoSuchElementException();
|
throw new StateError('No element');
|
||||||
}
|
}
|
||||||
return _currentIterator.key;
|
return _currentIterator.key;
|
||||||
}
|
}
|
||||||
|
@ -578,7 +578,7 @@ class MultipleMapIterator<K, V> implements MapIterator<K, V> {
|
||||||
@override
|
@override
|
||||||
V get value {
|
V get value {
|
||||||
if (_currentIterator == null) {
|
if (_currentIterator == null) {
|
||||||
throw new NoSuchElementException();
|
throw new StateError('No element');
|
||||||
}
|
}
|
||||||
return _currentIterator.value;
|
return _currentIterator.value;
|
||||||
}
|
}
|
||||||
|
@ -586,7 +586,7 @@ class MultipleMapIterator<K, V> implements MapIterator<K, V> {
|
||||||
@override
|
@override
|
||||||
void set value(V newValue) {
|
void set value(V newValue) {
|
||||||
if (_currentIterator == null) {
|
if (_currentIterator == null) {
|
||||||
throw new NoSuchElementException();
|
throw new StateError('No element');
|
||||||
}
|
}
|
||||||
_currentIterator.value = newValue;
|
_currentIterator.value = newValue;
|
||||||
}
|
}
|
||||||
|
@ -672,7 +672,7 @@ class SingleMapIterator<K, V> implements MapIterator<K, V> {
|
||||||
@override
|
@override
|
||||||
K get key {
|
K get key {
|
||||||
if (_currentKey == null) {
|
if (_currentKey == null) {
|
||||||
throw new NoSuchElementException();
|
throw new StateError('No element');
|
||||||
}
|
}
|
||||||
return _currentKey;
|
return _currentKey;
|
||||||
}
|
}
|
||||||
|
@ -680,7 +680,7 @@ class SingleMapIterator<K, V> implements MapIterator<K, V> {
|
||||||
@override
|
@override
|
||||||
V get value {
|
V get value {
|
||||||
if (_currentKey == null) {
|
if (_currentKey == null) {
|
||||||
throw new NoSuchElementException();
|
throw new StateError('No element');
|
||||||
}
|
}
|
||||||
if (_currentValue == null) {
|
if (_currentValue == null) {
|
||||||
_currentValue = _map[_currentKey];
|
_currentValue = _map[_currentKey];
|
||||||
|
@ -691,7 +691,7 @@ class SingleMapIterator<K, V> implements MapIterator<K, V> {
|
||||||
@override
|
@override
|
||||||
void set value(V newValue) {
|
void set value(V newValue) {
|
||||||
if (_currentKey == null) {
|
if (_currentKey == null) {
|
||||||
throw new NoSuchElementException();
|
throw new StateError('No element');
|
||||||
}
|
}
|
||||||
_currentValue = newValue;
|
_currentValue = newValue;
|
||||||
_map[_currentKey] = newValue;
|
_map[_currentKey] = newValue;
|
||||||
|
|
|
@ -12,8 +12,6 @@ import 'package:analyzer/file_system/memory_file_system.dart';
|
||||||
import 'package:analyzer/src/dart/element/element.dart';
|
import 'package:analyzer/src/dart/element/element.dart';
|
||||||
import 'package:analyzer/src/generated/element_resolver.dart';
|
import 'package:analyzer/src/generated/element_resolver.dart';
|
||||||
import 'package:analyzer/src/generated/engine.dart';
|
import 'package:analyzer/src/generated/engine.dart';
|
||||||
import 'package:analyzer/src/generated/java_core.dart';
|
|
||||||
import 'package:analyzer/src/generated/java_engine.dart';
|
|
||||||
import 'package:analyzer/src/generated/resolver.dart';
|
import 'package:analyzer/src/generated/resolver.dart';
|
||||||
import 'package:analyzer/src/generated/source.dart';
|
import 'package:analyzer/src/generated/source.dart';
|
||||||
import 'package:analyzer/src/generated/testing/ast_factory.dart';
|
import 'package:analyzer/src/generated/testing/ast_factory.dart';
|
||||||
|
@ -884,12 +882,7 @@ class ElementResolverTest extends EngineTestCase {
|
||||||
_visitor = new ResolverVisitor(
|
_visitor = new ResolverVisitor(
|
||||||
_definingLibrary, source, _typeProvider, _listener,
|
_definingLibrary, source, _typeProvider, _listener,
|
||||||
nameScope: new LibraryScope(_definingLibrary));
|
nameScope: new LibraryScope(_definingLibrary));
|
||||||
try {
|
return _visitor.elementResolver;
|
||||||
return _visitor.elementResolver;
|
|
||||||
} catch (exception) {
|
|
||||||
throw new IllegalArgumentException(
|
|
||||||
"Could not create resolver", exception);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -943,21 +936,16 @@ class ElementResolverTest extends EngineTestCase {
|
||||||
* @return the element to which the expression was resolved
|
* @return the element to which the expression was resolved
|
||||||
*/
|
*/
|
||||||
void _resolveInClass(AstNode node, ClassElement enclosingClass) {
|
void _resolveInClass(AstNode node, ClassElement enclosingClass) {
|
||||||
|
Scope outerScope = _visitor.nameScope;
|
||||||
try {
|
try {
|
||||||
Scope outerScope = _visitor.nameScope;
|
_visitor.enclosingClass = enclosingClass;
|
||||||
try {
|
EnclosedScope innerScope = new ClassScope(
|
||||||
_visitor.enclosingClass = enclosingClass;
|
new TypeParameterScope(outerScope, enclosingClass), enclosingClass);
|
||||||
EnclosedScope innerScope = new ClassScope(
|
_visitor.nameScope = innerScope;
|
||||||
new TypeParameterScope(outerScope, enclosingClass), enclosingClass);
|
node.accept(_resolver);
|
||||||
_visitor.nameScope = innerScope;
|
} finally {
|
||||||
node.accept(_resolver);
|
_visitor.enclosingClass = null;
|
||||||
} finally {
|
_visitor.nameScope = outerScope;
|
||||||
_visitor.enclosingClass = null;
|
|
||||||
_visitor.nameScope = outerScope;
|
|
||||||
}
|
|
||||||
} catch (exception, stackTrace) {
|
|
||||||
throw new IllegalArgumentException(
|
|
||||||
"Could not resolve node", new CaughtException(exception, stackTrace));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -986,22 +974,18 @@ class ElementResolverTest extends EngineTestCase {
|
||||||
* @return the element to which the expression was resolved
|
* @return the element to which the expression was resolved
|
||||||
*/
|
*/
|
||||||
void _resolveNode(AstNode node, [List<Element> definedElements]) {
|
void _resolveNode(AstNode node, [List<Element> definedElements]) {
|
||||||
|
Scope outerScope = _visitor.nameScope;
|
||||||
try {
|
try {
|
||||||
Scope outerScope = _visitor.nameScope;
|
EnclosedScope innerScope = new EnclosedScope(outerScope);
|
||||||
try {
|
if (definedElements != null) {
|
||||||
EnclosedScope innerScope = new EnclosedScope(outerScope);
|
for (Element element in definedElements) {
|
||||||
if (definedElements != null) {
|
innerScope.define(element);
|
||||||
for (Element element in definedElements) {
|
|
||||||
innerScope.define(element);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
_visitor.nameScope = innerScope;
|
|
||||||
node.accept(_resolver);
|
|
||||||
} finally {
|
|
||||||
_visitor.nameScope = outerScope;
|
|
||||||
}
|
}
|
||||||
} catch (exception) {
|
_visitor.nameScope = innerScope;
|
||||||
throw new IllegalArgumentException("Could not resolve node", exception);
|
node.accept(_resolver);
|
||||||
|
} finally {
|
||||||
|
_visitor.nameScope = outerScope;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1015,23 +999,19 @@ class ElementResolverTest extends EngineTestCase {
|
||||||
*/
|
*/
|
||||||
void _resolveStatement(
|
void _resolveStatement(
|
||||||
Statement statement, LabelElementImpl labelElement, AstNode labelTarget) {
|
Statement statement, LabelElementImpl labelElement, AstNode labelTarget) {
|
||||||
|
LabelScope outerScope = _visitor.labelScope;
|
||||||
try {
|
try {
|
||||||
LabelScope outerScope = _visitor.labelScope;
|
LabelScope innerScope;
|
||||||
try {
|
if (labelElement == null) {
|
||||||
LabelScope innerScope;
|
innerScope = outerScope;
|
||||||
if (labelElement == null) {
|
} else {
|
||||||
innerScope = outerScope;
|
innerScope = new LabelScope(
|
||||||
} else {
|
outerScope, labelElement.name, labelTarget, labelElement);
|
||||||
innerScope = new LabelScope(
|
|
||||||
outerScope, labelElement.name, labelTarget, labelElement);
|
|
||||||
}
|
|
||||||
_visitor.labelScope = innerScope;
|
|
||||||
statement.accept(_resolver);
|
|
||||||
} finally {
|
|
||||||
_visitor.labelScope = outerScope;
|
|
||||||
}
|
}
|
||||||
} catch (exception) {
|
_visitor.labelScope = innerScope;
|
||||||
throw new IllegalArgumentException("Could not resolve node", exception);
|
statement.accept(_resolver);
|
||||||
|
} finally {
|
||||||
|
_visitor.labelScope = outerScope;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -81,7 +81,7 @@ class CompilationUnitMock extends TypedMock implements CompilationUnit {}
|
||||||
class MockSourceFactory extends SourceFactoryImpl {
|
class MockSourceFactory extends SourceFactoryImpl {
|
||||||
MockSourceFactory() : super([]);
|
MockSourceFactory() : super([]);
|
||||||
Source resolveUri(Source containingSource, String containedUri) {
|
Source resolveUri(Source containingSource, String containedUri) {
|
||||||
throw new JavaIOException();
|
throw new UnimplementedError();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -985,24 +985,18 @@ class SubtypeManagerTest {
|
||||||
class TypeOverrideManagerTest extends EngineTestCase {
|
class TypeOverrideManagerTest extends EngineTestCase {
|
||||||
void test_exitScope_noScopes() {
|
void test_exitScope_noScopes() {
|
||||||
TypeOverrideManager manager = new TypeOverrideManager();
|
TypeOverrideManager manager = new TypeOverrideManager();
|
||||||
try {
|
expect(() {
|
||||||
manager.exitScope();
|
manager.exitScope();
|
||||||
fail("Expected IllegalStateException");
|
}, throwsStateError);
|
||||||
} on IllegalStateException {
|
|
||||||
// Expected
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void test_exitScope_oneScope() {
|
void test_exitScope_oneScope() {
|
||||||
TypeOverrideManager manager = new TypeOverrideManager();
|
TypeOverrideManager manager = new TypeOverrideManager();
|
||||||
manager.enterScope();
|
manager.enterScope();
|
||||||
manager.exitScope();
|
manager.exitScope();
|
||||||
try {
|
expect(() {
|
||||||
manager.exitScope();
|
manager.exitScope();
|
||||||
fail("Expected IllegalStateException");
|
}, throwsStateError);
|
||||||
} on IllegalStateException {
|
|
||||||
// Expected
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void test_exitScope_twoScopes() {
|
void test_exitScope_twoScopes() {
|
||||||
|
@ -1011,12 +1005,9 @@ class TypeOverrideManagerTest extends EngineTestCase {
|
||||||
manager.exitScope();
|
manager.exitScope();
|
||||||
manager.enterScope();
|
manager.enterScope();
|
||||||
manager.exitScope();
|
manager.exitScope();
|
||||||
try {
|
expect(() {
|
||||||
manager.exitScope();
|
manager.exitScope();
|
||||||
fail("Expected IllegalStateException");
|
}, throwsStateError);
|
||||||
} on IllegalStateException {
|
|
||||||
// Expected
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void test_getType_enclosedOverride() {
|
void test_getType_enclosedOverride() {
|
||||||
|
|
|
@ -590,7 +590,7 @@ class ResolverTestCase extends EngineTestCase {
|
||||||
// "fail_*" tests. However, an assertion failure is success for the
|
// "fail_*" tests. However, an assertion failure is success for the
|
||||||
// purpose of "fail_*" tests, so without catching them here "fail_*" tests
|
// purpose of "fail_*" tests, so without catching them here "fail_*" tests
|
||||||
// can succeed by failing for the wrong reason.
|
// can succeed by failing for the wrong reason.
|
||||||
throw new JavaException("Unexexpected assertion failure: $exception");
|
throw new StateError("Unexpected assertion failure: $exception");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -239,14 +239,13 @@ class SourceFactoryTest {
|
||||||
|
|
||||||
void test_fromEncoding_invalidUri() {
|
void test_fromEncoding_invalidUri() {
|
||||||
SourceFactory factory = new SourceFactory([]);
|
SourceFactory factory = new SourceFactory([]);
|
||||||
expect(() => factory.fromEncoding("<:&%>"),
|
expect(() => factory.fromEncoding("<:&%>"), throwsArgumentError);
|
||||||
throwsA(new isInstanceOf<IllegalArgumentException>()));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void test_fromEncoding_noResolver() {
|
void test_fromEncoding_noResolver() {
|
||||||
SourceFactory factory = new SourceFactory([]);
|
SourceFactory factory = new SourceFactory([]);
|
||||||
expect(() => factory.fromEncoding("foo:/does/not/exist.dart"),
|
expect(() => factory.fromEncoding("foo:/does/not/exist.dart"),
|
||||||
throwsA(new isInstanceOf<IllegalArgumentException>()));
|
throwsArgumentError);
|
||||||
}
|
}
|
||||||
|
|
||||||
void test_fromEncoding_valid() {
|
void test_fromEncoding_valid() {
|
||||||
|
|
|
@ -15,7 +15,6 @@ import 'package:analyzer/src/dart/element/element.dart';
|
||||||
import 'package:analyzer/src/dart/element/member.dart';
|
import 'package:analyzer/src/dart/element/member.dart';
|
||||||
import 'package:analyzer/src/dart/element/type.dart';
|
import 'package:analyzer/src/dart/element/type.dart';
|
||||||
import 'package:analyzer/src/generated/engine.dart';
|
import 'package:analyzer/src/generated/engine.dart';
|
||||||
import 'package:analyzer/src/generated/java_core.dart';
|
|
||||||
import 'package:analyzer/src/generated/resolver.dart';
|
import 'package:analyzer/src/generated/resolver.dart';
|
||||||
import 'package:analyzer/src/generated/source.dart';
|
import 'package:analyzer/src/generated/source.dart';
|
||||||
import 'package:analyzer/src/generated/static_type_analyzer.dart';
|
import 'package:analyzer/src/generated/static_type_analyzer.dart';
|
||||||
|
@ -1427,12 +1426,7 @@ class StaticTypeAnalyzerTest extends EngineTestCase {
|
||||||
*/
|
*/
|
||||||
DartType _analyze4(
|
DartType _analyze4(
|
||||||
Expression node, InterfaceType thisType, bool useStaticType) {
|
Expression node, InterfaceType thisType, bool useStaticType) {
|
||||||
try {
|
_analyzer.thisType = thisType;
|
||||||
_analyzer.thisType = thisType;
|
|
||||||
} catch (exception) {
|
|
||||||
throw new IllegalArgumentException(
|
|
||||||
"Could not set type of 'this'", exception);
|
|
||||||
}
|
|
||||||
node.accept(_analyzer);
|
node.accept(_analyzer);
|
||||||
if (useStaticType) {
|
if (useStaticType) {
|
||||||
return node.staticType;
|
return node.staticType;
|
||||||
|
@ -1554,12 +1548,7 @@ class StaticTypeAnalyzerTest extends EngineTestCase {
|
||||||
definingLibrary, source, _typeProvider, _listener,
|
definingLibrary, source, _typeProvider, _listener,
|
||||||
nameScope: new LibraryScope(definingLibrary));
|
nameScope: new LibraryScope(definingLibrary));
|
||||||
_visitor.overrideManager.enterScope();
|
_visitor.overrideManager.enterScope();
|
||||||
try {
|
return _visitor.typeAnalyzer;
|
||||||
return _visitor.typeAnalyzer;
|
|
||||||
} catch (exception) {
|
|
||||||
throw new IllegalArgumentException(
|
|
||||||
"Could not create analyzer", exception);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
DartType _flatten(DartType type) => type.flattenFutures(_typeSystem);
|
DartType _flatten(DartType type) => type.flattenFutures(_typeSystem);
|
||||||
|
|
|
@ -12,7 +12,6 @@ import 'package:analyzer/dart/element/type.dart';
|
||||||
import 'package:analyzer/src/dart/ast/utilities.dart';
|
import 'package:analyzer/src/dart/ast/utilities.dart';
|
||||||
import 'package:analyzer/src/generated/engine.dart';
|
import 'package:analyzer/src/generated/engine.dart';
|
||||||
import 'package:analyzer/src/generated/error.dart';
|
import 'package:analyzer/src/generated/error.dart';
|
||||||
import 'package:analyzer/src/generated/java_core.dart';
|
|
||||||
import 'package:analyzer/src/generated/java_engine.dart';
|
import 'package:analyzer/src/generated/java_engine.dart';
|
||||||
import 'package:analyzer/src/generated/source.dart';
|
import 'package:analyzer/src/generated/source.dart';
|
||||||
import 'package:plugin/manager.dart';
|
import 'package:plugin/manager.dart';
|
||||||
|
@ -129,7 +128,7 @@ class EngineTestCase {
|
||||||
AstNode root, String code, String prefix, Predicate<AstNode> predicate) {
|
AstNode root, String code, String prefix, Predicate<AstNode> predicate) {
|
||||||
int offset = code.indexOf(prefix);
|
int offset = code.indexOf(prefix);
|
||||||
if (offset == -1) {
|
if (offset == -1) {
|
||||||
throw new IllegalArgumentException("Not found '$prefix'.");
|
throw new ArgumentError("Not found '$prefix'.");
|
||||||
}
|
}
|
||||||
AstNode node = new NodeLocator(offset).searchWithin(root);
|
AstNode node = new NodeLocator(offset).searchWithin(root);
|
||||||
return node.getAncestor(predicate);
|
return node.getAncestor(predicate);
|
||||||
|
@ -142,7 +141,7 @@ class EngineTestCase {
|
||||||
AstNode root, String code, String prefix) {
|
AstNode root, String code, String prefix) {
|
||||||
int offset = code.indexOf(prefix);
|
int offset = code.indexOf(prefix);
|
||||||
if (offset == -1) {
|
if (offset == -1) {
|
||||||
throw new IllegalArgumentException("Not found '$prefix'.");
|
throw new ArgumentError("Not found '$prefix'.");
|
||||||
}
|
}
|
||||||
return new NodeLocator(offset).searchWithin(root);
|
return new NodeLocator(offset).searchWithin(root);
|
||||||
}
|
}
|
||||||
|
@ -589,7 +588,7 @@ class TestSource extends Source {
|
||||||
Uri get uri => new Uri.file(_name);
|
Uri get uri => new Uri.file(_name);
|
||||||
|
|
||||||
UriKind get uriKind {
|
UriKind get uriKind {
|
||||||
throw new UnsupportedOperationException();
|
throw new UnsupportedError('uriKind');
|
||||||
}
|
}
|
||||||
|
|
||||||
bool operator ==(Object other) {
|
bool operator ==(Object other) {
|
||||||
|
@ -601,11 +600,11 @@ class TestSource extends Source {
|
||||||
|
|
||||||
bool exists() => exists2;
|
bool exists() => exists2;
|
||||||
void getContentsToReceiver(Source_ContentReceiver receiver) {
|
void getContentsToReceiver(Source_ContentReceiver receiver) {
|
||||||
throw new UnsupportedOperationException();
|
throw new UnsupportedError('getContentsToReceiver');
|
||||||
}
|
}
|
||||||
|
|
||||||
Source resolve(String uri) {
|
Source resolve(String uri) {
|
||||||
throw new UnsupportedOperationException();
|
throw new UnsupportedError('resolve');
|
||||||
}
|
}
|
||||||
|
|
||||||
void setContents(String value) {
|
void setContents(String value) {
|
||||||
|
|
|
@ -1455,12 +1455,7 @@ class DirectedGraphTest extends EngineTestCase {
|
||||||
void test_findCycleContaining_null() {
|
void test_findCycleContaining_null() {
|
||||||
DirectedGraph<DirectedGraphTest_Node> graph =
|
DirectedGraph<DirectedGraphTest_Node> graph =
|
||||||
new DirectedGraph<DirectedGraphTest_Node>();
|
new DirectedGraph<DirectedGraphTest_Node>();
|
||||||
try {
|
expect(() => graph.findCycleContaining(null), throwsArgumentError);
|
||||||
graph.findCycleContaining(null);
|
|
||||||
fail("Expected IllegalArgumentException");
|
|
||||||
} on IllegalArgumentException {
|
|
||||||
// Expected
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void test_findCycleContaining_singleton() {
|
void test_findCycleContaining_singleton() {
|
||||||
|
@ -2524,21 +2519,15 @@ class LineInfoTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
void test_creation_empty() {
|
void test_creation_empty() {
|
||||||
try {
|
expect(() {
|
||||||
new LineInfo(<int>[]);
|
new LineInfo(<int>[]);
|
||||||
fail("Expected IllegalArgumentException");
|
}, throwsArgumentError);
|
||||||
} on IllegalArgumentException {
|
|
||||||
// Expected
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void test_creation_null() {
|
void test_creation_null() {
|
||||||
try {
|
expect(() {
|
||||||
new LineInfo(null);
|
new LineInfo(null);
|
||||||
fail("Expected IllegalArgumentException");
|
}, throwsArgumentError);
|
||||||
} on IllegalArgumentException {
|
|
||||||
// Expected
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void test_firstLine() {
|
void test_firstLine() {
|
||||||
|
@ -2899,24 +2888,11 @@ class MultipleMapIteratorTest extends EngineTestCase {
|
||||||
Map<String, String> map = new HashMap<String, String>();
|
Map<String, String> map = new HashMap<String, String>();
|
||||||
MultipleMapIterator<String, String> iterator = _iterator(<Map>[map]);
|
MultipleMapIterator<String, String> iterator = _iterator(<Map>[map]);
|
||||||
expect(iterator.moveNext(), isFalse);
|
expect(iterator.moveNext(), isFalse);
|
||||||
try {
|
expect(() => iterator.key, throwsStateError);
|
||||||
iterator.key;
|
expect(() => iterator.value, throwsStateError);
|
||||||
fail("Expected NoSuchElementException");
|
expect(() {
|
||||||
} on NoSuchElementException {
|
iterator.value = 'x';
|
||||||
// Expected
|
}, throwsStateError);
|
||||||
}
|
|
||||||
try {
|
|
||||||
iterator.value;
|
|
||||||
fail("Expected NoSuchElementException");
|
|
||||||
} on NoSuchElementException {
|
|
||||||
// Expected
|
|
||||||
}
|
|
||||||
try {
|
|
||||||
iterator.value = "x";
|
|
||||||
fail("Expected NoSuchElementException");
|
|
||||||
} on NoSuchElementException {
|
|
||||||
// Expected
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void test_singleMap_multiple() {
|
void test_singleMap_multiple() {
|
||||||
|
@ -3904,24 +3880,11 @@ class SingleMapIteratorTest extends EngineTestCase {
|
||||||
SingleMapIterator<String, String> iterator =
|
SingleMapIterator<String, String> iterator =
|
||||||
new SingleMapIterator<String, String>(map);
|
new SingleMapIterator<String, String>(map);
|
||||||
expect(iterator.moveNext(), isFalse);
|
expect(iterator.moveNext(), isFalse);
|
||||||
try {
|
expect(() => iterator.key, throwsStateError);
|
||||||
iterator.key;
|
expect(() => iterator.value, throwsStateError);
|
||||||
fail("Expected NoSuchElementException");
|
expect(() {
|
||||||
} on NoSuchElementException {
|
iterator.value = 'x';
|
||||||
// Expected
|
}, throwsStateError);
|
||||||
}
|
|
||||||
try {
|
|
||||||
iterator.value;
|
|
||||||
fail("Expected NoSuchElementException");
|
|
||||||
} on NoSuchElementException {
|
|
||||||
// Expected
|
|
||||||
}
|
|
||||||
try {
|
|
||||||
iterator.value = "x";
|
|
||||||
fail("Expected NoSuchElementException");
|
|
||||||
} on NoSuchElementException {
|
|
||||||
// Expected
|
|
||||||
}
|
|
||||||
expect(iterator.moveNext(), isFalse);
|
expect(iterator.moveNext(), isFalse);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4214,12 +4177,9 @@ class StringUtilitiesTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
void test_printListOfQuotedNames_empty() {
|
void test_printListOfQuotedNames_empty() {
|
||||||
try {
|
expect(() {
|
||||||
StringUtilities.printListOfQuotedNames(new List<String>(0));
|
StringUtilities.printListOfQuotedNames(new List<String>(0));
|
||||||
fail("Expected IllegalArgumentException");
|
}, throwsArgumentError);
|
||||||
} on IllegalArgumentException {
|
|
||||||
// Expected
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void test_printListOfQuotedNames_five() {
|
void test_printListOfQuotedNames_five() {
|
||||||
|
@ -4230,21 +4190,15 @@ class StringUtilitiesTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
void test_printListOfQuotedNames_null() {
|
void test_printListOfQuotedNames_null() {
|
||||||
try {
|
expect(() {
|
||||||
StringUtilities.printListOfQuotedNames(null);
|
StringUtilities.printListOfQuotedNames(null);
|
||||||
fail("Expected IllegalArgumentException");
|
}, throwsArgumentError);
|
||||||
} on IllegalArgumentException {
|
|
||||||
// Expected
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void test_printListOfQuotedNames_one() {
|
void test_printListOfQuotedNames_one() {
|
||||||
try {
|
expect(() {
|
||||||
StringUtilities.printListOfQuotedNames(<String>["a"]);
|
StringUtilities.printListOfQuotedNames(<String>["a"]);
|
||||||
fail("Expected IllegalArgumentException");
|
}, throwsArgumentError);
|
||||||
} on IllegalArgumentException {
|
|
||||||
// Expected
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void test_printListOfQuotedNames_three() {
|
void test_printListOfQuotedNames_three() {
|
||||||
|
|
Loading…
Reference in a new issue