@@ -13,101 +13,11 @@ import 'package:analyzer/error/listener.dart';
13
13
import 'package:analyzer/src/dart/ast/ast.dart' ;
14
14
import 'package:analyzer/src/dart/ast/token.dart' ;
15
15
import 'package:analyzer/src/dart/error/syntactic_errors.dart' ;
16
- import 'package:analyzer/src/dart/scanner/scanner.dart' ;
17
16
import 'package:analyzer/src/fasta/ast_builder.dart' ;
18
17
import 'package:analyzer/src/generated/source.dart' ;
19
18
20
19
export 'package:analyzer/src/dart/error/syntactic_errors.dart' ;
21
20
22
- /// A simple data-holder for a method that needs to return multiple values.
23
- class CommentAndMetadata {
24
- /// The documentation comment that was parsed, or `null` if none was given.
25
- final Comment ? comment;
26
-
27
- /// The metadata that was parsed, or `null` if none was given.
28
- final List <Annotation >? metadata;
29
-
30
- /// Initialize a newly created holder with the given [comment] and [metadata] .
31
- CommentAndMetadata (this .comment, this .metadata);
32
-
33
- /// Return `true` if some metadata was parsed.
34
- bool get hasMetadata => metadata != null && metadata! .isNotEmpty;
35
- }
36
-
37
- /// A simple data-holder for a method that needs to return multiple values.
38
- class FinalConstVarOrType {
39
- /// The 'final', 'const' or 'var' keyword, or `null` if none was given.
40
- final Token keyword;
41
-
42
- /// The type, or `null` if no type was specified.
43
- final TypeAnnotation type;
44
-
45
- /// Initialize a newly created holder with the given [keyword] and [type] .
46
- FinalConstVarOrType (this .keyword, this .type);
47
- }
48
-
49
- /// A simple data-holder for a method that needs to return multiple values.
50
- class Modifiers {
51
- /// The token representing the keyword 'abstract', or `null` if the keyword
52
- /// was not found.
53
- Token ? abstractKeyword;
54
-
55
- /// The token representing the keyword 'const', or `null` if the keyword was
56
- /// not found.
57
- Token ? constKeyword;
58
-
59
- /// The token representing the keyword 'covariant', or `null` if the keyword
60
- /// was not found.
61
- Token ? covariantKeyword;
62
-
63
- /// The token representing the keyword 'external', or `null` if the keyword
64
- /// was not found.
65
- Token ? externalKeyword;
66
-
67
- /// The token representing the keyword 'factory', or `null` if the keyword was
68
- /// not found.
69
- Token ? factoryKeyword;
70
-
71
- /// The token representing the keyword 'final', or `null` if the keyword was
72
- /// not found.
73
- Token ? finalKeyword;
74
-
75
- /// The token representing the keyword 'static', or `null` if the keyword was
76
- /// not found.
77
- Token ? staticKeyword;
78
-
79
- /// The token representing the keyword 'var', or `null` if the keyword was not
80
- /// found.
81
- Token ? varKeyword;
82
-
83
- @override
84
- String toString () {
85
- StringBuffer buffer = StringBuffer ();
86
- bool needsSpace = _appendKeyword (buffer, false , abstractKeyword);
87
- needsSpace = _appendKeyword (buffer, needsSpace, constKeyword);
88
- needsSpace = _appendKeyword (buffer, needsSpace, externalKeyword);
89
- needsSpace = _appendKeyword (buffer, needsSpace, factoryKeyword);
90
- needsSpace = _appendKeyword (buffer, needsSpace, finalKeyword);
91
- needsSpace = _appendKeyword (buffer, needsSpace, staticKeyword);
92
- _appendKeyword (buffer, needsSpace, varKeyword);
93
- return buffer.toString ();
94
- }
95
-
96
- /// If the given [keyword] is not `null` , append it to the given [buffer] ,
97
- /// prefixing it with a space if [needsSpace] is `true` . Return `true` if
98
- /// subsequent keywords need to be prefixed with a space.
99
- bool _appendKeyword (StringBuffer buffer, bool needsSpace, Token ? keyword) {
100
- if (keyword != null ) {
101
- if (needsSpace) {
102
- buffer.writeCharCode (0x20 );
103
- }
104
- buffer.write (keyword.lexeme);
105
- return true ;
106
- }
107
- return needsSpace;
108
- }
109
- }
110
-
111
21
/// A parser used to parse tokens into an AST structure.
112
22
class Parser {
113
23
late Token currentToken;
0 commit comments