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

Side by Side Diff: pkg/front_end/lib/src/fasta/kernel/kernel_procedure_builder.dart

Issue 2970273004: Deprecate all diagnostics methods that use strings. (Closed)
Patch Set: Merged with 4df146dd9a465d63344330bf3e45524b927c92ec Created 3 years, 5 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) 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 library fasta.kernel_procedure_builder; 5 library fasta.kernel_procedure_builder;
6 6
7 import 'package:front_end/src/fasta/kernel/kernel_shadow_ast.dart' 7 import 'package:front_end/src/fasta/kernel/kernel_shadow_ast.dart'
8 show KernelProcedure; 8 show KernelProcedure;
9 9
10 import 'package:front_end/src/fasta/source/source_library_builder.dart' 10 import 'package:front_end/src/fasta/source/source_library_builder.dart'
(...skipping 26 matching lines...) Expand all
37 StringLiteral, 37 StringLiteral,
38 SuperInitializer, 38 SuperInitializer,
39 TypeParameter, 39 TypeParameter,
40 VariableDeclaration, 40 VariableDeclaration,
41 VariableGet, 41 VariableGet,
42 VoidType, 42 VoidType,
43 setParents; 43 setParents;
44 44
45 import 'package:kernel/type_algebra.dart' show containsTypeVariable, substitute; 45 import 'package:kernel/type_algebra.dart' show containsTypeVariable, substitute;
46 46
47 import '../errors.dart' show internalError; 47 import '../deprecated_problems.dart' show deprecated_internalProblem;
48 48
49 import '../messages.dart' show warning; 49 import '../messages.dart' show deprecated_warning;
50 50
51 import '../loader.dart' show Loader; 51 import '../loader.dart' show Loader;
52 52
53 import 'kernel_builder.dart' 53 import 'kernel_builder.dart'
54 show 54 show
55 Builder, 55 Builder,
56 ClassBuilder, 56 ClassBuilder,
57 ConstructorReferenceBuilder, 57 ConstructorReferenceBuilder,
58 FormalParameterBuilder, 58 FormalParameterBuilder,
59 KernelFormalParameterBuilder, 59 KernelFormalParameterBuilder,
60 KernelLibraryBuilder, 60 KernelLibraryBuilder,
61 KernelTypeBuilder, 61 KernelTypeBuilder,
62 KernelTypeVariableBuilder, 62 KernelTypeVariableBuilder,
63 LibraryBuilder, 63 LibraryBuilder,
64 MetadataBuilder, 64 MetadataBuilder,
65 ProcedureBuilder, 65 ProcedureBuilder,
66 TypeVariableBuilder, 66 TypeVariableBuilder,
67 isRedirectingGenerativeConstructorImplementation, 67 isRedirectingGenerativeConstructorImplementation,
68 memberError; 68 deprecated_memberError;
69 69
70 abstract class KernelFunctionBuilder 70 abstract class KernelFunctionBuilder
71 extends ProcedureBuilder<KernelTypeBuilder> { 71 extends ProcedureBuilder<KernelTypeBuilder> {
72 final String nativeMethodName; 72 final String nativeMethodName;
73 73
74 FunctionNode function; 74 FunctionNode function;
75 75
76 Statement actualBody; 76 Statement actualBody;
77 77
78 KernelFunctionBuilder( 78 KernelFunctionBuilder(
79 List<MetadataBuilder> metadata, 79 List<MetadataBuilder> metadata,
80 int modifiers, 80 int modifiers,
81 KernelTypeBuilder returnType, 81 KernelTypeBuilder returnType,
82 String name, 82 String name,
83 List<TypeVariableBuilder> typeVariables, 83 List<TypeVariableBuilder> typeVariables,
84 List<FormalParameterBuilder> formals, 84 List<FormalParameterBuilder> formals,
85 KernelLibraryBuilder compilationUnit, 85 KernelLibraryBuilder compilationUnit,
86 int charOffset, 86 int charOffset,
87 this.nativeMethodName) 87 this.nativeMethodName)
88 : super(metadata, modifiers, returnType, name, typeVariables, formals, 88 : super(metadata, modifiers, returnType, name, typeVariables, formals,
89 compilationUnit, charOffset); 89 compilationUnit, charOffset);
90 90
91 void set body(Statement newBody) { 91 void set body(Statement newBody) {
92 if (newBody != null) { 92 if (newBody != null) {
93 if (isAbstract) { 93 if (isAbstract) {
94 return internalError("Attempting to set body on abstract method."); 94 return deprecated_internalProblem(
95 "Attempting to set body on abstract method.");
95 } 96 }
96 if (isExternal) { 97 if (isExternal) {
97 return library.addCompileTimeError( 98 return library.deprecated_addCompileTimeError(
98 newBody.fileOffset, "An external method can't have a body."); 99 newBody.fileOffset, "An external method can't have a body.");
99 } 100 }
100 if (isConstructor && isConst) { 101 if (isConstructor && isConst) {
101 return library.addCompileTimeError( 102 return library.deprecated_addCompileTimeError(
102 newBody.fileOffset, "A const constructor can't have a body."); 103 newBody.fileOffset, "A const constructor can't have a body.");
103 } 104 }
104 } 105 }
105 actualBody = newBody; 106 actualBody = newBody;
106 if (function != null) { 107 if (function != null) {
107 function.body = newBody; 108 function.body = newBody;
108 newBody?.parent = function; 109 newBody?.parent = function;
109 } 110 }
110 } 111 }
111 112
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
143 List<TypeParameter> typeParameters = parent.target.typeParameters; 144 List<TypeParameter> typeParameters = parent.target.typeParameters;
144 if (typeParameters.isNotEmpty) { 145 if (typeParameters.isNotEmpty) {
145 Map<TypeParameter, DartType> substitution; 146 Map<TypeParameter, DartType> substitution;
146 DartType removeTypeVariables(DartType type) { 147 DartType removeTypeVariables(DartType type) {
147 if (substitution == null) { 148 if (substitution == null) {
148 substitution = <TypeParameter, DartType>{}; 149 substitution = <TypeParameter, DartType>{};
149 for (TypeParameter parameter in typeParameters) { 150 for (TypeParameter parameter in typeParameters) {
150 substitution[parameter] = const DynamicType(); 151 substitution[parameter] = const DynamicType();
151 } 152 }
152 } 153 }
153 warning(fileUri, charOffset, 154 deprecated_warning(fileUri, charOffset,
154 "Can only use type variables in instance methods."); 155 "Can only use type variables in instance methods.");
155 return substitute(type, substitution); 156 return substitute(type, substitution);
156 } 157 }
157 158
158 Set<TypeParameter> set = typeParameters.toSet(); 159 Set<TypeParameter> set = typeParameters.toSet();
159 for (VariableDeclaration parameter in result.positionalParameters) { 160 for (VariableDeclaration parameter in result.positionalParameters) {
160 if (containsTypeVariable(parameter.type, set)) { 161 if (containsTypeVariable(parameter.type, set)) {
161 parameter.type = removeTypeVariables(parameter.type); 162 parameter.type = removeTypeVariables(parameter.type);
162 } 163 }
163 } 164 }
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after
346 347
347 FunctionNode buildFunction(LibraryBuilder library) { 348 FunctionNode buildFunction(LibraryBuilder library) {
348 // TODO(ahe): Should complain if another type is explicitly set. 349 // TODO(ahe): Should complain if another type is explicitly set.
349 return super.buildFunction(library)..returnType = const VoidType(); 350 return super.buildFunction(library)..returnType = const VoidType();
350 } 351 }
351 352
352 Constructor get target => constructor; 353 Constructor get target => constructor;
353 354
354 void checkSuperOrThisInitializer(Initializer initializer) { 355 void checkSuperOrThisInitializer(Initializer initializer) {
355 if (superInitializer != null || redirectingInitializer != null) { 356 if (superInitializer != null || redirectingInitializer != null) {
356 memberError( 357 deprecated_memberError(
357 target, 358 target,
358 "Can't have more than one 'super' or 'this' initializer.", 359 "Can't have more than one 'super' or 'this' initializer.",
359 initializer.fileOffset); 360 initializer.fileOffset);
360 } 361 }
361 } 362 }
362 363
363 void addInitializer(Initializer initializer) { 364 void addInitializer(Initializer initializer) {
364 List<Initializer> initializers = constructor.initializers; 365 List<Initializer> initializers = constructor.initializers;
365 if (initializer is SuperInitializer) { 366 if (initializer is SuperInitializer) {
366 checkSuperOrThisInitializer(initializer); 367 checkSuperOrThisInitializer(initializer);
367 superInitializer = initializer; 368 superInitializer = initializer;
368 } else if (initializer is RedirectingInitializer) { 369 } else if (initializer is RedirectingInitializer) {
369 checkSuperOrThisInitializer(initializer); 370 checkSuperOrThisInitializer(initializer);
370 redirectingInitializer = initializer; 371 redirectingInitializer = initializer;
371 if (constructor.initializers.isNotEmpty) { 372 if (constructor.initializers.isNotEmpty) {
372 memberError(target, "'this' initializer must be the only initializer.", 373 deprecated_memberError(
374 target,
375 "'this' initializer must be the only initializer.",
373 initializer.fileOffset); 376 initializer.fileOffset);
374 } 377 }
375 } else if (redirectingInitializer != null) { 378 } else if (redirectingInitializer != null) {
376 memberError(target, "'this' initializer must be the only initializer.", 379 deprecated_memberError(
380 target,
381 "'this' initializer must be the only initializer.",
377 initializer.fileOffset); 382 initializer.fileOffset);
378 } else if (superInitializer != null) { 383 } else if (superInitializer != null) {
379 // If there is a super initializer ([initializer] isn't it), we need to 384 // If there is a super initializer ([initializer] isn't it), we need to
380 // insert [initializer] before the super initializer (thus ensuring that 385 // insert [initializer] before the super initializer (thus ensuring that
381 // the super initializer is always last). 386 // the super initializer is always last).
382 assert(superInitializer != initializer); 387 assert(superInitializer != initializer);
383 assert(initializers.last == superInitializer); 388 assert(initializers.last == superInitializer);
384 initializers.removeLast(); 389 initializers.removeLast();
385 if (!hasMovedSuperInitializer) { 390 if (!hasMovedSuperInitializer) {
386 // To preserve correct evaluation order, the arguments to super call 391 // To preserve correct evaluation order, the arguments to super call
(...skipping 19 matching lines...) Expand all
406 } 411 }
407 } 412 }
408 initializers.add(initializer..parent = constructor); 413 initializers.add(initializer..parent = constructor);
409 initializers.add(superInitializer); 414 initializers.add(superInitializer);
410 return; 415 return;
411 } 416 }
412 initializers.add(initializer); 417 initializers.add(initializer);
413 initializer.parent = constructor; 418 initializer.parent = constructor;
414 } 419 }
415 } 420 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698