Create new ProcessedOptions for every new file compiled.

With https://dart-review.googlesource.com/c/sdk/+/65082 CFE starts
requiring inputs in ProcessedOptions. We don't use it in Analyzer,
but this will help us avoid failing of all out tests.

R=brianwilkerson@google.com, paulberry@google.com

Bug: https://github.com/dart-lang/sdk/issues/33868
Change-Id: I5e1596b80b4c1940848ee774fe32700b778b2c0e
Reviewed-on: https://dart-review.googlesource.com/65164
Reviewed-by: Paul Berry <paulberry@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
diff --git a/pkg/analyzer/lib/src/dart/analysis/frontend_resolution.dart b/pkg/analyzer/lib/src/dart/analysis/frontend_resolution.dart
index bd22156..179242f 100644
--- a/pkg/analyzer/lib/src/dart/analysis/frontend_resolution.dart
+++ b/pkg/analyzer/lib/src/dart/analysis/frontend_resolution.dart
@@ -77,7 +77,7 @@
       'A compile() invocation is still executing.';
 
   /// Options used by the kernel compiler.
-  final ProcessedOptions _options;
+  final CompilerOptions _compilerOptions;
 
   /// The logger to report compilation progress.
   final PerformanceLog _logger;
@@ -171,7 +171,7 @@
     var uriTranslator = new UriTranslatorImpl(
         new TargetLibrariesSpecification('none', dartLibraries), packages);
     var errorListener = new _ErrorListener();
-    var options = new CompilerOptions()
+    var compilerOptions = new CompilerOptions()
       ..target = new _AnalyzerTarget(
           new TargetFlags(strongMode: analysisOptions.strongMode))
       ..reportMessages = false
@@ -179,15 +179,15 @@
       ..fileSystem = new _FileSystemAdaptor(fsState, pathContext)
       ..byteStore = byteStore
       ..onError = errorListener.onError;
-    var processedOptions = new ProcessedOptions(options);
 
     return new FrontEndCompiler._(
-        processedOptions, uriTranslator, errorListener);
+        compilerOptions, uriTranslator, errorListener);
   }
 
-  FrontEndCompiler._(this._options, this.uriTranslator, this._errorListener)
-      : _logger = _options.logger,
-        _fileSystem = _options.fileSystem;
+  FrontEndCompiler._(
+      this._compilerOptions, this.uriTranslator, this._errorListener)
+      : _logger = _compilerOptions.logger,
+        _fileSystem = _compilerOptions.fileSystem;
 
   /// Compile the library with the given absolute [uri], and everything it
   /// depends on. Return the result of the requested library compilation.
@@ -210,12 +210,15 @@
       }
     }
 
-    return _runWithFrontEndContext('Compile', () async {
+    return _runWithFrontEndContext('Compile', uri, (processedOptions) async {
       try {
         // Initialize the dill target once.
         if (_dillTarget == null) {
-          _dillTarget =
-              new DillTarget(_options.ticker, uriTranslator, _options.target);
+          _dillTarget = new DillTarget(
+            processedOptions.ticker,
+            uriTranslator,
+            processedOptions.target,
+          );
         }
 
         // Append new libraries from the current component.
@@ -347,10 +350,12 @@
     _component.libraries.forEach(processLibrary);
   }
 
-  Future<T> _runWithFrontEndContext<T>(String msg, Future<T> f()) async {
-    return await CompilerContext.runWithOptions(_options, (context) {
+  Future<T> _runWithFrontEndContext<T>(
+      String msg, Uri input, Future<T> Function(ProcessedOptions) f) async {
+    var processedOptions = new ProcessedOptions(_compilerOptions, [input]);
+    return await CompilerContext.runWithOptions(processedOptions, (context) {
       context.disableColors();
-      return _logger.runAsync(msg, f);
+      return _logger.runAsync(msg, () => f(processedOptions));
     });
   }
 }