OLD | NEW |
1 // Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2017, 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 | 6 |
7 import 'package:analyzer/dart/ast/ast.dart'; | 7 import 'package:analyzer/dart/ast/ast.dart'; |
8 import 'package:analyzer/file_system/file_system.dart'; | 8 import 'package:analyzer/file_system/file_system.dart'; |
9 import 'package:analyzer/src/context/context.dart'; | 9 import 'package:analyzer/src/context/context.dart'; |
10 import 'package:analyzer/src/dart/analysis/byte_store.dart'; | 10 import 'package:analyzer/src/dart/analysis/byte_store.dart'; |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
62 await init(); | 62 await init(); |
63 } | 63 } |
64 // The analysis driver doesn't currently support an asynchronous file API, | 64 // The analysis driver doesn't currently support an asynchronous file API, |
65 // so we have to find all the files first to read their contents. | 65 // so we have to find all the files first to read their contents. |
66 // TODO(paulberry): this is an unnecessary source of duplicate work and | 66 // TODO(paulberry): this is an unnecessary source of duplicate work and |
67 // should be eliminated ASAP. | 67 // should be eliminated ASAP. |
68 var graph = | 68 var graph = |
69 await graphForProgram([_source], _options, fileReader: _fileReader); | 69 await graphForProgram([_source], _options, fileReader: _fileReader); |
70 // TODO(paulberry): collect no-longer-referenced files from _fileState and | 70 // TODO(paulberry): collect no-longer-referenced files from _fileState and |
71 // _fileRepository. | 71 // _fileRepository. |
72 var libraries = <Uri, ResolvedLibrary>{}; | 72 var libraries = <Uri, Map<Uri, CompilationUnit>>{}; |
73 if (!_schedulerStarted) { | 73 if (!_schedulerStarted) { |
74 _scheduler.start(); | 74 _scheduler.start(); |
75 _schedulerStarted = true; | 75 _schedulerStarted = true; |
76 } | 76 } |
77 for (var libraryCycle in graph.topologicallySortedCycles) { | 77 for (var libraryCycle in graph.topologicallySortedCycles) { |
78 for (var libraryUri in libraryCycle.libraries.keys) { | 78 for (var libraryUri in libraryCycle.libraries.keys) { |
79 var libraryNode = libraryCycle.libraries[libraryUri]; | 79 var libraryNode = libraryCycle.libraries[libraryUri]; |
80 for (var partUri in libraryNode.parts) { | 80 for (var partUri in libraryNode.parts) { |
81 // TODO(paulberry): resolve the part URI. | 81 // TODO(paulberry): resolve the part URI. |
82 _fileReader(partUri, partUri); | 82 _fileReader(partUri, partUri); |
83 } | 83 } |
84 } | 84 } |
85 for (var libraryUri in libraryCycle.libraries.keys) { | 85 for (var libraryUri in libraryCycle.libraries.keys) { |
86 var libraryNode = libraryCycle.libraries[libraryUri]; | 86 var libraryNode = libraryCycle.libraries[libraryUri]; |
87 var result = | 87 var result = |
88 await _driver.getResult(_fileRepository.pathForUri(libraryUri)); | 88 await _driver.getResult(_fileRepository.pathForUri(libraryUri)); |
89 // TODO(paulberry): handle errors. | 89 // TODO(paulberry): handle errors. |
90 var definingCompilationUnit = result.unit; | 90 var units = {libraryUri: result.unit}; |
91 var partUnits = <Uri, CompilationUnit>{}; | |
92 for (var partUri in libraryNode.parts) { | 91 for (var partUri in libraryNode.parts) { |
93 // Really we ought to have a driver API that lets us request a | 92 // Really we ought to have a driver API that lets us request a |
94 // specific part of a given library. Otherwise we will run into | 93 // specific part of a given library. Otherwise we will run into |
95 // problems if a part is included in multiple libraries. | 94 // problems if a part is included in multiple libraries. |
96 // TODO(paulberry): address this. | 95 // TODO(paulberry): address this. |
97 var partResult = | 96 var partResult = |
98 await _driver.getResult(_fileRepository.pathForUri(partUri)); | 97 await _driver.getResult(_fileRepository.pathForUri(partUri)); |
99 // TODO(paulberry): handle errors. | 98 // TODO(paulberry): handle errors. |
100 partUnits[partUri] = partResult.unit; | 99 units[partUri] = partResult.unit; |
101 } | 100 } |
102 libraries[libraryUri] = | 101 libraries[libraryUri] = units; |
103 new ResolvedLibrary(definingCompilationUnit, partUnits); | |
104 } | 102 } |
105 } | 103 } |
106 _driver.addFile(_fileRepository.pathForUri(_source)); | 104 _driver.addFile(_fileRepository.pathForUri(_source)); |
107 // TODO(paulberry): stop the scheduler | 105 // TODO(paulberry): stop the scheduler |
108 return new DeltaLibraries(libraries); | 106 return new DeltaLibraries(libraries); |
109 } | 107 } |
110 | 108 |
111 Future<Null> init() async { | 109 Future<Null> init() async { |
112 // TODO(paulberry): can we just use null? | 110 // TODO(paulberry): can we just use null? |
113 var performanceLog = new driver.PerformanceLog(new _NullStringSink()); | 111 var performanceLog = new driver.PerformanceLog(new _NullStringSink()); |
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
295 class _SourceProxy extends BasicSource { | 293 class _SourceProxy extends BasicSource { |
296 @override | 294 @override |
297 final String fullName; | 295 final String fullName; |
298 | 296 |
299 _SourceProxy(Uri uri, this.fullName) : super(uri); | 297 _SourceProxy(Uri uri, this.fullName) : super(uri); |
300 | 298 |
301 int get modificationStamp => 0; | 299 int get modificationStamp => 0; |
302 | 300 |
303 noSuchMethod(Invocation invocation) => unimplemented(); | 301 noSuchMethod(Invocation invocation) => unimplemented(); |
304 } | 302 } |
OLD | NEW |