|
1 | 1 | part of 'exception_handler.dart';
|
2 | 2 |
|
3 |
| -@sealed |
4 |
| -class ParserErrorCode { |
5 |
| - static const cannotFindMatchingClose = ParserErrorCode._( |
6 |
| - 'CANNOT_FIND_MATCHING_CLOSE', |
7 |
| - 'Cannot find matching close element to this', |
8 |
| - ); |
9 |
| - |
10 |
| - static const danglingCloseElement = ParserErrorCode._( |
11 |
| - 'DANGLING_CLOSE_ELEMENT', |
12 |
| - 'Closing tag is dangling and no matching open tag can be found', |
13 |
| - ); |
14 |
| - |
15 |
| - static const duplicateStarDirective = ParserErrorCode._( |
16 |
| - 'DUPLICATE_STAR_DIRECTIVE', |
17 |
| - 'Already found a *-directive, limit 1 per element.', |
18 |
| - ); |
19 |
| - |
20 |
| - static const duplicateSelectDecorator = ParserErrorCode._( |
21 |
| - 'DUPLICATE_SELECT_DECORATOR', |
22 |
| - "Only 1 'select' decorator can exist in <ng-content>, found duplicate", |
23 |
| - ); |
24 |
| - |
25 |
| - static const duplicateProjectAsDecorator = ParserErrorCode._( |
26 |
| - 'DUPLICATE_PROJECT_AS_DECORATOR', |
27 |
| - "Only 1 'ngProjectAs' decorator can exist in <ng-content>, found duplicate", |
28 |
| - ); |
29 |
| - |
30 |
| - static const duplicateReferenceDecorator = ParserErrorCode._( |
31 |
| - 'DUPLICATE_REFERENCE_DECORATOR', |
32 |
| - 'Only 1 reference decorator can exist in <ng-content>, found duplicate', |
33 |
| - ); |
34 |
| - |
35 |
| - static const elementDecorator = ParserErrorCode._( |
36 |
| - 'ELEMENT_DECORATOR', |
37 |
| - 'Expected element decorator after whitespace', |
38 |
| - ); |
39 |
| - |
40 |
| - static const elementDecoratorAfterPrefix = ParserErrorCode._( |
41 |
| - 'ELEMENT_DECORATOR_AFTER_PREFIX', |
42 |
| - 'Expected element decorator identifier after prefix', |
43 |
| - ); |
44 |
| - |
45 |
| - static const elementDecoratorSuffixBeforePrefix = ParserErrorCode._( |
46 |
| - 'ELEMENT_DECORATOR', |
47 |
| - 'Found special decorator suffix before prefix', |
48 |
| - ); |
49 |
| - |
50 |
| - static const elementDecoratorValue = ParserErrorCode._( |
51 |
| - 'ELEMENT_DECORATOR_VALUE', |
52 |
| - "Expected quoted value following '='", |
53 |
| - ); |
54 |
| - |
55 |
| - static const elementDecoratorValueMissingQuotes = ParserErrorCode._( |
56 |
| - 'ELEMENT_DECORATOR_VALUE_MISSING_QUOTES', |
57 |
| - 'Decorator values must contain quotes', |
58 |
| - ); |
59 |
| - |
60 |
| - static const elementIdentifier = ParserErrorCode._( |
61 |
| - 'ELEMENT_IDENTIFIER', |
62 |
| - 'Expected element tag name', |
63 |
| - ); |
64 |
| - |
65 |
| - static const expectedAfterElementIdentifier = ParserErrorCode._( |
66 |
| - 'EXPECTED_AFTER_ELEMENT_IDENTIFIER', |
67 |
| - 'Expected either whitespace or close tag end after element identifier', |
68 |
| - ); |
69 |
| - |
70 |
| - static const expectedEqualSign = ParserErrorCode._( |
71 |
| - 'EXPECTED_EQUAL_SIGN', |
72 |
| - "Expected '=' between decorator and value", |
73 |
| - ); |
74 |
| - |
75 |
| - static const expectedStandalone = ParserErrorCode._( |
76 |
| - 'EXPECTING_STANDALONE', |
77 |
| - 'Expected standalone token', |
78 |
| - ); |
79 |
| - |
80 |
| - static const expectedTagClose = ParserErrorCode._( |
81 |
| - 'EXPECTED_TAG_CLOSE', |
82 |
| - 'Expected tag close.', |
83 |
| - ); |
84 |
| - |
| 3 | +enum ParserErrorCode { |
| 4 | + cannotFindMatchingClose('Cannot find matching close element to this'), |
| 5 | + danglingCloseElement( |
| 6 | + 'Closing tag is dangling and no matching open tag can be found'), |
| 7 | + duplicateStarDirective('Already found a *-directive, limit 1 per element.'), |
| 8 | + duplicateSelectDecorator( |
| 9 | + "Only 1 'select' decorator can exist in <ng-content>, found duplicate"), |
| 10 | + duplicateProjectAsDecorator( |
| 11 | + "Only 1 'ngProjectAs' decorator can exist in <ng-content>, found duplicate"), |
| 12 | + duplicateReferenceDecorator( |
| 13 | + 'Only 1 reference decorator can exist in <ng-content>, found duplicate'), |
| 14 | + elementDecorator('Expected element decorator after whitespace'), |
| 15 | + elementDecoratorAfterPrefix( |
| 16 | + 'Expected element decorator identifier after prefix'), |
| 17 | + elementDecoratorSuffixBeforePrefix( |
| 18 | + 'Found special decorator suffix before prefix'), |
| 19 | + elementDecoratorValue("Expected quoted value following '='"), |
| 20 | + elementDecoratorValueMissingQuotes('Decorator values must contain quotes'), |
| 21 | + elementIdentifier('Expected element tag name'), |
| 22 | + expectedAfterElementIdentifier( |
| 23 | + 'Expected either whitespace or close tag end after element identifier'), |
| 24 | + expectedEqualSign("Expected '=' between decorator and value"), |
| 25 | + expectedStandalone('Expected standalone token'), |
| 26 | + expectedTagClose('Expected tag close.'), |
85 | 27 | // 'Catch-all' error code.
|
86 |
| - static const expectedToken = ParserErrorCode._( |
87 |
| - 'UNEXPECTED_TOKEN', |
88 |
| - 'Unexpected token', |
89 |
| - ); |
90 |
| - |
91 |
| - static const expectedWhitespaceBeforeNewDecorator = ParserErrorCode._( |
92 |
| - 'EXPECTED_WHITESPACE_BEFORE_DECORATOR', |
93 |
| - 'Expected whitespace before a new decorator', |
94 |
| - ); |
95 |
| - |
96 |
| - static const emptyInterpolation = ParserErrorCode._( |
97 |
| - 'EMPTY_INTERPOLATION', |
98 |
| - 'Interpolation expression cannot be empty', |
99 |
| - ); |
100 |
| - |
101 |
| - static const invalidDecoratorInNgContainer = ParserErrorCode._( |
102 |
| - 'INVALID_DECORATOR_IN_NGCONTAINER', |
103 |
| - "Only '*' bindings are supported on <ng-container>", |
104 |
| - ); |
105 |
| - |
106 |
| - static const invalidDecoratorInNgContent = ParserErrorCode._( |
107 |
| - 'INVALID_DECORATOR_IN_NGCONTENT', |
108 |
| - "Only 'select' is a valid attribute/decorate in <ng-content>", |
109 |
| - ); |
110 |
| - |
111 |
| - static const invalidDecoratorInTemplate = ParserErrorCode._( |
112 |
| - 'INVALID_DECORATOR_IN_TEMPLATE', |
113 |
| - "Invalid decorator in 'template' element", |
114 |
| - ); |
115 |
| - |
116 |
| - static const invalidLetBindingInNoTemplate = ParserErrorCode._( |
117 |
| - 'INVALID_LET_BINDING_IN_NONTEMPLATE', |
118 |
| - "'let-' binding can only be used in 'template' element", |
119 |
| - ); |
120 |
| - |
121 |
| - static const invalidMicroExpression = ParserErrorCode._( |
122 |
| - 'INVALID_MICRO_EXPRESSION', |
123 |
| - 'Failed parsing micro expression', |
124 |
| - ); |
125 |
| - |
126 |
| - static const nonVoidElementUsingVoidEnd = ParserErrorCode._( |
127 |
| - 'NONVOID_ELEMENT_USING_VOID_END', |
128 |
| - 'Element is not a void-element', |
129 |
| - ); |
130 |
| - |
131 |
| - static const ngContentMustCLoseImmediately = ParserErrorCode._( |
132 |
| - 'NGCONTENT_MUST_CLOSE_IMMEDIATElY', |
133 |
| - "'<ng-content ...>' must be followed immediately by close '</ng-content>'", |
134 |
| - ); |
135 |
| - |
136 |
| - static const propertyNameTooManyFixes = ParserErrorCode._( |
137 |
| - 'PROPERTY_NAME_TOO_MANY_FIXES', |
138 |
| - "Property name can only be in format: 'name[.postfix[.unit]]", |
139 |
| - ); |
140 |
| - |
141 |
| - static const referenceIdentifierFound = ParserErrorCode._( |
142 |
| - 'REFERENCE_IDENTIFIER_FOUND', |
143 |
| - 'Reference decorator only supports #<variable> on <ng-content>', |
144 |
| - ); |
145 |
| - |
146 |
| - static const suffixBanana = ParserErrorCode._( |
147 |
| - 'SUFFIX_BANANA', |
148 |
| - "Expected closing banana ')]'", |
149 |
| - ); |
150 |
| - |
151 |
| - static const suffixEvent = ParserErrorCode._( |
152 |
| - 'SUFFIX_EVENT', |
153 |
| - "Expected closing parenthesis ')'", |
154 |
| - ); |
155 |
| - |
156 |
| - static const suffixProperty = ParserErrorCode._( |
157 |
| - 'SUFFIX_PROPERTY', |
158 |
| - "Expected closing bracket ']'", |
159 |
| - ); |
160 |
| - |
161 |
| - static const enclosedQuote = ParserErrorCode._( |
162 |
| - 'UNCLOSED_QUOTE', |
163 |
| - 'Expected close quote for element decorator value', |
164 |
| - ); |
165 |
| - |
166 |
| - static const unopenedMustache = ParserErrorCode._( |
167 |
| - 'UNOPENED_MUSTACHE', |
168 |
| - 'Unopened mustache', |
169 |
| - ); |
170 |
| - |
171 |
| - static const unterminatedComment = ParserErrorCode._( |
172 |
| - 'UNTERMINATED COMMENT', |
173 |
| - 'Unterminated comment', |
174 |
| - ); |
175 |
| - |
176 |
| - static const unterminatedMustache = ParserErrorCode._( |
177 |
| - 'UNTERMINATED_MUSTACHE', |
178 |
| - 'Unterminated mustache', |
179 |
| - ); |
180 |
| - |
181 |
| - static const voidElementInCloseTag = ParserErrorCode._( |
182 |
| - 'VOID_ELEMENT_IN_CLOSE_TAG', |
183 |
| - 'Void element identifiers cannot be used in close element tag', |
184 |
| - ); |
185 |
| - |
186 |
| - static const voidCloseInCloseTag = ParserErrorCode._( |
187 |
| - 'VOID_CLOSE_IN_CLOSE_TAG', |
188 |
| - "Void close '/>' cannot be used in a close element", |
189 |
| - ); |
190 |
| - |
191 |
| - final String name; |
| 28 | + expectedToken('Unexpected token'), |
| 29 | + expectedWhitespaceBeforeNewDecorator( |
| 30 | + 'Expected whitespace before a new decorator'), |
| 31 | + emptyInterpolation('Interpolation expression cannot be empty'), |
| 32 | + invalidDecoratorInNgContainer( |
| 33 | + "Only '*' bindings are supported on <ng-container>"), |
| 34 | + invalidDecoratorInNgContent( |
| 35 | + "Only 'select' is a valid attribute/decorate in <ng-content>"), |
| 36 | + invalidDecoratorInTemplate("Invalid decorator in 'template' element"), |
| 37 | + invalidLetBindingInNoTemplate( |
| 38 | + "'let-' binding can only be used in 'template' element"), |
| 39 | + invalidMicroExpression('Failed parsing micro expression'), |
| 40 | + nonVoidElementUsingVoidEnd('Element is not a void-element'), |
| 41 | + ngContentMustCLoseImmediately( |
| 42 | + "'<ng-content ...>' must be followed immediately by close '</ng-content>'"), |
| 43 | + propertyNameTooManyFixes( |
| 44 | + "Property name can only be in format: 'name[.postfix[.unit]]"), |
| 45 | + referenceIdentifierFound( |
| 46 | + 'Reference decorator only supports #<variable> on <ng-content>'), |
| 47 | + suffixBanana("Expected closing banana ')]'"), |
| 48 | + suffixEvent("Expected closing parenthesis ')'"), |
| 49 | + suffixProperty("Expected closing bracket ']'"), |
| 50 | + enclosedQuote('Expected close quote for element decorator value'), |
| 51 | + unopenedMustache('Unopened mustache'), |
| 52 | + unterminatedComment('Unterminated comment'), |
| 53 | + unterminatedMustache('Unterminated mustache'), |
| 54 | + voidElementInCloseTag( |
| 55 | + 'Void element identifiers cannot be used in close element tag'), |
| 56 | + voidCloseInCloseTag("Void close '/>' cannot be used in a close element"); |
192 | 57 |
|
193 | 58 | final String message;
|
194 | 59 |
|
195 | 60 | /// Initialize a newly created erorr code to have the given [name].
|
196 | 61 | /// The message associated with the error will be created from the
|
197 | 62 | /// given [message] template. The correction associated with the error
|
198 | 63 | /// will be created from the given [correction] template.
|
199 |
| - const ParserErrorCode._( |
200 |
| - this.name, |
201 |
| - this.message, |
202 |
| - ); |
| 64 | + const ParserErrorCode(this.message); |
203 | 65 | }
|
0 commit comments