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

Side by Side Diff: pkg/analyzer/lib/src/dart/analysis/driver.dart

Issue 2658983004: Implement AnalysisDriver.getSourceKind() and use it in analyzer-cli. (Closed)
Patch Set: Created 3 years, 10 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 | « no previous file | pkg/analyzer/test/src/dart/analysis/driver_test.dart » ('j') | 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) 2016, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2016, 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 import 'dart:async'; 5 import 'dart:async';
6 import 'dart:collection'; 6 import 'dart:collection';
7 import 'dart:typed_data'; 7 import 'dart:typed_data';
8 8
9 import 'package:analyzer/context/declared_variables.dart'; 9 import 'package:analyzer/context/declared_variables.dart';
10 import 'package:analyzer/dart/ast/ast.dart'; 10 import 'package:analyzer/dart/ast/ast.dart';
(...skipping 569 matching lines...) Expand 10 before | Expand all | Expand 10 after
580 var completer = new Completer<AnalysisResult>(); 580 var completer = new Completer<AnalysisResult>();
581 _requestedFiles 581 _requestedFiles
582 .putIfAbsent(path, () => <Completer<AnalysisResult>>[]) 582 .putIfAbsent(path, () => <Completer<AnalysisResult>>[])
583 .add(completer); 583 .add(completer);
584 _statusSupport.transitionToAnalyzing(); 584 _statusSupport.transitionToAnalyzing();
585 _scheduler._notify(this); 585 _scheduler._notify(this);
586 return completer.future; 586 return completer.future;
587 } 587 }
588 588
589 /** 589 /**
590 * Return a [Future] that completes with the [SourceKind] for the Dart
591 * file with the given [path]. If the file is not a Dart file or cannot
592 * be analyzed, the [Future] completes with `null`.
593 *
594 * The [path] must be absolute and normalized.
595 */
596 Future<SourceKind> getSourceKind(String path) async {
597 if (AnalysisEngine.isDartFileName(path)) {
598 FileState file = _fsState.getFileForPath(path);
599 return file.isPart ? SourceKind.PART : SourceKind.LIBRARY;
600 }
601 return null;
602 }
603
604 /**
590 * Return a [Future] that completes with top-level declarations with the 605 * Return a [Future] that completes with top-level declarations with the
591 * given [name] in all known libraries. 606 * given [name] in all known libraries.
592 */ 607 */
593 Future<List<TopLevelDeclarationInSource>> getTopLevelNameDeclarations( 608 Future<List<TopLevelDeclarationInSource>> getTopLevelNameDeclarations(
594 String name) { 609 String name) {
595 var task = new _TopLevelNameDeclarationsTask(this, name); 610 var task = new _TopLevelNameDeclarationsTask(this, name);
596 _topLevelNameDeclarationsTasks.add(task); 611 _topLevelNameDeclarationsTasks.add(task);
597 _statusSupport.transitionToAnalyzing(); 612 _statusSupport.transitionToAnalyzing();
598 _scheduler._notify(this); 613 _scheduler._notify(this);
599 return task.completer.future; 614 return task.completer.future;
(...skipping 1162 matching lines...) Expand 10 before | Expand all | Expand 10 after
1762 libraryDeclarations.add(new TopLevelDeclarationInSource( 1777 libraryDeclarations.add(new TopLevelDeclarationInSource(
1763 file.source, declaration, isExported)); 1778 file.source, declaration, isExported));
1764 } 1779 }
1765 } 1780 }
1766 } 1781 }
1767 1782
1768 // We're not done yet. 1783 // We're not done yet.
1769 return false; 1784 return false;
1770 } 1785 }
1771 } 1786 }
OLDNEW
« no previous file with comments | « no previous file | pkg/analyzer/test/src/dart/analysis/driver_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698