| 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 services.src.index.store.split_store; | 5 library services.src.index.store.split_store; |
| 6 | 6 |
| 7 import 'dart:async'; | 7 import 'dart:async'; |
| 8 import 'dart:collection'; | 8 import 'dart:collection'; |
| 9 import 'dart:typed_data'; | 9 import 'dart:typed_data'; |
| 10 | 10 |
| (...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 276 * locations to be returned | 276 * locations to be returned |
| 277 */ | 277 */ |
| 278 List<LocationImpl> getRelationships( | 278 List<LocationImpl> getRelationships( |
| 279 Element element, RelationshipImpl relationship) { | 279 Element element, RelationshipImpl relationship) { |
| 280 // prepare key | 280 // prepare key |
| 281 RelationKeyData key = new RelationKeyData.forObject( | 281 RelationKeyData key = new RelationKeyData.forObject( |
| 282 _elementCodec, _relationshipCodec, element, relationship); | 282 _elementCodec, _relationshipCodec, element, relationship); |
| 283 // find LocationData(s) | 283 // find LocationData(s) |
| 284 List<LocationData> locationDatas = _relations[key]; | 284 List<LocationData> locationDatas = _relations[key]; |
| 285 if (locationDatas == null) { | 285 if (locationDatas == null) { |
| 286 return LocationImpl.EMPTY_ARRAY; | 286 return LocationImpl.EMPTY_LIST; |
| 287 } | 287 } |
| 288 // convert to Location(s) | 288 // convert to Location(s) |
| 289 List<LocationImpl> locations = <LocationImpl>[]; | 289 List<LocationImpl> locations = <LocationImpl>[]; |
| 290 for (LocationData locationData in locationDatas) { | 290 for (LocationData locationData in locationDatas) { |
| 291 LocationImpl location = locationData.getLocation(context, _elementCodec); | 291 LocationImpl location = locationData.getLocation(context, _elementCodec); |
| 292 if (location != null) { | 292 if (location != null) { |
| 293 locations.add(location); | 293 locations.add(location); |
| 294 } | 294 } |
| 295 } | 295 } |
| 296 return locations; | 296 return locations; |
| (...skipping 429 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 726 } | 726 } |
| 727 // prepare Future(s) for reading each IndexNode | 727 // prepare Future(s) for reading each IndexNode |
| 728 List<Future<List<LocationImpl>>> nodeFutures = | 728 List<Future<List<LocationImpl>>> nodeFutures = |
| 729 <Future<List<LocationImpl>>>[]; | 729 <Future<List<LocationImpl>>>[]; |
| 730 for (int nodeNameId in nodeNameIds) { | 730 for (int nodeNameId in nodeNameIds) { |
| 731 String nodeName = _stringCodec.decode(nodeNameId); | 731 String nodeName = _stringCodec.decode(nodeNameId); |
| 732 Future<IndexNode> nodeFuture = _nodeManager.getNode(nodeName); | 732 Future<IndexNode> nodeFuture = _nodeManager.getNode(nodeName); |
| 733 Future<List<LocationImpl>> locationsFuture = nodeFuture.then((node) { | 733 Future<List<LocationImpl>> locationsFuture = nodeFuture.then((node) { |
| 734 if (node == null) { | 734 if (node == null) { |
| 735 // TODO(scheglov) remove node | 735 // TODO(scheglov) remove node |
| 736 return LocationImpl.EMPTY_ARRAY; | 736 return LocationImpl.EMPTY_LIST; |
| 737 } | 737 } |
| 738 return node.getRelationships(element, relationship); | 738 return node.getRelationships(element, relationship); |
| 739 }); | 739 }); |
| 740 nodeFutures.add(locationsFuture); | 740 nodeFutures.add(locationsFuture); |
| 741 } | 741 } |
| 742 // return Future that merges separate IndexNode Location(s) | 742 // return Future that merges separate IndexNode Location(s) |
| 743 return Future | 743 return Future |
| 744 .wait(nodeFutures) | 744 .wait(nodeFutures) |
| 745 .then((List<List<LocationImpl>> locationsList) { | 745 .then((List<List<LocationImpl>> locationsList) { |
| 746 List<LocationImpl> allLocations = <LocationImpl>[]; | 746 List<LocationImpl> allLocations = <LocationImpl>[]; |
| (...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1032 elementCodec.encode2(element), elementCodec.encode3(element)); | 1032 elementCodec.encode2(element), elementCodec.encode3(element)); |
| 1033 } | 1033 } |
| 1034 | 1034 |
| 1035 _TopElementData._( | 1035 _TopElementData._( |
| 1036 this.name, this.elementId1, this.elementId2, this.elementId3); | 1036 this.name, this.elementId1, this.elementId2, this.elementId3); |
| 1037 | 1037 |
| 1038 Element getElement(AnalysisContext context, ElementCodec elementCodec) { | 1038 Element getElement(AnalysisContext context, ElementCodec elementCodec) { |
| 1039 return elementCodec.decode(context, elementId1, elementId2, elementId3); | 1039 return elementCodec.decode(context, elementId1, elementId2, elementId3); |
| 1040 } | 1040 } |
| 1041 } | 1041 } |
| OLD | NEW |