Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(15)

Side by Side Diff: pkg/analysis_server/lib/src/index/store/split_store.dart

Issue 351813002: A local file-based Index implementation. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 index.split.store; 5 library index.split_store;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 import 'dart:collection'; 8 import 'dart:collection';
9 import 'dart:io'; 9 import 'dart:io';
10 import 'dart:typed_data'; 10 import 'dart:typed_data';
11 11
12 import 'package:analysis_server/src/index/store/collection.dart'; 12 import 'package:analysis_server/src/index/store/collection.dart';
13 import 'package:analyzer/src/generated/element.dart'; 13 import 'package:analyzer/src/generated/element.dart';
14 import 'package:analyzer/src/generated/engine.dart'; 14 import 'package:analyzer/src/generated/engine.dart';
15 import 'package:analyzer/src/generated/index.dart'; 15 import 'package:analyzer/src/generated/index.dart';
(...skipping 567 matching lines...) Expand 10 before | Expand all | Expand 10 after
583 String sourceName = source.fullName; 583 String sourceName = source.fullName;
584 int sourceNameIndex = _stringCodec.encode(sourceName); 584 int sourceNameIndex = _stringCodec.encode(sourceName);
585 _currentNodeName = '${sourceNameIndex}.index'; 585 _currentNodeName = '${sourceNameIndex}.index';
586 _currentNodeNameId = _stringCodec.encode(_currentNodeName); 586 _currentNodeNameId = _stringCodec.encode(_currentNodeName);
587 _currentNode = _nodeManager.newNode(context); 587 _currentNode = _nodeManager.newNode(context);
588 return true; 588 return true;
589 } 589 }
590 590
591 @override 591 @override
592 void clear() { 592 void clear() {
593 _contextNodeRelations.clear();
593 _nodeManager.clear(); 594 _nodeManager.clear();
594 _nameToNodeNames.clear(); 595 _nameToNodeNames.clear();
595 } 596 }
596 597
597 @override 598 @override
598 void doneIndex() { 599 void doneIndex() {
599 if (_currentNode != null) { 600 if (_currentNode != null) {
600 _nodeManager.putNode(_currentNodeName, _currentNode); 601 _nodeManager.putNode(_currentNodeName, _currentNode);
601 _currentNodeName = null; 602 _currentNodeName = null;
602 _currentNodeNameId = -1; 603 _currentNodeNameId = -1;
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after
827 /** 828 /**
828 * Removes locations recorded in the given library/unit pair. 829 * Removes locations recorded in the given library/unit pair.
829 */ 830 */
830 void _removeLocations(AnalysisContext context, Source library, Source unit) { 831 void _removeLocations(AnalysisContext context, Source library, Source unit) {
831 // remove node 832 // remove node
832 String libraryName = library != null ? library.fullName : null; 833 String libraryName = library != null ? library.fullName : null;
833 String unitName = unit.fullName; 834 String unitName = unit.fullName;
834 int libraryNameIndex = _stringCodec.encode(libraryName); 835 int libraryNameIndex = _stringCodec.encode(libraryName);
835 int unitNameIndex = _stringCodec.encode(unitName); 836 int unitNameIndex = _stringCodec.encode(unitName);
836 String nodeName = '${libraryNameIndex}_${unitNameIndex}.index'; 837 String nodeName = '${libraryNameIndex}_${unitNameIndex}.index';
838 int nodeNameId = _stringCodec.encode(nodeName);
837 _nodeManager.removeNode(nodeName); 839 _nodeManager.removeNode(nodeName);
838 // remove source 840 // remove source
839 _sources.remove(library); 841 _sources.remove(library);
840 _sources.remove(unit); 842 _sources.remove(unit);
843 // remove universe relations
844 {
845 int contextId = _contextCodec.encode(context);
846 Map<int, Object> nodeRelations = _contextNodeRelations[contextId];
847 if (nodeRelations != null) {
848 nodeRelations.remove(nodeNameId);
849 }
850 }
841 } 851 }
842 852
843 /** 853 /**
844 * When logging is on, [AnalysisEngine] actually creates 854 * When logging is on, [AnalysisEngine] actually creates
845 * [InstrumentedAnalysisContextImpl], which wraps [AnalysisContextImpl] used t o create 855 * [InstrumentedAnalysisContextImpl], which wraps [AnalysisContextImpl] used t o create
846 * actual [Element]s. So, in index we have to unwrap [InstrumentedAnalysisCont extImpl] 856 * actual [Element]s. So, in index we have to unwrap [InstrumentedAnalysisCont extImpl]
847 * when perform any operation. 857 * when perform any operation.
848 */ 858 */
849 AnalysisContext _unwrapContext(AnalysisContext context) { 859 AnalysisContext _unwrapContext(AnalysisContext context) {
850 if (context is InstrumentedAnalysisContextImpl) { 860 if (context is InstrumentedAnalysisContextImpl) {
(...skipping 28 matching lines...) Expand all
879 return new Uint8List.fromList(_buffer.takeBytes()); 889 return new Uint8List.fromList(_buffer.takeBytes());
880 } 890 }
881 891
882 void writeInt(int value) { 892 void writeInt(int value) {
883 _buffer.addByte((value & 0xFF000000) >> 24); 893 _buffer.addByte((value & 0xFF000000) >> 24);
884 _buffer.addByte((value & 0x00FF0000) >> 16); 894 _buffer.addByte((value & 0x00FF0000) >> 16);
885 _buffer.addByte((value & 0x0000FF00) >> 8); 895 _buffer.addByte((value & 0x0000FF00) >> 8);
886 _buffer.addByte(value & 0xFF); 896 _buffer.addByte(value & 0xFF);
887 } 897 }
888 } 898 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698