| Index: pkg/analyzer/test/generated/resolver_test.dart
|
| diff --git a/pkg/analyzer/test/generated/resolver_test.dart b/pkg/analyzer/test/generated/resolver_test.dart
|
| index cbe106ecbbfcbe3116be5aef716cf2de47f1479f..924cf6dba17d2e72c54b5ae11687b70e9057bb9c 100644
|
| --- a/pkg/analyzer/test/generated/resolver_test.dart
|
| +++ b/pkg/analyzer/test/generated/resolver_test.dart
|
| @@ -28,7 +28,6 @@ import 'package:analyzer/src/generated/utilities_dart.dart';
|
| import 'package:unittest/unittest.dart';
|
|
|
| import '../reflective_tests.dart';
|
| -import 'parser_test.dart';
|
| import 'test_support.dart';
|
|
|
|
|
| @@ -39,11 +38,8 @@ main() {
|
| runReflectiveTests(EnclosedScopeTest);
|
| runReflectiveTests(LibraryImportScopeTest);
|
| runReflectiveTests(LibraryScopeTest);
|
| - runReflectiveTests(ScopeBuilderTest);
|
| runReflectiveTests(ScopeTest);
|
| - runReflectiveTests(DeclarationMatcherTest);
|
| runReflectiveTests(ElementResolverTest);
|
| - runReflectiveTests(IncrementalResolverTest);
|
| runReflectiveTests(InheritanceManagerTest);
|
| runReflectiveTests(LibraryElementBuilderTest);
|
| runReflectiveTests(LibraryResolver2Test);
|
| @@ -1141,129 +1137,6 @@ var v = const A.a1(0);''');
|
| }
|
| }
|
|
|
| -class DeclarationMatcherTest extends ResolverTestCase {
|
| - void test_compilationUnitMatches_false_topLevelVariable() {
|
| - _assertCompilationUnitMatches(false, r'''
|
| -class C {
|
| - int m(int p) {
|
| - return p + p;
|
| - }
|
| -}''', r'''
|
| -const int ZERO = 0;
|
| -class C {
|
| - int m(int p) {
|
| - return p + p;
|
| - }
|
| -}''');
|
| - }
|
| -
|
| - void test_compilationUnitMatches_true_different() {
|
| - _assertCompilationUnitMatches(true, r'''
|
| -class C {
|
| - int m(int p) {
|
| - return p + p;
|
| - }
|
| -}''', r'''
|
| -class C {
|
| - int m(int p) {
|
| - return (p * p) + (p * p);
|
| - }
|
| -}''');
|
| - }
|
| -
|
| - void test_compilationUnitMatches_true_same() {
|
| - String content = r'''
|
| -class C {
|
| - int m(int p) {
|
| - return p + p;
|
| - }
|
| -}''';
|
| - _assertCompilationUnitMatches(true, content, content);
|
| - }
|
| -
|
| - void test_methodDeclarationMatches_false_localVariable() {
|
| - _assertMethodMatches(false, r'''
|
| -class C {
|
| - int m(int p) {
|
| - return p + p;
|
| - }
|
| -}''', r'''
|
| -class C {
|
| - int m(int p) {
|
| - int product = p * p;
|
| - return product + product;
|
| - }
|
| -}''');
|
| - }
|
| -
|
| - void test_methodDeclarationMatches_false_parameter() {
|
| - _assertMethodMatches(false, r'''
|
| -class C {
|
| - int m(int p) {
|
| - return p + p;
|
| - }
|
| -}''', r'''
|
| -class C {
|
| - int m(int p, int q) {
|
| - return (p * q) + (q * p);
|
| - }
|
| -}''');
|
| - }
|
| -
|
| - void test_methodDeclarationMatches_true_different() {
|
| - _assertMethodMatches(true, r'''
|
| -class C {
|
| - int m(int p) {
|
| - return p + p;
|
| - }
|
| -}''', r'''
|
| -class C {
|
| - int m(int p) {
|
| - return (p * p) + (p * p);
|
| - }
|
| -}''');
|
| - }
|
| -
|
| - void test_methodDeclarationMatches_true_same() {
|
| - String content = r'''
|
| -class C {
|
| - int m(int p) {
|
| - return p + p;
|
| - }
|
| -}''';
|
| - _assertMethodMatches(true, content, content);
|
| - }
|
| -
|
| - void _assertCompilationUnitMatches(bool expectMatch, String oldContent,
|
| - String newContent) {
|
| - Source source = addSource(oldContent);
|
| - LibraryElement library = resolve(source);
|
| - CompilationUnit oldUnit = resolveCompilationUnit(source, library);
|
| - CompilationUnit newUnit = ParserTestCase.parseCompilationUnit(newContent);
|
| - DeclarationMatcher matcher = new DeclarationMatcher();
|
| - expect(matcher.matches(newUnit, oldUnit.element), expectMatch);
|
| - }
|
| -
|
| - void _assertMethodMatches(bool expectMatch, String oldContent,
|
| - String newContent) {
|
| - Source source = addSource(oldContent);
|
| - LibraryElement library = resolve(source);
|
| - CompilationUnit oldUnit = resolveCompilationUnit(source, library);
|
| - MethodElement element = _getFirstMethod(oldUnit).element as MethodElement;
|
| - AnalysisContext context = analysisContext;
|
| - context.setContents(source, newContent);
|
| - CompilationUnit newUnit = context.parseCompilationUnit(source);
|
| - MethodDeclaration newMethod = _getFirstMethod(newUnit);
|
| - DeclarationMatcher matcher = new DeclarationMatcher();
|
| - expect(matcher.matches(newMethod, element), expectMatch);
|
| - }
|
| -
|
| - MethodDeclaration _getFirstMethod(CompilationUnit unit) {
|
| - ClassDeclaration classNode = unit.declarations[0] as ClassDeclaration;
|
| - return classNode.members[0] as MethodDeclaration;
|
| - }
|
| -}
|
| -
|
| class ElementResolverTest extends EngineTestCase {
|
| /**
|
| * The error listener to which errors will be reported.
|
| @@ -4499,40 +4372,6 @@ class A {
|
| }
|
| }
|
|
|
| -class IncrementalResolverTest extends ResolverTestCase {
|
| - void test_resolve() {
|
| - MethodDeclaration method = _resolveMethod(r'''
|
| -class C {
|
| - int m(int a) {
|
| - return a + a;
|
| - }
|
| -}''');
|
| - BlockFunctionBody body = method.body as BlockFunctionBody;
|
| - ReturnStatement statement = body.block.statements[0] as ReturnStatement;
|
| - BinaryExpression expression = statement.expression as BinaryExpression;
|
| - SimpleIdentifier left = expression.leftOperand as SimpleIdentifier;
|
| - Element leftElement = left.staticElement;
|
| - SimpleIdentifier right = expression.rightOperand as SimpleIdentifier;
|
| - Element rightElement = right.staticElement;
|
| - expect(leftElement, isNotNull);
|
| - expect(rightElement, same(leftElement));
|
| - }
|
| -
|
| - MethodDeclaration _resolveMethod(String content) {
|
| - Source source = addSource(content);
|
| - LibraryElement library = resolve(source);
|
| - CompilationUnit unit = resolveCompilationUnit(source, library);
|
| - ClassDeclaration classNode = unit.declarations[0] as ClassDeclaration;
|
| - MethodDeclaration method = classNode.members[0] as MethodDeclaration;
|
| - method.body.accept(new ResolutionEraser());
|
| - GatheringErrorListener errorListener = new GatheringErrorListener();
|
| - IncrementalResolver resolver =
|
| - new IncrementalResolver(library, source, typeProvider, errorListener);
|
| - resolver.resolve(method.body);
|
| - return method;
|
| - }
|
| -}
|
| -
|
| class InheritanceManagerTest extends EngineTestCase {
|
| /**
|
| * The type provider used to access the types.
|
| @@ -8050,264 +7889,6 @@ class Scope_EnclosedScopeTest_test_define_normal extends Scope {
|
| null;
|
| }
|
|
|
| -class ScopeBuilderTest extends EngineTestCase {
|
| - void test_scopeFor_ClassDeclaration() {
|
| - GatheringErrorListener listener = new GatheringErrorListener();
|
| - Scope scope =
|
| - ScopeBuilder.scopeFor(_createResolvedClassDeclaration(), listener);
|
| - EngineTestCase.assertInstanceOf(
|
| - (obj) => obj is LibraryScope,
|
| - LibraryScope,
|
| - scope);
|
| - }
|
| -
|
| - void test_scopeFor_ClassTypeAlias() {
|
| - GatheringErrorListener listener = new GatheringErrorListener();
|
| - Scope scope =
|
| - ScopeBuilder.scopeFor(_createResolvedClassTypeAlias(), listener);
|
| - EngineTestCase.assertInstanceOf(
|
| - (obj) => obj is LibraryScope,
|
| - LibraryScope,
|
| - scope);
|
| - }
|
| -
|
| - void test_scopeFor_CompilationUnit() {
|
| - GatheringErrorListener listener = new GatheringErrorListener();
|
| - Scope scope =
|
| - ScopeBuilder.scopeFor(_createResolvedCompilationUnit(), listener);
|
| - EngineTestCase.assertInstanceOf(
|
| - (obj) => obj is LibraryScope,
|
| - LibraryScope,
|
| - scope);
|
| - }
|
| -
|
| - void test_scopeFor_ConstructorDeclaration() {
|
| - GatheringErrorListener listener = new GatheringErrorListener();
|
| - Scope scope =
|
| - ScopeBuilder.scopeFor(_createResolvedConstructorDeclaration(), listener);
|
| - EngineTestCase.assertInstanceOf(
|
| - (obj) => obj is ClassScope,
|
| - ClassScope,
|
| - scope);
|
| - }
|
| -
|
| - void test_scopeFor_ConstructorDeclaration_parameters() {
|
| - GatheringErrorListener listener = new GatheringErrorListener();
|
| - Scope scope = ScopeBuilder.scopeFor(
|
| - _createResolvedConstructorDeclaration().parameters,
|
| - listener);
|
| - EngineTestCase.assertInstanceOf(
|
| - (obj) => obj is FunctionScope,
|
| - FunctionScope,
|
| - scope);
|
| - }
|
| -
|
| - void test_scopeFor_FunctionDeclaration() {
|
| - GatheringErrorListener listener = new GatheringErrorListener();
|
| - Scope scope =
|
| - ScopeBuilder.scopeFor(_createResolvedFunctionDeclaration(), listener);
|
| - EngineTestCase.assertInstanceOf(
|
| - (obj) => obj is LibraryScope,
|
| - LibraryScope,
|
| - scope);
|
| - }
|
| -
|
| - void test_scopeFor_FunctionDeclaration_parameters() {
|
| - GatheringErrorListener listener = new GatheringErrorListener();
|
| - Scope scope = ScopeBuilder.scopeFor(
|
| - _createResolvedFunctionDeclaration().functionExpression.parameters,
|
| - listener);
|
| - EngineTestCase.assertInstanceOf(
|
| - (obj) => obj is FunctionScope,
|
| - FunctionScope,
|
| - scope);
|
| - }
|
| -
|
| - void test_scopeFor_FunctionTypeAlias() {
|
| - GatheringErrorListener listener = new GatheringErrorListener();
|
| - Scope scope =
|
| - ScopeBuilder.scopeFor(_createResolvedFunctionTypeAlias(), listener);
|
| - EngineTestCase.assertInstanceOf(
|
| - (obj) => obj is LibraryScope,
|
| - LibraryScope,
|
| - scope);
|
| - }
|
| -
|
| - void test_scopeFor_FunctionTypeAlias_parameters() {
|
| - GatheringErrorListener listener = new GatheringErrorListener();
|
| - Scope scope =
|
| - ScopeBuilder.scopeFor(_createResolvedFunctionTypeAlias().parameters, listener);
|
| - EngineTestCase.assertInstanceOf(
|
| - (obj) => obj is FunctionTypeScope,
|
| - FunctionTypeScope,
|
| - scope);
|
| - }
|
| -
|
| - void test_scopeFor_MethodDeclaration() {
|
| - GatheringErrorListener listener = new GatheringErrorListener();
|
| - Scope scope =
|
| - ScopeBuilder.scopeFor(_createResolvedMethodDeclaration(), listener);
|
| - EngineTestCase.assertInstanceOf(
|
| - (obj) => obj is ClassScope,
|
| - ClassScope,
|
| - scope);
|
| - }
|
| -
|
| - void test_scopeFor_MethodDeclaration_body() {
|
| - GatheringErrorListener listener = new GatheringErrorListener();
|
| - Scope scope =
|
| - ScopeBuilder.scopeFor(_createResolvedMethodDeclaration().body, listener);
|
| - EngineTestCase.assertInstanceOf(
|
| - (obj) => obj is FunctionScope,
|
| - FunctionScope,
|
| - scope);
|
| - }
|
| -
|
| - void test_scopeFor_notInCompilationUnit() {
|
| - GatheringErrorListener listener = new GatheringErrorListener();
|
| - try {
|
| - ScopeBuilder.scopeFor(AstFactory.identifier3("x"), listener);
|
| - fail("Expected AnalysisException");
|
| - } on AnalysisException catch (exception) {
|
| - // Expected
|
| - }
|
| - }
|
| -
|
| - void test_scopeFor_null() {
|
| - GatheringErrorListener listener = new GatheringErrorListener();
|
| - try {
|
| - ScopeBuilder.scopeFor(null, listener);
|
| - fail("Expected AnalysisException");
|
| - } on AnalysisException catch (exception) {
|
| - // Expected
|
| - }
|
| - }
|
| -
|
| - void test_scopeFor_unresolved() {
|
| - GatheringErrorListener listener = new GatheringErrorListener();
|
| - try {
|
| - ScopeBuilder.scopeFor(AstFactory.compilationUnit(), listener);
|
| - fail("Expected AnalysisException");
|
| - } on AnalysisException catch (exception) {
|
| - // Expected
|
| - }
|
| - }
|
| -
|
| - ClassDeclaration _createResolvedClassDeclaration() {
|
| - CompilationUnit unit = _createResolvedCompilationUnit();
|
| - String className = "C";
|
| - ClassDeclaration classNode = AstFactory.classDeclaration(
|
| - null,
|
| - className,
|
| - AstFactory.typeParameterList(),
|
| - null,
|
| - null,
|
| - null);
|
| - unit.declarations.add(classNode);
|
| - ClassElement classElement = ElementFactory.classElement2(className);
|
| - classNode.name.staticElement = classElement;
|
| - (unit.element as CompilationUnitElementImpl).types =
|
| - <ClassElement>[classElement];
|
| - return classNode;
|
| - }
|
| -
|
| - ClassTypeAlias _createResolvedClassTypeAlias() {
|
| - CompilationUnit unit = _createResolvedCompilationUnit();
|
| - String className = "C";
|
| - ClassTypeAlias classNode = AstFactory.classTypeAlias(
|
| - className,
|
| - AstFactory.typeParameterList(),
|
| - null,
|
| - null,
|
| - null,
|
| - null);
|
| - unit.declarations.add(classNode);
|
| - ClassElement classElement = ElementFactory.classElement2(className);
|
| - classNode.name.staticElement = classElement;
|
| - (unit.element as CompilationUnitElementImpl).types =
|
| - <ClassElement>[classElement];
|
| - return classNode;
|
| - }
|
| -
|
| - CompilationUnit _createResolvedCompilationUnit() {
|
| - CompilationUnit unit = AstFactory.compilationUnit();
|
| - LibraryElementImpl library =
|
| - ElementFactory.library(AnalysisContextFactory.contextWithCore(), "lib");
|
| - unit.element = library.definingCompilationUnit;
|
| - return unit;
|
| - }
|
| -
|
| - ConstructorDeclaration _createResolvedConstructorDeclaration() {
|
| - ClassDeclaration classNode = _createResolvedClassDeclaration();
|
| - String constructorName = "f";
|
| - ConstructorDeclaration constructorNode = AstFactory.constructorDeclaration(
|
| - AstFactory.identifier3(constructorName),
|
| - null,
|
| - AstFactory.formalParameterList(),
|
| - null);
|
| - classNode.members.add(constructorNode);
|
| - ConstructorElement constructorElement =
|
| - ElementFactory.constructorElement2(classNode.element, null);
|
| - constructorNode.element = constructorElement;
|
| - (classNode.element as ClassElementImpl).constructors =
|
| - <ConstructorElement>[constructorElement];
|
| - return constructorNode;
|
| - }
|
| -
|
| - FunctionDeclaration _createResolvedFunctionDeclaration() {
|
| - CompilationUnit unit = _createResolvedCompilationUnit();
|
| - String functionName = "f";
|
| - FunctionDeclaration functionNode = AstFactory.functionDeclaration(
|
| - null,
|
| - null,
|
| - functionName,
|
| - AstFactory.functionExpression());
|
| - unit.declarations.add(functionNode);
|
| - FunctionElement functionElement =
|
| - ElementFactory.functionElement(functionName);
|
| - functionNode.name.staticElement = functionElement;
|
| - (unit.element as CompilationUnitElementImpl).functions =
|
| - <FunctionElement>[functionElement];
|
| - return functionNode;
|
| - }
|
| -
|
| - FunctionTypeAlias _createResolvedFunctionTypeAlias() {
|
| - CompilationUnit unit = _createResolvedCompilationUnit();
|
| - FunctionTypeAlias aliasNode = AstFactory.typeAlias(
|
| - AstFactory.typeName4("A"),
|
| - "F",
|
| - AstFactory.typeParameterList(),
|
| - AstFactory.formalParameterList());
|
| - unit.declarations.add(aliasNode);
|
| - SimpleIdentifier aliasName = aliasNode.name;
|
| - FunctionTypeAliasElement aliasElement =
|
| - new FunctionTypeAliasElementImpl.forNode(aliasName);
|
| - aliasName.staticElement = aliasElement;
|
| - (unit.element as CompilationUnitElementImpl).typeAliases =
|
| - <FunctionTypeAliasElement>[aliasElement];
|
| - return aliasNode;
|
| - }
|
| -
|
| - MethodDeclaration _createResolvedMethodDeclaration() {
|
| - ClassDeclaration classNode = _createResolvedClassDeclaration();
|
| - String methodName = "f";
|
| - MethodDeclaration methodNode = AstFactory.methodDeclaration(
|
| - null,
|
| - null,
|
| - null,
|
| - null,
|
| - AstFactory.identifier3(methodName),
|
| - AstFactory.formalParameterList());
|
| - classNode.members.add(methodNode);
|
| - MethodElement methodElement =
|
| - ElementFactory.methodElement(methodName, null);
|
| - methodNode.name.staticElement = methodElement;
|
| - (classNode.element as ClassElementImpl).methods =
|
| - <MethodElement>[methodElement];
|
| - return methodNode;
|
| - }
|
| -}
|
| -
|
| class ScopeTest extends ResolverTestCase {
|
| void test_define_duplicate() {
|
| GatheringErrorListener errorListener = new GatheringErrorListener();
|
|
|