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

Unified Diff: pkg/analyzer/lib/src/dart/analysis/library_context.dart

Issue 2835123004: Add AnalysisDriver.getLibraryByUri(). (Closed)
Patch Set: Created 3 years, 8 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 side-by-side diff with in-line comments
Download patch
Index: pkg/analyzer/lib/src/dart/analysis/library_context.dart
diff --git a/pkg/analyzer/lib/src/dart/analysis/library_context.dart b/pkg/analyzer/lib/src/dart/analysis/library_context.dart
index 4d6641b8d9480125b3143e4990f07b7000e8d655..9ec2aea835b4eefe1b688978b8367c0b459d8d8f 100644
--- a/pkg/analyzer/lib/src/dart/analysis/library_context.dart
+++ b/pkg/analyzer/lib/src/dart/analysis/library_context.dart
@@ -4,7 +4,8 @@
import 'package:analyzer/context/declared_variables.dart';
import 'package:analyzer/dart/ast/ast.dart';
-import 'package:analyzer/dart/element/element.dart' show CompilationUnitElement;
+import 'package:analyzer/dart/element/element.dart'
+ show CompilationUnitElement, LibraryElement;
import 'package:analyzer/error/error.dart';
import 'package:analyzer/src/context/context.dart';
import 'package:analyzer/src/dart/analysis/byte_store.dart';
@@ -130,8 +131,9 @@ class LibraryContext {
byteStore.put(key, bytes);
});
- var analysisContext = _createAnalysisContext(
- options, declaredVariables, sourceFactory, fsState, store);
+ AnalysisContextImpl analysisContext = _createAnalysisContext(
+ options, declaredVariables, sourceFactory, store);
+ analysisContext.contentCache = new _ContentCacheWrapper(fsState);
return new LibraryContext._(store, analysisContext);
});
@@ -169,19 +171,37 @@ class LibraryContext {
return new ResolutionResult(resolvedUnit, errors);
}
- static AnalysisContext _createAnalysisContext(
- AnalysisOptions _analysisOptions,
+ /**
+ * Resynthesize the [LibraryElement] from the given [store].
+ */
+ static LibraryElement resynthesizeLibraryElement(
+ AnalysisOptions analysisOptions,
+ DeclaredVariables declaredVariables,
+ SourceFactory sourceFactory,
+ SummaryDataStore store,
+ String uri) {
+ AnalysisContextImpl analysisContext = _createAnalysisContext(
+ analysisOptions, declaredVariables, sourceFactory, store);
+ try {
+ return new StoreBasedSummaryResynthesizer(
+ analysisContext, sourceFactory, analysisOptions.strongMode, store)
+ .getLibraryElement(uri);
+ } finally {
+ analysisContext.dispose();
+ }
+ }
+
+ static AnalysisContextImpl _createAnalysisContext(
+ AnalysisOptions analysisOptions,
DeclaredVariables declaredVariables,
- SourceFactory _sourceFactory,
- FileSystemState fileSystemState,
+ SourceFactory sourceFactory,
SummaryDataStore store) {
AnalysisContextImpl analysisContext =
AnalysisEngine.instance.createAnalysisContext();
analysisContext.useSdkCachePartition = false;
- analysisContext.analysisOptions = _analysisOptions;
+ analysisContext.analysisOptions = analysisOptions;
analysisContext.declaredVariables.addAll(declaredVariables);
- analysisContext.sourceFactory = _sourceFactory.clone();
- analysisContext.contentCache = new _ContentCacheWrapper(fileSystemState);
+ analysisContext.sourceFactory = sourceFactory.clone();
analysisContext.resultProvider =
new InputPackagesResultProvider(analysisContext, store);
return analysisContext;
« no previous file with comments | « pkg/analyzer/lib/src/dart/analysis/driver.dart ('k') | pkg/analyzer/test/src/dart/analysis/driver_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698