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

Side by Side Diff: pkg/analysis_server/test/src/plugin/plugin_watcher_test.dart

Issue 2954153002: Add AnalysisSession to analyzer (Closed)
Patch Set: Created 3 years, 6 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) 2017, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2017, 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 import 'dart:async'; 5 import 'dart:async';
6 import 'dart:typed_data'; 6 import 'dart:typed_data';
7 7
8 import 'package:analysis_server/src/plugin/plugin_locator.dart'; 8 import 'package:analysis_server/src/plugin/plugin_locator.dart';
9 import 'package:analysis_server/src/plugin/plugin_manager.dart'; 9 import 'package:analysis_server/src/plugin/plugin_manager.dart';
10 import 'package:analysis_server/src/plugin/plugin_watcher.dart'; 10 import 'package:analysis_server/src/plugin/plugin_watcher.dart';
11 import 'package:analyzer/context/context_root.dart'; 11 import 'package:analyzer/context/context_root.dart';
12 import 'package:analyzer/dart/analysis/session.dart';
12 import 'package:analyzer/file_system/memory_file_system.dart'; 13 import 'package:analyzer/file_system/memory_file_system.dart';
13 import 'package:analyzer/source/package_map_resolver.dart'; 14 import 'package:analyzer/source/package_map_resolver.dart';
14 import 'package:analyzer/src/dart/analysis/driver.dart'; 15 import 'package:analyzer/src/dart/analysis/driver.dart';
15 import 'package:analyzer/src/dart/analysis/file_state.dart'; 16 import 'package:analyzer/src/dart/analysis/file_state.dart';
17 import 'package:analyzer/src/dart/analysis/session.dart';
16 import 'package:analyzer/src/generated/engine.dart' show AnalysisOptionsImpl; 18 import 'package:analyzer/src/generated/engine.dart' show AnalysisOptionsImpl;
17 import 'package:analyzer/src/generated/source.dart'; 19 import 'package:analyzer/src/generated/source.dart';
18 import 'package:front_end/src/base/performace_logger.dart'; 20 import 'package:front_end/src/base/performace_logger.dart';
19 import 'package:front_end/src/incremental/byte_store.dart'; 21 import 'package:front_end/src/incremental/byte_store.dart';
20 import 'package:path/path.dart' as path; 22 import 'package:path/path.dart' as path;
21 import 'package:test/test.dart'; 23 import 'package:test/test.dart';
22 import 'package:test_reflective_loader/test_reflective_loader.dart'; 24 import 'package:test_reflective_loader/test_reflective_loader.dart';
23 25
24 import '../../mock_sdk.dart'; 26 import '../../mock_sdk.dart';
25 27
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
90 watcher.removedDriver(driver); 92 watcher.removedDriver(driver);
91 expect(manager.removedContextRoots, equals([contextRoot])); 93 expect(manager.removedContextRoots, equals([contextRoot]));
92 } 94 }
93 } 95 }
94 96
95 class TestDriver implements AnalysisDriver { 97 class TestDriver implements AnalysisDriver {
96 final MemoryResourceProvider resourceProvider; 98 final MemoryResourceProvider resourceProvider;
97 99
98 SourceFactory sourceFactory; 100 SourceFactory sourceFactory;
99 FileSystemState fsState; 101 FileSystemState fsState;
102 AnalysisSession currentSession;
100 103
101 final _resultController = new StreamController<AnalysisResult>(); 104 final _resultController = new StreamController<AnalysisResult>();
102 105
103 TestDriver(this.resourceProvider, ContextRoot contextRoot) { 106 TestDriver(this.resourceProvider, ContextRoot contextRoot) {
104 path.Context pathContext = resourceProvider.pathContext; 107 path.Context pathContext = resourceProvider.pathContext;
105 MockSdk sdk = new MockSdk(resourceProvider: resourceProvider); 108 MockSdk sdk = new MockSdk(resourceProvider: resourceProvider);
106 String packageName = pathContext.basename(contextRoot.root); 109 String packageName = pathContext.basename(contextRoot.root);
107 String libPath = pathContext.join(contextRoot.root, 'lib'); 110 String libPath = pathContext.join(contextRoot.root, 'lib');
108 sourceFactory = new SourceFactory([ 111 sourceFactory = new SourceFactory([
109 new DartUriResolver(sdk), 112 new DartUriResolver(sdk),
110 new PackageMapUriResolver(resourceProvider, { 113 new PackageMapUriResolver(resourceProvider, {
111 packageName: [resourceProvider.getFolder(libPath)], 114 packageName: [resourceProvider.getFolder(libPath)],
112 'pkg2': [ 115 'pkg2': [
113 resourceProvider.getFolder(resourceProvider.convertPath('/pkg2/lib')) 116 resourceProvider.getFolder(resourceProvider.convertPath('/pkg2/lib'))
114 ] 117 ]
115 }) 118 })
116 ]); 119 ]);
117 fsState = new FileSystemState( 120 fsState = new FileSystemState(
118 new PerformanceLog(null), 121 new PerformanceLog(null),
119 new MemoryByteStore(), 122 new MemoryByteStore(),
120 null, 123 null,
121 resourceProvider, 124 resourceProvider,
122 sourceFactory, 125 sourceFactory,
123 new AnalysisOptionsImpl(), 126 new AnalysisOptionsImpl(),
124 new Uint32List(0)); 127 new Uint32List(0));
128 currentSession = new DriverBasedAnalysisSession(this);
125 } 129 }
126 130
127 Stream<AnalysisResult> get results => _resultController.stream; 131 Stream<AnalysisResult> get results => _resultController.stream;
128 132
129 Future<Null> computeResult(String uri) { 133 Future<Null> computeResult(String uri) {
130 FileState file = fsState.getFileForUri(Uri.parse(uri)); 134 FileState file = fsState.getFileForUri(Uri.parse(uri));
131 AnalysisResult result = new AnalysisResult( 135 AnalysisResult result = new AnalysisResult(
132 this, null, file.path, null, true, null, null, null, null, null, null); 136 this, null, file.path, null, true, null, null, null, null, null, null);
133 _resultController.add(result); 137 _resultController.add(result);
134 return new Future.delayed(new Duration(milliseconds: 1)); 138 return new Future.delayed(new Duration(milliseconds: 1));
(...skipping 14 matching lines...) Expand all
149 return null; 153 return null;
150 } 154 }
151 155
152 noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation); 156 noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation);
153 157
154 @override 158 @override
155 void removedContextRoot(ContextRoot contextRoot) { 159 void removedContextRoot(ContextRoot contextRoot) {
156 removedContextRoots.add(contextRoot); 160 removedContextRoots.add(contextRoot);
157 } 161 }
158 } 162 }
OLDNEW
« no previous file with comments | « no previous file | pkg/analyzer/lib/dart/analysis/results.dart » ('j') | pkg/analyzer/lib/dart/analysis/session.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698