OLD | NEW |
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.analysis_server; | 5 library test.analysis_server; |
6 | 6 |
7 import 'dart:async'; | 7 import 'dart:async'; |
8 | 8 |
9 import 'package:analysis_server/plugin/protocol/protocol.dart'; | 9 import 'package:analysis_server/plugin/protocol/protocol.dart'; |
10 import 'package:analysis_server/src/analysis_server.dart'; | 10 import 'package:analysis_server/src/analysis_server.dart'; |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
63 '''); | 63 '''); |
64 Source fooSource = foo.createSource(); | 64 Source fooSource = foo.createSource(); |
65 File bar = resourceProvider.newFile( | 65 File bar = resourceProvider.newFile( |
66 '/bar/bar.dart', | 66 '/bar/bar.dart', |
67 ''' | 67 ''' |
68 library bar; | 68 library bar; |
69 import "../foo/foo.dart"; | 69 import "../foo/foo.dart"; |
70 '''); | 70 '''); |
71 Source barSource = bar.createSource(); | 71 Source barSource = bar.createSource(); |
72 server.setAnalysisRoots('0', ['/foo', '/bar'], [], {}); | 72 server.setAnalysisRoots('0', ['/foo', '/bar'], [], {}); |
73 return pumpEventQueue(40).then((_) { | 73 return server.onAnalysisComplete.then((_) { |
74 expect(server.statusAnalyzing, isFalse); | 74 expect(server.statusAnalyzing, isFalse); |
75 // Make sure getAnalysisContext returns the proper context for each. | 75 // Make sure getAnalysisContext returns the proper context for each. |
76 AnalysisContext fooContext = | 76 AnalysisContext fooContext = |
77 server.getAnalysisContextForSource(fooSource); | 77 server.getAnalysisContextForSource(fooSource); |
78 expect(fooContext, isNotNull); | 78 expect(fooContext, isNotNull); |
79 AnalysisContext barContext = | 79 AnalysisContext barContext = |
80 server.getAnalysisContextForSource(barSource); | 80 server.getAnalysisContextForSource(barSource); |
81 expect(barContext, isNotNull); | 81 expect(barContext, isNotNull); |
82 expect(fooContext, isNot(same(barContext))); | 82 expect(fooContext, isNot(same(barContext))); |
83 expect(fooContext.getKindOf(fooSource), SourceKind.LIBRARY); | 83 expect(fooContext.getKindOf(fooSource), SourceKind.LIBRARY); |
(...skipping 19 matching lines...) Expand all Loading... |
103 File foo = resourceProvider.newFile('/foo/foo.dart', 'library lib;'); | 103 File foo = resourceProvider.newFile('/foo/foo.dart', 'library lib;'); |
104 Source fooSource = foo.createSource(); | 104 Source fooSource = foo.createSource(); |
105 File bar = resourceProvider.newFile('/bar/bar.dart', 'library lib;'); | 105 File bar = resourceProvider.newFile('/bar/bar.dart', 'library lib;'); |
106 Source barSource = bar.createSource(); | 106 Source barSource = bar.createSource(); |
107 server.setAnalysisRoots('0', ['/foo', '/bar'], [], {}); | 107 server.setAnalysisRoots('0', ['/foo', '/bar'], [], {}); |
108 AnalysisContext fooContext = server.getAnalysisContextForSource(fooSource); | 108 AnalysisContext fooContext = server.getAnalysisContextForSource(fooSource); |
109 expect(fooContext, isNotNull); | 109 expect(fooContext, isNotNull); |
110 AnalysisContext barContext = server.getAnalysisContextForSource(barSource); | 110 AnalysisContext barContext = server.getAnalysisContextForSource(barSource); |
111 expect(barContext, isNotNull); | 111 expect(barContext, isNotNull); |
112 expect(fooContext, isNot(same(barContext))); | 112 expect(fooContext, isNot(same(barContext))); |
113 return pumpEventQueue(40).then((_) { | 113 return server.onAnalysisComplete.then((_) { |
114 expect(server.statusAnalyzing, isFalse); | 114 expect(server.statusAnalyzing, isFalse); |
115 // Make sure getAnalysisContext returned the proper context for each. | 115 // Make sure getAnalysisContext returned the proper context for each. |
116 expect(fooContext.getKindOf(fooSource), SourceKind.LIBRARY); | 116 expect(fooContext.getKindOf(fooSource), SourceKind.LIBRARY); |
117 expect(fooContext.getKindOf(barSource), SourceKind.UNKNOWN); | 117 expect(fooContext.getKindOf(barSource), SourceKind.UNKNOWN); |
118 expect(barContext.getKindOf(fooSource), SourceKind.UNKNOWN); | 118 expect(barContext.getKindOf(fooSource), SourceKind.UNKNOWN); |
119 expect(barContext.getKindOf(barSource), SourceKind.LIBRARY); | 119 expect(barContext.getKindOf(barSource), SourceKind.LIBRARY); |
120 }); | 120 }); |
121 } | 121 } |
122 | 122 |
123 void processRequiredPlugins() { | 123 void processRequiredPlugins() { |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
229 server.serverServices = [ServerService.STATUS].toSet(); | 229 server.serverServices = [ServerService.STATUS].toSet(); |
230 // Analyze project foo containing foo.dart and project bar containing | 230 // Analyze project foo containing foo.dart and project bar containing |
231 // bar.dart. | 231 // bar.dart. |
232 resourceProvider.newFolder('/foo'); | 232 resourceProvider.newFolder('/foo'); |
233 resourceProvider.newFolder('/bar'); | 233 resourceProvider.newFolder('/bar'); |
234 File foo = resourceProvider.newFile('/foo/foo.dart', 'library lib;'); | 234 File foo = resourceProvider.newFile('/foo/foo.dart', 'library lib;'); |
235 Source fooSource = foo.createSource(); | 235 Source fooSource = foo.createSource(); |
236 File bar = resourceProvider.newFile('/bar/bar.dart', 'library lib;'); | 236 File bar = resourceProvider.newFile('/bar/bar.dart', 'library lib;'); |
237 Source barSource = bar.createSource(); | 237 Source barSource = bar.createSource(); |
238 server.setAnalysisRoots('0', ['/foo', '/bar'], [], {}); | 238 server.setAnalysisRoots('0', ['/foo', '/bar'], [], {}); |
239 return pumpEventQueue(500).then((_) { | 239 return server.onAnalysisComplete.then((_) { |
240 expect(server.statusAnalyzing, isFalse); | 240 expect(server.statusAnalyzing, isFalse); |
241 // Make sure getAnalysisContext returns the proper context for each. | 241 // Make sure getAnalysisContext returns the proper context for each. |
242 AnalysisContext fooContext = | 242 AnalysisContext fooContext = |
243 server.getAnalysisContextForSource(fooSource); | 243 server.getAnalysisContextForSource(fooSource); |
244 expect(fooContext, isNotNull); | 244 expect(fooContext, isNotNull); |
245 AnalysisContext barContext = | 245 AnalysisContext barContext = |
246 server.getAnalysisContextForSource(barSource); | 246 server.getAnalysisContextForSource(barSource); |
247 expect(barContext, isNotNull); | 247 expect(barContext, isNotNull); |
248 expect(fooContext, isNot(same(barContext))); | 248 expect(fooContext, isNot(same(barContext))); |
249 expect(fooContext.getKindOf(fooSource), SourceKind.LIBRARY); | 249 expect(fooContext.getKindOf(fooSource), SourceKind.LIBRARY); |
(...skipping 343 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
593 _MockServerOperation(this.context); | 593 _MockServerOperation(this.context); |
594 | 594 |
595 @override | 595 @override |
596 ServerOperationPriority get priority => ServerOperationPriority.ANALYSIS; | 596 ServerOperationPriority get priority => ServerOperationPriority.ANALYSIS; |
597 | 597 |
598 @override | 598 @override |
599 void perform(AnalysisServer server) { | 599 void perform(AnalysisServer server) { |
600 isComplete = true; | 600 isComplete = true; |
601 } | 601 } |
602 } | 602 } |
OLD | NEW |