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

Side by Side Diff: pkg/analyzer/lib/src/task/dart.dart

Issue 1118963003: Fix for computing IS_CLIENT. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 5 years, 7 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 | Annotate | Revision Log
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.src.task.dart; 5 library analyzer.src.task.dart;
6 6
7 import 'dart:collection'; 7 import 'dart:collection';
8 import 'dart:math' as math; 8 import 'dart:math' as math;
9 9
10 import 'package:analyzer/src/generated/ast.dart'; 10 import 'package:analyzer/src/generated/ast.dart';
(...skipping 1418 matching lines...) Expand 10 before | Expand all | Expand 10 after
1429 } 1429 }
1430 1430
1431 /** 1431 /**
1432 * A task that builds [IMPORT_SOURCE_CLOSURE] and [EXPORT_SOURCE_CLOSURE] of 1432 * A task that builds [IMPORT_SOURCE_CLOSURE] and [EXPORT_SOURCE_CLOSURE] of
1433 * a library. 1433 * a library.
1434 */ 1434 */
1435 class BuildSourceClosuresTask extends SourceBasedAnalysisTask { 1435 class BuildSourceClosuresTask extends SourceBasedAnalysisTask {
1436 /** 1436 /**
1437 * The name of the import closure. 1437 * The name of the import closure.
1438 */ 1438 */
1439 static const String IMPORT_CLOSURE_INPUT = 'IMPORT_CLOSURE_INPUT'; 1439 static const String IMPORT_INPUT = 'IMPORT_INPUT';
1440 1440
1441 /** 1441 /**
1442 * The name of the export closure. 1442 * The name of the export closure.
1443 */ 1443 */
1444 static const String EXPORT_CLOSURE_INPUT = 'EXPORT_CLOSURE_INPUT'; 1444 static const String EXPORT_INPUT = 'EXPORT_INPUT';
1445
1446 /**
1447 * The name of the import/export closure.
1448 */
1449 static const String IMPORT_EXPORT_INPUT = 'IMPORT_EXPORT_INPUT';
1445 1450
1446 /** 1451 /**
1447 * The task descriptor describing this kind of task. 1452 * The task descriptor describing this kind of task.
1448 */ 1453 */
1449 static final TaskDescriptor DESCRIPTOR = new TaskDescriptor( 1454 static final TaskDescriptor DESCRIPTOR = new TaskDescriptor(
1450 'BuildExportSourceClosureTask', createTask, buildInputs, 1455 'BuildExportSourceClosureTask', createTask, buildInputs,
1451 <ResultDescriptor>[ 1456 <ResultDescriptor>[
1452 IMPORT_SOURCE_CLOSURE, 1457 IMPORT_SOURCE_CLOSURE,
1453 EXPORT_SOURCE_CLOSURE, 1458 EXPORT_SOURCE_CLOSURE,
1454 IS_CLIENT 1459 IS_CLIENT
1455 ]); 1460 ]);
1456 1461
1457 BuildSourceClosuresTask( 1462 BuildSourceClosuresTask(
1458 InternalAnalysisContext context, AnalysisTarget target) 1463 InternalAnalysisContext context, AnalysisTarget target)
1459 : super(context, target); 1464 : super(context, target);
1460 1465
1461 @override 1466 @override
1462 TaskDescriptor get descriptor => DESCRIPTOR; 1467 TaskDescriptor get descriptor => DESCRIPTOR;
1463 1468
1464 @override 1469 @override
1465 void internalPerform() { 1470 void internalPerform() {
1466 List<Source> importClosure = getRequiredInput(IMPORT_CLOSURE_INPUT); 1471 List<Source> importClosure = getRequiredInput(IMPORT_INPUT);
1467 List<Source> exportClosure = getRequiredInput(EXPORT_CLOSURE_INPUT); 1472 List<Source> exportClosure = getRequiredInput(EXPORT_INPUT);
1473 List<Source> importExportClosure = getRequiredInput(IMPORT_EXPORT_INPUT);
1468 Source htmlSource = context.sourceFactory.forUri(DartSdk.DART_HTML); 1474 Source htmlSource = context.sourceFactory.forUri(DartSdk.DART_HTML);
1469 // 1475 //
1470 // Record outputs. 1476 // Record outputs.
1471 // 1477 //
1472 outputs[IMPORT_SOURCE_CLOSURE] = importClosure; 1478 outputs[IMPORT_SOURCE_CLOSURE] = importClosure;
1473 outputs[EXPORT_SOURCE_CLOSURE] = exportClosure; 1479 outputs[EXPORT_SOURCE_CLOSURE] = exportClosure;
1474 outputs[IS_CLIENT] = importClosure.contains(htmlSource); 1480 outputs[IS_CLIENT] = importExportClosure.contains(htmlSource);
1475 } 1481 }
1476 1482
1477 /** 1483 /**
1478 * Return a map from the names of the inputs of this kind of task to the task 1484 * Return a map from the names of the inputs of this kind of task to the task
1479 * input descriptors describing those inputs for a task with the 1485 * input descriptors describing those inputs for a task with the
1480 * given library [libSource]. 1486 * given library [libSource].
1481 */ 1487 */
1482 static Map<String, TaskInput> buildInputs(Source libSource) { 1488 static Map<String, TaskInput> buildInputs(Source libSource) {
1483 return <String, TaskInput>{ 1489 return <String, TaskInput>{
1484 IMPORT_CLOSURE_INPUT: new _ImportSourceClosureTaskInput(libSource), 1490 IMPORT_INPUT: new _ImportSourceClosureTaskInput(libSource),
1485 EXPORT_CLOSURE_INPUT: new _ExportSourceClosureTaskInput(libSource) 1491 EXPORT_INPUT: new _ExportSourceClosureTaskInput(libSource),
1492 IMPORT_EXPORT_INPUT: new _ImportExportSourceClosureTaskInput(libSource)
1486 }; 1493 };
1487 } 1494 }
1488 1495
1489 /** 1496 /**
1490 * Create a [BuildSourceClosuresTask] based on the given [target] in 1497 * Create a [BuildSourceClosuresTask] based on the given [target] in
1491 * the given [context]. 1498 * the given [context].
1492 */ 1499 */
1493 static BuildSourceClosuresTask createTask( 1500 static BuildSourceClosuresTask createTask(
1494 AnalysisContext context, AnalysisTarget target) { 1501 AnalysisContext context, AnalysisTarget target) {
1495 return new BuildSourceClosuresTask(context, target); 1502 return new BuildSourceClosuresTask(context, target);
(...skipping 1016 matching lines...) Expand 10 before | Expand all | Expand 10 after
2512 _ExportSourceClosureTaskInput(this.target); 2519 _ExportSourceClosureTaskInput(this.target);
2513 2520
2514 @override 2521 @override
2515 TaskInputBuilder<List<Source>> createBuilder() => 2522 TaskInputBuilder<List<Source>> createBuilder() =>
2516 new _SourceClosureTaskInputBuilder(target, _SourceClosureKind.EXPORT); 2523 new _SourceClosureTaskInputBuilder(target, _SourceClosureKind.EXPORT);
2517 } 2524 }
2518 2525
2519 /** 2526 /**
2520 * The kind of the source closure to build. 2527 * The kind of the source closure to build.
2521 */ 2528 */
2522 enum _SourceClosureKind { IMPORT, EXPORT } 2529 enum _SourceClosureKind { IMPORT, EXPORT, IMPORT_EXPORT }
2530
2531 /**
2532 * A [TaskInput] whose value is a list of library sources imported or exported,
2533 * directly or indirectly by the target [Source].
2534 */
2535 class _ImportExportSourceClosureTaskInput implements TaskInput<List<Source>> {
2536 final Source target;
2537
2538 _ImportExportSourceClosureTaskInput(this.target);
2539
2540 @override
2541 TaskInputBuilder<List<Source>> createBuilder() =>
2542 new _SourceClosureTaskInputBuilder(
2543 target, _SourceClosureKind.IMPORT_EXPORT);
2544 }
2523 2545
2524 /** 2546 /**
2525 * A [TaskInput] whose value is a list of library sources imported directly 2547 * A [TaskInput] whose value is a list of library sources imported directly
2526 * or indirectly by the target [Source]. 2548 * or indirectly by the target [Source].
2527 */ 2549 */
2528 class _ImportSourceClosureTaskInput implements TaskInput<List<Source>> { 2550 class _ImportSourceClosureTaskInput implements TaskInput<List<Source>> {
2529 final Source target; 2551 final Source target;
2530 2552
2531 _ImportSourceClosureTaskInput(this.target); 2553 _ImportSourceClosureTaskInput(this.target);
2532 2554
(...skipping 15 matching lines...) Expand all
2548 _SourceClosureTaskInputBuilder(Source librarySource, this.kind) { 2570 _SourceClosureTaskInputBuilder(Source librarySource, this.kind) {
2549 _newSources.add(librarySource); 2571 _newSources.add(librarySource);
2550 } 2572 }
2551 2573
2552 @override 2574 @override
2553 ResultDescriptor get currentResult => LIBRARY_ELEMENT2; 2575 ResultDescriptor get currentResult => LIBRARY_ELEMENT2;
2554 2576
2555 @override 2577 @override
2556 void set currentValue(LibraryElement library) { 2578 void set currentValue(LibraryElement library) {
2557 if (_libraries.add(library)) { 2579 if (_libraries.add(library)) {
2558 if (kind == _SourceClosureKind.IMPORT) { 2580 if (kind == _SourceClosureKind.IMPORT ||
2581 kind == _SourceClosureKind.IMPORT_EXPORT) {
2559 for (ImportElement importElement in library.imports) { 2582 for (ImportElement importElement in library.imports) {
2560 Source importedSource = importElement.importedLibrary.source; 2583 Source importedSource = importElement.importedLibrary.source;
2561 _newSources.add(importedSource); 2584 _newSources.add(importedSource);
2562 } 2585 }
2563 } else { 2586 }
2587 if (kind == _SourceClosureKind.EXPORT ||
2588 kind == _SourceClosureKind.IMPORT_EXPORT) {
2564 for (ExportElement exportElement in library.exports) { 2589 for (ExportElement exportElement in library.exports) {
2565 Source importedSource = exportElement.exportedLibrary.source; 2590 Source exportedSource = exportElement.exportedLibrary.source;
2566 _newSources.add(importedSource); 2591 _newSources.add(exportedSource);
2567 } 2592 }
2568 } 2593 }
2569 } 2594 }
2570 } 2595 }
2571 2596
2572 @override 2597 @override
2573 List<Source> get inputValue { 2598 List<Source> get inputValue {
2574 return _libraries.map((LibraryElement library) => library.source).toList(); 2599 return _libraries.map((LibraryElement library) => library.source).toList();
2575 } 2600 }
2576 2601
2577 @override 2602 @override
2578 bool moveNext() { 2603 bool moveNext() {
2579 if (_newSources.isEmpty) { 2604 if (_newSources.isEmpty) {
2580 return false; 2605 return false;
2581 } 2606 }
2582 currentTarget = _newSources.first; 2607 currentTarget = _newSources.first;
2583 _newSources.remove(currentTarget); 2608 _newSources.remove(currentTarget);
2584 return true; 2609 return true;
2585 } 2610 }
2586 } 2611 }
OLDNEW
« no previous file with comments | « pkg/analyzer/lib/src/context/context.dart ('k') | pkg/analyzer/test/src/context/context_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698