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 |
11 import 'package:analysis_server/src/analysis_server.dart'; | 11 import 'package:analysis_server/src/analysis_server.dart'; |
12 import 'package:analysis_server/src/services/index/index.dart'; | 12 import 'package:analysis_server/src/services/index/index.dart'; |
13 import 'package:analysis_server/src/services/index/index_store.dart'; | 13 import 'package:analysis_server/src/services/index/index_store.dart'; |
14 import 'package:analysis_server/src/services/index/store/codec.dart'; | 14 import 'package:analysis_server/src/services/index/store/codec.dart'; |
15 import 'package:analysis_server/src/services/index/store/collection.dart'; | 15 import 'package:analysis_server/src/services/index/store/collection.dart'; |
16 import 'package:analyzer/src/generated/element.dart'; | 16 import 'package:analyzer/src/generated/element.dart'; |
17 import 'package:analyzer/src/generated/engine.dart'; | 17 import 'package:analyzer/src/generated/engine.dart'; |
18 import 'package:analyzer/src/generated/java_engine.dart'; | 18 import 'package:analyzer/src/generated/java_engine.dart'; |
19 import 'package:analyzer/src/generated/source.dart'; | 19 import 'package:analyzer/src/generated/source.dart'; |
20 import 'package:analyzer/src/generated/utilities_general.dart'; | 20 import 'package:analyzer/src/generated/utilities_general.dart'; |
21 | 21 |
22 class _TopElementData { | |
23 final String name; | |
24 final int elementId1; | |
25 final int elementId2; | |
26 final int elementId3; | |
27 | |
28 factory _TopElementData(ElementCodec elementCodec, Element element) { | |
29 return new _TopElementData._(element.name, elementCodec.encode1(element), | |
30 elementCodec.encode2(element), elementCodec.encode3(element)); | |
31 } | |
32 | |
33 _TopElementData._( | |
34 this.name, this.elementId1, this.elementId2, this.elementId3); | |
35 | |
36 Element getElement(AnalysisContext context, ElementCodec elementCodec) { | |
37 return elementCodec.decode(context, elementId1, elementId2, elementId3); | |
38 } | |
39 } | |
40 | |
41 /** | 22 /** |
42 * A manager for files content. | 23 * A manager for files content. |
43 */ | 24 */ |
44 abstract class FileManager { | 25 abstract class FileManager { |
45 /** | 26 /** |
46 * Removes all files. | 27 * Removes all files. |
47 */ | 28 */ |
48 void clear(); | 29 void clear(); |
49 | 30 |
50 /** | 31 /** |
(...skipping 459 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
510 int get hashCode { | 491 int get hashCode { |
511 int hash = 0; | 492 int hash = 0; |
512 hash = JenkinsSmiHash.combine(hash, elementId1); | 493 hash = JenkinsSmiHash.combine(hash, elementId1); |
513 hash = JenkinsSmiHash.combine(hash, elementId2); | 494 hash = JenkinsSmiHash.combine(hash, elementId2); |
514 hash = JenkinsSmiHash.combine(hash, elementId3); | 495 hash = JenkinsSmiHash.combine(hash, elementId3); |
515 hash = JenkinsSmiHash.combine(hash, relationshipId); | 496 hash = JenkinsSmiHash.combine(hash, relationshipId); |
516 return JenkinsSmiHash.finish(hash); | 497 return JenkinsSmiHash.finish(hash); |
517 } | 498 } |
518 | 499 |
519 @override | 500 @override |
520 String toString() { | |
521 return 'Key($elementId2, $elementId2, $elementId3, $relationshipId)'; | |
522 } | |
523 | |
524 @override | |
525 bool operator ==(Object obj) { | 501 bool operator ==(Object obj) { |
526 if (obj is! RelationKeyData) { | 502 if (obj is! RelationKeyData) { |
527 return false; | 503 return false; |
528 } | 504 } |
529 RelationKeyData other = obj; | 505 RelationKeyData other = obj; |
530 return other.elementId1 == elementId1 && | 506 return other.elementId1 == elementId1 && |
531 other.elementId2 == elementId2 && | 507 other.elementId2 == elementId2 && |
532 other.elementId3 == elementId3 && | 508 other.elementId3 == elementId3 && |
533 other.relationshipId == relationshipId; | 509 other.relationshipId == relationshipId; |
534 } | 510 } |
| 511 |
| 512 @override |
| 513 String toString() { |
| 514 return 'Key($elementId2, $elementId2, $elementId3, $relationshipId)'; |
| 515 } |
535 } | 516 } |
536 | 517 |
537 /** | 518 /** |
538 * An [IndexStore] which keeps index information in separate nodes for each unit
. | 519 * An [InternalIndexStore] which keeps index information in separate nodes for |
| 520 * each unit. |
539 */ | 521 */ |
540 class SplitIndexStore implements IndexStore { | 522 class SplitIndexStore implements InternalIndexStore { |
541 /** | 523 /** |
542 * The [ContextCodec] to encode/decode [AnalysisContext]s. | 524 * The [ContextCodec] to encode/decode [AnalysisContext]s. |
543 */ | 525 */ |
544 ContextCodec _contextCodec; | 526 ContextCodec _contextCodec; |
545 | 527 |
546 /** | 528 /** |
547 * Information about top-level elements. | 529 * Information about top-level elements. |
548 * We need to keep them together to avoid loading of all index nodes. | 530 * We need to keep them together to avoid loading of all index nodes. |
549 * | 531 * |
550 * Order of keys: contextId, nodeId. | 532 * Order of keys: contextId, nodeId. |
(...skipping 475 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1026 if (_pos == _size) { | 1008 if (_pos == _size) { |
1027 int newSize = _size << 1; | 1009 int newSize = _size << 1; |
1028 Uint32List newBuf = new Uint32List(newSize); | 1010 Uint32List newBuf = new Uint32List(newSize); |
1029 newBuf.setRange(0, _size, _buf); | 1011 newBuf.setRange(0, _size, _buf); |
1030 _size = newSize; | 1012 _size = newSize; |
1031 _buf = newBuf; | 1013 _buf = newBuf; |
1032 } | 1014 } |
1033 _buf[_pos++] = value; | 1015 _buf[_pos++] = value; |
1034 } | 1016 } |
1035 } | 1017 } |
| 1018 |
| 1019 class _TopElementData { |
| 1020 final String name; |
| 1021 final int elementId1; |
| 1022 final int elementId2; |
| 1023 final int elementId3; |
| 1024 |
| 1025 factory _TopElementData(ElementCodec elementCodec, Element element) { |
| 1026 return new _TopElementData._(element.name, elementCodec.encode1(element), |
| 1027 elementCodec.encode2(element), elementCodec.encode3(element)); |
| 1028 } |
| 1029 |
| 1030 _TopElementData._( |
| 1031 this.name, this.elementId1, this.elementId2, this.elementId3); |
| 1032 |
| 1033 Element getElement(AnalysisContext context, ElementCodec elementCodec) { |
| 1034 return elementCodec.decode(context, elementId1, elementId2, elementId3); |
| 1035 } |
| 1036 } |
OLD | NEW |