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

Side by Side Diff: pkg/analyzer/lib/src/dart/analysis/file_state.dart

Issue 2670843004: Record defined top-level/class-mebber names with unlinked bundles. (Closed)
Patch Set: Created 3 years, 10 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
OLDNEW
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 import 'dart:typed_data'; 6 import 'dart:typed_data';
7 7
8 import 'package:analyzer/dart/ast/ast.dart'; 8 import 'package:analyzer/dart/ast/ast.dart';
9 import 'package:analyzer/dart/ast/token.dart'; 9 import 'package:analyzer/dart/ast/token.dart';
10 import 'package:analyzer/error/listener.dart'; 10 import 'package:analyzer/error/listener.dart';
11 import 'package:analyzer/file_system/file_system.dart'; 11 import 'package:analyzer/file_system/file_system.dart';
12 import 'package:analyzer/src/dart/analysis/byte_store.dart'; 12 import 'package:analyzer/src/dart/analysis/byte_store.dart';
13 import 'package:analyzer/src/dart/analysis/defined_names.dart';
13 import 'package:analyzer/src/dart/analysis/driver.dart'; 14 import 'package:analyzer/src/dart/analysis/driver.dart';
14 import 'package:analyzer/src/dart/analysis/referenced_names.dart'; 15 import 'package:analyzer/src/dart/analysis/referenced_names.dart';
15 import 'package:analyzer/src/dart/analysis/top_level_declaration.dart'; 16 import 'package:analyzer/src/dart/analysis/top_level_declaration.dart';
16 import 'package:analyzer/src/dart/scanner/reader.dart'; 17 import 'package:analyzer/src/dart/scanner/reader.dart';
17 import 'package:analyzer/src/dart/scanner/scanner.dart'; 18 import 'package:analyzer/src/dart/scanner/scanner.dart';
18 import 'package:analyzer/src/generated/engine.dart'; 19 import 'package:analyzer/src/generated/engine.dart';
19 import 'package:analyzer/src/generated/parser.dart'; 20 import 'package:analyzer/src/generated/parser.dart';
20 import 'package:analyzer/src/generated/source.dart'; 21 import 'package:analyzer/src/generated/source.dart';
21 import 'package:analyzer/src/generated/utilities_dart.dart'; 22 import 'package:analyzer/src/generated/utilities_dart.dart';
22 import 'package:analyzer/src/source/source_resource.dart'; 23 import 'package:analyzer/src/source/source_resource.dart';
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
81 82
82 /** 83 /**
83 * The [Source] of the file with the [uri]. 84 * The [Source] of the file with the [uri].
84 */ 85 */
85 Source source; 86 Source source;
86 87
87 bool _exists; 88 bool _exists;
88 String _content; 89 String _content;
89 String _contentHash; 90 String _contentHash;
90 LineInfo _lineInfo; 91 LineInfo _lineInfo;
92 Set<String> _definedTopLevelNames;
93 Set<String> _definedClassMemberNames;
91 Set<String> _referencedNames; 94 Set<String> _referencedNames;
92 UnlinkedUnit _unlinked; 95 UnlinkedUnit _unlinked;
93 List<int> _apiSignature; 96 List<int> _apiSignature;
94 97
95 List<FileState> _importedFiles; 98 List<FileState> _importedFiles;
96 List<FileState> _exportedFiles; 99 List<FileState> _exportedFiles;
97 List<FileState> _partedFiles; 100 List<FileState> _partedFiles;
98 List<NameFilter> _exportFilters; 101 List<NameFilter> _exportFilters;
99 102
100 Set<FileState> _directReferencedFiles = new Set<FileState>(); 103 Set<FileState> _directReferencedFiles = new Set<FileState>();
(...skipping 14 matching lines...) Expand all
115 * The content of the file. 118 * The content of the file.
116 */ 119 */
117 String get content => _content; 120 String get content => _content;
118 121
119 /** 122 /**
120 * The MD5 hash of the [content]. 123 * The MD5 hash of the [content].
121 */ 124 */
122 String get contentHash => _contentHash; 125 String get contentHash => _contentHash;
123 126
124 /** 127 /**
128 * The class member names defined by the file.
129 */
130 Set<String> get definedClassMemberNames => _definedClassMemberNames;
131
132 /**
133 * The top-level names defined by the file.
134 */
135 Set<String> get definedTopLevelNames => _definedTopLevelNames;
136
137 /**
125 * Return the set of all directly referenced files - imported, exported or 138 * Return the set of all directly referenced files - imported, exported or
126 * parted. 139 * parted.
127 */ 140 */
128 Set<FileState> get directReferencedFiles => _directReferencedFiles; 141 Set<FileState> get directReferencedFiles => _directReferencedFiles;
129 142
130 /** 143 /**
131 * Return `true` if the file exists. 144 * Return `true` if the file exists.
132 */ 145 */
133 bool get exists => _exists; 146 bool get exists => _exists;
134 147
(...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after
381 394
382 // Prepare bytes of the unlinked bundle - existing or new. 395 // Prepare bytes of the unlinked bundle - existing or new.
383 List<int> bytes; 396 List<int> bytes;
384 { 397 {
385 bytes = _fsState._byteStore.get(unlinkedKey); 398 bytes = _fsState._byteStore.get(unlinkedKey);
386 if (bytes == null) { 399 if (bytes == null) {
387 CompilationUnit unit = parse(AnalysisErrorListener.NULL_LISTENER); 400 CompilationUnit unit = parse(AnalysisErrorListener.NULL_LISTENER);
388 _fsState._logger.run('Create unlinked for $path', () { 401 _fsState._logger.run('Create unlinked for $path', () {
389 UnlinkedUnitBuilder unlinkedUnit = serializeAstUnlinked(unit); 402 UnlinkedUnitBuilder unlinkedUnit = serializeAstUnlinked(unit);
390 List<String> referencedNames = computeReferencedNames(unit).toList(); 403 List<String> referencedNames = computeReferencedNames(unit).toList();
404 DefinedNames definedNames = computeDefinedNames(unit);
391 bytes = new AnalysisDriverUnlinkedUnitBuilder( 405 bytes = new AnalysisDriverUnlinkedUnitBuilder(
392 unit: unlinkedUnit, referencedNames: referencedNames) 406 unit: unlinkedUnit,
407 definedTopLevelNames: definedNames.topLevelNames.toList(),
408 definedClassMemberNames:
409 definedNames.classMemberNames.toList(),
410 referencedNames: referencedNames)
393 .toBuffer(); 411 .toBuffer();
394 _fsState._byteStore.put(unlinkedKey, bytes); 412 _fsState._byteStore.put(unlinkedKey, bytes);
395 }); 413 });
396 } 414 }
397 } 415 }
398 416
399 // Read the unlinked bundle. 417 // Read the unlinked bundle.
400 var driverUnlinkedUnit = new AnalysisDriverUnlinkedUnit.fromBuffer(bytes); 418 var driverUnlinkedUnit = new AnalysisDriverUnlinkedUnit.fromBuffer(bytes);
401 _referencedNames = new Set<String>.from(driverUnlinkedUnit.referencedNames); 419 _definedTopLevelNames = driverUnlinkedUnit.definedTopLevelNames.toSet();
420 _definedClassMemberNames =
421 driverUnlinkedUnit.definedClassMemberNames.toSet();
422 _referencedNames = driverUnlinkedUnit.referencedNames.toSet();
402 _unlinked = driverUnlinkedUnit.unit; 423 _unlinked = driverUnlinkedUnit.unit;
403 _lineInfo = new LineInfo(_unlinked.lineStarts); 424 _lineInfo = new LineInfo(_unlinked.lineStarts);
404 _topLevelDeclarations = null; 425 _topLevelDeclarations = null;
405 426
406 // Prepare API signature. 427 // Prepare API signature.
407 List<int> newApiSignature = _unlinked.apiSignature; 428 List<int> newApiSignature = _unlinked.apiSignature;
408 bool apiSignatureChanged = _apiSignature != null && 429 bool apiSignatureChanged = _apiSignature != null &&
409 !_equalByteLists(_apiSignature, newApiSignature); 430 !_equalByteLists(_apiSignature, newApiSignature);
410 _apiSignature = newApiSignature; 431 _apiSignature = newApiSignature;
411 432
(...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after
711 .where((f) => f._transitiveFiles == null) 732 .where((f) => f._transitiveFiles == null)
712 .toSet(); 733 .toSet();
713 } 734 }
714 735
715 Set<FileState> get filesWithoutTransitiveSignature { 736 Set<FileState> get filesWithoutTransitiveSignature {
716 return state._uriToFile.values 737 return state._uriToFile.values
717 .where((f) => f._transitiveSignature == null) 738 .where((f) => f._transitiveSignature == null)
718 .toSet(); 739 .toSet();
719 } 740 }
720 } 741 }
OLDNEW
« no previous file with comments | « pkg/analyzer/lib/src/dart/analysis/driver.dart ('k') | pkg/analyzer/lib/src/summary/format.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698