OLD | NEW |
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 edit.domain; | 5 library edit.domain; |
6 | 6 |
7 import 'dart:async'; | 7 import 'dart:async'; |
8 | 8 |
9 import 'package:analysis_server/plugin/edit/assist/assist_core.dart'; | 9 import 'package:analysis_server/plugin/edit/assist/assist_core.dart'; |
10 import 'package:analysis_server/plugin/edit/assist/assist_dart.dart'; | 10 import 'package:analysis_server/plugin/edit/assist/assist_dart.dart'; |
(...skipping 618 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
629 } | 629 } |
630 _reset(); | 630 _reset(); |
631 }); | 631 }); |
632 } | 632 } |
633 | 633 |
634 /** | 634 /** |
635 * Perform enough analysis to be able to perform refactoring of the given | 635 * Perform enough analysis to be able to perform refactoring of the given |
636 * [kind] in the given [file]. | 636 * [kind] in the given [file]. |
637 */ | 637 */ |
638 Future<Null> _analyzeForRefactoring(String file, RefactoringKind kind) async { | 638 Future<Null> _analyzeForRefactoring(String file, RefactoringKind kind) async { |
| 639 if (server.options.enableNewAnalysisDriver) { |
| 640 return; |
| 641 } |
639 // "Extract Local" and "Inline Local" refactorings need only local analysis. | 642 // "Extract Local" and "Inline Local" refactorings need only local analysis. |
640 if (kind == RefactoringKind.EXTRACT_LOCAL_VARIABLE || | 643 if (kind == RefactoringKind.EXTRACT_LOCAL_VARIABLE || |
641 kind == RefactoringKind.INLINE_LOCAL_VARIABLE) { | 644 kind == RefactoringKind.INLINE_LOCAL_VARIABLE) { |
642 ContextSourcePair pair = server.getContextSourcePair(file); | 645 ContextSourcePair pair = server.getContextSourcePair(file); |
643 engine.AnalysisContext context = pair.context; | 646 engine.AnalysisContext context = pair.context; |
644 Source source = pair.source; | 647 Source source = pair.source; |
645 if (context != null && source != null) { | 648 if (context != null && source != null) { |
646 if (context.computeResult(source, SOURCE_KIND) == SourceKind.LIBRARY) { | 649 if (context.computeResult(source, SOURCE_KIND) == SourceKind.LIBRARY) { |
647 await context.computeResolvedCompilationUnitAsync(source, source); | 650 await context.computeResolvedCompilationUnitAsync(source, source); |
648 return; | 651 return; |
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
858 subscriptionToReset?.cancel(); | 861 subscriptionToReset?.cancel(); |
859 subscriptionToReset = server.onAnalysisStarted.listen((_) => _reset()); | 862 subscriptionToReset = server.onAnalysisStarted.listen((_) => _reset()); |
860 } | 863 } |
861 | 864 |
862 /** | 865 /** |
863 * We're performing a refactoring that affects only the given [file]. | 866 * We're performing a refactoring that affects only the given [file]. |
864 * So, when the [file] resolution is changed, we need to reset refactoring. | 867 * So, when the [file] resolution is changed, we need to reset refactoring. |
865 * But when any other file is changed or analyzed, we can continue. | 868 * But when any other file is changed or analyzed, we can continue. |
866 */ | 869 */ |
867 void _resetOnFileResolutionChanged(String file) { | 870 void _resetOnFileResolutionChanged(String file) { |
| 871 if (server.options.enableNewAnalysisDriver) { |
| 872 return; |
| 873 } |
868 subscriptionToReset?.cancel(); | 874 subscriptionToReset?.cancel(); |
869 subscriptionToReset = server | 875 subscriptionToReset = server |
870 .getAnalysisContext(file) | 876 .getAnalysisContext(file) |
871 ?.onResultChanged(RESOLVED_UNIT) | 877 ?.onResultChanged(RESOLVED_UNIT) |
872 ?.listen((event) { | 878 ?.listen((event) { |
873 Source targetSource = event.target.source; | 879 Source targetSource = event.target.source; |
874 if (targetSource?.fullName == file) { | 880 if (targetSource?.fullName == file) { |
875 _reset(); | 881 _reset(); |
876 } | 882 } |
877 }); | 883 }); |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
936 } | 942 } |
937 return new RefactoringStatus(); | 943 return new RefactoringStatus(); |
938 } | 944 } |
939 } | 945 } |
940 | 946 |
941 /** | 947 /** |
942 * [_RefactoringManager] throws instances of this class internally to stop | 948 * [_RefactoringManager] throws instances of this class internally to stop |
943 * processing in a manager that was reset. | 949 * processing in a manager that was reset. |
944 */ | 950 */ |
945 class _ResetError {} | 951 class _ResetError {} |
OLD | NEW |