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

Side by Side Diff: pkg/analyzer/test/src/task/dart_test.dart

Issue 1850813002: Issue dartdoc#1124. Get used elements from directive comments. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 8 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
« no previous file with comments | « pkg/analyzer/test/generated/hint_code_test.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) 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 analyzer.test.src.task.dart_test; 5 library analyzer.test.src.task.dart_test;
6 6
7 import 'package:analyzer/dart/ast/ast.dart'; 7 import 'package:analyzer/dart/ast/ast.dart';
8 import 'package:analyzer/dart/ast/token.dart'; 8 import 'package:analyzer/dart/ast/token.dart';
9 import 'package:analyzer/dart/ast/visitor.dart'; 9 import 'package:analyzer/dart/ast/visitor.dart';
10 import 'package:analyzer/dart/element/element.dart'; 10 import 'package:analyzer/dart/element/element.dart';
(...skipping 2209 matching lines...) Expand 10 before | Expand all | Expand 10 after
2220 .evaluationResult, 2220 .evaluationResult,
2221 isNotNull); 2221 isNotNull);
2222 } 2222 }
2223 } 2223 }
2224 2224
2225 @reflectiveTest 2225 @reflectiveTest
2226 class GatherUsedImportedElementsTaskTest extends _AbstractDartTaskTest { 2226 class GatherUsedImportedElementsTaskTest extends _AbstractDartTaskTest {
2227 UsedImportedElements usedElements; 2227 UsedImportedElements usedElements;
2228 Set<String> usedElementNames; 2228 Set<String> usedElementNames;
2229 2229
2230 test_perform() { 2230 test_perform_inBody() {
2231 newSource( 2231 newSource(
2232 '/a.dart', 2232 '/a.dart',
2233 r''' 2233 r'''
2234 library lib_a; 2234 library lib_a;
2235 class A {} 2235 class A {}
2236 '''); 2236 ''');
2237 newSource( 2237 newSource(
2238 '/b.dart', 2238 '/b.dart',
2239 r''' 2239 r'''
2240 library lib_b; 2240 library lib_b;
2241 class B {} 2241 class B {}
2242 '''); 2242 ''');
2243 Source source = newSource( 2243 Source source = newSource(
2244 '/test.dart', 2244 '/test.dart',
2245 r''' 2245 r'''
2246 import 'a.dart'; 2246 import 'a.dart';
2247 import 'b.dart'; 2247 import 'b.dart';
2248 main() { 2248 main() {
2249 new A(); 2249 new A();
2250 }'''); 2250 }''');
2251 _computeUsedElements(source); 2251 _computeUsedElements(source);
2252 // validate 2252 // validate
2253 expect(usedElementNames, unorderedEquals(['A'])); 2253 expect(usedElementNames, unorderedEquals(['A']));
2254 } 2254 }
2255 2255
2256 test_perform_inComment_exportDirective() {
2257 Source source = newSource(
2258 '/test.dart',
2259 r'''
2260 import 'dart:async';
2261 /// Use [Future].
2262 export 'dart:math';
2263 ''');
2264 _computeUsedElements(source);
2265 expect(usedElementNames, unorderedEquals(['Future']));
2266 }
2267
2268 test_perform_inComment_importDirective() {
2269 Source source = newSource(
2270 '/test.dart',
2271 r'''
2272 import 'dart:async';
2273 /// Use [Future].
2274 import 'dart:math';
2275 ''');
2276 _computeUsedElements(source);
2277 expect(usedElementNames, unorderedEquals(['Future']));
2278 }
2279
2280 test_perform_inComment_libraryDirective() {
2281 Source source = newSource(
2282 '/test.dart',
2283 r'''
2284 /// Use [Future].
2285 library test;
2286 import 'dart:async';
2287 ''');
2288 _computeUsedElements(source);
2289 expect(usedElementNames, unorderedEquals(['Future']));
2290 }
2291
2292 test_perform_inComment_topLevelFunction() {
2293 Source source = newSource(
2294 '/test.dart',
2295 r'''
2296 import 'dart:async';
2297 /// Use [Future].
2298 main() {}
2299 ''');
2300 _computeUsedElements(source);
2301 expect(usedElementNames, unorderedEquals(['Future']));
2302 }
2303
2256 void _computeUsedElements(Source source) { 2304 void _computeUsedElements(Source source) {
2257 LibrarySpecificUnit target = new LibrarySpecificUnit(source, source); 2305 LibrarySpecificUnit target = new LibrarySpecificUnit(source, source);
2258 computeResult(target, USED_IMPORTED_ELEMENTS, 2306 computeResult(target, USED_IMPORTED_ELEMENTS,
2259 matcher: isGatherUsedImportedElementsTask); 2307 matcher: isGatherUsedImportedElementsTask);
2260 usedElements = outputs[USED_IMPORTED_ELEMENTS]; 2308 usedElements = outputs[USED_IMPORTED_ELEMENTS];
2261 usedElementNames = usedElements.elements.map((e) => e.name).toSet(); 2309 usedElementNames = usedElements.elements.map((e) => e.name).toSet();
2262 } 2310 }
2263 } 2311 }
2264 2312
2265 @reflectiveTest 2313 @reflectiveTest
(...skipping 2770 matching lines...) Expand 10 before | Expand all | Expand 10 after
5036 /** 5084 /**
5037 * Fill [errorListener] with [result] errors in the current [task]. 5085 * Fill [errorListener] with [result] errors in the current [task].
5038 */ 5086 */
5039 void _fillErrorListener(ResultDescriptor<List<AnalysisError>> result) { 5087 void _fillErrorListener(ResultDescriptor<List<AnalysisError>> result) {
5040 List<AnalysisError> errors = task.outputs[result]; 5088 List<AnalysisError> errors = task.outputs[result];
5041 expect(errors, isNotNull, reason: result.name); 5089 expect(errors, isNotNull, reason: result.name);
5042 errorListener = new GatheringErrorListener(); 5090 errorListener = new GatheringErrorListener();
5043 errorListener.addAll(errors); 5091 errorListener.addAll(errors);
5044 } 5092 }
5045 } 5093 }
OLDNEW
« no previous file with comments | « pkg/analyzer/test/generated/hint_code_test.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698