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

Side by Side 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, 2 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, 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 library test.context.directory.manager; 5 library test.context.directory.manager;
6 6
7 import 'dart:collection'; 7 import 'dart:collection';
8 import 'dart:io' as io; 8 import 'dart:io' as io;
9 9
10 import 'package:analysis_server/src/context_manager.dart'; 10 import 'package:analysis_server/src/context_manager.dart';
(...skipping 2317 matching lines...) Expand 10 before | Expand all | Expand 10 after
2328 # errors: 2328 # errors:
2329 # unused_local_variable: ignore 2329 # unused_local_variable: ignore
2330 '''); 2330 ''');
2331 // Setup context. 2331 // Setup context.
2332 manager.setRoots(<String>[projPath], <String>[], <String, String>{}); 2332 manager.setRoots(<String>[projPath], <String>[], <String, String>{});
2333 2333
2334 // Verify filter setup. 2334 // Verify filter setup.
2335 expect(errorProcessors, isEmpty); 2335 expect(errorProcessors, isEmpty);
2336 } 2336 }
2337 2337
2338 test_optionsFile_update_strongMode() async {
2339 var file = resourceProvider.newFile(
2340 '$projPath/bin/test.dart',
2341 r'''
2342 main() {
2343 var paths = <int>[];
2344 var names = <String>[];
2345 paths.addAll(names.map((s) => s.length));
2346 }
2347 ''');
2348 resourceProvider.newFile(
2349 '$projPath/$optionsFileName',
2350 r'''
2351 analyzer:
2352 strong-mode: false
2353 ''');
2354 // Create the context.
2355 manager.setRoots(<String>[projPath], <String>[], <String, String>{});
2356 await pumpEventQueue();
2357
2358 AnalysisContext context = manager.getContextFor(projPath);
2359 Source testSource = context.getSourcesWithFullName(file.path).single;
2360
2361 // Not strong mode - both in the context and the SDK context.
2362 {
2363 AnalysisContext sdkContext = context.sourceFactory.dartSdk.context;
2364 expect(context.analysisOptions.strongMode, isFalse);
2365 expect(sdkContext.analysisOptions.strongMode, isFalse);
2366 expect(context.computeErrors(testSource), isEmpty);
2367 }
2368
2369 // Update the options file - turn on 'strong-mode'.
2370 resourceProvider.updateFile(
2371 '$projPath/$optionsFileName',
2372 r'''
2373 analyzer:
2374 strong-mode: true
2375 ''');
2376 await pumpEventQueue();
2377
2378 // Strong mode - both in the context and the SDK context.
2379 {
2380 AnalysisContext context = manager.getContextFor(projPath);
2381 AnalysisContext sdkContext = context.sourceFactory.dartSdk.context;
2382 expect(context.analysisOptions.strongMode, isTrue);
2383 expect(sdkContext.analysisOptions.strongMode, isTrue);
2384 // The code is strong-mode clean.
2385 // Verify that TypeSystem was reset.
2386 expect(context.computeErrors(testSource), isEmpty);
2387 }
2388 }
2389
2338 test_path_filter_analysis_option() async { 2390 test_path_filter_analysis_option() async {
2339 // Create files. 2391 // Create files.
2340 String libPath = newFolder([projPath, ContextManagerTest.LIB_NAME]); 2392 String libPath = newFolder([projPath, ContextManagerTest.LIB_NAME]);
2341 newFile([libPath, 'main.dart']); 2393 newFile([libPath, 'main.dart']);
2342 newFile([libPath, 'nope.dart']); 2394 newFile([libPath, 'nope.dart']);
2343 String sdkExtPath = newFolder([projPath, 'sdk_ext']); 2395 String sdkExtPath = newFolder([projPath, 'sdk_ext']);
2344 newFile([sdkExtPath, 'entry.dart']); 2396 newFile([sdkExtPath, 'entry.dart']);
2345 String sdkExtSrcPath = newFolder([projPath, 'sdk_ext', 'src']); 2397 String sdkExtSrcPath = newFolder([projPath, 'sdk_ext', 'src']);
2346 newFile([sdkExtSrcPath, 'part.dart']); 2398 newFile([sdkExtSrcPath, 'part.dart']);
2347 // Setup analysis options file with ignore list. 2399 // Setup analysis options file with ignore list.
(...skipping 366 matching lines...) Expand 10 before | Expand all | Expand 10 after
2714 class TestUriResolver extends UriResolver { 2766 class TestUriResolver extends UriResolver {
2715 Map<Uri, Source> uriMap; 2767 Map<Uri, Source> uriMap;
2716 2768
2717 TestUriResolver(this.uriMap); 2769 TestUriResolver(this.uriMap);
2718 2770
2719 @override 2771 @override
2720 Source resolveAbsolute(Uri uri, [Uri actualUri]) { 2772 Source resolveAbsolute(Uri uri, [Uri actualUri]) {
2721 return uriMap[uri]; 2773 return uriMap[uri];
2722 } 2774 }
2723 } 2775 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698