| 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 2215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2226 | 2226 |
| 2227 visitInStaticContext(Node node) { | 2227 visitInStaticContext(Node node) { |
| 2228 inStaticContext(() => visit(node)); | 2228 inStaticContext(() => visit(node)); |
| 2229 } | 2229 } |
| 2230 | 2230 |
| 2231 ErroneousElement warnAndCreateErroneousElement(Node node, | 2231 ErroneousElement warnAndCreateErroneousElement(Node node, |
| 2232 String name, | 2232 String name, |
| 2233 MessageKind kind, | 2233 MessageKind kind, |
| 2234 [Map arguments = const {}]) { | 2234 [Map arguments = const {}]) { |
| 2235 compiler.reportWarning(node, kind, arguments); | 2235 compiler.reportWarning(node, kind, arguments); |
| 2236 // TODO(ahe): Use [allowedCategory] to synthesize a more precise subclass |
| 2237 // of [ErroneousElementX]. For example, [ErroneousFieldElementX], |
| 2238 // [ErroneousConstructorElementX], etc. |
| 2236 return new ErroneousElementX(kind, arguments, name, enclosingElement); | 2239 return new ErroneousElementX(kind, arguments, name, enclosingElement); |
| 2237 } | 2240 } |
| 2238 | 2241 |
| 2239 ResolutionResult visitIdentifier(Identifier node) { | 2242 ResolutionResult visitIdentifier(Identifier node) { |
| 2240 if (node.isThis()) { | 2243 if (node.isThis()) { |
| 2241 if (!inInstanceContext) { | 2244 if (!inInstanceContext) { |
| 2242 error(node, MessageKind.NO_INSTANCE_AVAILABLE, {'name': node}); | 2245 error(node, MessageKind.NO_INSTANCE_AVAILABLE, {'name': node}); |
| 2243 } | 2246 } |
| 2244 return null; | 2247 return null; |
| 2245 } else if (node.isSuper()) { | 2248 } else if (node.isSuper()) { |
| (...skipping 2669 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4915 // TODO(johnniwinther): Change errors to warnings, cf. 11.11.1. | 4918 // TODO(johnniwinther): Change errors to warnings, cf. 11.11.1. |
| 4916 if (element == null) { | 4919 if (element == null) { |
| 4917 return failOrReturnErroneousElement(resolver.enclosingElement, node, name, | 4920 return failOrReturnErroneousElement(resolver.enclosingElement, node, name, |
| 4918 MessageKind.CANNOT_RESOLVE, | 4921 MessageKind.CANNOT_RESOLVE, |
| 4919 {'name': name}); | 4922 {'name': name}); |
| 4920 } else if (element.isErroneous) { | 4923 } else if (element.isErroneous) { |
| 4921 return element; | 4924 return element; |
| 4922 } else if (element.isTypedef) { | 4925 } else if (element.isTypedef) { |
| 4923 error(node, MessageKind.CANNOT_INSTANTIATE_TYPEDEF, | 4926 error(node, MessageKind.CANNOT_INSTANTIATE_TYPEDEF, |
| 4924 {'typedefName': name}); | 4927 {'typedefName': name}); |
| 4925 element = new ErroneousElementX( | 4928 element = new ErroneousConstructorElementX( |
| 4926 MessageKind.CANNOT_INSTANTIATE_TYPEDEF, | 4929 MessageKind.CANNOT_INSTANTIATE_TYPEDEF, |
| 4927 {'typedefName': name}, name, resolver.enclosingElement); | 4930 {'typedefName': name}, name, resolver.enclosingElement); |
| 4928 } else if (element.isTypeVariable) { | 4931 } else if (element.isTypeVariable) { |
| 4929 error(node, MessageKind.CANNOT_INSTANTIATE_TYPE_VARIABLE, | 4932 error(node, MessageKind.CANNOT_INSTANTIATE_TYPE_VARIABLE, |
| 4930 {'typeVariableName': name}); | 4933 {'typeVariableName': name}); |
| 4931 element = new ErroneousElementX( | 4934 element = new ErroneousConstructorElementX( |
| 4932 MessageKind.CANNOT_INSTANTIATE_TYPE_VARIABLE, | 4935 MessageKind.CANNOT_INSTANTIATE_TYPE_VARIABLE, |
| 4933 {'typeVariableName': name}, name, resolver.enclosingElement); | 4936 {'typeVariableName': name}, name, resolver.enclosingElement); |
| 4934 } else if (!element.isClass && !element.isPrefix) { | 4937 } else if (!element.isClass && !element.isPrefix) { |
| 4935 error(node, MessageKind.NOT_A_TYPE, {'node': name}); | 4938 error(node, MessageKind.NOT_A_TYPE, {'node': name}); |
| 4936 element = new ErroneousElementX( | 4939 element = new ErroneousConstructorElementX( |
| 4937 MessageKind.NOT_A_TYPE, {'node': name}, name, | 4940 MessageKind.NOT_A_TYPE, {'node': name}, name, |
| 4938 resolver.enclosingElement); | 4941 resolver.enclosingElement); |
| 4939 } | 4942 } |
| 4940 return element; | 4943 return element; |
| 4941 } | 4944 } |
| 4942 | 4945 |
| 4943 /// Assumed to be called by [resolveRedirectingFactory]. | 4946 /// Assumed to be called by [resolveRedirectingFactory]. |
| 4944 Element visitRedirectingFactoryBody(RedirectingFactoryBody node) { | 4947 Element visitRedirectingFactoryBody(RedirectingFactoryBody node) { |
| 4945 Node constructorReference = node.constructorReference; | 4948 Node constructorReference = node.constructorReference; |
| 4946 return finishConstructorReference(visit(constructorReference), | 4949 return finishConstructorReference(visit(constructorReference), |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5011 } | 5014 } |
| 5012 | 5015 |
| 5013 /// The result for the resolution of the `assert` method. | 5016 /// The result for the resolution of the `assert` method. |
| 5014 class AssertResult implements ResolutionResult { | 5017 class AssertResult implements ResolutionResult { |
| 5015 const AssertResult(); | 5018 const AssertResult(); |
| 5016 | 5019 |
| 5017 Element get element => null; | 5020 Element get element => null; |
| 5018 | 5021 |
| 5019 String toString() => 'AssertResult()'; | 5022 String toString() => 'AssertResult()'; |
| 5020 } | 5023 } |
| OLD | NEW |