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/dart/element/element.dart' show CompilationUnitElement; | 10 import 'package:analyzer/dart/element/element.dart' show CompilationUnitElement; |
(...skipping 574 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
585 AnalysisResult analysisResult = _computeAnalysisResult(path, | 585 AnalysisResult analysisResult = _computeAnalysisResult(path, |
586 withUnit: false, asIsIfPartWithoutLibrary: true); | 586 withUnit: false, asIsIfPartWithoutLibrary: true); |
587 FileState libraryFile = analysisResult._libraryFile; | 587 FileState libraryFile = analysisResult._libraryFile; |
588 FileState file = analysisResult._file; | 588 FileState file = analysisResult._file; |
589 | 589 |
590 // Create the AnalysisContext to resynthesize elements in. | 590 // Create the AnalysisContext to resynthesize elements in. |
591 _LibraryContext libraryContext = _createLibraryContext(libraryFile); | 591 _LibraryContext libraryContext = _createLibraryContext(libraryFile); |
592 AnalysisContext analysisContext = _createAnalysisContext(libraryContext); | 592 AnalysisContext analysisContext = _createAnalysisContext(libraryContext); |
593 | 593 |
594 // Resynthesize the CompilationUnitElement in the context. | 594 // Resynthesize the CompilationUnitElement in the context. |
595 CompilationUnitElement unitElement = analysisContext.computeResult( | 595 CompilationUnitElement unitElement; |
596 new LibrarySpecificUnit(libraryFile.source, file.source), | 596 try { |
597 COMPILATION_UNIT_ELEMENT); | 597 unitElement = analysisContext.computeResult( |
| 598 new LibrarySpecificUnit(libraryFile.source, file.source), |
| 599 COMPILATION_UNIT_ELEMENT); |
| 600 } finally { |
| 601 analysisContext.dispose(); |
| 602 } |
598 | 603 |
599 // Return as IndexResult. | 604 // Return as IndexResult. |
600 return new IndexResult(unitElement, analysisResult._index); | 605 return new IndexResult(unitElement, analysisResult._index); |
601 } | 606 } |
602 | 607 |
603 AnalysisContext _createAnalysisContext(_LibraryContext libraryContext) { | 608 AnalysisContext _createAnalysisContext(_LibraryContext libraryContext) { |
604 AnalysisContextImpl analysisContext = | 609 AnalysisContextImpl analysisContext = |
605 AnalysisEngine.instance.createAnalysisContext(); | 610 AnalysisEngine.instance.createAnalysisContext(); |
606 analysisContext.analysisOptions = analysisOptions; | 611 analysisContext.analysisOptions = analysisOptions; |
607 | 612 |
(...skipping 686 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1294 } | 1299 } |
1295 | 1300 |
1296 /** | 1301 /** |
1297 * TODO(scheglov) document | 1302 * TODO(scheglov) document |
1298 */ | 1303 */ |
1299 class _LibraryContext { | 1304 class _LibraryContext { |
1300 final FileState file; | 1305 final FileState file; |
1301 final SummaryDataStore store; | 1306 final SummaryDataStore store; |
1302 _LibraryContext(this.file, this.store); | 1307 _LibraryContext(this.file, this.store); |
1303 } | 1308 } |
OLD | NEW |