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

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

Issue 2906373002: Override ChangeBuilder methods in subclass to specify better type information (Closed)
Patch Set: Created 3 years, 6 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_plugin/lib/utilities/change_builder/change_builder_dart.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) 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/ast/ast.dart'; 7 import 'package:analyzer/dart/ast/ast.dart';
8 import 'package:analyzer/dart/ast/token.dart'; 8 import 'package:analyzer/dart/ast/token.dart';
9 import 'package:analyzer/dart/element/element.dart'; 9 import 'package:analyzer/dart/element/element.dart';
10 import 'package:analyzer/dart/element/type.dart'; 10 import 'package:analyzer/dart/element/type.dart';
(...skipping 21 matching lines...) Expand all
32 * The analysis driver in which the files being edited were analyzed. 32 * The analysis driver in which the files being edited were analyzed.
33 */ 33 */
34 final AnalysisDriver driver; 34 final AnalysisDriver driver;
35 35
36 /** 36 /**
37 * Initialize a newly created change builder. 37 * Initialize a newly created change builder.
38 */ 38 */
39 DartChangeBuilderImpl(this.driver); 39 DartChangeBuilderImpl(this.driver);
40 40
41 @override 41 @override
42 Future<Null> addFileEdit(String path, int fileStamp,
43 void buildFileEdit(DartFileEditBuilder builder)) =>
44 super.addFileEdit(path, fileStamp, buildFileEdit);
45
46 @override
42 Future<DartFileEditBuilderImpl> createFileEditBuilder( 47 Future<DartFileEditBuilderImpl> createFileEditBuilder(
43 String path, int fileStamp) async { 48 String path, int fileStamp) async {
44 AnalysisResult result = await driver.getResult(path); 49 AnalysisResult result = await driver.getResult(path);
45 return new DartFileEditBuilderImpl(this, path, fileStamp, result.unit); 50 return new DartFileEditBuilderImpl(this, path, fileStamp, result.unit);
46 } 51 }
47 } 52 }
48 53
49 /** 54 /**
50 * An [EditBuilder] used to build edits in Dart files. 55 * An [EditBuilder] used to build edits in Dart files.
51 */ 56 */
52 class DartEditBuilderImpl extends EditBuilderImpl implements DartEditBuilder { 57 class DartEditBuilderImpl extends EditBuilderImpl implements DartEditBuilder {
53 List<String> _KNOWN_METHOD_NAME_PREFIXES = ['get', 'is', 'to']; 58 List<String> _KNOWN_METHOD_NAME_PREFIXES = ['get', 'is', 'to'];
54 59
55 /** 60 /**
56 * Initialize a newly created builder to build a source edit. 61 * Initialize a newly created builder to build a source edit.
57 */ 62 */
58 DartEditBuilderImpl( 63 DartEditBuilderImpl(
59 DartFileEditBuilderImpl sourceFileEditBuilder, int offset, int length) 64 DartFileEditBuilderImpl sourceFileEditBuilder, int offset, int length)
60 : super(sourceFileEditBuilder, offset, length); 65 : super(sourceFileEditBuilder, offset, length);
61 66
62 DartFileEditBuilderImpl get dartFileEditBuilder => fileEditBuilder; 67 DartFileEditBuilderImpl get dartFileEditBuilder => fileEditBuilder;
63 68
64 @override 69 @override
70 void addLinkedEdit(String groupName,
71 void buildLinkedEdit(DartLinkedEditBuilder builder)) =>
72 super.addLinkedEdit(groupName, buildLinkedEdit);
73
74 @override
65 LinkedEditBuilderImpl createLinkedEditBuilder() { 75 LinkedEditBuilderImpl createLinkedEditBuilder() {
66 return new DartLinkedEditBuilderImpl(this); 76 return new DartLinkedEditBuilderImpl(this);
67 } 77 }
68 78
69 /** 79 /**
70 * Returns the indentation with the given [level]. 80 * Returns the indentation with the given [level].
71 */ 81 */
72 String getIndent(int level) => ' ' * level; 82 String getIndent(int level) => ' ' * level;
73 83
74 /** 84 /**
(...skipping 889 matching lines...) Expand 10 before | Expand all | Expand 10 after
964 /** 974 /**
965 * Initialize a newly created builder to build a source file edit within the 975 * Initialize a newly created builder to build a source file edit within the
966 * change being built by the given [changeBuilder]. The file being edited has 976 * change being built by the given [changeBuilder]. The file being edited has
967 * the given [source] and [timeStamp], and the given fully resolved [unit]. 977 * the given [source] and [timeStamp], and the given fully resolved [unit].
968 */ 978 */
969 DartFileEditBuilderImpl(DartChangeBuilderImpl changeBuilder, String path, 979 DartFileEditBuilderImpl(DartChangeBuilderImpl changeBuilder, String path,
970 int timeStamp, this.unit) 980 int timeStamp, this.unit)
971 : super(changeBuilder, path, timeStamp); 981 : super(changeBuilder, path, timeStamp);
972 982
973 @override 983 @override
984 void addInsertion(int offset, void buildEdit(DartEditBuilder builder)) =>
985 super.addInsertion(offset, buildEdit);
986
987 @override
988 void addReplacement(
989 SourceRange range, void buildEdit(DartEditBuilder builder)) =>
990 super.addReplacement(range, buildEdit);
991
992 @override
974 void convertFunctionFromSyncToAsync( 993 void convertFunctionFromSyncToAsync(
975 FunctionBody body, TypeProvider typeProvider) { 994 FunctionBody body, TypeProvider typeProvider) {
976 if (body == null && body.keyword != null) { 995 if (body == null && body.keyword != null) {
977 throw new ArgumentError( 996 throw new ArgumentError(
978 'The function must have a synchronous, non-generator body.'); 997 'The function must have a synchronous, non-generator body.');
979 } 998 }
980 addInsertion(body.offset, (EditBuilder builder) { 999 addInsertion(body.offset, (EditBuilder builder) {
981 builder.write('async '); 1000 builder.write('async ');
982 }); 1001 });
983 _replaceReturnTypeWithFuture(body, typeProvider); 1002 _replaceReturnTypeWithFuture(body, typeProvider);
(...skipping 323 matching lines...) Expand 10 before | Expand all | Expand 10 after
1307 } 1326 }
1308 } 1327 }
1309 1328
1310 class _InsertionDescription { 1329 class _InsertionDescription {
1311 final int offset; 1330 final int offset;
1312 final bool insertEmptyLineBefore; 1331 final bool insertEmptyLineBefore;
1313 final bool insertEmptyLineAfter; 1332 final bool insertEmptyLineAfter;
1314 _InsertionDescription( 1333 _InsertionDescription(
1315 this.offset, this.insertEmptyLineBefore, this.insertEmptyLineAfter); 1334 this.offset, this.insertEmptyLineBefore, this.insertEmptyLineAfter);
1316 } 1335 }
OLDNEW
« no previous file with comments | « no previous file | pkg/analyzer_plugin/lib/utilities/change_builder/change_builder_dart.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698