Chromium Code Reviews| 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 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 115 // 1.dart and 2.dart: interface I default C { I(); } | 115 // 1.dart and 2.dart: interface I default C { I(); } |
| 116 // now we have to duplicate our I() constructor in C class with | 116 // now we have to duplicate our I() constructor in C class with |
| 117 // proper names. | 117 // proper names. |
| 118 // 2) (even worse for us): | 118 // 2) (even worse for us): |
| 119 // 0.dart: class C { C(); } | 119 // 0.dart: class C { C(); } |
| 120 // 1.dart: interface C default p0.C { C(); } | 120 // 1.dart: interface C default p0.C { C(); } |
| 121 // the second case is just a bug now. | 121 // the second case is just a bug now. |
| 122 final enclosingClass = element.getEnclosingClass(); | 122 final enclosingClass = element.getEnclosingClass(); |
| 123 Node nameNode = node.name; | 123 Node nameNode = node.name; |
| 124 if (nameNode is Send) nameNode = nameNode.receiver; | 124 if (nameNode is Send) nameNode = nameNode.receiver; |
| 125 // For cases like class C implements I { I(); } | 125 // Skip cases like class C implements I { I(); } |
| 126 if (nameNode.asIdentifier().token.slowToString() | 126 if (nameNode.asIdentifier().token.slowToString() |
|
Anton Muhin
2012/08/21 09:06:36
as you're touching this code anyway, maybe make it
Roman
2012/08/21 09:18:41
Done.
| |
| 127 == enclosingClass.name.slowToString()) { | 127 == enclosingClass.name.slowToString()) { |
| 128 makeTypePlaceholder(nameNode, enclosingClass.type); | 128 makeTypePlaceholder(nameNode, enclosingClass.type); |
| 129 } | 129 } |
| 130 | |
| 131 // If we have interface constructor, make sure that we put placeholder | |
| 132 // for its default factory implementation. | |
| 133 // Example: | |
| 134 // interface I { I();} | |
| 135 // class C { I() {} } | |
| 136 if (element.defaultImplementation !== null | |
| 137 && element.defaultImplementation !== element) { | |
| 138 FunctionElement implementingFactory = element.defaultImplementation; | |
| 139 Node factoryName = implementingFactory.cachedNode.name; | |
| 140 if (factoryName is Identifier) { | |
| 141 // Plain interface name. Rename it unless it is the default | |
| 142 // constructor for enclosing class. | |
| 143 // Example: | |
| 144 // interface I { I(); } | |
| 145 // class C implements I { C(); } don't rename this case. | |
| 146 if (factoryName.token | |
| 147 != implementingFactory.getEnclosingClass().name) { | |
| 148 makeElementPlaceholder(factoryName, enclosingClass); | |
| 149 } | |
| 150 } else { | |
| 151 // I.named() inside C, rename first part. | |
| 152 assert(factoryName is Send); | |
| 153 makeElementPlaceholder(factoryName.asSend().receiver, enclosingClass); | |
|
Anton Muhin
2012/08/21 09:06:36
it looks like you don't check here if you should r
Roman
2012/08/21 09:18:41
I don't understand your comment., what should I re
| |
| 154 } | |
| 155 } | |
| 156 | |
| 130 // Process Ctor(this._field) correctly. | 157 // Process Ctor(this._field) correctly. |
| 131 for (Node parameter in node.parameters) { | 158 for (Node parameter in node.parameters) { |
| 132 VariableDefinitions definitions = parameter.asVariableDefinitions(); | 159 VariableDefinitions definitions = parameter.asVariableDefinitions(); |
| 133 if (definitions !== null) { | 160 if (definitions !== null) { |
| 134 for (Node definition in definitions.definitions) { | 161 for (Node definition in definitions.definitions) { |
| 135 Send send = definition.asSend(); | 162 Send send = definition.asSend(); |
| 136 if (send !== null) { | 163 if (send !== null) { |
| 137 assert(send.receiver is Identifier); | 164 assert(send.receiver is Identifier); |
| 138 assert(send.receiver.asIdentifier().isThis()); | 165 assert(send.receiver.asIdentifier().isThis()); |
| 139 if (send.selector is Identifier) { | 166 if (send.selector is Identifier) { |
| (...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 423 visit(node.defaultClause.typeArguments); | 450 visit(node.defaultClause.typeArguments); |
| 424 } | 451 } |
| 425 } | 452 } |
| 426 | 453 |
| 427 visitTypedef(Typedef node) { | 454 visitTypedef(Typedef node) { |
| 428 assert(currentElement is TypedefElement); | 455 assert(currentElement is TypedefElement); |
| 429 makeElementPlaceholder(node.name, currentElement); | 456 makeElementPlaceholder(node.name, currentElement); |
| 430 node.visitChildren(this); | 457 node.visitChildren(this); |
| 431 } | 458 } |
| 432 } | 459 } |
| OLD | NEW |