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

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

Issue 2473003003: Implement 'Sort Members' for the new analysis driver. (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
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/dart/ast/ast.dart'; 9 import 'package:analyzer/dart/ast/ast.dart';
10 import 'package:analyzer/error/error.dart'; 10 import 'package:analyzer/error/error.dart';
11 import 'package:analyzer/error/listener.dart';
11 import 'package:analyzer/file_system/file_system.dart'; 12 import 'package:analyzer/file_system/file_system.dart';
12 import 'package:analyzer/src/context/context.dart'; 13 import 'package:analyzer/src/context/context.dart';
13 import 'package:analyzer/src/dart/analysis/byte_store.dart'; 14 import 'package:analyzer/src/dart/analysis/byte_store.dart';
14 import 'package:analyzer/src/dart/analysis/file_state.dart'; 15 import 'package:analyzer/src/dart/analysis/file_state.dart';
15 import 'package:analyzer/src/generated/engine.dart' 16 import 'package:analyzer/src/generated/engine.dart'
16 show AnalysisContext, AnalysisEngine, AnalysisOptions, ChangeSet; 17 show AnalysisContext, AnalysisEngine, AnalysisOptions, ChangeSet;
17 import 'package:analyzer/src/generated/source.dart'; 18 import 'package:analyzer/src/generated/source.dart';
18 import 'package:analyzer/src/summary/api_signature.dart'; 19 import 'package:analyzer/src/summary/api_signature.dart';
19 import 'package:analyzer/src/summary/format.dart'; 20 import 'package:analyzer/src/summary/format.dart';
20 import 'package:analyzer/src/summary/idl.dart'; 21 import 'package:analyzer/src/summary/idl.dart';
(...skipping 356 matching lines...) Expand 10 before | Expand all | Expand 10 after
377 378
378 /** 379 /**
379 * Return `true` if the file with the given [path] was explicitly added 380 * Return `true` if the file with the given [path] was explicitly added
380 * to analysis using [addFile]. 381 * to analysis using [addFile].
381 */ 382 */
382 bool isAddedFile(String path) { 383 bool isAddedFile(String path) {
383 return _explicitFiles.contains(path); 384 return _explicitFiles.contains(path);
384 } 385 }
385 386
386 /** 387 /**
388 * Return the [Future] that completes with a [ParseResult] for the file
389 * with the given [path].
390 *
391 * The [path] must be absolute and normalized.
392 *
393 * The [path] can be any file - explicitly or implicitly analyzed, or neither.
394 *
395 * The parsing is performed in the method itself, and the result is not
396 * produced through the [results] stream (just because it is not a fully
397 * resolved unit).
398 */
399 Future<ParseResult> parseFile(String path) async {
400 FileState file = _fsState.getFileForPath(path);
401 RecordingErrorListener listener = new RecordingErrorListener();
402 CompilationUnit unit = file.parse(listener);
403 return new ParseResult(file.path, file.uri, file.content, file.contentHash,
404 unit.lineInfo, unit, listener.errors);
405 }
406
407 /**
387 * Remove the file with the given [path] from the list of files to analyze. 408 * Remove the file with the given [path] from the list of files to analyze.
388 * 409 *
389 * The [path] must be absolute and normalized. 410 * The [path] must be absolute and normalized.
390 * 411 *
391 * The results of analysis of the file might still be produced by the 412 * The results of analysis of the file might still be produced by the
392 * [results] stream. The driver will try to stop producing these results, 413 * [results] stream. The driver will try to stop producing these results,
393 * but does not guarantee this. 414 * but does not guarantee this.
394 */ 415 */
395 void removeFile(String path) { 416 void removeFile(String path) {
396 _explicitFiles.remove(path); 417 _explicitFiles.remove(path);
(...skipping 392 matching lines...) Expand 10 before | Expand all | Expand 10 after
789 */ 810 */
790 bool get isAnalyzing => _analyzing; 811 bool get isAnalyzing => _analyzing;
791 812
792 /** 813 /**
793 * Return `true` is the driver is idle. 814 * Return `true` is the driver is idle.
794 */ 815 */
795 bool get isIdle => !_analyzing; 816 bool get isIdle => !_analyzing;
796 } 817 }
797 818
798 /** 819 /**
820 * The result of parsing of a single file.
821 *
822 * These results are self-consistent, i.e. [content], [contentHash], the
823 * resolved [unit] correspond to each other. But none of the results is
824 * guaranteed to be consistent with the state of the files.
825 */
826 class ParseResult {
827 /**
828 * The path of the parsed file, absolute and normalized.
829 */
830 final String path;
831
832 /**
833 * The URI of the file that corresponded to the [path].
834 */
835 final Uri uri;
836
837 /**
838 * The content of the file that was scanned and parsed.
839 */
840 final String content;
841
842 /**
843 * The MD5 hash of the [content].
844 */
845 final String contentHash;
846
847 /**
848 * Information about lines in the [content].
849 */
850 final LineInfo lineInfo;
851
852 /**
853 * The parsed, unresolved compilation unit for the [content].
854 */
855 final CompilationUnit unit;
856
857 /**
858 * The scanning and parsing errors.
859 */
860 final List<AnalysisError> errors;
861
862 ParseResult(this.path, this.uri, this.content, this.contentHash,
863 this.lineInfo, this.unit, this.errors);
864 }
865
866 /**
799 * This class is used to gather and print performance information. 867 * This class is used to gather and print performance information.
800 */ 868 */
801 class PerformanceLog { 869 class PerformanceLog {
802 final StringSink sink; 870 final StringSink sink;
803 int _level = 0; 871 int _level = 0;
804 872
805 PerformanceLog(this.sink); 873 PerformanceLog(this.sink);
806 874
807 /** 875 /**
808 * Enter a new execution section, which starts at one point of code, runs 876 * Enter a new execution section, which starts at one point of code, runs
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
954 /** 1022 /**
955 * Complete the [signal] future if it is not completed yet. It is safe to 1023 * Complete the [signal] future if it is not completed yet. It is safe to
956 * call this method multiple times, but the [signal] will complete only once. 1024 * call this method multiple times, but the [signal] will complete only once.
957 */ 1025 */
958 void notify() { 1026 void notify() {
959 if (!_completer.isCompleted) { 1027 if (!_completer.isCompleted) {
960 _completer.complete(null); 1028 _completer.complete(null);
961 } 1029 }
962 } 1030 }
963 } 1031 }
OLDNEW
« no previous file with comments | « pkg/analysis_server/test/edit/sort_members_test.dart ('k') | pkg/analyzer/lib/src/dart/analysis/file_state.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698