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

Side by Side Diff: pkg/analyzer/lib/src/generated/resolver.dart

Issue 1265453005: Code clean-up, mostly constructors (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Created 5 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
« no previous file with comments | « pkg/analyzer/lib/src/generated/html.dart ('k') | pkg/analyzer/lib/src/generated/scanner.dart » ('j') | 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; 5 library engine.resolver;
6 6
7 import 'dart:collection'; 7 import 'dart:collection';
8 8
9 import 'ast.dart'; 9 import 'ast.dart';
10 import 'constant.dart'; 10 import 'constant.dart';
(...skipping 4740 matching lines...) Expand 10 before | Expand all | Expand 10 after
4751 /** 4751 /**
4752 * Initialize a newly created information holder to hold the given information about the tags in 4752 * Initialize a newly created information holder to hold the given information about the tags in
4753 * an HTML file. 4753 * an HTML file.
4754 * 4754 *
4755 * @param allTags an array containing all of the tags used in the HTML file 4755 * @param allTags an array containing all of the tags used in the HTML file
4756 * @param idToTagMap a table mapping the id's defined in the HTML file to an a rray containing the 4756 * @param idToTagMap a table mapping the id's defined in the HTML file to an a rray containing the
4757 * names of tags with that identifier 4757 * names of tags with that identifier
4758 * @param classToTagsMap a table mapping the classes defined in the HTML file to an array 4758 * @param classToTagsMap a table mapping the classes defined in the HTML file to an array
4759 * containing the names of tags with that class 4759 * containing the names of tags with that class
4760 */ 4760 */
4761 HtmlTagInfo(List<String> allTags, HashMap<String, String> idToTagMap, 4761 HtmlTagInfo(this.allTags, this.idToTagMap, this.classToTagsMap);
4762 HashMap<String, List<String>> classToTagsMap) {
4763 this.allTags = allTags;
4764 this.idToTagMap = idToTagMap;
4765 this.classToTagsMap = classToTagsMap;
4766 }
4767 4762
4768 /** 4763 /**
4769 * Return an array containing the tags that have the given class, or {@code nu ll} if there are no 4764 * Return an array containing the tags that have the given class, or {@code nu ll} if there are no
4770 * such tags. 4765 * such tags.
4771 * 4766 *
4772 * @return an array containing the tags that have the given class 4767 * @return an array containing the tags that have the given class
4773 */ 4768 */
4774 List<String> getTagsWithClass(String identifier) { 4769 List<String> getTagsWithClass(String identifier) {
4775 return classToTagsMap[identifier]; 4770 return classToTagsMap[identifier];
4776 } 4771 }
(...skipping 6366 matching lines...) Expand 10 before | Expand all | Expand 10 after
11143 } 11138 }
11144 FunctionExpression closure = mayBeClosure as FunctionExpression; 11139 FunctionExpression closure = mayBeClosure as FunctionExpression;
11145 // prepare expected closure type 11140 // prepare expected closure type
11146 if (mayByFunctionType is! FunctionType) { 11141 if (mayByFunctionType is! FunctionType) {
11147 return; 11142 return;
11148 } 11143 }
11149 FunctionType expectedClosureType = mayByFunctionType as FunctionType; 11144 FunctionType expectedClosureType = mayByFunctionType as FunctionType;
11150 // If the expectedClosureType is not more specific than the static type, 11145 // If the expectedClosureType is not more specific than the static type,
11151 // return. 11146 // return.
11152 DartType staticClosureType = 11147 DartType staticClosureType =
11153 (closure.element != null ? closure.element.type : null) as DartType; 11148 closure.element != null ? closure.element.type : null;
11154 if (staticClosureType != null && 11149 if (staticClosureType != null &&
11155 !expectedClosureType.isMoreSpecificThan(staticClosureType)) { 11150 !expectedClosureType.isMoreSpecificThan(staticClosureType)) {
11156 return; 11151 return;
11157 } 11152 }
11158 // set propagated type for the closure 11153 // set propagated type for the closure
11159 closure.propagatedType = expectedClosureType; 11154 closure.propagatedType = expectedClosureType;
11160 // set inferred types for parameters 11155 // set inferred types for parameters
11161 NodeList<FormalParameter> parameters = closure.parameters.parameters; 11156 NodeList<FormalParameter> parameters = closure.parameters.parameters;
11162 List<ParameterElement> expectedParameters = expectedClosureType.parameters; 11157 List<ParameterElement> expectedParameters = expectedClosureType.parameters;
11163 for (int i = 0; 11158 for (int i = 0;
(...skipping 469 matching lines...) Expand 10 before | Expand all | Expand 10 after
11633 } 11628 }
11634 11629
11635 /** 11630 /**
11636 * The abstract class `ScopedVisitor` maintains name and label scopes as an AST structure is 11631 * The abstract class `ScopedVisitor` maintains name and label scopes as an AST structure is
11637 * being visited. 11632 * being visited.
11638 */ 11633 */
11639 abstract class ScopedVisitor extends UnifyingAstVisitor<Object> { 11634 abstract class ScopedVisitor extends UnifyingAstVisitor<Object> {
11640 /** 11635 /**
11641 * The element for the library containing the compilation unit being visited. 11636 * The element for the library containing the compilation unit being visited.
11642 */ 11637 */
11643 LibraryElement _definingLibrary; 11638 final LibraryElement definingLibrary;
11644 11639
11645 /** 11640 /**
11646 * The source representing the compilation unit being visited. 11641 * The source representing the compilation unit being visited.
11647 */ 11642 */
11648 final Source source; 11643 final Source source;
11649 11644
11650 /** 11645 /**
11651 * The error listener that will be informed of any errors that are found durin g resolution. 11646 * The error listener that will be informed of any errors that are found durin g resolution.
11652 */ 11647 */
11653 AnalysisErrorListener _errorListener; 11648 final AnalysisErrorListener errorListener;
11654 11649
11655 /** 11650 /**
11656 * The scope used to resolve identifiers. 11651 * The scope used to resolve identifiers.
11657 */ 11652 */
11658 Scope nameScope; 11653 Scope nameScope;
11659 11654
11660 /** 11655 /**
11661 * The object used to access the types from the core library. 11656 * The object used to access the types from the core library.
11662 */ 11657 */
11663 final TypeProvider typeProvider; 11658 final TypeProvider typeProvider;
(...skipping 23 matching lines...) Expand all
11687 * compilation unit being visited. 11682 * compilation unit being visited.
11688 * [source] is the source representing the compilation unit being visited. 11683 * [source] is the source representing the compilation unit being visited.
11689 * [typeProvider] is the object used to access the types from the core 11684 * [typeProvider] is the object used to access the types from the core
11690 * library. 11685 * library.
11691 * [errorListener] is the error listener that will be informed of any errors 11686 * [errorListener] is the error listener that will be informed of any errors
11692 * that are found during resolution. 11687 * that are found during resolution.
11693 * [nameScope] is the scope used to resolve identifiers in the node that will 11688 * [nameScope] is the scope used to resolve identifiers in the node that will
11694 * first be visited. If `null` or unspecified, a new [LibraryScope] will be 11689 * first be visited. If `null` or unspecified, a new [LibraryScope] will be
11695 * created based on [definingLibrary] and [typeProvider]. 11690 * created based on [definingLibrary] and [typeProvider].
11696 */ 11691 */
11697 ScopedVisitor(LibraryElement definingLibrary, this.source, this.typeProvider, 11692 ScopedVisitor(
11698 AnalysisErrorListener errorListener, {Scope nameScope}) { 11693 this.definingLibrary, this.source, this.typeProvider, this.errorListener,
11699 this._definingLibrary = definingLibrary; 11694 {Scope nameScope}) {
11700 this._errorListener = errorListener;
11701 if (nameScope == null) { 11695 if (nameScope == null) {
11702 this.nameScope = new LibraryScope(definingLibrary, errorListener); 11696 this.nameScope = new LibraryScope(definingLibrary, errorListener);
11703 } else { 11697 } else {
11704 this.nameScope = nameScope; 11698 this.nameScope = nameScope;
11705 } 11699 }
11706 } 11700 }
11707 11701
11708 /** 11702 /**
11709 * Return the library element for the library containing the compilation unit being resolved.
11710 *
11711 * @return the library element for the library containing the compilation unit being resolved
11712 */
11713 LibraryElement get definingLibrary => _definingLibrary;
11714
11715 /**
11716 * Return the implicit label scope in which the current node is being 11703 * Return the implicit label scope in which the current node is being
11717 * resolved. 11704 * resolved.
11718 */ 11705 */
11719 ImplicitLabelScope get implicitLabelScope => _implicitLabelScope; 11706 ImplicitLabelScope get implicitLabelScope => _implicitLabelScope;
11720 11707
11721 /** 11708 /**
11722 * Replaces the current [Scope] with the enclosing [Scope]. 11709 * Replaces the current [Scope] with the enclosing [Scope].
11723 * 11710 *
11724 * @return the enclosing [Scope]. 11711 * @return the enclosing [Scope].
11725 */ 11712 */
(...skipping 15 matching lines...) Expand all
11741 11728
11742 /** 11729 /**
11743 * Report an error with the given error code and arguments. 11730 * Report an error with the given error code and arguments.
11744 * 11731 *
11745 * @param errorCode the error code of the error to be reported 11732 * @param errorCode the error code of the error to be reported
11746 * @param node the node specifying the location of the error 11733 * @param node the node specifying the location of the error
11747 * @param arguments the arguments to the error, used to compose the error mess age 11734 * @param arguments the arguments to the error, used to compose the error mess age
11748 */ 11735 */
11749 void reportErrorForNode(ErrorCode errorCode, AstNode node, 11736 void reportErrorForNode(ErrorCode errorCode, AstNode node,
11750 [List<Object> arguments]) { 11737 [List<Object> arguments]) {
11751 _errorListener.onError(new AnalysisError( 11738 errorListener.onError(new AnalysisError(
11752 source, node.offset, node.length, errorCode, arguments)); 11739 source, node.offset, node.length, errorCode, arguments));
11753 } 11740 }
11754 11741
11755 /** 11742 /**
11756 * Report an error with the given error code and arguments. 11743 * Report an error with the given error code and arguments.
11757 * 11744 *
11758 * @param errorCode the error code of the error to be reported 11745 * @param errorCode the error code of the error to be reported
11759 * @param offset the offset of the location of the error 11746 * @param offset the offset of the location of the error
11760 * @param length the length of the location of the error 11747 * @param length the length of the location of the error
11761 * @param arguments the arguments to the error, used to compose the error mess age 11748 * @param arguments the arguments to the error, used to compose the error mess age
11762 */ 11749 */
11763 void reportErrorForOffset(ErrorCode errorCode, int offset, int length, 11750 void reportErrorForOffset(ErrorCode errorCode, int offset, int length,
11764 [List<Object> arguments]) { 11751 [List<Object> arguments]) {
11765 _errorListener.onError( 11752 errorListener.onError(
11766 new AnalysisError(source, offset, length, errorCode, arguments)); 11753 new AnalysisError(source, offset, length, errorCode, arguments));
11767 } 11754 }
11768 11755
11769 /** 11756 /**
11770 * Report an error with the given error code and arguments. 11757 * Report an error with the given error code and arguments.
11771 * 11758 *
11772 * @param errorCode the error code of the error to be reported 11759 * @param errorCode the error code of the error to be reported
11773 * @param token the token specifying the location of the error 11760 * @param token the token specifying the location of the error
11774 * @param arguments the arguments to the error, used to compose the error mess age 11761 * @param arguments the arguments to the error, used to compose the error mess age
11775 */ 11762 */
11776 void reportErrorForToken(ErrorCode errorCode, sc.Token token, 11763 void reportErrorForToken(ErrorCode errorCode, sc.Token token,
11777 [List<Object> arguments]) { 11764 [List<Object> arguments]) {
11778 _errorListener.onError(new AnalysisError( 11765 errorListener.onError(new AnalysisError(
11779 source, token.offset, token.length, errorCode, arguments)); 11766 source, token.offset, token.length, errorCode, arguments));
11780 } 11767 }
11781 11768
11782 /** 11769 /**
11783 * Visit the given AST node if it is not null. 11770 * Visit the given AST node if it is not null.
11784 * 11771 *
11785 * @param node the node to be visited 11772 * @param node the node to be visited
11786 */ 11773 */
11787 void safelyVisit(AstNode node) { 11774 void safelyVisit(AstNode node) {
11788 if (node != null) { 11775 if (node != null) {
(...skipping 3398 matching lines...) Expand 10 before | Expand all | Expand 10 after
15187 nonFields.add(node); 15174 nonFields.add(node);
15188 return null; 15175 return null;
15189 } 15176 }
15190 15177
15191 @override 15178 @override
15192 Object visitNode(AstNode node) => node.accept(TypeResolverVisitor_this); 15179 Object visitNode(AstNode node) => node.accept(TypeResolverVisitor_this);
15193 15180
15194 @override 15181 @override
15195 Object visitWithClause(WithClause node) => null; 15182 Object visitWithClause(WithClause node) => null;
15196 } 15183 }
OLDNEW
« no previous file with comments | « pkg/analyzer/lib/src/generated/html.dart ('k') | pkg/analyzer/lib/src/generated/scanner.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698