refactor(dart/transform): Rename `dumbEval` to `naiveEval`
This commit is contained in:
parent
d69bd021ee
commit
798be2776d
|
@ -3,7 +3,7 @@ library angular2.transform.common.code.queries_code;
|
|||
import 'package:analyzer/analyzer.dart';
|
||||
import 'package:analyzer/src/generated/ast.dart';
|
||||
import 'package:angular2/src/transform/common/annotation_matcher.dart';
|
||||
import 'package:angular2/src/transform/common/dumb_eval.dart';
|
||||
import 'package:angular2/src/transform/common/naive_eval.dart';
|
||||
import 'package:barback/barback.dart';
|
||||
|
||||
/// Visitor responsbile for processing a [ClassDeclaration] and extracting any
|
||||
|
@ -125,7 +125,7 @@ class _QueriesAnnotationVisitor extends SimpleAstVisitor<Iterable<String>> {
|
|||
}
|
||||
final queries = node.expression as MapLiteral;
|
||||
for (var entry in queries.entries) {
|
||||
var queryField = dumbEval(entry.key);
|
||||
var queryField = naiveEval(entry.key);
|
||||
if (queryField != NOT_A_CONSTANT) {
|
||||
_queryFields.add(queryField.toString());
|
||||
}
|
||||
|
|
|
@ -12,7 +12,7 @@ import 'package:angular2/src/transform/common/annotation_matcher.dart';
|
|||
import 'package:angular2/src/transform/common/interface_matcher.dart';
|
||||
import 'package:barback/barback.dart' show AssetId;
|
||||
|
||||
import 'dumb_eval.dart';
|
||||
import 'naive_eval.dart';
|
||||
|
||||
class DirectiveMetadataReader {
|
||||
final _DirectiveMetadataVisitor _visitor;
|
||||
|
@ -59,7 +59,7 @@ class DirectiveMetadataReader {
|
|||
/// `value` pairs to `map`. If `expression` does not evaluate to a [Map],
|
||||
/// throws a descriptive [FormatException].
|
||||
void _populateMap(Expression expression, Map map, String propertyName) {
|
||||
var evaluated = dumbEval(expression);
|
||||
var evaluated = naiveEval(expression);
|
||||
if (evaluated is! Map) {
|
||||
throw new FormatException(
|
||||
'Angular 2 expects a Map but could not understand the value for '
|
||||
|
@ -78,7 +78,7 @@ void _populateMap(Expression expression, Map map, String propertyName) {
|
|||
/// descriptive [FormatException].
|
||||
void _populateList(
|
||||
Expression expression, List<String> list, String propertyName) {
|
||||
var evaluated = dumbEval(expression);
|
||||
var evaluated = naiveEval(expression);
|
||||
if (evaluated is! List) {
|
||||
throw new FormatException(
|
||||
'Angular 2 expects a List but could not understand the value for '
|
||||
|
@ -91,7 +91,7 @@ void _populateList(
|
|||
/// Evaluates `node` and expects that the result will be a string. If not,
|
||||
/// throws a [FormatException].
|
||||
String _expressionToString(Expression node, String nodeDescription) {
|
||||
var value = dumbEval(node);
|
||||
var value = naiveEval(node);
|
||||
if (value is! String) {
|
||||
throw new FormatException(
|
||||
'Angular 2 could not understand the value '
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
library angular2.transform.common.dumb_eval;
|
||||
library angular2.transform.common.naive_eval;
|
||||
|
||||
import 'package:analyzer/analyzer.dart';
|
||||
|
||||
final _constantEvaluator = new ConstantEvaluator();
|
||||
|
||||
/// The value returned if the result of `dumbEval` is not a constant.
|
||||
/// The value returned if the result of `naiveEval` is not a constant.
|
||||
final NOT_A_CONSTANT = ConstantEvaluator.NOT_A_CONSTANT;
|
||||
|
||||
/// Performs a very limited syntactic evaluation of `expr`.
|
||||
|
@ -15,7 +15,7 @@ final NOT_A_CONSTANT = ConstantEvaluator.NOT_A_CONSTANT;
|
|||
/// even if that identifier is defined in the same [CompilationUnit].
|
||||
///
|
||||
/// Returns the result of evaluation or [NOT_A_CONSTANT] where appropriate.
|
||||
dynamic dumbEval(Expression expr) {
|
||||
dynamic naiveEval(Expression expr) {
|
||||
var val;
|
||||
if (expr is SimpleStringLiteral) {
|
||||
val = stringLiteralToString(expr);
|
|
@ -7,7 +7,7 @@ import 'package:analyzer/src/generated/ast.dart';
|
|||
import 'package:angular2/src/core/compiler/xhr.dart' show XHR;
|
||||
import 'package:angular2/src/transform/common/annotation_matcher.dart';
|
||||
import 'package:angular2/src/transform/common/asset_reader.dart';
|
||||
import 'package:angular2/src/transform/common/dumb_eval.dart';
|
||||
import 'package:angular2/src/transform/common/naive_eval.dart';
|
||||
import 'package:angular2/src/transform/common/async_string_writer.dart';
|
||||
import 'package:angular2/src/transform/common/logging.dart';
|
||||
import 'package:angular2/src/transform/common/options.dart';
|
||||
|
@ -142,7 +142,7 @@ class _ViewPropInliner extends RecursiveAstVisitor<Object> {
|
|||
}
|
||||
|
||||
void _populateStyleUrls(NamedExpression node) {
|
||||
var urls = dumbEval(node.expression);
|
||||
var urls = naiveEval(node.expression);
|
||||
if (urls is! List) {
|
||||
logger.warning('styleUrls is not a List of Strings (${node.expression})');
|
||||
return;
|
||||
|
@ -163,7 +163,7 @@ class _ViewPropInliner extends RecursiveAstVisitor<Object> {
|
|||
}
|
||||
|
||||
void _populateTemplateUrl(NamedExpression node) {
|
||||
var url = dumbEval(node.expression);
|
||||
var url = naiveEval(node.expression);
|
||||
if (url is! String) {
|
||||
logger.warning('template url is not a String (${node.expression})');
|
||||
return;
|
||||
|
|
Loading…
Reference in New Issue