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

Side by Side Diff: pkg/analysis_server/test/domain_analysis_test.dart

Issue 2525693002: Use single unit/node/element. (Closed)
Patch Set: Created 4 years, 1 month 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
« no previous file with comments | « pkg/analysis_server/lib/src/search/search_domain.dart ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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.domain.analysis; 5 library test.domain.analysis;
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 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
109 String fileA = '/project/aaa/a.dart'; 109 String fileA = '/project/aaa/a.dart';
110 String fileB = '/project/bbb/b.dart'; 110 String fileB = '/project/bbb/b.dart';
111 resourceProvider.newFile(fileA, '// a'); 111 resourceProvider.newFile(fileA, '// a');
112 resourceProvider.newFile(fileB, '// b'); 112 resourceProvider.newFile(fileB, '// b');
113 var response = testSetAnalysisRoots(['/project'], ['/project/bbb']); 113 var response = testSetAnalysisRoots(['/project'], ['/project/bbb']);
114 var serverRef = server; 114 var serverRef = server;
115 expect(response, isResponseSuccess('0')); 115 expect(response, isResponseSuccess('0'));
116 // unit "a" is resolved eventually 116 // unit "a" is resolved eventually
117 // unit "b" is not resolved 117 // unit "b" is not resolved
118 return server.onAnalysisComplete.then((_) { 118 return server.onAnalysisComplete.then((_) {
119 expect(serverRef.getResolvedCompilationUnits(fileA), hasLength(1)); 119 expect(serverRef.getResolvedCompilationUnit(fileA), isNotNull);
120 expect(serverRef.getResolvedCompilationUnits(fileB), isEmpty); 120 expect(serverRef.getResolvedCompilationUnit(fileB), isNull);
121 }); 121 });
122 }); 122 });
123 123
124 test('not absolute', () async { 124 test('not absolute', () async {
125 var response = testSetAnalysisRoots([], ['foo/bar']); 125 var response = testSetAnalysisRoots([], ['foo/bar']);
126 expect( 126 expect(
127 response, 127 response,
128 isResponseFailure( 128 isResponseFailure(
129 '0', RequestErrorCode.INVALID_FILE_PATH_FORMAT)); 129 '0', RequestErrorCode.INVALID_FILE_PATH_FORMAT));
130 }); 130 });
(...skipping 10 matching lines...) Expand all
141 group('included', () { 141 group('included', () {
142 test('new folder', () { 142 test('new folder', () {
143 String file = '/project/bin/test.dart'; 143 String file = '/project/bin/test.dart';
144 resourceProvider.newFile('/project/pubspec.yaml', 'name: project'); 144 resourceProvider.newFile('/project/pubspec.yaml', 'name: project');
145 resourceProvider.newFile(file, 'main() {}'); 145 resourceProvider.newFile(file, 'main() {}');
146 var response = testSetAnalysisRoots(['/project'], []); 146 var response = testSetAnalysisRoots(['/project'], []);
147 var serverRef = server; 147 var serverRef = server;
148 expect(response, isResponseSuccess('0')); 148 expect(response, isResponseSuccess('0'));
149 // verify that unit is resolved eventually 149 // verify that unit is resolved eventually
150 return server.onAnalysisComplete.then((_) { 150 return server.onAnalysisComplete.then((_) {
151 var units = serverRef.getResolvedCompilationUnits(file); 151 var unit = serverRef.getResolvedCompilationUnit(file);
152 expect(units, hasLength(1)); 152 expect(unit, isNotNull);
153 }); 153 });
154 }); 154 });
155 155
156 test('nonexistent folder', () async { 156 test('nonexistent folder', () async {
157 String fileB = '/project_b/b.dart'; 157 String fileB = '/project_b/b.dart';
158 resourceProvider.newFile(fileB, '// b'); 158 resourceProvider.newFile(fileB, '// b');
159 var response = testSetAnalysisRoots(['/project_a', '/project_b'], []); 159 var response = testSetAnalysisRoots(['/project_a', '/project_b'], []);
160 var serverRef = server; 160 var serverRef = server;
161 expect(response, isResponseSuccess('0')); 161 expect(response, isResponseSuccess('0'));
162 // Non-existence of /project_a should not prevent files in /project_b 162 // Non-existence of /project_a should not prevent files in /project_b
163 // from being analyzed. 163 // from being analyzed.
164 await server.onAnalysisComplete; 164 await server.onAnalysisComplete;
165 expect(serverRef.getResolvedCompilationUnits(fileB), hasLength(1)); 165 expect(serverRef.getResolvedCompilationUnit(fileB), isNotNull);
166 }); 166 });
167 167
168 test('not absolute', () async { 168 test('not absolute', () async {
169 var response = testSetAnalysisRoots(['foo/bar'], []); 169 var response = testSetAnalysisRoots(['foo/bar'], []);
170 expect( 170 expect(
171 response, 171 response,
172 isResponseFailure( 172 isResponseFailure(
173 '0', RequestErrorCode.INVALID_FILE_PATH_FORMAT)); 173 '0', RequestErrorCode.INVALID_FILE_PATH_FORMAT));
174 }); 174 });
175 175
(...skipping 599 matching lines...) Expand 10 before | Expand all | Expand 10 after
775 test_beforeAnalysis() async { 775 test_beforeAnalysis() async {
776 addTestFile('int V = 42;'); 776 addTestFile('int V = 42;');
777 createProject(); 777 createProject();
778 // subscribe 778 // subscribe
779 addAnalysisSubscription(AnalysisService.HIGHLIGHTS, testFile); 779 addAnalysisSubscription(AnalysisService.HIGHLIGHTS, testFile);
780 // wait for analysis 780 // wait for analysis
781 await waitForTasksFinished(); 781 await waitForTasksFinished();
782 expect(filesHighlights[testFile], isNotEmpty); 782 expect(filesHighlights[testFile], isNotEmpty);
783 } 783 }
784 } 784 }
OLDNEW
« no previous file with comments | « pkg/analysis_server/lib/src/search/search_domain.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698