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

Side by Side Diff: pkg/analyzer/test/generated/resolver_test_case.dart

Issue 2551023005: Prepare for decoupling analyzer ASTs from element model. (Closed)
Patch Set: 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) 2016, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2016, 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.test.generated.resolver_test_case; 5 library analyzer.test.generated.resolver_test_case;
6 6
7 import 'package:analyzer/dart/ast/ast.dart'; 7 import 'package:analyzer/dart/ast/ast.dart';
8 import 'package:analyzer/dart/ast/resolution_accessors.dart';
8 import 'package:analyzer/dart/ast/visitor.dart'; 9 import 'package:analyzer/dart/ast/visitor.dart';
9 import 'package:analyzer/dart/element/element.dart'; 10 import 'package:analyzer/dart/element/element.dart';
10 import 'package:analyzer/dart/element/type.dart'; 11 import 'package:analyzer/dart/element/type.dart';
11 import 'package:analyzer/error/error.dart'; 12 import 'package:analyzer/error/error.dart';
12 import 'package:analyzer/file_system/memory_file_system.dart'; 13 import 'package:analyzer/file_system/memory_file_system.dart';
13 import 'package:analyzer/src/dart/element/element.dart'; 14 import 'package:analyzer/src/dart/element/element.dart';
14 import 'package:analyzer/src/dart/element/type.dart'; 15 import 'package:analyzer/src/dart/element/type.dart';
15 import 'package:analyzer/src/error/codes.dart'; 16 import 'package:analyzer/src/error/codes.dart';
16 import 'package:analyzer/src/generated/engine.dart'; 17 import 'package:analyzer/src/generated/engine.dart';
17 import 'package:analyzer/src/generated/java_engine.dart'; 18 import 'package:analyzer/src/generated/java_engine.dart';
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after
225 return null; 226 return null;
226 } 227 }
227 return node.propertyName.accept(this); 228 return node.propertyName.accept(this);
228 } 229 }
229 230
230 @override 231 @override
231 Object visitSimpleIdentifier(SimpleIdentifier node) { 232 Object visitSimpleIdentifier(SimpleIdentifier node) {
232 if (node.name == "void") { 233 if (node.name == "void") {
233 return null; 234 return null;
234 } 235 }
235 if (node.staticType != null && 236 if (staticTypeForExpression(node) != null &&
236 node.staticType.isDynamic && 237 staticTypeForExpression(node).isDynamic &&
237 node.staticElement == null) { 238 node.staticElement == null) {
238 return null; 239 return null;
239 } 240 }
240 AstNode parent = node.parent; 241 AstNode parent = node.parent;
241 if (parent is MethodInvocation) { 242 if (parent is MethodInvocation) {
242 MethodInvocation invocation = parent; 243 MethodInvocation invocation = parent;
243 if (identical(invocation.methodName, node)) { 244 if (identical(invocation.methodName, node)) {
244 Expression target = invocation.realTarget; 245 Expression target = invocation.realTarget;
245 DartType targetType = target == null ? null : target.staticType; 246 DartType targetType = target == null ? null : target.staticType;
246 if (targetType == null || targetType.isDynamic) { 247 if (targetType == null || targetType.isDynamic) {
(...skipping 19 matching lines...) Expand all
266 } 267 }
267 268
268 String _getFileName(AstNode node) { 269 String _getFileName(AstNode node) {
269 // TODO (jwren) there are two copies of this method, one here and one in 270 // TODO (jwren) there are two copies of this method, one here and one in
270 // StaticTypeVerifier, they should be resolved into a single method 271 // StaticTypeVerifier, they should be resolved into a single method
271 if (node != null) { 272 if (node != null) {
272 AstNode root = node.root; 273 AstNode root = node.root;
273 if (root is CompilationUnit) { 274 if (root is CompilationUnit) {
274 CompilationUnit rootCU = root; 275 CompilationUnit rootCU = root;
275 if (rootCU.element != null) { 276 if (rootCU.element != null) {
276 return rootCU.element.source.fullName; 277 return elementForCompilationUnit(rootCU).source.fullName;
277 } else { 278 } else {
278 return "<unknown file- CompilationUnit.getElement() returned null>"; 279 return "<unknown file- CompilationUnit.getElement() returned null>";
279 } 280 }
280 } else { 281 } else {
281 return "<unknown file- CompilationUnit.getRoot() is not a CompilationUni t>"; 282 return "<unknown file- CompilationUnit.getRoot() is not a CompilationUni t>";
282 } 283 }
283 } 284 }
284 return "<unknown file- ASTNode is null>"; 285 return "<unknown file- ASTNode is null>";
285 } 286 }
286 287
(...skipping 376 matching lines...) Expand 10 before | Expand all | Expand 10 after
663 LibraryElement library = analysisContext.computeLibraryElement(source); 664 LibraryElement library = analysisContext.computeLibraryElement(source);
664 return analysisContext.resolveCompilationUnit(source, library); 665 return analysisContext.resolveCompilationUnit(source, library);
665 } 666 }
666 667
667 Source resolveSources(List<String> sourceTexts) { 668 Source resolveSources(List<String> sourceTexts) {
668 for (int i = 0; i < sourceTexts.length; i++) { 669 for (int i = 0; i < sourceTexts.length; i++) {
669 CompilationUnit unit = 670 CompilationUnit unit =
670 resolveSource2("/lib${i + 1}.dart", sourceTexts[i]); 671 resolveSource2("/lib${i + 1}.dart", sourceTexts[i]);
671 // reference the source if this is the last source 672 // reference the source if this is the last source
672 if (i + 1 == sourceTexts.length) { 673 if (i + 1 == sourceTexts.length) {
673 return unit.element.source; 674 return elementForCompilationUnit(unit).source;
674 } 675 }
675 } 676 }
676 return null; 677 return null;
677 } 678 }
678 679
679 void resolveWithAndWithoutExperimental( 680 void resolveWithAndWithoutExperimental(
680 List<String> strSources, 681 List<String> strSources,
681 List<ErrorCode> codesWithoutExperimental, 682 List<ErrorCode> codesWithoutExperimental,
682 List<ErrorCode> codesWithExperimental) { 683 List<ErrorCode> codesWithExperimental) {
683 // Setup analysis context as non-experimental 684 // Setup analysis context as non-experimental
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
835 * text. Otherwise, [expected] is used directly a [Matcher] to match the type. 836 * text. Otherwise, [expected] is used directly a [Matcher] to match the type.
836 */ 837 */
837 _expectType(DartType type, expected) { 838 _expectType(DartType type, expected) {
838 if (expected is String) { 839 if (expected is String) {
839 expect(type.toString(), expected); 840 expect(type.toString(), expected);
840 } else { 841 } else {
841 expect(type, expected); 842 expect(type, expected);
842 } 843 }
843 } 844 }
844 } 845 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698