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

Side by Side Diff: pkg/analyzer/test/src/context/context_test.dart

Issue 1405643002: Issue 24566. Main AnalysisContext.getLibrariesContaining() should work also for SDK sources. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 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.src.context.context_test; 5 library test.src.context.context_test;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 8
9 import 'package:analyzer/file_system/memory_file_system.dart'; 9 import 'package:analyzer/file_system/memory_file_system.dart';
10 import 'package:analyzer/src/cancelable_future.dart'; 10 import 'package:analyzer/src/cancelable_future.dart';
(...skipping 1191 matching lines...) Expand 10 before | Expand all | Expand 10 after
1202 // prepare "Stream" ClassElement 1202 // prepare "Stream" ClassElement
1203 ClassElement streamElement; 1203 ClassElement streamElement;
1204 { 1204 {
1205 CompilationUnitElement testUnit = testLibrary.definingCompilationUnit; 1205 CompilationUnitElement testUnit = testLibrary.definingCompilationUnit;
1206 InterfaceType streamType = testUnit.topLevelVariables[0].type; 1206 InterfaceType streamType = testUnit.topLevelVariables[0].type;
1207 streamElement = streamType.element; 1207 streamElement = streamType.element;
1208 } 1208 }
1209 // must be from SDK context 1209 // must be from SDK context
1210 AnalysisContext sdkContext = context.sourceFactory.dartSdk.context; 1210 AnalysisContext sdkContext = context.sourceFactory.dartSdk.context;
1211 expect(sdkContext, streamElement.context); 1211 expect(sdkContext, streamElement.context);
1212 // must be in the "async" library
1213 Source intSource = streamElement.source; 1212 Source intSource = streamElement.source;
1214 List<Source> coreLibraries = sdkContext.getLibrariesContaining(intSource); 1213 // must be in the "async" library - SDK context
1215 expect(coreLibraries, hasLength(1)); 1214 {
1216 Source coreSource = coreLibraries[0]; 1215 List<Source> coreLibraries = sdkContext.getLibrariesContaining(intSource);
1217 expect(coreSource.isInSystemLibrary, isTrue); 1216 expect(coreLibraries, hasLength(1));
1218 expect(coreSource.shortName, 'async.dart'); 1217 Source coreSource = coreLibraries[0];
1218 expect(coreSource.isInSystemLibrary, isTrue);
1219 expect(coreSource.shortName, 'async.dart');
1220 }
1221 // must be in the "async" library - main context
1222 {
1223 List<Source> coreLibraries = context.getLibrariesContaining(intSource);
1224 expect(coreLibraries, hasLength(1));
1225 Source coreSource = coreLibraries[0];
1226 expect(coreSource.isInSystemLibrary, isTrue);
1227 expect(coreSource.shortName, 'async.dart');
1228 }
1219 } 1229 }
1220 1230
1221 void test_getLineInfo() { 1231 void test_getLineInfo() {
1222 Source source = addSource( 1232 Source source = addSource(
1223 "/test.dart", 1233 "/test.dart",
1224 r''' 1234 r'''
1225 library lib; 1235 library lib;
1226 1236
1227 main() {}'''); 1237 main() {}''');
1228 LineInfo info = context.getLineInfo(source); 1238 LineInfo info = context.getLineInfo(source);
(...skipping 1313 matching lines...) Expand 10 before | Expand all | Expand 10 after
2542 } 2552 }
2543 } 2553 }
2544 2554
2545 class _AnalysisContextImplTest_test_applyChanges_removeContainer 2555 class _AnalysisContextImplTest_test_applyChanges_removeContainer
2546 implements SourceContainer { 2556 implements SourceContainer {
2547 Source libB; 2557 Source libB;
2548 _AnalysisContextImplTest_test_applyChanges_removeContainer(this.libB); 2558 _AnalysisContextImplTest_test_applyChanges_removeContainer(this.libB);
2549 @override 2559 @override
2550 bool contains(Source source) => source == libB; 2560 bool contains(Source source) => source == libB;
2551 } 2561 }
OLDNEW
« no previous file with comments | « pkg/analyzer/lib/src/task/dart_work_manager.dart ('k') | pkg/analyzer/test/src/task/dart_work_manager_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698