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

Side by Side Diff: pkg/analyzer_plugin/lib/src/utilities/change_builder/change_builder_dart.dart

Issue 3009563002: Make finalize() async and await adding imports, if any. (Closed)
Patch Set: Created 3 years, 4 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_plugin/lib/src/utilities/change_builder/change_builder_core.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) 2017, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2017, 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 6
7 import 'package:analyzer/dart/analysis/results.dart'; 7 import 'package:analyzer/dart/analysis/results.dart';
8 import 'package:analyzer/dart/analysis/session.dart'; 8 import 'package:analyzer/dart/analysis/session.dart';
9 import 'package:analyzer/dart/ast/ast.dart'; 9 import 'package:analyzer/dart/ast/ast.dart';
10 import 'package:analyzer/dart/ast/token.dart'; 10 import 'package:analyzer/dart/ast/token.dart';
(...skipping 1020 matching lines...) Expand 10 before | Expand all | Expand 10 after
1031 }); 1031 });
1032 _replaceReturnTypeWithFuture(body, typeProvider); 1032 _replaceReturnTypeWithFuture(body, typeProvider);
1033 } 1033 }
1034 1034
1035 @override 1035 @override
1036 DartEditBuilderImpl createEditBuilder(int offset, int length) { 1036 DartEditBuilderImpl createEditBuilder(int offset, int length) {
1037 return new DartEditBuilderImpl(this, offset, length); 1037 return new DartEditBuilderImpl(this, offset, length);
1038 } 1038 }
1039 1039
1040 @override 1040 @override
1041 void finalize() { 1041 Future<Null> finalize() async {
1042 CompilationUnitElement unitElement = unit.element; 1042 if (librariesToImport.isNotEmpty) {
1043 LibraryElement libraryElement = unitElement.library; 1043 CompilationUnitElement unitElement = unit.element;
1044 CompilationUnitElement definingUnitElement = 1044 LibraryElement libraryElement = unitElement.library;
1045 libraryElement.definingCompilationUnit; 1045 CompilationUnitElement definingUnitElement =
1046 if (definingUnitElement == unitElement) { 1046 libraryElement.definingCompilationUnit;
1047 _addLibraryImports(libraryElement, librariesToImport); 1047 if (definingUnitElement == unitElement) {
1048 } else { 1048 _addLibraryImports(libraryElement, librariesToImport);
1049 (changeBuilder as DartChangeBuilder).addFileEdit( 1049 } else {
1050 definingUnitElement.source.fullName, (DartFileEditBuilder builder) { 1050 await (changeBuilder as DartChangeBuilder).addFileEdit(
1051 (builder as DartFileEditBuilderImpl) 1051 definingUnitElement.source.fullName, (DartFileEditBuilder builder) {
1052 ._addLibraryImports(libraryElement, librariesToImport); 1052 (builder as DartFileEditBuilderImpl)
1053 }); 1053 ._addLibraryImports(libraryElement, librariesToImport);
1054 });
1055 }
1054 } 1056 }
1055 } 1057 }
1056 1058
1057 @override 1059 @override
1058 void importLibraries(Iterable<Source> libraries) { 1060 void importLibraries(Iterable<Source> libraries) {
1059 librariesToImport.addAll(libraries); 1061 librariesToImport.addAll(libraries);
1060 } 1062 }
1061 1063
1062 @override 1064 @override
1063 void replaceTypeWithFuture( 1065 void replaceTypeWithFuture(
(...skipping 336 matching lines...) Expand 10 before | Expand all | Expand 10 after
1400 } 1402 }
1401 } 1403 }
1402 1404
1403 class _InsertionDescription { 1405 class _InsertionDescription {
1404 final int offset; 1406 final int offset;
1405 final bool insertEmptyLineBefore; 1407 final bool insertEmptyLineBefore;
1406 final bool insertEmptyLineAfter; 1408 final bool insertEmptyLineAfter;
1407 _InsertionDescription( 1409 _InsertionDescription(
1408 this.offset, this.insertEmptyLineBefore, this.insertEmptyLineAfter); 1410 this.offset, this.insertEmptyLineBefore, this.insertEmptyLineAfter);
1409 } 1411 }
OLDNEW
« no previous file with comments | « pkg/analyzer_plugin/lib/src/utilities/change_builder/change_builder_core.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698