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

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

Issue 1711433002: Deprecate old "isPotentiallyMutated..." API. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 10 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 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 library analyzer.src.dart.element.element; 5 library analyzer.src.dart.element.element;
6 6
7 import 'dart:collection'; 7 import 'dart:collection';
8 import 'dart:math' show min; 8 import 'dart:math' show min;
9 9
10 import 'package:analyzer/dart/ast/ast.dart'; 10 import 'package:analyzer/dart/ast/ast.dart';
(...skipping 3539 matching lines...) Expand 10 before | Expand all | Expand 10 after
3550 3550
3551 @override 3551 @override
3552 String get identifier { 3552 String get identifier {
3553 int enclosingOffset = 3553 int enclosingOffset =
3554 enclosingElement != null ? enclosingElement.nameOffset : 0; 3554 enclosingElement != null ? enclosingElement.nameOffset : 0;
3555 int delta = nameOffset - enclosingOffset; 3555 int delta = nameOffset - enclosingOffset;
3556 return '${super.identifier}@$delta'; 3556 return '${super.identifier}@$delta';
3557 } 3557 }
3558 3558
3559 @override 3559 @override
3560 bool get isPotentiallyMutatedInClosure => 3560 bool get isPotentiallyMutatedInClosure => true;
3561 hasModifier(Modifier.POTENTIALLY_MUTATED_IN_CONTEXT);
3562 3561
3563 @override 3562 @override
3564 bool get isPotentiallyMutatedInScope => 3563 bool get isPotentiallyMutatedInScope => true;
3565 hasModifier(Modifier.POTENTIALLY_MUTATED_IN_SCOPE);
3566 3564
3567 @override 3565 @override
3568 ElementKind get kind => ElementKind.LOCAL_VARIABLE; 3566 ElementKind get kind => ElementKind.LOCAL_VARIABLE;
3569 3567
3570 @override 3568 @override
3571 SourceRange get visibleRange { 3569 SourceRange get visibleRange {
3572 if (_visibleRangeLength < 0) { 3570 if (_visibleRangeLength < 0) {
3573 return null; 3571 return null;
3574 } 3572 }
3575 return new SourceRange(_visibleRangeOffset, _visibleRangeLength); 3573 return new SourceRange(_visibleRangeOffset, _visibleRangeLength);
3576 } 3574 }
3577 3575
3578 @override 3576 @override
3579 accept(ElementVisitor visitor) => visitor.visitLocalVariableElement(this); 3577 accept(ElementVisitor visitor) => visitor.visitLocalVariableElement(this);
3580 3578
3581 @override 3579 @override
3582 void appendTo(StringBuffer buffer) { 3580 void appendTo(StringBuffer buffer) {
3583 buffer.write(type); 3581 buffer.write(type);
3584 buffer.write(" "); 3582 buffer.write(" ");
3585 buffer.write(displayName); 3583 buffer.write(displayName);
3586 } 3584 }
3587 3585
3588 @override 3586 @override
3589 VariableDeclaration computeNode() => 3587 VariableDeclaration computeNode() =>
3590 getNodeMatching((node) => node is VariableDeclaration); 3588 getNodeMatching((node) => node is VariableDeclaration);
3591 3589
3592 /** 3590 /**
3593 * Specifies that this variable is potentially mutated somewhere in closure.
3594 */
3595 void markPotentiallyMutatedInClosure() {
3596 setModifier(Modifier.POTENTIALLY_MUTATED_IN_CONTEXT, true);
3597 }
3598
3599 /**
3600 * Specifies that this variable is potentially mutated somewhere in its scope.
3601 */
3602 void markPotentiallyMutatedInScope() {
3603 setModifier(Modifier.POTENTIALLY_MUTATED_IN_SCOPE, true);
3604 }
3605
3606 /**
3607 * Set the visible range for this element to the range starting at the given 3591 * Set the visible range for this element to the range starting at the given
3608 * [offset] with the given [length]. 3592 * [offset] with the given [length].
3609 */ 3593 */
3610 void setVisibleRange(int offset, int length) { 3594 void setVisibleRange(int offset, int length) {
3611 _visibleRangeOffset = offset; 3595 _visibleRangeOffset = offset;
3612 _visibleRangeLength = length; 3596 _visibleRangeLength = length;
3613 } 3597 }
3614 } 3598 }
3615 3599
3616 /** 3600 /**
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
3771 */ 3755 */
3772 static const Modifier IMPLICIT_TYPE = const Modifier('IMPLICIT_TYPE', 11); 3756 static const Modifier IMPLICIT_TYPE = const Modifier('IMPLICIT_TYPE', 11);
3773 3757
3774 /** 3758 /**
3775 * Indicates that a class is a mixin application. 3759 * Indicates that a class is a mixin application.
3776 */ 3760 */
3777 static const Modifier MIXIN_APPLICATION = 3761 static const Modifier MIXIN_APPLICATION =
3778 const Modifier('MIXIN_APPLICATION', 12); 3762 const Modifier('MIXIN_APPLICATION', 12);
3779 3763
3780 /** 3764 /**
3781 * Indicates that the value of a parameter or local variable might be mutated
3782 * within the context.
3783 */
3784 static const Modifier POTENTIALLY_MUTATED_IN_CONTEXT =
3785 const Modifier('POTENTIALLY_MUTATED_IN_CONTEXT', 13);
3786
3787 /**
3788 * Indicates that the value of a parameter or local variable might be mutated
3789 * within the scope.
3790 */
3791 static const Modifier POTENTIALLY_MUTATED_IN_SCOPE =
3792 const Modifier('POTENTIALLY_MUTATED_IN_SCOPE', 14);
3793
3794 /**
3795 * Indicates that a class contains an explicit reference to 'super'. 3765 * Indicates that a class contains an explicit reference to 'super'.
3796 */ 3766 */
3797 static const Modifier REFERENCES_SUPER = 3767 static const Modifier REFERENCES_SUPER =
3798 const Modifier('REFERENCES_SUPER', 15); 3768 const Modifier('REFERENCES_SUPER', 13);
3799 3769
3800 /** 3770 /**
3801 * Indicates that the pseudo-modifier 'set' was applied to the element. 3771 * Indicates that the pseudo-modifier 'set' was applied to the element.
3802 */ 3772 */
3803 static const Modifier SETTER = const Modifier('SETTER', 16); 3773 static const Modifier SETTER = const Modifier('SETTER', 14);
3804 3774
3805 /** 3775 /**
3806 * Indicates that the modifier 'static' was applied to the element. 3776 * Indicates that the modifier 'static' was applied to the element.
3807 */ 3777 */
3808 static const Modifier STATIC = const Modifier('STATIC', 17); 3778 static const Modifier STATIC = const Modifier('STATIC', 15);
3809 3779
3810 /** 3780 /**
3811 * Indicates that the element does not appear in the source code but was 3781 * Indicates that the element does not appear in the source code but was
3812 * implicitly created. For example, if a class does not define any 3782 * implicitly created. For example, if a class does not define any
3813 * constructors, an implicit zero-argument constructor will be created and it 3783 * constructors, an implicit zero-argument constructor will be created and it
3814 * will be marked as being synthetic. 3784 * will be marked as being synthetic.
3815 */ 3785 */
3816 static const Modifier SYNTHETIC = const Modifier('SYNTHETIC', 18); 3786 static const Modifier SYNTHETIC = const Modifier('SYNTHETIC', 16);
3817 3787
3818 static const List<Modifier> values = const [ 3788 static const List<Modifier> values = const [
3819 ABSTRACT, 3789 ABSTRACT,
3820 ASYNCHRONOUS, 3790 ASYNCHRONOUS,
3821 CONST, 3791 CONST,
3822 DEFERRED, 3792 DEFERRED,
3823 ENUM, 3793 ENUM,
3824 EXTERNAL, 3794 EXTERNAL,
3825 FACTORY, 3795 FACTORY,
3826 FINAL, 3796 FINAL,
3827 GENERATOR, 3797 GENERATOR,
3828 GETTER, 3798 GETTER,
3829 HAS_EXT_URI, 3799 HAS_EXT_URI,
3830 IMPLICIT_TYPE, 3800 IMPLICIT_TYPE,
3831 MIXIN_APPLICATION, 3801 MIXIN_APPLICATION,
3832 POTENTIALLY_MUTATED_IN_CONTEXT,
3833 POTENTIALLY_MUTATED_IN_SCOPE,
3834 REFERENCES_SUPER, 3802 REFERENCES_SUPER,
3835 SETTER, 3803 SETTER,
3836 STATIC, 3804 STATIC,
3837 SYNTHETIC 3805 SYNTHETIC
3838 ]; 3806 ];
3839 3807
3840 const Modifier(String name, int ordinal) : super(name, ordinal); 3808 const Modifier(String name, int ordinal) : super(name, ordinal);
3841 } 3809 }
3842 3810
3843 /** 3811 /**
(...skipping 310 matching lines...) Expand 10 before | Expand all | Expand 10 after
4154 * Set Dart code of the default value. 4122 * Set Dart code of the default value.
4155 */ 4123 */
4156 void set defaultValueCode(String defaultValueCode) { 4124 void set defaultValueCode(String defaultValueCode) {
4157 this._defaultValueCode = StringUtilities.intern(defaultValueCode); 4125 this._defaultValueCode = StringUtilities.intern(defaultValueCode);
4158 } 4126 }
4159 4127
4160 @override 4128 @override
4161 bool get isInitializingFormal => false; 4129 bool get isInitializingFormal => false;
4162 4130
4163 @override 4131 @override
4164 bool get isPotentiallyMutatedInClosure => 4132 bool get isPotentiallyMutatedInClosure => true;
4165 hasModifier(Modifier.POTENTIALLY_MUTATED_IN_CONTEXT);
4166 4133
4167 @override 4134 @override
4168 bool get isPotentiallyMutatedInScope => 4135 bool get isPotentiallyMutatedInScope => true;
4169 hasModifier(Modifier.POTENTIALLY_MUTATED_IN_SCOPE);
4170 4136
4171 @override 4137 @override
4172 ElementKind get kind => ElementKind.PARAMETER; 4138 ElementKind get kind => ElementKind.PARAMETER;
4173 4139
4174 @override 4140 @override
4175 List<ParameterElement> get parameters => _parameters; 4141 List<ParameterElement> get parameters => _parameters;
4176 4142
4177 /** 4143 /**
4178 * Set the parameters defined by this executable element to the given 4144 * Set the parameters defined by this executable element to the given
4179 * [parameters]. 4145 * [parameters].
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
4237 ElementImpl getChild(String identifier) { 4203 ElementImpl getChild(String identifier) {
4238 for (ParameterElement parameter in _parameters) { 4204 for (ParameterElement parameter in _parameters) {
4239 if ((parameter as ParameterElementImpl).identifier == identifier) { 4205 if ((parameter as ParameterElementImpl).identifier == identifier) {
4240 return parameter as ParameterElementImpl; 4206 return parameter as ParameterElementImpl;
4241 } 4207 }
4242 } 4208 }
4243 return null; 4209 return null;
4244 } 4210 }
4245 4211
4246 /** 4212 /**
4247 * Specifies that this variable is potentially mutated somewhere in closure.
4248 */
4249 void markPotentiallyMutatedInClosure() {
4250 setModifier(Modifier.POTENTIALLY_MUTATED_IN_CONTEXT, true);
4251 }
4252
4253 /**
4254 * Specifies that this variable is potentially mutated somewhere in its scope.
4255 */
4256 void markPotentiallyMutatedInScope() {
4257 setModifier(Modifier.POTENTIALLY_MUTATED_IN_SCOPE, true);
4258 }
4259
4260 /**
4261 * Set the visible range for this element to the range starting at the given 4213 * Set the visible range for this element to the range starting at the given
4262 * [offset] with the given [length]. 4214 * [offset] with the given [length].
4263 */ 4215 */
4264 void setVisibleRange(int offset, int length) { 4216 void setVisibleRange(int offset, int length) {
4265 _visibleRangeOffset = offset; 4217 _visibleRangeOffset = offset;
4266 _visibleRangeLength = length; 4218 _visibleRangeLength = length;
4267 } 4219 }
4268 4220
4269 @override 4221 @override
4270 void visitChildren(ElementVisitor visitor) { 4222 void visitChildren(ElementVisitor visitor) {
(...skipping 520 matching lines...) Expand 10 before | Expand all | Expand 10 after
4791 4743
4792 @override 4744 @override
4793 void visitElement(Element element) { 4745 void visitElement(Element element) {
4794 int offset = element.nameOffset; 4746 int offset = element.nameOffset;
4795 if (offset != -1) { 4747 if (offset != -1) {
4796 map[offset] = element; 4748 map[offset] = element;
4797 } 4749 }
4798 super.visitElement(element); 4750 super.visitElement(element);
4799 } 4751 }
4800 } 4752 }
OLDNEW
« no previous file with comments | « pkg/analyzer/lib/dart/element/element.dart ('k') | pkg/analyzer/lib/src/generated/resolver.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698