| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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 class LocalPlaceholder implements Hashable { | 5 class LocalPlaceholder implements Hashable { |
| 6 final String identifier; | 6 final String identifier; |
| 7 final Set<Node> nodes; | 7 final Set<Node> nodes; |
| 8 LocalPlaceholder(this.identifier) : nodes = new Set<Node>(); | 8 LocalPlaceholder(this.identifier) : nodes = new Set<Node>(); |
| 9 int hashCode() => identifier.hashCode(); | 9 int hashCode() => identifier.hashCode(); |
| 10 String toString() => | 10 String toString() => |
| (...skipping 309 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 320 | 320 |
| 321 static bool isDynamicType(TypeAnnotation typeAnnotation) { | 321 static bool isDynamicType(TypeAnnotation typeAnnotation) { |
| 322 if (!isPlainTypeName(typeAnnotation)) return false; | 322 if (!isPlainTypeName(typeAnnotation)) return false; |
| 323 String name = typeAnnotation.typeName.asIdentifier().source.slowToString(); | 323 String name = typeAnnotation.typeName.asIdentifier().source.slowToString(); |
| 324 return name == 'Dynamic'; | 324 return name == 'Dynamic'; |
| 325 } | 325 } |
| 326 | 326 |
| 327 visitTypeAnnotation(TypeAnnotation node) { | 327 visitTypeAnnotation(TypeAnnotation node) { |
| 328 // Poor man generic variables resolution. | 328 // Poor man generic variables resolution. |
| 329 // TODO(antonm): get rid of it once resolver can deal with it. | 329 // TODO(antonm): get rid of it once resolver can deal with it. |
| 330 if (isPlainTypeName(node)) { | 330 if (isPlainTypeName(node) && currentElement is TypeDeclarationElement) { |
| 331 NodeList typeParameters = null; | 331 SourceString name = node.typeName.asIdentifier().source; |
| 332 if (currentElement is TypedefElement) { | 332 TypeDeclarationElement typeElement = currentElement; |
| 333 Typedef typedefNode = currentElement.parseNode(compiler); | 333 for (TypeVariableType parameter in typeElement.typeVariables) { |
| 334 typeParameters = typedefNode.typeParameters; | 334 if (parameter.name == name) { |
| 335 } | 335 // type annotation matches one of parameters, shouldn't be renamed. |
| 336 if (currentElement is ClassElement) { | 336 return; |
| 337 ClassNode classNode = currentElement.parseNode(compiler); | |
| 338 typeParameters = classNode.typeParameters; | |
| 339 } | |
| 340 if (typeParameters !== null) { | |
| 341 SourceString name = node.typeName.asIdentifier().source; | |
| 342 for (TypeVariable parameter in typeParameters) { | |
| 343 if (parameter.name.source == name) { | |
| 344 // type annotation matches one of parameters, shouldn't be renamed. | |
| 345 return; | |
| 346 } | |
| 347 } | 337 } |
| 348 } | 338 } |
| 349 } | 339 } |
| 350 final type = compiler.resolveTypeAnnotation(currentElement, node); | 340 final type = compiler.resolveTypeAnnotation(currentElement, node); |
| 351 if (type is InterfaceType || type is TypedefType) { | 341 if (type is InterfaceType || type is TypedefType) { |
| 352 var target = node.typeName; | 342 var target = node.typeName; |
| 353 if (node.typeName is Send) { | 343 if (node.typeName is Send) { |
| 354 final element = treeElements[node]; | 344 final element = treeElements[node]; |
| 355 if (element !== null) { | 345 if (element !== null) { |
| 356 final send = node.typeName.asSend(); | 346 final send = node.typeName.asSend(); |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 422 makeElementPlaceholder(node.name, currentElement); | 412 makeElementPlaceholder(node.name, currentElement); |
| 423 node.visitChildren(this); | 413 node.visitChildren(this); |
| 424 } | 414 } |
| 425 | 415 |
| 426 visitTypedef(Typedef node) { | 416 visitTypedef(Typedef node) { |
| 427 assert(currentElement is TypedefElement); | 417 assert(currentElement is TypedefElement); |
| 428 makeElementPlaceholder(node.name, currentElement); | 418 makeElementPlaceholder(node.name, currentElement); |
| 429 node.visitChildren(this); | 419 node.visitChildren(this); |
| 430 } | 420 } |
| 431 } | 421 } |
| OLD | NEW |