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

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

Issue 1042453003: Issue 22521. Drop '_J2DAccessor' suffixes. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 5 years, 8 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/analyzer/lib/task/dart.dart ('k') | no next file » | 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 library engine.resolver_test; 5 library engine.resolver_test;
6 6
7 import 'dart:collection'; 7 import 'dart:collection';
8 8
9 import 'package:analyzer/src/generated/ast.dart'; 9 import 'package:analyzer/src/generated/ast.dart';
10 import 'package:analyzer/src/generated/element.dart'; 10 import 'package:analyzer/src/generated/element.dart';
(...skipping 1839 matching lines...) Expand 10 before | Expand all | Expand 10 after
1850 new FileBasedSource.con1(FileUtilities2.createFile("/test.dart")); 1850 new FileBasedSource.con1(FileUtilities2.createFile("/test.dart"));
1851 CompilationUnitElementImpl definingCompilationUnit = 1851 CompilationUnitElementImpl definingCompilationUnit =
1852 new CompilationUnitElementImpl("test.dart"); 1852 new CompilationUnitElementImpl("test.dart");
1853 definingCompilationUnit.source = source; 1853 definingCompilationUnit.source = source;
1854 _definingLibrary = ElementFactory.library(context, "test"); 1854 _definingLibrary = ElementFactory.library(context, "test");
1855 _definingLibrary.definingCompilationUnit = definingCompilationUnit; 1855 _definingLibrary.definingCompilationUnit = definingCompilationUnit;
1856 Library library = new Library(context, _listener, source); 1856 Library library = new Library(context, _listener, source);
1857 library.libraryElement = _definingLibrary; 1857 library.libraryElement = _definingLibrary;
1858 _visitor = new ResolverVisitor.con1(library, source, _typeProvider); 1858 _visitor = new ResolverVisitor.con1(library, source, _typeProvider);
1859 try { 1859 try {
1860 return _visitor.elementResolver_J2DAccessor as ElementResolver; 1860 return _visitor.elementResolver;
1861 } catch (exception) { 1861 } catch (exception) {
1862 throw new IllegalArgumentException( 1862 throw new IllegalArgumentException(
1863 "Could not create resolver", exception); 1863 "Could not create resolver", exception);
1864 } 1864 }
1865 } 1865 }
1866 1866
1867 /** 1867 /**
1868 * Return the element associated with the label of [statement] after the 1868 * Return the element associated with the label of [statement] after the
1869 * resolver has resolved it. [labelElement] is the label element to be 1869 * resolver has resolved it. [labelElement] is the label element to be
1870 * defined in the statement's label scope, and [labelTarget] is the statement 1870 * defined in the statement's label scope, and [labelTarget] is the statement
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
1909 /** 1909 /**
1910 * Return the element associated with the given identifier after the resolver has resolved the 1910 * Return the element associated with the given identifier after the resolver has resolved the
1911 * identifier. 1911 * identifier.
1912 * 1912 *
1913 * @param node the expression to be resolved 1913 * @param node the expression to be resolved
1914 * @param enclosingClass the element representing the class enclosing the iden tifier 1914 * @param enclosingClass the element representing the class enclosing the iden tifier
1915 * @return the element to which the expression was resolved 1915 * @return the element to which the expression was resolved
1916 */ 1916 */
1917 void _resolveInClass(AstNode node, ClassElement enclosingClass) { 1917 void _resolveInClass(AstNode node, ClassElement enclosingClass) {
1918 try { 1918 try {
1919 Scope outerScope = _visitor.nameScope_J2DAccessor as Scope; 1919 Scope outerScope = _visitor.nameScope;
1920 try { 1920 try {
1921 _visitor.enclosingClass = enclosingClass; 1921 _visitor.enclosingClass = enclosingClass;
1922 EnclosedScope innerScope = new ClassScope( 1922 EnclosedScope innerScope = new ClassScope(
1923 new TypeParameterScope(outerScope, enclosingClass), enclosingClass); 1923 new TypeParameterScope(outerScope, enclosingClass), enclosingClass);
1924 _visitor.nameScope_J2DAccessor = innerScope; 1924 _visitor.nameScope = innerScope;
1925 node.accept(_resolver); 1925 node.accept(_resolver);
1926 } finally { 1926 } finally {
1927 _visitor.enclosingClass = null; 1927 _visitor.enclosingClass = null;
1928 _visitor.nameScope_J2DAccessor = outerScope; 1928 _visitor.nameScope = outerScope;
1929 } 1929 }
1930 } catch (exception) { 1930 } catch (exception) {
1931 throw new IllegalArgumentException("Could not resolve node", exception); 1931 throw new IllegalArgumentException("Could not resolve node", exception);
1932 } 1932 }
1933 } 1933 }
1934 1934
1935 /** 1935 /**
1936 * Return the element associated with the given expression after the resolver has resolved the 1936 * Return the element associated with the given expression after the resolver has resolved the
1937 * expression. 1937 * expression.
1938 * 1938 *
(...skipping 12 matching lines...) Expand all
1951 * Return the element associated with the given identifier after the resolver has resolved the 1951 * Return the element associated with the given identifier after the resolver has resolved the
1952 * identifier. 1952 * identifier.
1953 * 1953 *
1954 * @param node the expression to be resolved 1954 * @param node the expression to be resolved
1955 * @param definedElements the elements that are to be defined in the scope in which the element is 1955 * @param definedElements the elements that are to be defined in the scope in which the element is
1956 * being resolved 1956 * being resolved
1957 * @return the element to which the expression was resolved 1957 * @return the element to which the expression was resolved
1958 */ 1958 */
1959 void _resolveNode(AstNode node, [List<Element> definedElements]) { 1959 void _resolveNode(AstNode node, [List<Element> definedElements]) {
1960 try { 1960 try {
1961 Scope outerScope = _visitor.nameScope_J2DAccessor as Scope; 1961 Scope outerScope = _visitor.nameScope;
1962 try { 1962 try {
1963 EnclosedScope innerScope = new EnclosedScope(outerScope); 1963 EnclosedScope innerScope = new EnclosedScope(outerScope);
1964 if (definedElements != null) { 1964 if (definedElements != null) {
1965 for (Element element in definedElements) { 1965 for (Element element in definedElements) {
1966 innerScope.define(element); 1966 innerScope.define(element);
1967 } 1967 }
1968 } 1968 }
1969 _visitor.nameScope_J2DAccessor = innerScope; 1969 _visitor.nameScope = innerScope;
1970 node.accept(_resolver); 1970 node.accept(_resolver);
1971 } finally { 1971 } finally {
1972 _visitor.nameScope_J2DAccessor = outerScope; 1972 _visitor.nameScope = outerScope;
1973 } 1973 }
1974 } catch (exception) { 1974 } catch (exception) {
1975 throw new IllegalArgumentException("Could not resolve node", exception); 1975 throw new IllegalArgumentException("Could not resolve node", exception);
1976 } 1976 }
1977 } 1977 }
1978 1978
1979 /** 1979 /**
1980 * Return the element associated with the label of the given statement after t he resolver has 1980 * Return the element associated with the label of the given statement after t he resolver has
1981 * resolved the statement. 1981 * resolved the statement.
1982 * 1982 *
1983 * @param statement the statement to be resolved 1983 * @param statement the statement to be resolved
1984 * @param labelElement the label element to be defined in the statement's labe l scope 1984 * @param labelElement the label element to be defined in the statement's labe l scope
1985 * @return the element to which the statement's label was resolved 1985 * @return the element to which the statement's label was resolved
1986 */ 1986 */
1987 void _resolveStatement( 1987 void _resolveStatement(
1988 Statement statement, LabelElementImpl labelElement, AstNode labelTarget) { 1988 Statement statement, LabelElementImpl labelElement, AstNode labelTarget) {
1989 try { 1989 try {
1990 LabelScope outerScope = _visitor.labelScope_J2DAccessor as LabelScope; 1990 LabelScope outerScope = _visitor.labelScope;
1991 try { 1991 try {
1992 LabelScope innerScope; 1992 LabelScope innerScope;
1993 if (labelElement == null) { 1993 if (labelElement == null) {
1994 innerScope = outerScope; 1994 innerScope = outerScope;
1995 } else { 1995 } else {
1996 innerScope = new LabelScope( 1996 innerScope = new LabelScope(
1997 outerScope, labelElement.name, labelTarget, labelElement); 1997 outerScope, labelElement.name, labelTarget, labelElement);
1998 } 1998 }
1999 _visitor.labelScope_J2DAccessor = innerScope; 1999 _visitor.labelScope = innerScope;
2000 statement.accept(_resolver); 2000 statement.accept(_resolver);
2001 } finally { 2001 } finally {
2002 _visitor.labelScope_J2DAccessor = outerScope; 2002 _visitor.labelScope = outerScope;
2003 } 2003 }
2004 } catch (exception) { 2004 } catch (exception) {
2005 throw new IllegalArgumentException("Could not resolve node", exception); 2005 throw new IllegalArgumentException("Could not resolve node", exception);
2006 } 2006 }
2007 } 2007 }
2008 } 2008 }
2009 2009
2010 @reflectiveTest 2010 @reflectiveTest
2011 class EnclosedScopeTest extends ResolverTestCase { 2011 class EnclosedScopeTest extends ResolverTestCase {
2012 void test_define_duplicate() { 2012 void test_define_duplicate() {
(...skipping 8895 matching lines...) Expand 10 before | Expand all | Expand 10 after
10908 new CompilationUnitElementImpl("lib.dart"); 10908 new CompilationUnitElementImpl("lib.dart");
10909 definingCompilationUnit.source = source; 10909 definingCompilationUnit.source = source;
10910 LibraryElementImpl definingLibrary = 10910 LibraryElementImpl definingLibrary =
10911 new LibraryElementImpl.forNode(context, null); 10911 new LibraryElementImpl.forNode(context, null);
10912 definingLibrary.definingCompilationUnit = definingCompilationUnit; 10912 definingLibrary.definingCompilationUnit = definingCompilationUnit;
10913 Library library = new Library(context, _listener, source); 10913 Library library = new Library(context, _listener, source);
10914 library.libraryElement = definingLibrary; 10914 library.libraryElement = definingLibrary;
10915 _visitor = new ResolverVisitor.con1(library, source, _typeProvider); 10915 _visitor = new ResolverVisitor.con1(library, source, _typeProvider);
10916 _visitor.overrideManager.enterScope(); 10916 _visitor.overrideManager.enterScope();
10917 try { 10917 try {
10918 return _visitor.typeAnalyzer_J2DAccessor as StaticTypeAnalyzer; 10918 return _visitor.typeAnalyzer;
10919 } catch (exception) { 10919 } catch (exception) {
10920 throw new IllegalArgumentException( 10920 throw new IllegalArgumentException(
10921 "Could not create analyzer", exception); 10921 "Could not create analyzer", exception);
10922 } 10922 }
10923 } 10923 }
10924 10924
10925 DartType _flatten(DartType type) => 10925 DartType _flatten(DartType type) =>
10926 StaticTypeAnalyzer.flattenFutures(_typeProvider, type); 10926 StaticTypeAnalyzer.flattenFutures(_typeProvider, type);
10927 10927
10928 /** 10928 /**
(...skipping 2759 matching lines...) Expand 10 before | Expand all | Expand 10 after
13688 // check propagated type 13688 // check propagated type
13689 FunctionType propagatedType = node.propagatedType as FunctionType; 13689 FunctionType propagatedType = node.propagatedType as FunctionType;
13690 expect(propagatedType.returnType, test.typeProvider.stringType); 13690 expect(propagatedType.returnType, test.typeProvider.stringType);
13691 } on AnalysisException catch (e, stackTrace) { 13691 } on AnalysisException catch (e, stackTrace) {
13692 thrownException[0] = new CaughtException(e, stackTrace); 13692 thrownException[0] = new CaughtException(e, stackTrace);
13693 } 13693 }
13694 } 13694 }
13695 return null; 13695 return null;
13696 } 13696 }
13697 } 13697 }
OLDNEW
« no previous file with comments | « pkg/analyzer/lib/task/dart.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698