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

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

Issue 2539243002: Transition analyzer and analysis_server to new astFactory; remove old AST factory methods. (Closed)
Patch Set: Update CHANGELOG 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.element_resolver_test; 5 library analyzer.test.generated.element_resolver_test;
6 6
7 import 'package:analyzer/dart/ast/ast.dart'; 7 import 'package:analyzer/dart/ast/ast.dart';
8 import 'package:analyzer/dart/ast/standard_ast_factory.dart';
8 import 'package:analyzer/dart/ast/token.dart'; 9 import 'package:analyzer/dart/ast/token.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/file_system/memory_file_system.dart'; 12 import 'package:analyzer/file_system/memory_file_system.dart';
12 import 'package:analyzer/src/dart/element/element.dart'; 13 import 'package:analyzer/src/dart/element/element.dart';
13 import 'package:analyzer/src/generated/element_resolver.dart'; 14 import 'package:analyzer/src/generated/element_resolver.dart';
14 import 'package:analyzer/src/generated/engine.dart'; 15 import 'package:analyzer/src/generated/engine.dart';
15 import 'package:analyzer/src/generated/resolver.dart'; 16 import 'package:analyzer/src/generated/resolver.dart';
16 import 'package:analyzer/src/generated/source.dart'; 17 import 'package:analyzer/src/generated/source.dart';
17 import 'package:analyzer/src/generated/testing/ast_test_factory.dart'; 18 import 'package:analyzer/src/generated/testing/ast_test_factory.dart';
(...skipping 521 matching lines...) Expand 10 before | Expand all | Expand 10 after
539 PropertyAccessorElement getter = 540 PropertyAccessorElement getter =
540 ElementFactory.getterElement(propName, false, _typeProvider.intType); 541 ElementFactory.getterElement(propName, false, _typeProvider.intType);
541 PropertyAccessorElement setter = 542 PropertyAccessorElement setter =
542 ElementFactory.setterElement(propName, false, _typeProvider.intType); 543 ElementFactory.setterElement(propName, false, _typeProvider.intType);
543 classA.accessors = <PropertyAccessorElement>[getter, setter]; 544 classA.accessors = <PropertyAccessorElement>[getter, setter];
544 // set name scope 545 // set name scope
545 _visitor.nameScope = new EnclosedScope(null) 546 _visitor.nameScope = new EnclosedScope(null)
546 ..defineNameWithoutChecking('A', classA); 547 ..defineNameWithoutChecking('A', classA);
547 // prepare "A.p" 548 // prepare "A.p"
548 PrefixedIdentifier prefixed = AstTestFactory.identifier5('A', 'p'); 549 PrefixedIdentifier prefixed = AstTestFactory.identifier5('A', 'p');
549 CommentReference commentReference = new CommentReference(null, prefixed); 550 CommentReference commentReference =
551 astFactory.commentReference(null, prefixed);
550 // resolve 552 // resolve
551 _resolveNode(commentReference); 553 _resolveNode(commentReference);
552 expect(prefixed.prefix.staticElement, classA); 554 expect(prefixed.prefix.staticElement, classA);
553 expect(prefixed.identifier.staticElement, getter); 555 expect(prefixed.identifier.staticElement, getter);
554 _listener.assertNoErrors(); 556 _listener.assertNoErrors();
555 } 557 }
556 558
557 void test_visitCommentReference_prefixedIdentifier_class_method() { 559 void test_visitCommentReference_prefixedIdentifier_class_method() {
558 ClassElementImpl classA = ElementFactory.classElement2("A"); 560 ClassElementImpl classA = ElementFactory.classElement2("A");
559 // set method 561 // set method
560 MethodElement method = 562 MethodElement method =
561 ElementFactory.methodElement("m", _typeProvider.intType); 563 ElementFactory.methodElement("m", _typeProvider.intType);
562 classA.methods = <MethodElement>[method]; 564 classA.methods = <MethodElement>[method];
563 // set name scope 565 // set name scope
564 _visitor.nameScope = new EnclosedScope(null) 566 _visitor.nameScope = new EnclosedScope(null)
565 ..defineNameWithoutChecking('A', classA); 567 ..defineNameWithoutChecking('A', classA);
566 // prepare "A.m" 568 // prepare "A.m"
567 PrefixedIdentifier prefixed = AstTestFactory.identifier5('A', 'm'); 569 PrefixedIdentifier prefixed = AstTestFactory.identifier5('A', 'm');
568 CommentReference commentReference = new CommentReference(null, prefixed); 570 CommentReference commentReference =
571 astFactory.commentReference(null, prefixed);
569 // resolve 572 // resolve
570 _resolveNode(commentReference); 573 _resolveNode(commentReference);
571 expect(prefixed.prefix.staticElement, classA); 574 expect(prefixed.prefix.staticElement, classA);
572 expect(prefixed.identifier.staticElement, method); 575 expect(prefixed.identifier.staticElement, method);
573 _listener.assertNoErrors(); 576 _listener.assertNoErrors();
574 } 577 }
575 578
576 void test_visitCommentReference_prefixedIdentifier_class_operator() { 579 void test_visitCommentReference_prefixedIdentifier_class_operator() {
577 ClassElementImpl classA = ElementFactory.classElement2("A"); 580 ClassElementImpl classA = ElementFactory.classElement2("A");
578 // set method 581 // set method
579 MethodElement method = 582 MethodElement method =
580 ElementFactory.methodElement("==", _typeProvider.boolType); 583 ElementFactory.methodElement("==", _typeProvider.boolType);
581 classA.methods = <MethodElement>[method]; 584 classA.methods = <MethodElement>[method];
582 // set name scope 585 // set name scope
583 _visitor.nameScope = new EnclosedScope(null) 586 _visitor.nameScope = new EnclosedScope(null)
584 ..defineNameWithoutChecking('A', classA); 587 ..defineNameWithoutChecking('A', classA);
585 // prepare "A.==" 588 // prepare "A.=="
586 PrefixedIdentifier prefixed = AstTestFactory.identifier5('A', '=='); 589 PrefixedIdentifier prefixed = AstTestFactory.identifier5('A', '==');
587 CommentReference commentReference = new CommentReference(null, prefixed); 590 CommentReference commentReference =
591 astFactory.commentReference(null, prefixed);
588 // resolve 592 // resolve
589 _resolveNode(commentReference); 593 _resolveNode(commentReference);
590 expect(prefixed.prefix.staticElement, classA); 594 expect(prefixed.prefix.staticElement, classA);
591 expect(prefixed.identifier.staticElement, method); 595 expect(prefixed.identifier.staticElement, method);
592 _listener.assertNoErrors(); 596 _listener.assertNoErrors();
593 } 597 }
594 598
595 void test_visitConstructorName_named() { 599 void test_visitConstructorName_named() {
596 ClassElementImpl classA = ElementFactory.classElement2("A"); 600 ClassElementImpl classA = ElementFactory.classElement2("A");
597 String constructorName = "a"; 601 String constructorName = "a";
(...skipping 688 matching lines...) Expand 10 before | Expand all | Expand 10 after
1286 innerScope = new LabelScope( 1290 innerScope = new LabelScope(
1287 outerScope, labelElement.name, labelTarget, labelElement); 1291 outerScope, labelElement.name, labelTarget, labelElement);
1288 } 1292 }
1289 _visitor.labelScope = innerScope; 1293 _visitor.labelScope = innerScope;
1290 statement.accept(_resolver); 1294 statement.accept(_resolver);
1291 } finally { 1295 } finally {
1292 _visitor.labelScope = outerScope; 1296 _visitor.labelScope = outerScope;
1293 } 1297 }
1294 } 1298 }
1295 } 1299 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698