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

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

Issue 1310263003: Reformat code to minimize churn (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Created 5 years, 3 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
OLDNEW
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2015, 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 analysis_server.src.utilities.change_builder_dart; 5 library analysis_server.src.utilities.change_builder_dart;
6 6
7 import 'package:analysis_server/src/protocol.dart' hide ElementKind; 7 import 'package:analysis_server/src/protocol.dart' hide ElementKind;
8 import 'package:analysis_server/src/services/correction/name_suggestion.dart'; 8 import 'package:analysis_server/src/services/correction/name_suggestion.dart';
9 import 'package:analysis_server/src/services/correction/util.dart'; 9 import 'package:analysis_server/src/services/correction/util.dart';
10 import 'package:analysis_server/src/utilities/change_builder_core.dart'; 10 import 'package:analysis_server/src/utilities/change_builder_core.dart';
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
51 * Initialize a newly created builder to build a source edit. 51 * Initialize a newly created builder to build a source edit.
52 */ 52 */
53 DartEditBuilderImpl( 53 DartEditBuilderImpl(
54 DartFileEditBuilderImpl sourceFileEditBuilder, int offset, int length) 54 DartFileEditBuilderImpl sourceFileEditBuilder, int offset, int length)
55 : utils = sourceFileEditBuilder.utils, 55 : utils = sourceFileEditBuilder.utils,
56 super(sourceFileEditBuilder, offset, length); 56 super(sourceFileEditBuilder, offset, length);
57 57
58 DartFileEditBuilderImpl get dartFileEditBuilder => fileEditBuilder; 58 DartFileEditBuilderImpl get dartFileEditBuilder => fileEditBuilder;
59 59
60 @override 60 @override
61 void writeClassDeclaration(String name, {Iterable<DartType> interfaces, 61 void writeClassDeclaration(String name,
62 bool isAbstract: false, void memberWriter(), Iterable<DartType> mixins, 62 {Iterable<DartType> interfaces,
63 String nameGroupName, DartType superclass}) { 63 bool isAbstract: false,
64 void memberWriter(),
65 Iterable<DartType> mixins,
66 String nameGroupName,
67 DartType superclass}) {
64 // TODO(brianwilkerson) Add support for type parameters, probably as a 68 // TODO(brianwilkerson) Add support for type parameters, probably as a
65 // parameterWriter parameter. 69 // parameterWriter parameter.
66 // TODO(brianwilkerson) Add a superclassGroupName parameter. 70 // TODO(brianwilkerson) Add a superclassGroupName parameter.
67 if (isAbstract) { 71 if (isAbstract) {
68 write(Keyword.ABSTRACT.syntax); 72 write(Keyword.ABSTRACT.syntax);
69 write(' '); 73 write(' ');
70 } 74 }
71 write('class '); 75 write('class ');
72 if (nameGroupName == null) { 76 if (nameGroupName == null) {
73 write(name); 77 write(name);
(...skipping 14 matching lines...) Expand all
88 if (memberWriter != null) { 92 if (memberWriter != null) {
89 writeln(); 93 writeln();
90 memberWriter(); 94 memberWriter();
91 writeln(); 95 writeln();
92 } 96 }
93 write('}'); 97 write('}');
94 } 98 }
95 99
96 //@override 100 //@override
97 void writeConstructorDeclaration(ClassElement classElement, 101 void writeConstructorDeclaration(ClassElement classElement,
98 {ArgumentList argumentList, SimpleIdentifier constructorName, 102 {ArgumentList argumentList,
103 SimpleIdentifier constructorName,
99 bool isConst: false}) { 104 bool isConst: false}) {
100 // TODO(brianwilkerson) Clean up the API and add it to the public API. 105 // TODO(brianwilkerson) Clean up the API and add it to the public API.
101 // 106 //
102 // TODO(brianwilkerson) Support passing a list of final fields rather than 107 // TODO(brianwilkerson) Support passing a list of final fields rather than
103 // an argument list. 108 // an argument list.
104 if (isConst) { 109 if (isConst) {
105 write(Keyword.CONST.syntax); 110 write(Keyword.CONST.syntax);
106 write(' '); 111 write(' ');
107 } 112 }
108 write(classElement.name); 113 write(classElement.name);
(...skipping 18 matching lines...) Expand all
127 if (argumentList != null) { 132 if (argumentList != null) {
128 writeParametersMatchingArguments(argumentList); 133 writeParametersMatchingArguments(argumentList);
129 } else { 134 } else {
130 write('()'); 135 write('()');
131 } 136 }
132 writeln(' {'); 137 writeln(' {');
133 write(' }'); 138 write(' }');
134 } 139 }
135 140
136 @override 141 @override
137 void writeFieldDeclaration(String name, {void initializerWriter(), 142 void writeFieldDeclaration(String name,
138 bool isConst: false, bool isFinal: false, bool isStatic: false, 143 {void initializerWriter(),
139 String nameGroupName, DartType type, String typeGroupName}) { 144 bool isConst: false,
145 bool isFinal: false,
146 bool isStatic: false,
147 String nameGroupName,
148 DartType type,
149 String typeGroupName}) {
140 if (isStatic) { 150 if (isStatic) {
141 write(Keyword.STATIC.syntax); 151 write(Keyword.STATIC.syntax);
142 write(' '); 152 write(' ');
143 } 153 }
144 bool typeRequired = true; 154 bool typeRequired = true;
145 if (isConst) { 155 if (isConst) {
146 write(Keyword.CONST.syntax); 156 write(Keyword.CONST.syntax);
147 typeRequired = false; 157 typeRequired = false;
148 } else if (isFinal) { 158 } else if (isFinal) {
149 write(Keyword.FINAL.syntax); 159 write(Keyword.FINAL.syntax);
(...skipping 13 matching lines...) Expand all
163 write(name); 173 write(name);
164 } 174 }
165 if (initializerWriter != null) { 175 if (initializerWriter != null) {
166 write(' = '); 176 write(' = ');
167 initializerWriter(); 177 initializerWriter();
168 } 178 }
169 write(';'); 179 write(';');
170 } 180 }
171 181
172 @override 182 @override
173 void writeGetterDeclaration(String name, {void bodyWriter(), 183 void writeGetterDeclaration(String name,
174 bool isStatic: false, String nameGroupName, DartType returnType, 184 {void bodyWriter(),
185 bool isStatic: false,
186 String nameGroupName,
187 DartType returnType,
175 String returnTypeGroupName}) { 188 String returnTypeGroupName}) {
176 if (isStatic) { 189 if (isStatic) {
177 write(Keyword.STATIC.syntax); 190 write(Keyword.STATIC.syntax);
178 write(' '); 191 write(' ');
179 } 192 }
180 if (returnType != null) { 193 if (returnType != null) {
181 writeType(returnType, groupName: returnTypeGroupName); 194 writeType(returnType, groupName: returnTypeGroupName);
182 write(' '); 195 write(' ');
183 } 196 }
184 write(Keyword.GET.syntax); 197 write(Keyword.GET.syntax);
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after
342 } 355 }
343 356
344 @override 357 @override
345 void writeParameterSource(DartType type, String name) { 358 void writeParameterSource(DartType type, String name) {
346 String parameterSource = utils.getParameterSource( 359 String parameterSource = utils.getParameterSource(
347 type, name, dartFileEditBuilder.librariesToImport); 360 type, name, dartFileEditBuilder.librariesToImport);
348 write(parameterSource); 361 write(parameterSource);
349 } 362 }
350 363
351 @override 364 @override
352 bool writeType(DartType type, {bool addSupertypeProposals: false, 365 bool writeType(DartType type,
353 String groupName, bool required: false}) { 366 {bool addSupertypeProposals: false,
367 String groupName,
368 bool required: false}) {
354 if (type != null && !type.isDynamic) { 369 if (type != null && !type.isDynamic) {
355 String typeSource = 370 String typeSource =
356 utils.getTypeSource(type, dartFileEditBuilder.librariesToImport); 371 utils.getTypeSource(type, dartFileEditBuilder.librariesToImport);
357 if (groupName != null) { 372 if (groupName != null) {
358 addLinkedEdit(groupName, (LinkedEditBuilder builder) { 373 addLinkedEdit(groupName, (LinkedEditBuilder builder) {
359 write(typeSource); 374 write(typeSource);
360 if (addSupertypeProposals) { 375 if (addSupertypeProposals) {
361 _addSuperTypeProposals(builder, type, new Set<DartType>()); 376 _addSuperTypeProposals(builder, type, new Set<DartType>());
362 } 377 }
363 }); 378 });
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
462 } 477 }
463 unit = context.resolveCompilationUnit2(source, librariesContaining[0]); 478 unit = context.resolveCompilationUnit2(source, librariesContaining[0]);
464 utils = new CorrectionUtils(unit); 479 utils = new CorrectionUtils(unit);
465 } 480 }
466 481
467 @override 482 @override
468 DartEditBuilderImpl createEditBuilder(int offset, int length) { 483 DartEditBuilderImpl createEditBuilder(int offset, int length) {
469 return new DartEditBuilderImpl(this, offset, length); 484 return new DartEditBuilderImpl(this, offset, length);
470 } 485 }
471 } 486 }
OLDNEW
« no previous file with comments | « pkg/analysis_server/lib/src/status/tree_writer.dart ('k') | pkg/analysis_server/lib/utilities/change_builder_dart.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698