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

Side by Side Diff: pkg/analyzer/lib/dart/element/element.dart

Issue 2551023005: Prepare for decoupling analyzer ASTs from element model. (Closed)
Patch Set: Address review comments Created 4 years 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 /** 5 /**
6 * Defines the element model. The element model describes the semantic (as 6 * Defines the element model. The element model describes the semantic (as
7 * opposed to syntactic) structure of Dart code. The syntactic structure of the 7 * opposed to syntactic) structure of Dart code. The syntactic structure of the
8 * code is modeled by the [AST structure](../ast/ast.dart). 8 * code is modeled by the [AST structure](../ast/ast.dart).
9 * 9 *
10 * The element model consists of two closely related kinds of objects: elements 10 * The element model consists of two closely related kinds of objects: elements
(...skipping 19 matching lines...) Expand all
30 * 30 *
31 * The element model does not contain everything in the code, only those things 31 * The element model does not contain everything in the code, only those things
32 * that are declared by the code. For example, it does not include any 32 * that are declared by the code. For example, it does not include any
33 * representation of the statements in a method body, but if one of those 33 * representation of the statements in a method body, but if one of those
34 * statements declares a local variable then the local variable will be 34 * statements declares a local variable then the local variable will be
35 * represented by an element. 35 * represented by an element.
36 */ 36 */
37 library analyzer.dart.element.element; 37 library analyzer.dart.element.element;
38 38
39 import 'package:analyzer/dart/ast/ast.dart'; 39 import 'package:analyzer/dart/ast/ast.dart';
40 import 'package:analyzer/dart/ast/resolution_base_classes.dart';
40 import 'package:analyzer/dart/constant/value.dart'; 41 import 'package:analyzer/dart/constant/value.dart';
41 import 'package:analyzer/dart/element/type.dart'; 42 import 'package:analyzer/dart/element/type.dart';
42 import 'package:analyzer/src/generated/engine.dart' show AnalysisContext; 43 import 'package:analyzer/src/generated/engine.dart' show AnalysisContext;
43 import 'package:analyzer/src/generated/java_engine.dart'; 44 import 'package:analyzer/src/generated/java_engine.dart';
44 import 'package:analyzer/src/generated/resolver.dart'; 45 import 'package:analyzer/src/generated/resolver.dart';
45 import 'package:analyzer/src/generated/source.dart'; 46 import 'package:analyzer/src/generated/source.dart';
46 import 'package:analyzer/src/generated/utilities_dart.dart'; 47 import 'package:analyzer/src/generated/utilities_dart.dart';
47 import 'package:analyzer/src/task/dart.dart'; 48 import 'package:analyzer/src/task/dart.dart';
48 import 'package:analyzer/task/model.dart' show AnalysisTarget; 49 import 'package:analyzer/task/model.dart' show AnalysisTarget;
49 50
(...skipping 506 matching lines...) Expand 10 before | Expand all | Expand 10 after
556 * * fields that are induced by explicit declarations of getters and setters, 557 * * fields that are induced by explicit declarations of getters and setters,
557 * and 558 * and
558 * * functions representing the initialization expression for a variable. 559 * * functions representing the initialization expression for a variable.
559 * 560 *
560 * Second, there are elements in the element model that do not have a name. 561 * Second, there are elements in the element model that do not have a name.
561 * These correspond to unnamed functions and exist in order to more accurately 562 * These correspond to unnamed functions and exist in order to more accurately
562 * represent the semantic structure of the program. 563 * represent the semantic structure of the program.
563 * 564 *
564 * Clients may not extend, implement or mix-in this class. 565 * Clients may not extend, implement or mix-in this class.
565 */ 566 */
566 abstract class Element implements AnalysisTarget { 567 abstract class Element implements AnalysisTarget, ResolutionTarget {
567 /** 568 /**
568 * A comparator that can be used to sort elements by their name offset. 569 * A comparator that can be used to sort elements by their name offset.
569 * Elements with a smaller offset will be sorted to be before elements with a 570 * Elements with a smaller offset will be sorted to be before elements with a
570 * larger name offset. 571 * larger name offset.
571 */ 572 */
572 static final Comparator<Element> SORT_BY_OFFSET = 573 static final Comparator<Element> SORT_BY_OFFSET =
573 (Element firstElement, Element secondElement) => 574 (Element firstElement, Element secondElement) =>
574 firstElement.nameOffset - secondElement.nameOffset; 575 firstElement.nameOffset - secondElement.nameOffset;
575 576
576 /** 577 /**
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after
780 * is no guarantee of the order in which the children will be visited. 781 * is no guarantee of the order in which the children will be visited.
781 */ 782 */
782 void visitChildren(ElementVisitor visitor); 783 void visitChildren(ElementVisitor visitor);
783 } 784 }
784 785
785 /** 786 /**
786 * A single annotation associated with an element. 787 * A single annotation associated with an element.
787 * 788 *
788 * Clients may not extend, implement or mix-in this class. 789 * Clients may not extend, implement or mix-in this class.
789 */ 790 */
790 abstract class ElementAnnotation implements ConstantEvaluationTarget { 791 abstract class ElementAnnotation
792 implements ConstantEvaluationTarget, ResolutionTarget {
791 /** 793 /**
792 * An empty list of annotations. 794 * An empty list of annotations.
793 */ 795 */
794 static const List<ElementAnnotation> EMPTY_LIST = const <ElementAnnotation>[]; 796 static const List<ElementAnnotation> EMPTY_LIST = const <ElementAnnotation>[];
795 797
796 /** 798 /**
797 * Return a representation of the value of this annotation. 799 * Return a representation of the value of this annotation.
798 * 800 *
799 * Return `null` if the value of this annotation could not be computed because 801 * Return `null` if the value of this annotation could not be computed because
800 * of errors. 802 * of errors.
(...skipping 1226 matching lines...) Expand 10 before | Expand all | Expand 10 after
2027 DartType get type; 2029 DartType get type;
2028 2030
2029 /** 2031 /**
2030 * Return a representation of the value of this variable, forcing the value 2032 * Return a representation of the value of this variable, forcing the value
2031 * to be computed if it had not previously been computed, or `null` if either 2033 * to be computed if it had not previously been computed, or `null` if either
2032 * this variable was not declared with the 'const' modifier or if the value of 2034 * this variable was not declared with the 'const' modifier or if the value of
2033 * this variable could not be computed because of errors. 2035 * this variable could not be computed because of errors.
2034 */ 2036 */
2035 DartObject computeConstantValue(); 2037 DartObject computeConstantValue();
2036 } 2038 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698