OLD | NEW |
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.formal_parameter_builder; | 5 library fasta.formal_parameter_builder; |
6 | 6 |
7 import '../parser/parser.dart' show FormalParameterType; | 7 import '../parser.dart' show FormalParameterKind; |
| 8 |
| 9 import '../parser/formal_parameter_kind.dart' |
| 10 show |
| 11 isMandatoryFormalParameterKind, |
| 12 isOptionalNamedFormalParameterKind, |
| 13 isOptionalPositionalFormalParameterKind; |
8 | 14 |
9 import 'builder.dart' | 15 import 'builder.dart' |
10 show LibraryBuilder, MetadataBuilder, ModifierBuilder, TypeBuilder; | 16 show LibraryBuilder, MetadataBuilder, ModifierBuilder, TypeBuilder; |
11 | 17 |
12 abstract class FormalParameterBuilder<T extends TypeBuilder> | 18 abstract class FormalParameterBuilder<T extends TypeBuilder> |
13 extends ModifierBuilder { | 19 extends ModifierBuilder { |
14 @override | 20 @override |
15 final int charOffset; | 21 final int charOffset; |
16 | 22 |
17 final List<MetadataBuilder> metadata; | 23 final List<MetadataBuilder> metadata; |
18 | 24 |
19 final int modifiers; | 25 final int modifiers; |
20 | 26 |
21 final T type; | 27 final T type; |
22 | 28 |
23 final String name; | 29 final String name; |
24 | 30 |
25 /// True if this parameter is on the form `this.name`. | 31 /// True if this parameter is on the form `this.name`. |
26 final bool hasThis; | 32 final bool hasThis; |
27 | 33 |
28 FormalParameterType kind = FormalParameterType.REQUIRED; | 34 FormalParameterKind kind = FormalParameterKind.mandatory; |
29 | 35 |
30 FormalParameterBuilder(this.metadata, this.modifiers, this.type, this.name, | 36 FormalParameterBuilder(this.metadata, this.modifiers, this.type, this.name, |
31 this.hasThis, LibraryBuilder compilationUnit, this.charOffset) | 37 this.hasThis, LibraryBuilder compilationUnit, this.charOffset) |
32 : super(compilationUnit, charOffset); | 38 : super(compilationUnit, charOffset); |
33 | 39 |
34 String get debugName => "FormalParameterBuilder"; | 40 String get debugName => "FormalParameterBuilder"; |
35 | 41 |
36 bool get isRequired => kind.isRequired; | 42 bool get isRequired => isMandatoryFormalParameterKind(kind); |
37 | 43 |
38 bool get isPositional => kind.isPositional || kind.isRequired; | 44 bool get isPositional { |
| 45 return isOptionalPositionalFormalParameterKind(kind) || |
| 46 isMandatoryFormalParameterKind(kind); |
| 47 } |
39 | 48 |
40 bool get isNamed => kind.isNamed; | 49 bool get isNamed => isOptionalNamedFormalParameterKind(kind); |
41 | 50 |
42 bool get isOptional => !isRequired; | 51 bool get isOptional => !isRequired; |
43 | 52 |
44 bool get isLocal => true; | 53 bool get isLocal => true; |
45 | 54 |
46 @override | 55 @override |
47 String get fullNameForErrors => name; | 56 String get fullNameForErrors => name; |
48 | 57 |
49 FormalParameterBuilder forFormalParameterInitializerScope(); | 58 FormalParameterBuilder forFormalParameterInitializerScope(); |
50 } | 59 } |
OLD | NEW |