| OLD | NEW |
| 1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2016, 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 import 'dart:async'; | 5 import 'dart:async'; |
| 6 import 'dart:collection'; | 6 import 'dart:collection'; |
| 7 import 'dart:typed_data'; | 7 import 'dart:typed_data'; |
| 8 | 8 |
| 9 import 'package:analyzer/dart/ast/ast.dart'; | 9 import 'package:analyzer/dart/ast/ast.dart'; |
| 10 import 'package:analyzer/error/error.dart'; | 10 import 'package:analyzer/error/error.dart'; |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 59 * | 59 * |
| 60 * | 60 * |
| 61 * TODO(scheglov) Clean up the list of implicitly analyzed files. | 61 * TODO(scheglov) Clean up the list of implicitly analyzed files. |
| 62 * | 62 * |
| 63 * TODO(scheglov) Handle not existing 'dart:x' URIs (while user is typing). | 63 * TODO(scheglov) Handle not existing 'dart:x' URIs (while user is typing). |
| 64 */ | 64 */ |
| 65 class AnalysisDriver { | 65 class AnalysisDriver { |
| 66 /** | 66 /** |
| 67 * The version of data format, should be incremented on every format change. | 67 * The version of data format, should be incremented on every format change. |
| 68 */ | 68 */ |
| 69 static const int DATA_VERSION = 2; | 69 static const int DATA_VERSION = 3; |
| 70 | 70 |
| 71 /** | 71 /** |
| 72 * The name of the driver, e.g. the name of the folder. | 72 * The name of the driver, e.g. the name of the folder. |
| 73 */ | 73 */ |
| 74 String name; | 74 String name; |
| 75 | 75 |
| 76 /** | 76 /** |
| 77 * The scheduler that schedules analysis work in this, and possibly other | 77 * The scheduler that schedules analysis work in this, and possibly other |
| 78 * analysis drivers. | 78 * analysis drivers. |
| 79 */ | 79 */ |
| (...skipping 29 matching lines...) Expand all Loading... |
| 109 final SourceFactory _sourceFactory; | 109 final SourceFactory _sourceFactory; |
| 110 | 110 |
| 111 /** | 111 /** |
| 112 * The analysis options to analyze with. | 112 * The analysis options to analyze with. |
| 113 */ | 113 */ |
| 114 final AnalysisOptions _analysisOptions; | 114 final AnalysisOptions _analysisOptions; |
| 115 | 115 |
| 116 /** | 116 /** |
| 117 * The salt to mix into all hashes used as keys for serialized data. | 117 * The salt to mix into all hashes used as keys for serialized data. |
| 118 */ | 118 */ |
| 119 final Uint32List _salt = new Uint32List(2); | 119 final Uint32List _salt = |
| 120 new Uint32List(1 + AnalysisOptions.crossContextOptionsLength); |
| 120 | 121 |
| 121 /** | 122 /** |
| 122 * The current file system state. | 123 * The current file system state. |
| 123 */ | 124 */ |
| 124 FileSystemState _fsState; | 125 FileSystemState _fsState; |
| 125 | 126 |
| 126 /** | 127 /** |
| 127 * The combined unlinked and linked package for the SDK, extracted from | 128 * The combined unlinked and linked package for the SDK, extracted from |
| 128 * the given [_sourceFactory]. | 129 * the given [_sourceFactory]. |
| 129 */ | 130 */ |
| (...skipping 460 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 590 | 591 |
| 591 return new _LibraryContext(libraryFile, libraryNode, store); | 592 return new _LibraryContext(libraryFile, libraryNode, store); |
| 592 }); | 593 }); |
| 593 } | 594 } |
| 594 | 595 |
| 595 /** | 596 /** |
| 596 * Fill [_salt] with data. | 597 * Fill [_salt] with data. |
| 597 */ | 598 */ |
| 598 void _fillSalt() { | 599 void _fillSalt() { |
| 599 _salt[0] = DATA_VERSION; | 600 _salt[0] = DATA_VERSION; |
| 600 _salt[1] = _analysisOptions.encodeCrossContextOptions(); | 601 List<int> crossContextOptions = |
| 602 _analysisOptions.encodeCrossContextOptions(); |
| 603 assert(crossContextOptions.length == |
| 604 AnalysisOptions.crossContextOptionsLength); |
| 605 for (int i = 0; i < crossContextOptions.length; i++) { |
| 606 _salt[i + 1] = crossContextOptions[i]; |
| 607 } |
| 601 } | 608 } |
| 602 | 609 |
| 603 /** | 610 /** |
| 604 * If we know the result [key] for the [file], try to load the analysis | 611 * If we know the result [key] for the [file], try to load the analysis |
| 605 * result from the cache. Return `null` if not found. | 612 * result from the cache. Return `null` if not found. |
| 606 */ | 613 */ |
| 607 AnalysisResult _getCachedAnalysisResult(FileState file, String key) { | 614 AnalysisResult _getCachedAnalysisResult(FileState file, String key) { |
| 608 List<int> bytes = _byteStore.get(key); | 615 List<int> bytes = _byteStore.get(key); |
| 609 if (bytes != null) { | 616 if (bytes != null) { |
| 610 var unit = new AnalysisDriverResolvedUnit.fromBuffer(bytes); | 617 var unit = new AnalysisDriverResolvedUnit.fromBuffer(bytes); |
| (...skipping 529 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1140 /** | 1147 /** |
| 1141 * Complete the [signal] future if it is not completed yet. It is safe to | 1148 * Complete the [signal] future if it is not completed yet. It is safe to |
| 1142 * call this method multiple times, but the [signal] will complete only once. | 1149 * call this method multiple times, but the [signal] will complete only once. |
| 1143 */ | 1150 */ |
| 1144 void notify() { | 1151 void notify() { |
| 1145 if (!_completer.isCompleted) { | 1152 if (!_completer.isCompleted) { |
| 1146 _completer.complete(null); | 1153 _completer.complete(null); |
| 1147 } | 1154 } |
| 1148 } | 1155 } |
| 1149 } | 1156 } |
| OLD | NEW |