| OLD | NEW |
| 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 | 8 |
| 9 import 'ast.dart'; | 9 import 'ast.dart'; |
| 10 import 'constant.dart'; | 10 import 'constant.dart'; |
| (...skipping 9243 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9254 * @param definedNames the mapping from names that are defined in this namespa
ce to the | 9254 * @param definedNames the mapping from names that are defined in this namespa
ce to the |
| 9255 * corresponding elements | 9255 * corresponding elements |
| 9256 */ | 9256 */ |
| 9257 Namespace(this._definedNames); | 9257 Namespace(this._definedNames); |
| 9258 | 9258 |
| 9259 /** | 9259 /** |
| 9260 * Return a table containing the same mappings as those defined by this namesp
ace. | 9260 * Return a table containing the same mappings as those defined by this namesp
ace. |
| 9261 * | 9261 * |
| 9262 * @return a table containing the same mappings as those defined by this names
pace | 9262 * @return a table containing the same mappings as those defined by this names
pace |
| 9263 */ | 9263 */ |
| 9264 Map<String, Element> get definedNames => | 9264 Map<String, Element> get definedNames => _definedNames; |
| 9265 new HashMap<String, Element>.from(_definedNames); | |
| 9266 | 9265 |
| 9267 /** | 9266 /** |
| 9268 * Return the element in this namespace that is available to the containing sc
ope using the given | 9267 * Return the element in this namespace that is available to the containing sc
ope using the given |
| 9269 * name. | 9268 * name. |
| 9270 * | 9269 * |
| 9271 * @param name the name used to reference the | 9270 * @param name the name used to reference the |
| 9272 * @return the element represented by the given identifier | 9271 * @return the element represented by the given identifier |
| 9273 */ | 9272 */ |
| 9274 Element get(String name) => _definedNames[name]; | 9273 Element get(String name) => _definedNames[name]; |
| 9275 } | 9274 } |
| (...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9405 * Apply the given combinators to all of the names in the given mapping table. | 9404 * Apply the given combinators to all of the names in the given mapping table. |
| 9406 * | 9405 * |
| 9407 * @param definedNames the mapping table to which the namespace operations are
to be applied | 9406 * @param definedNames the mapping table to which the namespace operations are
to be applied |
| 9408 * @param combinators the combinators to be applied | 9407 * @param combinators the combinators to be applied |
| 9409 */ | 9408 */ |
| 9410 HashMap<String, Element> _applyCombinators( | 9409 HashMap<String, Element> _applyCombinators( |
| 9411 HashMap<String, Element> definedNames, | 9410 HashMap<String, Element> definedNames, |
| 9412 List<NamespaceCombinator> combinators) { | 9411 List<NamespaceCombinator> combinators) { |
| 9413 for (NamespaceCombinator combinator in combinators) { | 9412 for (NamespaceCombinator combinator in combinators) { |
| 9414 if (combinator is HideElementCombinator) { | 9413 if (combinator is HideElementCombinator) { |
| 9415 _hide(definedNames, combinator.hiddenNames); | 9414 definedNames = _hide(definedNames, combinator.hiddenNames); |
| 9416 } else if (combinator is ShowElementCombinator) { | 9415 } else if (combinator is ShowElementCombinator) { |
| 9417 definedNames = _show(definedNames, combinator.shownNames); | 9416 definedNames = _show(definedNames, combinator.shownNames); |
| 9418 } else { | 9417 } else { |
| 9419 // Internal error. | 9418 // Internal error. |
| 9420 AnalysisEngine.instance.logger | 9419 AnalysisEngine.instance.logger |
| 9421 .logError("Unknown type of combinator: ${combinator.runtimeType}"); | 9420 .logError("Unknown type of combinator: ${combinator.runtimeType}"); |
| 9422 } | 9421 } |
| 9423 } | 9422 } |
| 9424 return definedNames; | 9423 return definedNames; |
| 9425 } | 9424 } |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9484 definedNames, | 9483 definedNames, |
| 9485 (library.context as InternalAnalysisContext) | 9484 (library.context as InternalAnalysisContext) |
| 9486 .getPublicNamespace(library)); | 9485 .getPublicNamespace(library)); |
| 9487 return definedNames; | 9486 return definedNames; |
| 9488 } finally { | 9487 } finally { |
| 9489 visitedElements.remove(library); | 9488 visitedElements.remove(library); |
| 9490 } | 9489 } |
| 9491 } | 9490 } |
| 9492 | 9491 |
| 9493 /** | 9492 /** |
| 9494 * Hide all of the given names by removing them from the given collection of d
efined names. | 9493 * Return a new map of names which has all the names from [definedNames] |
| 9495 * | 9494 * with exception of [hiddenNames]. |
| 9496 * @param definedNames the names that were defined before this operation | |
| 9497 * @param hiddenNames the names to be hidden | |
| 9498 */ | 9495 */ |
| 9499 void _hide(HashMap<String, Element> definedNames, List<String> hiddenNames) { | 9496 Map<String, Element> _hide( |
| 9497 HashMap<String, Element> definedNames, List<String> hiddenNames) { |
| 9498 HashMap<String, Element> newNames = |
| 9499 new HashMap<String, Element>.from(definedNames); |
| 9500 for (String name in hiddenNames) { | 9500 for (String name in hiddenNames) { |
| 9501 definedNames.remove(name); | 9501 newNames.remove(name); |
| 9502 definedNames.remove("$name="); | 9502 newNames.remove("$name="); |
| 9503 } | 9503 } |
| 9504 return newNames; |
| 9504 } | 9505 } |
| 9505 | 9506 |
| 9506 /** | 9507 /** |
| 9507 * Show only the given names by removing all other names from the given collec
tion of defined | 9508 * Return a new map of names which has only [shownNames] from [definedNames]. |
| 9508 * names. | |
| 9509 * | |
| 9510 * @param definedNames the names that were defined before this operation | |
| 9511 * @param shownNames the names to be shown | |
| 9512 */ | 9509 */ |
| 9513 HashMap<String, Element> _show( | 9510 HashMap<String, Element> _show( |
| 9514 HashMap<String, Element> definedNames, List<String> shownNames) { | 9511 HashMap<String, Element> definedNames, List<String> shownNames) { |
| 9515 HashMap<String, Element> newNames = new HashMap<String, Element>(); | 9512 HashMap<String, Element> newNames = new HashMap<String, Element>(); |
| 9516 for (String name in shownNames) { | 9513 for (String name in shownNames) { |
| 9517 Element element = definedNames[name]; | 9514 Element element = definedNames[name]; |
| 9518 if (element != null) { | 9515 if (element != null) { |
| 9519 newNames[name] = element; | 9516 newNames[name] = element; |
| 9520 } | 9517 } |
| 9521 String setterName = "$name="; | 9518 String setterName = "$name="; |
| (...skipping 6427 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 15949 nonFields.add(node); | 15946 nonFields.add(node); |
| 15950 return null; | 15947 return null; |
| 15951 } | 15948 } |
| 15952 | 15949 |
| 15953 @override | 15950 @override |
| 15954 Object visitNode(AstNode node) => node.accept(TypeResolverVisitor_this); | 15951 Object visitNode(AstNode node) => node.accept(TypeResolverVisitor_this); |
| 15955 | 15952 |
| 15956 @override | 15953 @override |
| 15957 Object visitWithClause(WithClause node) => null; | 15954 Object visitWithClause(WithClause node) => null; |
| 15958 } | 15955 } |
| OLD | NEW |