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

Unified Diff: pkg/analysis_server/test/context_manager_test.dart

Issue 2361203004: Issue 27358. Reset AnalysisContext 'sourceFactory' and 'typeSystem' on analysis options change. (Closed)
Patch Set: Created 4 years, 3 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/analysis_server/test/context_manager_test.dart
diff --git a/pkg/analysis_server/test/context_manager_test.dart b/pkg/analysis_server/test/context_manager_test.dart
index 2a59a9b934c215ffd5730549c5cc40b0f13afa12..87f62fddfd25ebc48e1b0ea2cc4fb4e61bab3d6c 100644
--- a/pkg/analysis_server/test/context_manager_test.dart
+++ b/pkg/analysis_server/test/context_manager_test.dart
@@ -2335,6 +2335,58 @@ analyzer:
expect(errorProcessors, isEmpty);
}
+ test_optionsFile_update_strongMode() async {
+ var file = resourceProvider.newFile(
+ '$projPath/bin/test.dart',
+ r'''
+main() {
+ var paths = <int>[];
+ var names = <String>[];
+ paths.addAll(names.map((s) => s.length));
+}
+''');
+ resourceProvider.newFile(
+ '$projPath/$optionsFileName',
+ r'''
+analyzer:
+ strong-mode: false
+''');
+ // Create the context.
+ manager.setRoots(<String>[projPath], <String>[], <String, String>{});
+ await pumpEventQueue();
+
+ AnalysisContext context = manager.getContextFor(projPath);
+ Source testSource = context.getSourcesWithFullName(file.path).single;
+
+ // Not strong mode - both in the context and the SDK context.
+ {
+ AnalysisContext sdkContext = context.sourceFactory.dartSdk.context;
+ expect(context.analysisOptions.strongMode, isFalse);
+ expect(sdkContext.analysisOptions.strongMode, isFalse);
+ expect(context.computeErrors(testSource), isEmpty);
+ }
+
+ // Update the options file - turn on 'strong-mode'.
+ resourceProvider.updateFile(
+ '$projPath/$optionsFileName',
+ r'''
+analyzer:
+ strong-mode: true
+''');
+ await pumpEventQueue();
+
+ // Strong mode - both in the context and the SDK context.
+ {
+ AnalysisContext context = manager.getContextFor(projPath);
+ AnalysisContext sdkContext = context.sourceFactory.dartSdk.context;
+ expect(context.analysisOptions.strongMode, isTrue);
+ expect(sdkContext.analysisOptions.strongMode, isTrue);
+ // The code is strong-mode clean.
+ // Verify that TypeSystem was reset.
+ expect(context.computeErrors(testSource), isEmpty);
+ }
+ }
+
test_path_filter_analysis_option() async {
// Create files.
String libPath = newFolder([projPath, ContextManagerTest.LIB_NAME]);

Powered by Google App Engine
This is Rietveld 408576698