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 part of resolution; | 5 part of resolution; |
| 6 | 6 |
| 7 abstract class TreeElements { | 7 abstract class TreeElements { |
| 8 AnalyzableElement get analyzedElement; | 8 AnalyzableElement get analyzedElement; |
| 9 Iterable<Node> get superUses; | 9 Iterable<Node> get superUses; |
| 10 | 10 |
| (...skipping 2300 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2311 if (!inInstanceContext) { | 2311 if (!inInstanceContext) { |
| 2312 // We report an error within initializers because `this` is implicitly | 2312 // We report an error within initializers because `this` is implicitly |
| 2313 // accessed when unqualified identifiers are not resolved. For | 2313 // accessed when unqualified identifiers are not resolved. For |
| 2314 // details, see section 16.14.3 of the spec (2nd edition): | 2314 // details, see section 16.14.3 of the spec (2nd edition): |
| 2315 // An unqualified invocation `i` of the form `id(a1, ...)` | 2315 // An unqualified invocation `i` of the form `id(a1, ...)` |
| 2316 // ... | 2316 // ... |
| 2317 // If `i` does not occur inside a top level or static function, `i` | 2317 // If `i` does not occur inside a top level or static function, `i` |
| 2318 // is equivalent to `this.id(a1 , ...)`. | 2318 // is equivalent to `this.id(a1 , ...)`. |
| 2319 bool inInitializer = enclosingElement.isGenerativeConstructor || | 2319 bool inInitializer = enclosingElement.isGenerativeConstructor || |
| 2320 (enclosingElement.isInstanceMember && enclosingElement.isField); | 2320 (enclosingElement.isInstanceMember && enclosingElement.isField); |
| 2321 MessageKind kind = inInitializer | 2321 MessageKind kind; |
| 2322 ? MessageKind.CANNOT_RESOLVE_IN_INITIALIZER | 2322 Map arguments = {'name': name}; |
| 2323 : MessageKind.CANNOT_RESOLVE; | 2323 if (inInitializer) { |
| 2324 element = reportAndCreateErroneousElement(node, node.source, kind, | 2324 kind = MessageKind.CANNOT_RESOLVE_IN_INITIALIZER; |
| 2325 {'name': node.source}, isError: inInitializer); | 2325 } else if (name == 'await') { |
| 2326 kind = MessageKind.CANNOT_RESOLVE_AWAIT; | |
|
Johnni Winther
2015/04/17 18:01:31
Due to localization (if ever needed) we try not to
Siggi Cherem (dart-lang)
2015/04/17 20:58:51
Ah, I see. I went ahead and divided the message in
| |
| 2327 arguments['enclosingFunctionText'] = enclosingElement.name == '' | |
| 2328 ? 'the enclosing function' | |
| 2329 : "'${enclosingElement.name}'"; | |
| 2330 } else { | |
| 2331 kind = MessageKind.CANNOT_RESOLVE; | |
| 2332 } | |
| 2333 element = reportAndCreateErroneousElement(node, name, kind, | |
| 2334 arguments, isError: inInitializer); | |
| 2326 registry.registerThrowNoSuchMethod(); | 2335 registry.registerThrowNoSuchMethod(); |
| 2327 } | 2336 } |
| 2328 } else if (element.isErroneous) { | 2337 } else if (element.isErroneous) { |
| 2329 // Use the erroneous element. | 2338 // Use the erroneous element. |
| 2330 } else { | 2339 } else { |
| 2331 if ((element.kind.category & allowedCategory) == 0) { | 2340 if ((element.kind.category & allowedCategory) == 0) { |
| 2332 element = reportAndCreateErroneousElement( | 2341 element = reportAndCreateErroneousElement( |
| 2333 node, name, MessageKind.GENERIC, | 2342 node, name, MessageKind.GENERIC, |
| 2334 // TODO(ahe): Improve error message. Need UX input. | 2343 // TODO(ahe): Improve error message. Need UX input. |
| 2335 {'text': "is not an expression $element"}); | 2344 {'text': "is not an expression $element"}); |
| (...skipping 2789 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 5125 } | 5134 } |
| 5126 | 5135 |
| 5127 /// The result for the resolution of the `assert` method. | 5136 /// The result for the resolution of the `assert` method. |
| 5128 class AssertResult implements ResolutionResult { | 5137 class AssertResult implements ResolutionResult { |
| 5129 const AssertResult(); | 5138 const AssertResult(); |
| 5130 | 5139 |
| 5131 Element get element => null; | 5140 Element get element => null; |
| 5132 | 5141 |
| 5133 String toString() => 'AssertResult()'; | 5142 String toString() => 'AssertResult()'; |
| 5134 } | 5143 } |
| OLD | NEW |