1
- /// A scope in which to resolve a chunk of code.
2
- ///
3
- /// TODO: Specify more what these mean, what fields are available (if any), etc.
4
- abstract class Scope {}
5
-
6
1
/// The base class representing an arbitrary chunk of Dart code, which may or
7
2
/// may not be syntactically or semantically valid yet.
8
3
class Code {
9
- /// The scope in which to resolve anything from [parts] that does not have its
10
- /// own scope already defined.
11
- final Scope ? scope;
12
-
13
4
/// All the chunks of [Code] or raw [String] s that comprise this [Code]
14
5
/// object.
15
6
final List <Object > parts;
16
7
17
- Code .fromString (String code, { this .scope} ) : parts = [code];
8
+ Code .fromString (String code) : parts = [code];
18
9
19
- Code .fromParts (this .parts, { this .scope} );
10
+ Code .fromParts (this .parts);
20
11
}
21
12
22
13
/// A piece of code representing a syntactically valid declaration.
23
14
class DeclarationCode extends Code {
24
- DeclarationCode .fromString (String code, {Scope ? scope})
25
- : super .fromString (code, scope: scope);
15
+ DeclarationCode .fromString (String code) : super .fromString (code);
26
16
27
- DeclarationCode .fromParts (List <Object > parts, {Scope ? scope})
28
- : super .fromParts (parts, scope: scope);
17
+ DeclarationCode .fromParts (List <Object > parts) : super .fromParts (parts);
29
18
}
30
19
31
20
/// A piece of code representing a syntactically valid element.
32
21
///
33
22
/// Should not include any trailing commas,
34
23
class ElementCode extends Code {
35
- ElementCode .fromString (String code, {Scope ? scope})
36
- : super .fromString (code, scope: scope);
24
+ ElementCode .fromString (String code) : super .fromString (code);
37
25
38
- ElementCode .fromParts (List <Object > parts, {Scope ? scope})
39
- : super .fromParts (parts, scope: scope);
26
+ ElementCode .fromParts (List <Object > parts) : super .fromParts (parts);
40
27
}
41
28
42
29
/// A piece of code representing a syntactically valid expression.
43
30
class ExpressionCode extends Code {
44
- ExpressionCode .fromString (String code, {Scope ? scope})
45
- : super .fromString (code, scope: scope);
31
+ ExpressionCode .fromString (String code) : super .fromString (code);
46
32
47
- ExpressionCode .fromParts (List <Object > parts, {Scope ? scope})
48
- : super .fromParts (parts, scope: scope);
33
+ ExpressionCode .fromParts (List <Object > parts) : super .fromParts (parts);
49
34
}
50
35
51
36
/// A piece of code representing a syntactically valid function body.
@@ -55,31 +40,25 @@ class ExpressionCode extends Code {
55
40
///
56
41
/// Both arrow and block function bodies are allowed.
57
42
class FunctionBodyCode extends Code {
58
- FunctionBodyCode .fromString (String code, {Scope ? scope})
59
- : super .fromString (code, scope: scope);
43
+ FunctionBodyCode .fromString (String code) : super .fromString (code);
60
44
61
- FunctionBodyCode .fromParts (List <Object > parts, {Scope ? scope})
62
- : super .fromParts (parts, scope: scope);
45
+ FunctionBodyCode .fromParts (List <Object > parts) : super .fromParts (parts);
63
46
}
64
47
65
48
/// A piece of code representing a syntactically valid identifier.
66
49
class IdentifierCode extends Code {
67
- IdentifierCode .fromString (String code, {Scope ? scope})
68
- : super .fromString (code, scope: scope);
50
+ IdentifierCode .fromString (String code) : super .fromString (code);
69
51
70
- IdentifierCode .fromParts (List <Object > parts, {Scope ? scope})
71
- : super .fromParts (parts, scope: scope);
52
+ IdentifierCode .fromParts (List <Object > parts) : super .fromParts (parts);
72
53
}
73
54
74
55
/// A piece of code identifying a named argument.
75
56
///
76
57
/// This should not include any trailing commas.
77
58
class NamedArgumentCode extends Code {
78
- NamedArgumentCode .fromString (String code, {Scope ? scope})
79
- : super .fromString (code, scope: scope);
59
+ NamedArgumentCode .fromString (String code) : super .fromString (code);
80
60
81
- NamedArgumentCode .fromParts (List <Object > parts, {Scope ? scope})
82
- : super .fromParts (parts, scope: scope);
61
+ NamedArgumentCode .fromParts (List <Object > parts) : super .fromParts (parts);
83
62
}
84
63
85
64
/// A piece of code identifying a syntactically valid function parameter.
@@ -92,22 +71,18 @@ class NamedArgumentCode extends Code {
92
71
/// construct and combine these together in a way that creates valid parameter
93
72
/// lists.
94
73
class ParameterCode extends Code {
95
- ParameterCode .fromString (String code, {Scope ? scope})
96
- : super .fromString (code, scope: scope);
74
+ ParameterCode .fromString (String code) : super .fromString (code);
97
75
98
- ParameterCode .fromParts (List <Object > parts, {Scope ? scope})
99
- : super .fromParts (parts, scope: scope);
76
+ ParameterCode .fromParts (List <Object > parts) : super .fromParts (parts);
100
77
}
101
78
102
79
/// A piece of code representing a syntactically valid statement.
103
80
///
104
81
/// Should always end with a semicolon.
105
82
class StatementCode extends Code {
106
- StatementCode .fromString (String code, {Scope ? scope})
107
- : super .fromString (code, scope: scope);
83
+ StatementCode .fromString (String code) : super .fromString (code);
108
84
109
- StatementCode .fromParts (List <Object > parts, {Scope ? scope})
110
- : super .fromParts (parts, scope: scope);
85
+ StatementCode .fromParts (List <Object > parts) : super .fromParts (parts);
111
86
}
112
87
113
88
extension Join <T extends Code > on List <T > {
0 commit comments