OLD | NEW |
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, 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.updateContent; | 5 library test.analysis.updateContent; |
6 | 6 |
7 import 'package:analysis_server/src/analysis_server.dart'; | 7 import 'package:analysis_server/src/analysis_server.dart'; |
8 import 'package:analysis_server/src/constants.dart'; | 8 import 'package:analysis_server/src/constants.dart'; |
9 import 'package:analysis_server/src/protocol.dart'; | 9 import 'package:analysis_server/src/protocol.dart'; |
10 import 'package:analysis_server/src/services/index/index.dart'; | 10 import 'package:analysis_server/src/services/index/index.dart'; |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
88 expect(e.response.id, id); | 88 expect(e.response.id, id); |
89 expect(e.response.error.code, RequestErrorCode.INVALID_OVERLAY_CHANGE); | 89 expect(e.response.error.code, RequestErrorCode.INVALID_OVERLAY_CHANGE); |
90 } | 90 } |
91 } | 91 } |
92 | 92 |
93 test_indexUnitAfterNopChange() async { | 93 test_indexUnitAfterNopChange() async { |
94 var testUnitMatcher = compilationUnitMatcher(testFile) as dynamic; | 94 var testUnitMatcher = compilationUnitMatcher(testFile) as dynamic; |
95 createProject(); | 95 createProject(); |
96 addTestFile('main() { print(1); }'); | 96 addTestFile('main() { print(1); }'); |
97 await server.onAnalysisComplete; | 97 await server.onAnalysisComplete; |
98 verify(server.index.indexUnit(anyObject, testUnitMatcher)).times(1); | 98 verify(server.index.index(anyObject, testUnitMatcher)).times(1); |
99 // add an overlay | 99 // add an overlay |
100 server.updateContent( | 100 server.updateContent( |
101 '1', {testFile: new AddContentOverlay('main() { print(2); }')}); | 101 '1', {testFile: new AddContentOverlay('main() { print(2); }')}); |
102 // Perform the next single operation: analysis. | 102 // Perform the next single operation: analysis. |
103 // It will schedule an indexing operation. | 103 // It will schedule an indexing operation. |
104 await server.test_onOperationPerformed; | 104 await server.test_onOperationPerformed; |
105 // Update the file and remove an overlay. | 105 // Update the file and remove an overlay. |
106 resourceProvider.updateFile(testFile, 'main() { print(2); }'); | 106 resourceProvider.updateFile(testFile, 'main() { print(2); }'); |
107 server.updateContent('2', {testFile: new RemoveContentOverlay()}); | 107 server.updateContent('2', {testFile: new RemoveContentOverlay()}); |
108 // Validate that at the end the unit was indexed. | 108 // Validate that at the end the unit was indexed. |
109 await server.onAnalysisComplete; | 109 await server.onAnalysisComplete; |
110 verify(server.index.indexUnit(anyObject, testUnitMatcher)).times(2); | 110 verify(server.index.index(anyObject, testUnitMatcher)).times(2); |
111 } | 111 } |
112 | 112 |
113 test_multiple_contexts() async { | 113 test_multiple_contexts() async { |
114 String fooPath = '/project1/foo.dart'; | 114 String fooPath = '/project1/foo.dart'; |
115 resourceProvider.newFile( | 115 resourceProvider.newFile( |
116 fooPath, | 116 fooPath, |
117 ''' | 117 ''' |
118 library foo; | 118 library foo; |
119 import '../project2/baz.dart'; | 119 import '../project2/baz.dart'; |
120 main() { f(); }'''); | 120 main() { f(); }'''); |
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
266 | 266 |
267 @override | 267 @override |
268 bool matches(arg) { | 268 bool matches(arg) { |
269 return arg is CompilationUnit && arg.element.source.fullName == file; | 269 return arg is CompilationUnit && arg.element.source.fullName == file; |
270 } | 270 } |
271 } | 271 } |
272 | 272 |
273 class _MockIndex extends TypedMock implements Index { | 273 class _MockIndex extends TypedMock implements Index { |
274 noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation); | 274 noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation); |
275 } | 275 } |
OLD | NEW |