Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(112)

Unified Diff: pkg/analyzer/lib/src/generated/element.dart

Issue 1410643003: Add a public API for the results of constant evaluation (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « pkg/analyzer/lib/src/generated/constant.dart ('k') | pkg/analyzer/lib/src/generated/element_handle.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analyzer/lib/src/generated/element.dart
diff --git a/pkg/analyzer/lib/src/generated/element.dart b/pkg/analyzer/lib/src/generated/element.dart
index 9e7aeb4825871cb6b0c974897742ebf56df78838..af7d2291dbcf5980a027201dcd98528ba8a4aca6 100644
--- a/pkg/analyzer/lib/src/generated/element.dart
+++ b/pkg/analyzer/lib/src/generated/element.dart
@@ -13,7 +13,7 @@ import 'package:analyzer/task/model.dart'
show AnalysisTarget, ConstantEvaluationTarget;
import 'ast.dart';
-import 'constant.dart' show EvaluationResultImpl;
+import 'constant.dart' show DartObject, EvaluationResultImpl;
import 'engine.dart' show AnalysisContext, AnalysisEngine, AnalysisException;
import 'html.dart' show XmlAttributeNode, XmlTagNode;
import 'java_core.dart';
@@ -1760,6 +1760,9 @@ class ConstFieldElementImpl extends FieldElementImpl with ConstVariableElement {
ConstFieldElementImpl.forNode(Identifier name) : super.forNode(name);
@override
+ DartObject get constantValue => _result.value;
+
+ @override
EvaluationResultImpl get evaluationResult => _result;
@override
@@ -1791,6 +1794,9 @@ class ConstLocalVariableElementImpl extends LocalVariableElementImpl
ConstLocalVariableElementImpl.forNode(Identifier name) : super.forNode(name);
@override
+ DartObject get constantValue => _result.value;
+
+ @override
EvaluationResultImpl get evaluationResult => _result;
@override
@@ -2109,6 +2115,9 @@ class ConstTopLevelVariableElementImpl extends TopLevelVariableElementImpl
ConstTopLevelVariableElementImpl(Identifier name) : super.forNode(name);
@override
+ DartObject get constantValue => _result.value;
+
+ @override
EvaluationResultImpl get evaluationResult => _result;
@override
@@ -2273,6 +2282,9 @@ class DefaultFieldFormalParameterElementImpl
DefaultFieldFormalParameterElementImpl(Identifier name) : super(name);
@override
+ DartObject get constantValue => _result.value;
+
+ @override
EvaluationResultImpl get evaluationResult => _result;
@override
@@ -2297,6 +2309,9 @@ class DefaultParameterElementImpl extends ParameterElementImpl
DefaultParameterElementImpl(Identifier name) : super.forNode(name);
@override
+ DartObject get constantValue => _result.value;
+
+ @override
EvaluationResultImpl get evaluationResult => _result;
@override
@@ -2659,6 +2674,14 @@ abstract class ElementAnnotation {
static const List<ElementAnnotation> EMPTY_LIST = const <ElementAnnotation>[];
/**
+ * Return a representation of the value of this annotation.
+ *
+ * Return `null` if the value of this annotation could not be computed because
+ * of errors.
+ */
+ DartObject get constantValue;
+
+ /**
* Return the element representing the field, variable, or const constructor
* being used as an annotation.
*/
@@ -2738,6 +2761,9 @@ class ElementAnnotationImpl implements ElementAnnotation {
ElementAnnotationImpl(this.element);
@override
+ DartObject get constantValue => evaluationResult.value;
+
+ @override
bool get isDeprecated {
if (element != null) {
LibraryElement library = element.library;
@@ -10610,6 +10636,15 @@ abstract class VariableElement implements Element, ConstantEvaluationTarget {
static const List<VariableElement> EMPTY_LIST = const <VariableElement>[];
/**
+ * Return a representation of the value of this variable.
+ *
+ * Return `null` if either this variable was not declared with the 'const'
+ * modifier or if the value of this variable could not be computed because of
+ * errors.
+ */
+ DartObject get constantValue;
+
+ /**
* Return `true` if this variable element did not have an explicit type
* specified for it.
*/
@@ -10712,6 +10747,9 @@ abstract class VariableElementImpl extends ElementImpl
setModifier(Modifier.CONST, isConst);
}
+ @override
+ DartObject get constantValue => null;
+
/**
* Return the result of evaluating this variable's initializer as a
* compile-time constant expression, or `null` if this variable is not a
« no previous file with comments | « pkg/analyzer/lib/src/generated/constant.dart ('k') | pkg/analyzer/lib/src/generated/element_handle.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698