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

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

Issue 2226613004: Suppress follow-on errors when a file is imported with either a prefix or a show clause (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Cache URI existence in a modifier' Created 4 years, 4 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) 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/token.dart'; 8 import 'package:analyzer/dart/ast/token.dart';
9 import 'package:analyzer/dart/element/element.dart'; 9 import 'package:analyzer/dart/element/element.dart';
10 import 'package:analyzer/dart/element/type.dart'; 10 import 'package:analyzer/dart/element/type.dart';
11 import 'package:analyzer/src/dart/element/element.dart'; 11 import 'package:analyzer/src/dart/element/element.dart';
12 import 'package:analyzer/src/generated/element_resolver.dart'; 12 import 'package:analyzer/src/generated/element_resolver.dart';
13 import 'package:analyzer/src/generated/engine.dart'; 13 import 'package:analyzer/src/generated/engine.dart';
14 import 'package:analyzer/src/generated/java_core.dart'; 14 import 'package:analyzer/src/generated/java_core.dart';
15 import 'package:analyzer/src/generated/java_engine.dart';
15 import 'package:analyzer/src/generated/java_engine_io.dart'; 16 import 'package:analyzer/src/generated/java_engine_io.dart';
16 import 'package:analyzer/src/generated/resolver.dart'; 17 import 'package:analyzer/src/generated/resolver.dart';
17 import 'package:analyzer/src/generated/source_io.dart'; 18 import 'package:analyzer/src/generated/source_io.dart';
18 import 'package:analyzer/src/generated/testing/ast_factory.dart'; 19 import 'package:analyzer/src/generated/testing/ast_factory.dart';
19 import 'package:analyzer/src/generated/testing/element_factory.dart'; 20 import 'package:analyzer/src/generated/testing/element_factory.dart';
20 import 'package:analyzer/src/generated/testing/test_type_provider.dart'; 21 import 'package:analyzer/src/generated/testing/test_type_provider.dart';
21 import 'package:unittest/unittest.dart'; 22 import 'package:unittest/unittest.dart';
22 23
23 import '../reflective_tests.dart'; 24 import '../reflective_tests.dart';
24 import '../utils.dart'; 25 import '../utils.dart';
(...skipping 795 matching lines...) Expand 10 before | Expand all | Expand 10 after
820 ConstructorElementImpl superConstructor = 821 ConstructorElementImpl superConstructor =
821 ElementFactory.constructorElement2(superclass, null); 822 ElementFactory.constructorElement2(superclass, null);
822 superclass.constructors = <ConstructorElement>[superConstructor]; 823 superclass.constructors = <ConstructorElement>[superConstructor];
823 ClassElementImpl subclass = 824 ClassElementImpl subclass =
824 ElementFactory.classElement("B", superclass.type); 825 ElementFactory.classElement("B", superclass.type);
825 ConstructorElementImpl subConstructor = 826 ConstructorElementImpl subConstructor =
826 ElementFactory.constructorElement2(subclass, null); 827 ElementFactory.constructorElement2(subclass, null);
827 subclass.constructors = <ConstructorElement>[subConstructor]; 828 subclass.constructors = <ConstructorElement>[subConstructor];
828 SuperConstructorInvocation invocation = 829 SuperConstructorInvocation invocation =
829 AstFactory.superConstructorInvocation(); 830 AstFactory.superConstructorInvocation();
831 AstFactory.classDeclaration(null, 'C', null, null, null, null, [
832 AstFactory.constructorDeclaration(null, 'C', null, [invocation])
833 ]);
830 _resolveInClass(invocation, subclass); 834 _resolveInClass(invocation, subclass);
831 expect(invocation.staticElement, superConstructor); 835 expect(invocation.staticElement, superConstructor);
832 _listener.assertNoErrors(); 836 _listener.assertNoErrors();
833 } 837 }
834 838
835 void test_visitSuperConstructorInvocation_namedParameter() { 839 void test_visitSuperConstructorInvocation_namedParameter() {
836 ClassElementImpl superclass = ElementFactory.classElement2("A"); 840 ClassElementImpl superclass = ElementFactory.classElement2("A");
837 ConstructorElementImpl superConstructor = 841 ConstructorElementImpl superConstructor =
838 ElementFactory.constructorElement2(superclass, null); 842 ElementFactory.constructorElement2(superclass, null);
839 String parameterName = "p"; 843 String parameterName = "p";
840 ParameterElement parameter = ElementFactory.namedParameter(parameterName); 844 ParameterElement parameter = ElementFactory.namedParameter(parameterName);
841 superConstructor.parameters = <ParameterElement>[parameter]; 845 superConstructor.parameters = <ParameterElement>[parameter];
842 superclass.constructors = <ConstructorElement>[superConstructor]; 846 superclass.constructors = <ConstructorElement>[superConstructor];
843 ClassElementImpl subclass = 847 ClassElementImpl subclass =
844 ElementFactory.classElement("B", superclass.type); 848 ElementFactory.classElement("B", superclass.type);
845 ConstructorElementImpl subConstructor = 849 ConstructorElementImpl subConstructor =
846 ElementFactory.constructorElement2(subclass, null); 850 ElementFactory.constructorElement2(subclass, null);
847 subclass.constructors = <ConstructorElement>[subConstructor]; 851 subclass.constructors = <ConstructorElement>[subConstructor];
848 SuperConstructorInvocation invocation = AstFactory 852 SuperConstructorInvocation invocation = AstFactory
849 .superConstructorInvocation([ 853 .superConstructorInvocation([
850 AstFactory.namedExpression2(parameterName, AstFactory.integer(0)) 854 AstFactory.namedExpression2(parameterName, AstFactory.integer(0))
851 ]); 855 ]);
856 AstFactory.classDeclaration(null, 'C', null, null, null, null, [
857 AstFactory.constructorDeclaration(null, 'C', null, [invocation])
858 ]);
852 _resolveInClass(invocation, subclass); 859 _resolveInClass(invocation, subclass);
853 expect(invocation.staticElement, superConstructor); 860 expect(invocation.staticElement, superConstructor);
854 expect( 861 expect(
855 (invocation.argumentList.arguments[0] as NamedExpression) 862 (invocation.argumentList.arguments[0] as NamedExpression)
856 .name 863 .name
857 .label 864 .label
858 .staticElement, 865 .staticElement,
859 same(parameter)); 866 same(parameter));
860 _listener.assertNoErrors(); 867 _listener.assertNoErrors();
861 } 868 }
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
942 try { 949 try {
943 _visitor.enclosingClass = enclosingClass; 950 _visitor.enclosingClass = enclosingClass;
944 EnclosedScope innerScope = new ClassScope( 951 EnclosedScope innerScope = new ClassScope(
945 new TypeParameterScope(outerScope, enclosingClass), enclosingClass); 952 new TypeParameterScope(outerScope, enclosingClass), enclosingClass);
946 _visitor.nameScope = innerScope; 953 _visitor.nameScope = innerScope;
947 node.accept(_resolver); 954 node.accept(_resolver);
948 } finally { 955 } finally {
949 _visitor.enclosingClass = null; 956 _visitor.enclosingClass = null;
950 _visitor.nameScope = outerScope; 957 _visitor.nameScope = outerScope;
951 } 958 }
952 } catch (exception) { 959 } catch (exception, stackTrace) {
953 throw new IllegalArgumentException("Could not resolve node", exception); 960 throw new IllegalArgumentException(
961 "Could not resolve node", new CaughtException(exception, stackTrace));
954 } 962 }
955 } 963 }
956 964
957 /** 965 /**
958 * Return the element associated with the given expression after the resolver has resolved the 966 * Return the element associated with the given expression after the resolver has resolved the
959 * expression. 967 * expression.
960 * 968 *
961 * @param node the expression to be resolved 969 * @param node the expression to be resolved
962 * @param definedElements the elements that are to be defined in the scope in which the element is 970 * @param definedElements the elements that are to be defined in the scope in which the element is
963 * being resolved 971 * being resolved
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
1021 _visitor.labelScope = innerScope; 1029 _visitor.labelScope = innerScope;
1022 statement.accept(_resolver); 1030 statement.accept(_resolver);
1023 } finally { 1031 } finally {
1024 _visitor.labelScope = outerScope; 1032 _visitor.labelScope = outerScope;
1025 } 1033 }
1026 } catch (exception) { 1034 } catch (exception) {
1027 throw new IllegalArgumentException("Could not resolve node", exception); 1035 throw new IllegalArgumentException("Could not resolve node", exception);
1028 } 1036 }
1029 } 1037 }
1030 } 1038 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698