| OLD | NEW |
| 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, 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 js_backend.namer; | 5 library js_backend.namer; |
| 6 | 6 |
| 7 import 'dart:collection' show HashMap; | 7 import 'dart:collection' show HashMap; |
| 8 | 8 |
| 9 import 'package:js_runtime/shared/embedded_names.dart' show JsGetName; | 9 import 'package:js_runtime/shared/embedded_names.dart' show JsGetName; |
| 10 | 10 |
| (...skipping 758 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 769 ? 'self' | 769 ? 'self' |
| 770 : backend.nativeData.getUnescapedJSInteropName(e.name); | 770 : backend.nativeData.getUnescapedJSInteropName(e.name); |
| 771 } | 771 } |
| 772 | 772 |
| 773 /// Returns a JavaScript path specifying the context in which | 773 /// Returns a JavaScript path specifying the context in which |
| 774 /// [element.fixedBackendName] should be evaluated. Only applicable for | 774 /// [element.fixedBackendName] should be evaluated. Only applicable for |
| 775 /// elements using typed JavaScript interop. | 775 /// elements using typed JavaScript interop. |
| 776 /// For example: fixedBackendPath for the static method createMap in the | 776 /// For example: fixedBackendPath for the static method createMap in the |
| 777 /// Map class of the goog.map JavaScript library would have path | 777 /// Map class of the goog.map JavaScript library would have path |
| 778 /// "goog.maps.Map". | 778 /// "goog.maps.Map". |
| 779 String fixedBackendPath(Element element) { | 779 String fixedBackendMethodPath(MethodElement element) { |
| 780 return _fixedBackendPath(element); |
| 781 } |
| 782 |
| 783 String _fixedBackendPath(Element element) { |
| 780 if (!backend.isJsInterop(element)) return null; | 784 if (!backend.isJsInterop(element)) return null; |
| 781 if (element.isInstanceMember) return 'this'; | 785 if (element.isInstanceMember) return 'this'; |
| 782 if (element.isConstructor) return fixedBackendPath(element.enclosingClass); | 786 if (element.isConstructor) return _fixedBackendPath(element.enclosingClass); |
| 783 if (element.isLibrary) return 'self'; | 787 if (element.isLibrary) return 'self'; |
| 784 var sb = new StringBuffer(); | 788 var sb = new StringBuffer(); |
| 785 sb..write(_jsNameHelper(element.library)); | 789 sb..write(_jsNameHelper(element.library)); |
| 786 | 790 |
| 787 if (element.enclosingClass != null && element.enclosingClass != element) { | 791 if (element.enclosingClass != null && element.enclosingClass != element) { |
| 788 sb..write('.')..write(_jsNameHelper(element.enclosingClass)); | 792 sb..write('.')..write(_jsNameHelper(element.enclosingClass)); |
| 789 } | 793 } |
| 790 return sb.toString(); | 794 return sb.toString(); |
| 791 } | 795 } |
| 792 | 796 |
| (...skipping 1405 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2198 void addSuggestion(String original, String suggestion) { | 2202 void addSuggestion(String original, String suggestion) { |
| 2199 assert(!_suggestedNames.containsKey(original)); | 2203 assert(!_suggestedNames.containsKey(original)); |
| 2200 _suggestedNames[original] = suggestion; | 2204 _suggestedNames[original] = suggestion; |
| 2201 } | 2205 } |
| 2202 | 2206 |
| 2203 bool hasSuggestion(String original) => _suggestedNames.containsKey(original); | 2207 bool hasSuggestion(String original) => _suggestedNames.containsKey(original); |
| 2204 bool isSuggestion(String candidate) { | 2208 bool isSuggestion(String candidate) { |
| 2205 return _suggestedNames.containsValue(candidate); | 2209 return _suggestedNames.containsValue(candidate); |
| 2206 } | 2210 } |
| 2207 } | 2211 } |
| OLD | NEW |