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

Side by Side Diff: pkg/front_end/lib/src/fasta/kernel/kernel_field_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_field_builder; 5 library fasta.kernel_field_builder;
6 6
7 import 'package:front_end/src/fasta/kernel/body_builder.dart' show BodyBuilder; 7 import 'package:front_end/src/fasta/kernel/body_builder.dart' show BodyBuilder;
8 8
9 import 'package:front_end/src/fasta/kernel/kernel_shadow_ast.dart' 9 import 'package:front_end/src/fasta/kernel/kernel_shadow_ast.dart'
10 show KernelField; 10 show KernelField;
11 11
12 import 'package:front_end/src/fasta/parser/parser.dart' show Parser; 12 import 'package:front_end/src/fasta/parser/parser.dart' show Parser;
13 13
14 import 'package:front_end/src/scanner/token.dart' show Token; 14 import 'package:front_end/src/scanner/token.dart' show Token;
15 15
16 import 'package:front_end/src/fasta/builder/class_builder.dart' 16 import 'package:front_end/src/fasta/builder/class_builder.dart'
17 show ClassBuilder; 17 show ClassBuilder;
18 18
19 import 'package:front_end/src/fasta/source/source_library_builder.dart' 19 import 'package:front_end/src/fasta/source/source_library_builder.dart'
20 show SourceLibraryBuilder; 20 show SourceLibraryBuilder;
21 21
22 import 'package:front_end/src/fasta/type_inference/type_inference_listener.dart' 22 import 'package:front_end/src/fasta/type_inference/type_inference_listener.dart'
23 show TypeInferenceListener; 23 show TypeInferenceListener;
24 24
25 import 'package:kernel/ast.dart' 25 import 'package:kernel/ast.dart'
26 show DartType, Expression, Field, Name, NullLiteral; 26 show DartType, Expression, Field, Name, NullLiteral;
27 27
28 import '../errors.dart' show internalError; 28 import '../deprecated_problems.dart' show deprecated_internalProblem;
29 29
30 import 'kernel_builder.dart' 30 import 'kernel_builder.dart'
31 show Builder, FieldBuilder, KernelTypeBuilder, MetadataBuilder; 31 show Builder, FieldBuilder, KernelTypeBuilder, MetadataBuilder;
32 32
33 class KernelFieldBuilder extends FieldBuilder<Expression> { 33 class KernelFieldBuilder extends FieldBuilder<Expression> {
34 final KernelField field; 34 final KernelField field;
35 final List<MetadataBuilder> metadata; 35 final List<MetadataBuilder> metadata;
36 final KernelTypeBuilder type; 36 final KernelTypeBuilder type;
37 final Token initializerTokenForInference; 37 final Token initializerTokenForInference;
38 final bool hasInitializer; 38 final bool hasInitializer;
39 39
40 KernelFieldBuilder( 40 KernelFieldBuilder(
41 this.metadata, 41 this.metadata,
42 this.type, 42 this.type,
43 String name, 43 String name,
44 int modifiers, 44 int modifiers,
45 Builder compilationUnit, 45 Builder compilationUnit,
46 int charOffset, 46 int charOffset,
47 this.initializerTokenForInference, 47 this.initializerTokenForInference,
48 this.hasInitializer) 48 this.hasInitializer)
49 : field = new KernelField(null, fileUri: compilationUnit?.relativeFileUri) 49 : field = new KernelField(null, fileUri: compilationUnit?.relativeFileUri)
50 ..fileOffset = charOffset, 50 ..fileOffset = charOffset,
51 super(name, modifiers, compilationUnit, charOffset); 51 super(name, modifiers, compilationUnit, charOffset);
52 52
53 void set initializer(Expression value) { 53 void set initializer(Expression value) {
54 if (!hasInitializer && value is! NullLiteral && !isConst && !isFinal) { 54 if (!hasInitializer && value is! NullLiteral && !isConst && !isFinal) {
55 internalError("Attempt to set initializer on field without initializer."); 55 deprecated_internalProblem(
56 "Attempt to set initializer on field without initializer.");
56 } 57 }
57 field.initializer = value..parent = field; 58 field.initializer = value..parent = field;
58 } 59 }
59 60
60 bool get isEligibleForInference => 61 bool get isEligibleForInference =>
61 type == null && (hasInitializer || isInstanceMember); 62 type == null && (hasInitializer || isInstanceMember);
62 63
63 Field build(SourceLibraryBuilder library) { 64 Field build(SourceLibraryBuilder library) {
64 field.name ??= new Name(name, library.target); 65 field.name ??= new Name(name, library.target);
65 if (type != null) { 66 if (type != null) {
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
110 } 111 }
111 } 112 }
112 } 113 }
113 114
114 @override 115 @override
115 DartType get builtType => field.type; 116 DartType get builtType => field.type;
116 117
117 @override 118 @override
118 bool get hasImplicitType => type == null; 119 bool get hasImplicitType => type == null;
119 } 120 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698