| 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:convert'; | 5 import 'dart:convert'; |
| 6 | 6 |
| 7 import 'package:analyzer/dart/ast/ast.dart'; | 7 import 'package:analyzer/dart/ast/ast.dart'; |
| 8 import 'package:analyzer/dart/ast/token.dart'; | 8 import 'package:analyzer/dart/ast/token.dart'; |
| 9 import 'package:analyzer/error/listener.dart'; | 9 import 'package:analyzer/error/listener.dart'; |
| 10 import 'package:analyzer/file_system/file_system.dart'; | 10 import 'package:analyzer/file_system/file_system.dart'; |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 71 | 71 |
| 72 /** | 72 /** |
| 73 * The absolute URI of the file. | 73 * The absolute URI of the file. |
| 74 */ | 74 */ |
| 75 final Uri uri; | 75 final Uri uri; |
| 76 | 76 |
| 77 Source _source; | 77 Source _source; |
| 78 | 78 |
| 79 String _content; | 79 String _content; |
| 80 String _contentHash; | 80 String _contentHash; |
| 81 LineInfo _lineInfo; |
| 81 UnlinkedUnit _unlinked; | 82 UnlinkedUnit _unlinked; |
| 82 List<int> _apiSignature; | 83 List<int> _apiSignature; |
| 83 | 84 |
| 84 List<FileState> _importedFiles; | 85 List<FileState> _importedFiles; |
| 85 List<FileState> _exportedFiles; | 86 List<FileState> _exportedFiles; |
| 86 List<FileState> _partedFiles; | 87 List<FileState> _partedFiles; |
| 87 List<FileState> _dependencies; | 88 List<FileState> _dependencies; |
| 88 | 89 |
| 89 FileState(this._fsState, this.path, this.uri) { | 90 FileState(this._fsState, this.path, this.uri) { |
| 90 _source = new FileSource(_fsState._resourceProvider.getFile(path), uri); | 91 _source = new FileSource(_fsState._resourceProvider.getFile(path), uri); |
| 91 } | 92 } |
| 92 | 93 |
| 93 /** | 94 /** |
| 94 * The unlinked API signature of the file. | 95 * The unlinked API signature of the file. |
| 95 */ | 96 */ |
| 96 List<int> get apiSignature => _apiSignature; | 97 List<int> get apiSignature => _apiSignature; |
| 97 | 98 |
| 98 /** | 99 /** |
| 99 * The content of the file. | 100 * The content of the file. |
| 100 */ | 101 */ |
| 101 String get content => _content; | 102 String get content => _content; |
| 102 | 103 |
| 103 /** | 104 /** |
| 104 * The MD5 hash of the [content]. | 105 * The MD5 hash of the [content]. |
| 105 */ | 106 */ |
| 106 String get contentHash => _contentHash; | 107 String get contentHash => _contentHash; |
| 107 | 108 |
| 108 /** | 109 /** |
| 110 * Return information about line in the file. |
| 111 */ |
| 112 LineInfo get lineInfo => _lineInfo; |
| 113 |
| 114 /** |
| 109 * Return the list of all direct dependencies. | 115 * Return the list of all direct dependencies. |
| 110 */ | 116 */ |
| 111 List<FileState> get dependencies => _dependencies; | 117 List<FileState> get dependencies => _dependencies; |
| 112 | 118 |
| 113 /** | 119 /** |
| 114 * The list of files this file exports. | 120 * The list of files this file exports. |
| 115 */ | 121 */ |
| 116 List<FileState> get exportedFiles => _exportedFiles; | 122 List<FileState> get exportedFiles => _exportedFiles; |
| 117 | 123 |
| 118 /** | 124 /** |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 170 _parse(_source, _content, _fsState._analysisOptions); | 176 _parse(_source, _content, _fsState._analysisOptions); |
| 171 _fsState._logger.run('Create unlinked for $path', () { | 177 _fsState._logger.run('Create unlinked for $path', () { |
| 172 UnlinkedUnitBuilder unlinkedUnit = serializeAstUnlinked(unit); | 178 UnlinkedUnitBuilder unlinkedUnit = serializeAstUnlinked(unit); |
| 173 bytes = unlinkedUnit.toBuffer(); | 179 bytes = unlinkedUnit.toBuffer(); |
| 174 _fsState._byteStore.put(key, bytes); | 180 _fsState._byteStore.put(key, bytes); |
| 175 }); | 181 }); |
| 176 } | 182 } |
| 177 } | 183 } |
| 178 // Read the unlinked bundle. | 184 // Read the unlinked bundle. |
| 179 _unlinked = new UnlinkedUnit.fromBuffer(bytes); | 185 _unlinked = new UnlinkedUnit.fromBuffer(bytes); |
| 186 _lineInfo = new LineInfo(_unlinked.lineStarts); |
| 180 List<int> newApiSignature = _unlinked.apiSignature; | 187 List<int> newApiSignature = _unlinked.apiSignature; |
| 181 bool apiSignatureChanged = _apiSignature != null && | 188 bool apiSignatureChanged = _apiSignature != null && |
| 182 !_equalByteLists(_apiSignature, newApiSignature); | 189 !_equalByteLists(_apiSignature, newApiSignature); |
| 183 _apiSignature = newApiSignature; | 190 _apiSignature = newApiSignature; |
| 184 // Build the graph. | 191 // Build the graph. |
| 185 _importedFiles = <FileState>[]; | 192 _importedFiles = <FileState>[]; |
| 186 _exportedFiles = <FileState>[]; | 193 _exportedFiles = <FileState>[]; |
| 187 _partedFiles = <FileState>[]; | 194 _partedFiles = <FileState>[]; |
| 188 for (UnlinkedImport import in _unlinked.imports) { | 195 for (UnlinkedImport import in _unlinked.imports) { |
| 189 if (!import.isImplicit) { | 196 if (!import.isImplicit) { |
| (...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 308 } | 315 } |
| 309 | 316 |
| 310 /** | 317 /** |
| 311 * Return the default [Uri] for the given path in [_sourceFactory]. | 318 * Return the default [Uri] for the given path in [_sourceFactory]. |
| 312 */ | 319 */ |
| 313 Uri _uriForPath(String path) { | 320 Uri _uriForPath(String path) { |
| 314 Source fileSource = _resourceProvider.getFile(path).createSource(); | 321 Source fileSource = _resourceProvider.getFile(path).createSource(); |
| 315 return _sourceFactory.restoreUri(fileSource); | 322 return _sourceFactory.restoreUri(fileSource); |
| 316 } | 323 } |
| 317 } | 324 } |
| OLD | NEW |