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

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

Issue 1149083007: Fix for DeclarationResolver. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years, 6 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 | « no previous file | 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; 5 library engine.resolver;
6 6
7 import 'dart:collection'; 7 import 'dart:collection';
8 import "dart:math" as math; 8 import "dart:math" as math;
9 9
10 import 'package:analyzer/src/generated/utilities_collection.dart'; 10 import 'package:analyzer/src/generated/utilities_collection.dart';
(...skipping 2046 matching lines...) Expand 10 before | Expand all | Expand 10 after
2057 return super.visitLibraryDirective(node); 2057 return super.visitLibraryDirective(node);
2058 } 2058 }
2059 2059
2060 @override 2060 @override
2061 Object visitMethodDeclaration(MethodDeclaration node) { 2061 Object visitMethodDeclaration(MethodDeclaration node) {
2062 ExecutableElement outerExecutable = _enclosingExecutable; 2062 ExecutableElement outerExecutable = _enclosingExecutable;
2063 try { 2063 try {
2064 sc.Token property = node.propertyKeyword; 2064 sc.Token property = node.propertyKeyword;
2065 SimpleIdentifier methodName = node.name; 2065 SimpleIdentifier methodName = node.name;
2066 String nameOfMethod = methodName.name; 2066 String nameOfMethod = methodName.name;
2067 if (nameOfMethod == sc.TokenType.MINUS.lexeme &&
2068 node.parameters.parameters.length == 0) {
2069 nameOfMethod = "unary-";
2070 }
2071 if (property == null) { 2067 if (property == null) {
2072 _enclosingExecutable = _findWithNameAndOffset( 2068 _enclosingExecutable = _findWithNameAndOffset(
2073 _enclosingClass.methods, nameOfMethod, methodName.offset); 2069 _enclosingClass.methods, nameOfMethod, methodName.offset);
2074 methodName.staticElement = _enclosingExecutable; 2070 methodName.staticElement = _enclosingExecutable;
2075 } else { 2071 } else {
2076 PropertyAccessorElement accessor = 2072 PropertyAccessorElement accessor =
2077 _findIdentifier(_enclosingClass.accessors, methodName); 2073 _findIdentifier(_enclosingClass.accessors, methodName);
2078 if ((property as sc.KeywordToken).keyword == sc.Keyword.SET) { 2074 if ((property as sc.KeywordToken).keyword == sc.Keyword.SET) {
2079 accessor = accessor.variable.setter; 2075 accessor = accessor.variable.setter;
2080 methodName.staticElement = accessor; 2076 methodName.staticElement = accessor;
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after
2277 * given name at the given offset. 2273 * given name at the given offset.
2278 * 2274 *
2279 * @param elements the elements of the appropriate kind that exist in the curr ent context 2275 * @param elements the elements of the appropriate kind that exist in the curr ent context
2280 * @param name the name of the element to be returned 2276 * @param name the name of the element to be returned
2281 * @param offset the offset of the name of the element to be returned 2277 * @param offset the offset of the name of the element to be returned
2282 * @return the element with the given name and offset 2278 * @return the element with the given name and offset
2283 */ 2279 */
2284 Element _findWithNameAndOffset( 2280 Element _findWithNameAndOffset(
2285 List<Element> elements, String name, int offset) { 2281 List<Element> elements, String name, int offset) {
2286 for (Element element in elements) { 2282 for (Element element in elements) {
2287 if (element.displayName == name && element.nameOffset == offset) { 2283 if (element.nameOffset == offset && element.displayName == name) {
2288 return element; 2284 return element;
2289 } 2285 }
2290 } 2286 }
2291 return null; 2287 return null;
2292 } 2288 }
2293 2289
2294 /** 2290 /**
2295 * Search the most closely enclosing list of parameters for a parameter with t he given name. 2291 * Search the most closely enclosing list of parameters for a parameter with t he given name.
2296 * 2292 *
2297 * @param node the node defining the parameter with the given name 2293 * @param node the node defining the parameter with the given name
(...skipping 13173 matching lines...) Expand 10 before | Expand all | Expand 10 after
15471 nonFields.add(node); 15467 nonFields.add(node);
15472 return null; 15468 return null;
15473 } 15469 }
15474 15470
15475 @override 15471 @override
15476 Object visitNode(AstNode node) => node.accept(TypeResolverVisitor_this); 15472 Object visitNode(AstNode node) => node.accept(TypeResolverVisitor_this);
15477 15473
15478 @override 15474 @override
15479 Object visitWithClause(WithClause node) => null; 15475 Object visitWithClause(WithClause node) => null;
15480 } 15476 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698