Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(622)

Side by Side Diff: pkg/dart_messages/lib/shared_messages.dart

Issue 2718023003: One shared guide for diagnostics. (Closed)
Patch Set: Fix copyright year. Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « pkg/compiler/lib/src/diagnostics/messages.dart ('k') | pkg/front_end/lib/src/base/errors.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2015, 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 // An update to this file must be followed by regenerating the corresponding 5 /// An update to this file must be followed by regenerating the corresponding
6 // json, dart2js and analyzer file. Use `publish.dart` in the bin directory. 6 /// json, dart2js and analyzer file. Use `publish.dart` in the bin directory.
7 // 7 ///
8 // Every message in this file must have an id. Use `message_id.dart` in the 8 /// Every message in this file must have an id. Use `message_id.dart` in the
9 // bin directory to generate a fresh one. 9 /// bin directory to generate a fresh one.
10 10 ///
11 // The messages in this file should meet the following guide lines: 11 /// The messages in this file should follow the [Guide for Writing
12 // 12 /// Diagnostics](../../front_end/lib/src/fasta/diagnostics.md).
13 // 1. The message should be a complete sentence starting with an uppercase
14 // letter, and ending with a period.
15 //
16 // 2. Reserved words and embedded identifiers should be in single quotes, so
17 // prefer double quotes for the complete message. For example, "The
18 // class '#{className}' can't use 'super'." Notice that the word 'class' in the
19 // preceding message is not quoted as it refers to the concept 'class', not the
20 // reserved word. On the other hand, 'super' refers to the reserved word. Do
21 // not quote 'null' and numeric literals.
22 //
23 // 3. Do not try to compose messages, as it can make translating them hard.
24 //
25 // 4. Try to keep the error messages short, but informative.
26 //
27 // 5. Use simple words and terminology, assume the reader of the message
28 // doesn't have an advanced degree in math, and that English is not the
29 // reader's native language. Do not assume any formal computer science
30 // training. For example, do not use Latin abbreviations (prefer "that is" over
31 // "i.e.", and "for example" over "e.g."). Also avoid phrases such as "if and
32 // only if" and "iff", that level of precision is unnecessary.
33 //
34 // 6. Prefer contractions when they are in common use, for example, prefer
35 // "can't" over "cannot". Using "cannot", "must not", "shall not", etc. is
36 // off-putting to people new to programming.
37 //
38 // 7. Use common terminology, preferably from the Dart Language
39 // Specification. This increases the user's chance of finding a good
40 // explanation on the web.
41 //
42 // 8. Do not try to be cute or funny. It is extremely frustrating to work on a
43 // product that crashes with a "tongue-in-cheek" message, especially if you did
44 // not want to use this product to begin with.
45 //
46 // 9. Do not lie, that is, do not write error messages containing phrases like
47 // "can't happen". If the user ever saw this message, it would be a
48 // lie. Prefer messages like: "Internal error: This function should not be
49 // called when 'x' is null.".
50 //
51 // 10. Prefer to not use imperative tone. That is, the message should not sound
52 // accusing or like it is ordering the user around. The computer should
53 // describe the problem, not criticize for violating the specification.
54 //
55 // Other things to keep in mind:
56 //
57 // Generally, we want to provide messages that consists of three sentences:
58 // 1. what is wrong, 2. why is it wrong, 3. how do I fix it. However, we
59 // combine the first two in [template] and the last in [howToFix].
60
61 import 'dart:convert'; 13 import 'dart:convert';
62 14
63 /// Encodes the category of the message. 15 /// Encodes the category of the message.
64 /// 16 ///
65 /// This is currently only used in the analyzer. 17 /// This is currently only used in the analyzer.
66 // TODO(floitsch): encode severity and type in the category, so we can generate 18 // TODO(floitsch): encode severity and type in the category, so we can generate
67 // the corresponding ErrorCode subclasses. 19 // the corresponding ErrorCode subclasses.
68 class Category { 20 class Category {
69 static final analysisOptionsError = new Category("AnalysisOptionsError"); 21 static final analysisOptionsError = new Category("AnalysisOptionsError");
70 22
(...skipping 804 matching lines...) Expand 10 before | Expand all | Expand 10 after
875 main() { x = 3; } 827 main() { x = 3; }
876 """, 828 """,
877 """ 829 """
878 const x = 1; 830 const x = 1;
879 main() { x = 3; } 831 main() { x = 3; }
880 """, 832 """,
881 "get foo => null main() { foo = 5; }", 833 "get foo => null main() { foo = 5; }",
882 "const foo = 0 main() { foo = 5; }", 834 "const foo = 0 main() { foo = 5; }",
883 ]), 835 ]),
884 }; 836 };
OLDNEW
« no previous file with comments | « pkg/compiler/lib/src/diagnostics/messages.dart ('k') | pkg/front_end/lib/src/base/errors.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698