OLD | NEW |
---|---|
(Empty) | |
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | |
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. | |
4 | |
5 /// Contains all error and warning messages produced by polymer. | |
6 library polymer.src.build.messages; | |
7 | |
8 import 'package:code_transformers/messages/messages.dart'; | |
9 import 'constants.dart'; | |
10 | |
11 const importNotFound = const MessageTemplate( | |
12 const MessageId('polymer', 1), | |
13 'couldn\'t find imported asset "%-path-%" in package "%-package-%".', | |
14 'Import not found', | |
15 ''' | |
16 An HTML import seems to be broken. This could be because the file doesn't exist | |
17 or because the link URL is incorrect. | |
18 '''); | |
19 | |
20 const duplicateDefinition = const MessageTemplate( | |
21 const MessageId('polymer', 2), | |
22 'duplicate definition for custom tag "%-name-%".%-second-%', | |
23 'Duplicate definition', | |
24 ''' | |
25 Custom element names are global and can only be defined once. Some common | |
26 reasons why you might get two definitions: | |
27 | |
28 * Two different elements are declared with the same name. | |
29 * A single HTML file defining an element, has been imported using two differen t | |
30 URLs. | |
31 '''); | |
32 | |
33 const usePolymerHtmlMessage = const MessageTemplate( | |
34 const MessageId('polymer', 3), | |
35 'Missing definition for <polymer-element>, please add the following ' | |
36 'HTML import at the top of this file: <link rel="import" ' | |
37 'href="%-reachOutPrefix-%packages/polymer/polymer.html">.', | |
38 'Missing import to polymer.html', | |
39 ''' | |
40 Starting with polymer 0.11.0, each file that uses the definition | |
41 of polymer-element must import it either directly or transitively. | |
42 '''); | |
43 | |
44 const noImportWithinElement = const MessageTemplate( | |
45 const MessageId('polymer', 4), | |
46 'Polymer.dart\'s implementation of ' | |
47 'HTML imports are not supported within polymer element definitions, yet. ' | |
48 'Move the import out of this <polymer-element>.', | |
49 'Can\'t use imports inside <polymer-element>', | |
50 ''' | |
51 HTML imports are expected at the top of each document, outside of any | |
52 polymer-element definitions. The polymer build process combines all your HTML | |
53 files together so you can deploy a single HTML file with your application. This | |
54 build process ignores imports that appear to be in the wrong location. | |
55 '''); | |
56 | |
57 const useInitDart = const MessageTemplate( | |
58 const MessageId('polymer', 5), | |
59 'To run a polymer application, you need to call `initPolymer()`. You can ' | |
60 'either include a generic script tag that does this for you:' | |
61 '\'<script type="application/dart">export "package:polymer/init.dart";' | |
62 '</script>\' or add your own script tag and call that function. ' | |
63 'Make sure the script tag is placed after all HTML imports.', | |
64 'Missing init.dart', | |
65 ''' | |
66 Your application entry point didn't have any Dart script tags, so it's missing | |
67 some initialization needed for polymer.dart. | |
68 '''); | |
69 | |
70 const noDartScriptAndExperimental = const MessageTemplate( | |
71 const MessageId('polymer', 6), | |
72 'The experimental bootstrap feature doesn\'t support script tags on ' | |
73 'the main document (for now).', | |
74 'No script tags with experimental bootstrap', | |
75 'This experimental feature is no longer supported.'); | |
76 | |
77 const onlyOneTag = const MessageTemplate( | |
78 const MessageId('polymer', 7), | |
79 'Only one "application/dart" script tag per document is allowed.', | |
80 'Multiple Dart script tags per document are not supported', | |
81 ''' | |
82 Dartium currently allows only one script tag per document. Any | |
83 additional script tags might be ignored or result in an error. This will | |
84 likely change in the future, but for now, combine the script tags together into | |
85 a single Dart library. | |
86 '''); | |
87 | |
88 const moveHtmlImportsUp = const MessageTemplate( | |
89 const MessageId('polymer', 8), | |
90 'Move HTML imports above your Dart script tag.', | |
91 'Imports before script tags', | |
92 ''' | |
93 It is good practice to put all your HTML imports at the beginning of the | |
94 document, above any Dart script tags. Today, the execution of Dart script tags | |
95 is not synchronous in Dartium, so the difference is not noticeable. However, | |
96 Dartium that will eventually change and make the timing of script tags execution | |
97 match how they are in Javascript. At that point the order of your imports with | |
Kathy Walrath
2014/09/04 17:07:28
Javascript -> JavaScript (global)
Siggi Cherem (dart-lang)
2014/09/04 19:55:11
Done.
| |
98 respect to script tags will be important. Following the practice of putting | |
99 imports first protects your app from a future breaking change in this respect. | |
100 '''); | |
101 | |
102 const missingHref = const MessageTemplate( | |
103 const MessageId('polymer', 9), | |
104 'link rel="%-rel-%" missing href.', | |
105 'Missing href on a `<link>` tag', | |
106 'All `<link>` tags should have a valid URL to a resource.'); | |
107 | |
108 const elementWasDeprecatedEonsAgo = const MessageTemplate( | |
109 const MessageId('polymer', 10), | |
110 '<element> elements are not supported, use <polymer-element> instead', | |
111 '`<element>` is deprecated', | |
112 ''' | |
113 Long ago `<polymer-element>` used to be called `<element>`. You probably ran | |
114 into this error if you were migrating code that was written on a very early | |
115 version of polymer. | |
116 '''); | |
117 | |
118 // TODO(jmesserly): this warning is wrong if someone is using raw custom | |
119 // elements. Is there another way we can handle this warning that won't | |
120 // generate false positives? | |
121 const customElementNotFound = const MessageTemplate( | |
122 const MessageId('polymer', 11), | |
123 'custom element with name "%-tag-%" not found.', | |
124 'Definition of a custom element not found', | |
125 ''' | |
126 The polymer build was not able to find the definition of a custom element. This | |
127 can happen if an element is defined with a `<polymer-element>` tag, but you are | |
128 missing an HTML import or the import link is incorrect. | |
129 | |
130 This warning can also be a false alarm. For instance, when an element is defined | |
131 programatically using `document.registerElement`. In that case the polymer build | |
132 will not be able to see the definition and will produce this warning. | |
133 '''); | |
134 | |
135 const scriptTagSeemsEmpty = const MessageTemplate( | |
136 const MessageId('polymer', 12), | |
137 'script tag seems empty.', | |
138 'Empty script tag', | |
139 'Script tags should either have a `src` attribute or a non-empty body.'); | |
140 | |
141 const wrongScriptTypeExpectedDart = const MessageTemplate( | |
142 const MessageId('polymer', 13), | |
143 'Wrong script type, expected type="application/dart".', | |
144 'Expected Dart mime-type', | |
145 ''' | |
146 You seem to have a `.dart` extension on a script tag, but the mime-type | |
147 doesn't match `application/dart`. | |
148 '''); | |
149 | |
150 const wrongFileTypeExpectedDart = const MessageTemplate( | |
151 const MessageId('polymer', 14), | |
152 '"application/dart" scripts should use the .dart file extension.', | |
153 'Expected Dart file extension', | |
154 ''' | |
155 You are using the `application/dart` mime-type on a script tag, so | |
156 the URL to the script source URL should have a `.dart` extension. | |
157 '''); | |
158 | |
159 const foundBothScriptSrcAndBody = const MessageTemplate( | |
160 const MessageId('polymer', 15), | |
161 'script tag has "src" attribute and also has script text.', | |
162 'Script with both src and inline text', | |
163 ''' | |
164 You have a script tag that includes both a `src` attribute and inline script | |
165 text. You must choose one or the other. | |
166 '''); | |
167 | |
168 const incorrectInstantiationMissingBaseTag = const MessageTemplate( | |
169 const MessageId('polymer', 16), | |
170 'custom element "%-tag-%" extends from "%-base-%", but ' | |
171 'this tag will not include the default properties of "%-base-%". ' | |
172 'To fix this, either write this tag as <%-base-% ' | |
173 'is="%-tag-%"> or remove the "extends" attribute from ' | |
174 'the custom element declaration.', | |
175 'Incorrect instantiation: missing base tag in instantiation', | |
176 ''' | |
177 When you declare that a custom element extends from a base tag, for example: | |
178 | |
179 <polymer-element name="my-example" extends="ul"> | |
180 | |
181 or: | |
182 | |
183 <polymer-element name="my-example2" extends="ul"> | |
184 <polymer-element name="my-example" extends="my-example2"> | |
185 | |
186 You should instantiate `my-example` by using this syntax: | |
187 | |
188 <ul is="my-example"> | |
189 | |
190 And not: | |
191 | |
192 <my-example> | |
193 | |
194 Only elements that don't extend from existing HTML elements are created using | |
195 the latter form. | |
196 | |
197 This is because browsers first create the base element, and then upgrade it to | |
198 have the extra functionality of your custom element. In the example above, using | |
199 `<ul>` tells the browser which base type it must create before | |
200 doing the upgrade. | |
201 '''); | |
202 | |
203 const incorrectInstantiationBogusBaseTag = const MessageTemplate( | |
204 const MessageId('polymer', 17), | |
205 'custom element "%-tag-%" doesn\'t declare any type ' | |
206 'extensions. To fix this, either rewrite this tag as ' | |
207 '<%-tag-%> or add \'extends="%-base-%"\' to ' | |
208 'the custom element declaration.', | |
209 | |
210 'Incorrect instantiation: extra `is` attribute or missing `extends` ' | |
211 'in declaration', | |
212 ''' | |
213 Creating a custom element using the syntax: | |
214 | |
215 <ul is="my-example"> | |
216 | |
217 means that the declaration of `my-example` extends transitively from `ul`. This | |
218 error message is shown if the definition of `my-example` doesn't declare this | |
219 extension. It might be that you no longer extend from the base element, in which | |
220 case the fix is to change the instantiation to: | |
221 | |
222 <my-example> | |
223 | |
224 Another possibility is that the declaration needs to be fixed to include the | |
225 `extends` attribute, for example: | |
226 | |
227 <polymer-element name="my-example" extends="ul"> | |
228 '''); | |
229 | |
230 const incorrectInstantiationWrongBaseTag = const MessageTemplate( | |
231 const MessageId('polymer', 18), | |
232 'custom element "%-tag-%" extends from "%-base-%". ' | |
233 'Did you mean to write <%-base-% is="%-tag-%">?', | |
234 'Incorrect instantiation: base tag seems wrong', | |
235 ''' | |
236 It seems you have a declaration like: | |
237 | |
238 <polymer-element name="my-example" extends="div"> | |
239 | |
240 but an instantiation like: | |
241 | |
242 <span is="my-example"> | |
243 | |
244 Both the declaration and the instantiation need to match on the base type. So | |
245 either the instantiation needs to be fixed to be more like: | |
246 | |
247 <span is="my-example"> | |
248 | |
249 or the declaration should be fixed to be like: | |
250 | |
251 <polymer-element name="my-example" extends="span"> | |
252 '''); | |
253 | |
254 const noDashesInCustomAttributes = const MessageTemplate( | |
255 const MessageId('polymer', 19), | |
256 'PolymerElement no longer recognizes attribute names with ' | |
257 'dashes such as "%-name-%". Use %-alternative-% ' | |
258 'instead (both forms are equivalent in HTML).', | |
259 'No dashes allowed in custom attributes', | |
260 ''' | |
261 Polymer used to recognize attributes with dashes like `my-name` and convert them | |
262 to match properties where dashes were removed, and words follow the camelCase | |
263 style (for example `myName`). This feature is no longer available. Now simply | |
264 use the same name as the property. | |
265 | |
266 Because HTML attributes are case-insensitive, you can also write the name of | |
267 your property entirely in lowercase. Just be sure that your custom-elements | |
268 don't declare two properties with the same name but different capitalization. | |
269 '''); | |
270 | |
271 | |
272 const eventHandlersOnlyWithinPolymerElements = const MessageTemplate( | |
273 const MessageId('polymer', 20), | |
274 'Inline event handlers are only supported inside ' | |
275 'declarations of <polymer-element>.', | |
276 'Event handlers not supported here', | |
277 ''' | |
278 Bindings of the form `{{ }}` are supported inside `<template>` nodes, even outsi de | |
279 of `<polymer-element>` declarations. However, those bindings only support bindin g | |
280 values into the content of a node or an attribute. | |
281 | |
282 Inline event handlers of the form `on-click="{{method}}"` are a special feature | |
283 of polymer elements, so they are only supported inside `<polymer-element>` | |
284 definitions. | |
285 '''); | |
286 | |
287 const invalidEventHandlerBody = const MessageTemplate( | |
288 const MessageId('polymer', 21), | |
289 'Invalid event handler body "%-value-%". Declare a method ' | |
290 'in your custom element "void handlerName(event, detail, target)" ' | |
291 'and use the form %-name-%="{{handlerName}}".', | |
292 'No expressions allowed in event handler bindings', | |
293 ''' | |
294 Unlike data bindings, event handler bindings of the form `on-click="{{method}}"` | |
295 are not evaluated as expressions. They are meant to just contain a simple name | |
296 that resolves to a method in your polymer element's class definition. | |
297 '''); | |
298 | |
299 const nestedPolymerElementDefinitionsNotAllowed = const MessageTemplate( | |
300 const MessageId('polymer', 22), | |
301 'Nested polymer element definitions are not allowed.', | |
302 'Nested polymer element definitions not allowed', | |
303 ''' | |
304 Because custom element names are global, there is no need to have a | |
305 `<polymer-element>` definition nested within a `<polymer-element>`. If you have | |
306 a definition inside another, move the second definition out. | |
307 | |
308 You might see this error if you have an HTML import within a polymer element. | |
309 You should be able to move the import out of the element definition. | |
310 '''); | |
311 | |
312 const missingTagName = const MessageTemplate( | |
313 const MessageId('polymer', 23), | |
314 'Missing tag name of the custom element. Include an ' | |
315 'attribute like \'name="your-tag-name"\'.', | |
316 'Polymer element definitions without a name', | |
317 ''' | |
318 Polymer element definitions must have a name. You can include a name by using | |
319 the `name` attribute in `<polymer-element>` for example: | |
320 | |
321 <polymer-element name="my-example"> | |
322 '''); | |
323 | |
324 final invalidTagName = new MessageTemplate( | |
325 const MessageId('polymer', 24), | |
326 'Invalid name "%-name-%". Custom element names must have ' | |
327 'at least one dash (-) and can\'t be any of the following names: ' | |
328 '${invalidTagNames.keys.join(", ")}.', | |
329 'Custom element name missing a dash.', | |
330 ''' | |
331 Custom element names must have a dash (`-`) and can\'t be any of the following | |
332 reserved names: | |
333 | |
334 ${invalidTagNames.keys.map((e) => ' * `$e`\n').join('')} | |
335 | |
336 '''); | |
337 | |
338 final inlineImportFail = const MessageTemplate( | |
339 const MessageId('polymer', 25), | |
340 'Failed to inline HTML import: %-error-%', | |
341 'Error while inlining an import', | |
342 ''' | |
343 An error occurred while inlining an import in the polymer build. This is often | |
344 the result of a broken HTML import. | |
345 '''); | |
346 | |
347 final inlineStyleFail = const MessageTemplate( | |
348 const MessageId('polymer', 26), | |
349 'Failed to inline stylesheet: %-error-%', | |
350 'Error while inlining a stylesheet', | |
351 ''' | |
352 An error occurred while inlining a stylesheet in the polymer build. This is | |
353 often the result of a broken URL in a `<link rel="stylesheet" href="...">`. | |
354 '''); | |
355 | |
356 final scriptFileNotFound = const MessageTemplate( | |
357 const MessageId('polymer', 27), | |
358 'Script file at "%-url-%" not found.', | |
359 'URL to a script file might be incorrect', | |
360 ''' | |
361 An error occurred trying to read a script tag on a given URL. This is often the | |
362 result of a broken URL in a `<script src="...">`. | |
363 '''); | |
364 | |
365 final useUnderscorePrefix = const MessageTemplate( | |
366 const MessageId('polymer', 28), | |
367 'When using bindings with the "%-name-%" attribute you may ' | |
368 'experience errors in certain browsers. Please use the ' | |
369 '"_%-name-%" attribute instead.', | |
370 'Attribute missing "_" prefix', | |
371 ''' | |
372 Not all browsers support bindings to certain attributes, especially URL | |
373 attributes. Some browsers might sanitize attributes and result in an | |
374 incorrect value. For this reason polymer provides a special set of attributes | |
375 that let you bypass any browser internal attribute validation. The name of the | |
376 attribute is the same as the original attribute, but with a leading underscore. | |
377 For example, instead of writing: | |
378 | |
379 <img src="{{binding}}"> | |
380 | |
381 you can write: | |
382 | |
383 <img _src="{{binding}}"> | |
384 | |
385 For more information, see <http://goo.gl/5av8cU>. | |
386 '''); | |
387 | |
388 final dontUseUndercorePrefix = const MessageTemplate( | |
389 const MessageId('polymer', 29), | |
390 'The "_%-name-%" attribute is only supported when using bindings. ' | |
391 'Please change to the "%-name-%" attribute.', | |
392 'Attribute with extra "_" prefix', | |
393 ''' | |
394 A special attribute exists to support bindings on URL attributes. For example, | |
395 this correctly binds the `src` attribute in an image: | |
396 | |
397 <img _src="{{binding}}"> | |
398 | |
399 However, this special `_src` attribute is only available for bindings. If you | |
400 just have a URL, use the normal `src` attribute instead. | |
401 '''); | |
402 | |
403 final internalErrorDontKnowHowToImport = const MessageTemplate( | |
404 const MessageId('polymer', 30), | |
405 "internal error: don't know how to include %-target-% from" | |
406 " %-source-%.%-extra-%", | |
407 "Internal error: don't know how to include a URL", | |
408 ''' | |
409 Sorry, you just ran into a bug in the polymer transformer code. Please file a | |
410 bug at <http://dartbug.com/new> including, if possible, some example code that | |
411 can help the team reproduce the issue. | |
412 '''); | |
413 | |
414 final internalErrorUnexpectedScript = const MessageTemplate( | |
415 const MessageId('polymer', 31), | |
416 'unexpected script. The ScriptCompactor transformer should run after ' | |
417 'running the ImportInliner', | |
418 'Internal error: phases run out of order', | |
419 ''' | |
420 Sorry, you just ran into a bug in the polymer transformer code. Please file a | |
421 bug at <http://dartbug.com/new> including, if possible, some example code that | |
422 can help the team reproduce the issue. | |
423 '''); | |
424 | |
425 final noPrivateCustomTag = const MessageTemplate( | |
426 const MessageId('polymer', 32), | |
427 '@CustomTag is not currently supported on private classes:' | |
428 ' %-name-%. Consider making this class public, or create a ' | |
429 'public initialization method marked with `@initMethod` that calls ' | |
430 '`Polymer.register(%-name-%, %-className-%)`.', | |
431 '`@CustomTag` used on a private class', | |
432 ''' | |
433 The `@CustomTag` annotation is currently only supported on public classes. If | |
434 you need to register a custom element whose implementation is a private class | |
435 (that is, a class whose name starts with `_`), you can still do so by invoking | |
436 `Polymer.register` within a public method marked with `@initMethod`. | |
437 '''); | |
438 | |
439 final noPrivateInitMethod = const MessageTemplate( | |
440 const MessageId('polymer', 33), | |
441 '@initMethod is no longer supported on private functions: %-name-%', | |
442 '`@initMethod` is on a private function', | |
443 ''' | |
444 The `@initMethod` annotation is currently only supported on public top-level | |
445 functions. | |
446 '''); | |
447 | |
448 final missingArgumentInAnnotation = const MessageTemplate( | |
449 const MessageId('polymer', 34), | |
450 'Missing argument in @%-name-% annotation', | |
451 'Missing argument in annotation', | |
452 'The annotation expects one argument, but the argument was not provided.'); | |
453 | |
454 final invalidArgumentInAnnotation = const MessageTemplate( | |
455 const MessageId('polymer', 35), | |
456 'The parameter to @%-name-% seems to be invalid.', | |
457 'Invalid argument in annotation', | |
458 ''' | |
459 The polymer transformer was not able to extract a constant value for the | |
460 annotation argument. This can happen if your code is currently in a state that | |
461 can't be analyzed (for example, it has parse errors) or if the expression passed | |
462 as an argument is invalid (for example, it is not a compile-time constant). | |
463 '''); | |
464 | |
465 | |
466 final noInitializersError = const MessageTemplate( | |
467 const MessageId('polymer', 36), | |
468 'No polymer initializers were found. Make sure to either ' | |
469 'annotate your polymer elements with @CustomTag or include a ' | |
470 'top level method annotated with @initMethod that registers your ' | |
471 'elements. Both annotations are defined in the polymer library (' | |
472 'package:polymer/polymer.dart).', | |
473 'No polymer initializers found', | |
474 ''' | |
475 No polymer initializers were found. Make sure to either | |
476 annotate your polymer elements with @CustomTag or include a | |
477 top level method annotated with @initMethod that registers your | |
478 elements. Both annotations are defined in the polymer library ( | |
479 package:polymer/polymer.dart). | |
480 '''); | |
481 | |
482 final noEventBindingsWithAtExpression = const MessageTemplate( | |
483 const MessageId('polymer', 37), | |
484 'event bindings with @ are no longer supported', | |
485 'Event bindings with @ are no longer supported', | |
486 ''' | |
487 For a while there was an undocumented feature that allowed users to include | |
488 expressions in event bindings using the `@` prefix, for example: | |
489 | |
490 <div on-click="{{@a.b.c}}"> | |
491 | |
492 This feature is no longer supported. | |
493 '''); | |
494 | |
495 final noPrivateEventHandlers = const MessageTemplate( | |
496 const MessageId('polymer', 38), | |
497 'private symbols cannot be used in event handlers', | |
498 'Private symbol in event handler', | |
499 ''' | |
500 Currently private members can't be used in event handler bindings. So you can't | |
501 write: | |
502 | |
503 <div on-click="{{_method}}"> | |
504 | |
505 This restriction might be removed in the future, but for now, you need to make | |
506 your event handlers public. | |
507 '''); | |
508 | |
509 final noPrivateSymbolsInBinding = const MessageTemplate( | |
510 const MessageId('polymer', 39), | |
511 'private symbols are not supported', | |
512 'Private symbols in a binding expression', | |
513 ''' | |
514 Private members can't be used in binding expressions. For example, you can't | |
515 write: | |
516 | |
517 <div>{{a.b._c}}</div> | |
518 '''); | |
519 | |
520 final html5Warning = const MessageTemplate( | |
521 const MessageId('polymer', 40), | |
522 '(from html5lib) %-message-%', | |
523 'A warning was found while parsing the HTML document', | |
524 ''' | |
525 The polymer transformer uses a parser that implements the HTML5 spec | |
526 (`html5lib`). This message reports a | |
527 warning that the parser detected. | |
528 '''); | |
OLD | NEW |