From e5f3bb163bd9d2cd495566d421e3177b7ba6b0a5 Mon Sep 17 00:00:00 2001 From: pq Date: Tue, 13 Oct 2015 13:22:49 -0700 Subject: [PATCH] AS strong-mode .analysis_options awareness. R=brianwilkerson@google.com, leafp@google.com Review URL: https://codereview.chromium.org/1403983002 . --- .../lib/src/context_manager.dart | 10 ++++++++ .../test/context_manager_test.dart | 25 ++++++++++++++++--- 2 files changed, 32 insertions(+), 3 deletions(-) diff --git a/pkg/analysis_server/lib/src/context_manager.dart b/pkg/analysis_server/lib/src/context_manager.dart index 05a3fa108e7..3e72ad50054 100644 --- a/pkg/analysis_server/lib/src/context_manager.dart +++ b/pkg/analysis_server/lib/src/context_manager.dart @@ -484,6 +484,16 @@ class ContextManagerImpl implements ContextManager { return; } + // Set strong mode. + var strongMode = analyzer['strong-mode']; + if (strongMode == true) { + AnalysisContext context = info.context; + AnalysisOptionsImpl options = + new AnalysisOptionsImpl.from(context.analysisOptions); + options.strongMode = true; + context.analysisOptions = options; + } + // Set ignore patterns. YamlList exclude = analyzer['exclude']; if (exclude != null) { diff --git a/pkg/analysis_server/test/context_manager_test.dart b/pkg/analysis_server/test/context_manager_test.dart index 18e482c24c1..dc415095c1f 100644 --- a/pkg/analysis_server/test/context_manager_test.dart +++ b/pkg/analysis_server/test/context_manager_test.dart @@ -369,9 +369,6 @@ analyzer: expect(contexts[1].name, equals('/my/proj/lib')); } - // TODO(paulberry): This test only tests PackagesFileDisposition. - // Once http://dartbug.com/23909 is fixed, add a test for sdk extensions - // and PackageMapDisposition. test_refresh_folder_with_packagespec() { // create a context with a .packages file String packagespecFile = posix.join(projPath, '.packages'); @@ -388,6 +385,9 @@ analyzer: }); } + // TODO(paulberry): This test only tests PackagesFileDisposition. + // Once http://dartbug.com/23909 is fixed, add a test for sdk extensions + // and PackageMapDisposition. test_refresh_folder_with_packagespec_subfolders() { // Create a folder with no .packages file, containing two subfolders with // .packages files. @@ -1107,6 +1107,25 @@ test_pack:lib/ callbacks.assertContextFiles(project, [fileA]); } + test_strong_mode_analysis_option() async { + // Create files. + newFile( + [projPath, '.analysis_options'], + r''' +analyzer: + strong-mode: true +'''); + String libPath = newFolder([projPath, LIB_NAME]); + newFile([libPath, 'main.dart']); + // Setup context. + manager.setRoots([projPath], [], {}); + // Verify that analysis options was parsed and strong-mode set. + Map fileTimestamps = + callbacks.currentContextFilePaths[projPath]; + expect(fileTimestamps, isNotEmpty); + expect(callbacks.currentContext.analysisOptions.strongMode, true); + } + test_watch_addDummyLink() { manager.setRoots([projPath], [], {}); // empty folder initially