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

Side by Side Diff: pkg/analyzer2dart/lib/src/identifier_semantics.dart

Issue 609783002: Support static field access in analyzer2dart. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Updated cf. comments. Created 6 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « pkg/analyzer2dart/lib/src/element_converter.dart ('k') | pkg/analyzer2dart/lib/src/modely.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 * Code for classifying the semantics of identifiers appearing in a Dart file. 6 * Code for classifying the semantics of identifiers appearing in a Dart file.
7 */ 7 */
8 library analyzer2dart.identifierSemantics; 8 library analyzer2dart.identifierSemantics;
9 9
10 import 'package:analyzer/analyzer.dart'; 10 import 'package:analyzer/analyzer.dart';
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
159 * read-modify-write operation (e.g. "+="). 159 * read-modify-write operation (e.g. "+=").
160 */ 160 */
161 bool get isRead => !isInvoke && identifier.inGetterContext(); 161 bool get isRead => !isInvoke && identifier.inGetterContext();
162 162
163 /** 163 /**
164 * True if this is a write access to a property, or an (erroneous) attempt to 164 * True if this is a write access to a property, or an (erroneous) attempt to
165 * write to a method. Note that both [isRead] and [isWrite] will be true in 165 * write to a method. Note that both [isRead] and [isWrite] will be true in
166 * the case of a read-modify-write operation (e.g. "+="). 166 * the case of a read-modify-write operation (e.g. "+=").
167 */ 167 */
168 bool get isWrite => identifier.inSetterContext(); 168 bool get isWrite => identifier.inSetterContext();
169
170 String toString() {
171 StringBuffer sb = new StringBuffer();
172 sb.write('AccessSemantics[');
173 sb.write('kind=$kind,');
174 if (isRead && isWrite) {
175 assert(!isInvoke);
176 sb.write('read/write,');
177 } else if (isRead) {
178 sb.write('read,');
179 } else if (isWrite) {
180 sb.write('write,');
181 } else if (isInvoke) {
182 sb.write('call,');
183 }
184 if (element != null) {
185 sb.write('element=');
186 if (classElement != null) {
187 sb.write('${classElement.name}.');
188 }
189 sb.write('${element}');
190 } else {
191 if (target == null) {
192 sb.write('target=this.$identifier');
193 } else {
194 sb.write('target=$target.$identifier');
195 }
196 }
197 sb.write(']');
198 return sb.toString();
199 }
169 } 200 }
170 201
171 /** 202 /**
172 * Return the semantics for [node]. 203 * Return the semantics for [node].
173 */ 204 */
174 AccessSemantics classifyMethodInvocation(MethodInvocation node) { 205 AccessSemantics classifyMethodInvocation(MethodInvocation node) {
175 Expression target = node.realTarget; 206 Expression target = node.realTarget;
176 Element staticElement = node.methodName.staticElement; 207 Element staticElement = node.methodName.staticElement;
177 if (target == null) { 208 if (target == null) {
178 if (staticElement is FunctionElement) { 209 if (staticElement is FunctionElement) {
(...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after
411 return new AccessSemantics.localFunction(node, staticElement); 442 return new AccessSemantics.localFunction(node, staticElement);
412 } 443 }
413 } else if (staticElement is MethodElement && staticElement.isStatic) { 444 } else if (staticElement is MethodElement && staticElement.isStatic) {
414 return new AccessSemantics.staticMethod( 445 return new AccessSemantics.staticMethod(
415 node, 446 node,
416 staticElement, 447 staticElement,
417 staticElement.enclosingElement); 448 staticElement.enclosingElement);
418 } 449 }
419 return new AccessSemantics.dynamic(node, null); 450 return new AccessSemantics.dynamic(node, null);
420 } 451 }
OLDNEW
« no previous file with comments | « pkg/analyzer2dart/lib/src/element_converter.dart ('k') | pkg/analyzer2dart/lib/src/modely.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698