Skip to content

Commit 87ebb6b

Browse files
add rename localization messages.
1 parent edd82ce commit 87ebb6b

File tree

5 files changed

+33
-27
lines changed

5 files changed

+33
-27
lines changed

src/compiler/core.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -188,14 +188,11 @@ module ts {
188188

189189
export var localizedDiagnosticMessages: Map<string> = undefined;
190190

191-
function getLocaleSpecificMessage(message: string) {
191+
export function getLocaleSpecificMessage(message: string) {
192192
if (ts.localizedDiagnosticMessages) {
193193
message = localizedDiagnosticMessages[message];
194194
}
195195

196-
/* Check to see that we got an actual value back. */
197-
Debug.assert(message, "Diagnostic message does not exist in locale map.");
198-
199196
return message;
200197
}
201198

src/compiler/diagnosticInformationMap.generated.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,6 @@
22
/// <reference path="types.ts" />
33
module ts {
44
export var Diagnostics = {
5-
Unknown_compiler_option_0: { code: 6001, category: DiagnosticCategory.Error, key: "Unknown compiler option '{0}'." },
6-
File_0_not_found: { code: 6002, category: DiagnosticCategory.Error, key: "File '{0}' not found." },
7-
File_0_must_have_extension_ts_or_d_ts: { code: 6003, category: DiagnosticCategory.Error, key: "File '{0}' must have extension '.ts' or '.d.ts'." },
85
Unrecognized_escape_sequence: { code: 1000, category: DiagnosticCategory.Error, key: "Unrecognized escape sequence." },
96
Unexpected_character_0: { code: 1001, category: DiagnosticCategory.Error, key: "Unexpected character {0}." },
107
Missing_close_quote_character: { code: 1002, category: DiagnosticCategory.Error, key: "Missing close quote character." },
@@ -339,6 +336,9 @@ module ts {
339336
Unable_to_open_file_0: { code: 6049, category: DiagnosticCategory.Error, key: "Unable to open file '{0}'." },
340337
Corrupted_locale_file_0: { code: 6050, category: DiagnosticCategory.Error, key: "Corrupted locale file {0}." },
341338
No_input_files_specified: { code: 6051, category: DiagnosticCategory.Error, key: "No input files specified." },
339+
Unknown_compiler_option_0: { code: 6052, category: DiagnosticCategory.Error, key: "Unknown compiler option '{0}'." },
340+
File_0_not_found: { code: 6053, category: DiagnosticCategory.Error, key: "File '{0}' not found." },
341+
File_0_must_have_extension_ts_or_d_ts: { code: 6054, category: DiagnosticCategory.Error, key: "File '{0}' must have extension '.ts' or '.d.ts'." },
342342
Warn_on_expressions_and_declarations_with_an_implied_any_type: { code: 7004, category: DiagnosticCategory.Message, key: "Warn on expressions and declarations with an implied 'any' type." },
343343
Variable_0_implicitly_has_an_1_type: { code: 7005, category: DiagnosticCategory.Error, key: "Variable '{0}' implicitly has an '{1}' type." },
344344
Parameter_0_implicitly_has_an_1_type: { code: 7006, category: DiagnosticCategory.Error, key: "Parameter '{0}' implicitly has an '{1}' type." },
@@ -354,6 +354,8 @@ module ts {
354354
Object_literal_s_property_0_implicitly_has_an_1_type: { code: 7018, category: DiagnosticCategory.Error, key: "Object literal's property '{0}' implicitly has an '{1}' type." },
355355
Rest_parameter_0_implicitly_has_an_any_type: { code: 7019, category: DiagnosticCategory.Error, key: "Rest parameter '{0}' implicitly has an 'any[]' type." },
356356
Call_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type: { code: 7020, category: DiagnosticCategory.Error, key: "Call signature, which lacks return-type annotation, implicitly has an 'any' return type." },
357+
You_must_rename_an_identifier: { code: 8000, category: DiagnosticCategory.Error, key: "You must rename an identifier." },
358+
You_cannot_rename_this_element: { code: 8001, category: DiagnosticCategory.Error, key: "You cannot rename this element." },
357359
Variable_declaration_list_cannot_be_empty: { code: -9999999, category: DiagnosticCategory.Error, key: "Variable declaration list cannot be empty." },
358360
Digit_expected: { code: -9999999, category: DiagnosticCategory.Error, key: "Digit expected." },
359361
Hexadecimal_digit_expected: { code: -9999999, category: DiagnosticCategory.Error, key: "Hexadecimal digit expected." },

src/compiler/diagnosticMessages.json

Lines changed: 25 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,4 @@
1-
{
2-
"Unknown compiler option '{0}'.": {
3-
"category": "Error",
4-
"code": 6001
5-
},
6-
"File '{0}' not found.": {
7-
"category": "Error",
8-
"code": 6002
9-
},
10-
"File '{0}' must have extension '.ts' or '.d.ts'.": {
11-
"category": "Error",
12-
"code": 6003
13-
},
14-
1+
{
152
"Unrecognized escape sequence.": {
163
"category": "Error",
174
"code": 1000
@@ -1178,6 +1165,7 @@
11781165
"category": "Error",
11791166
"code": 5039
11801167
},
1168+
11811169
"Concatenate and emit output to single file.": {
11821170
"category": "Message",
11831171
"code": 6001
@@ -1254,7 +1242,6 @@
12541242
"category": "Message",
12551243
"code": 6027
12561244
},
1257-
12581245
"Version {0}": {
12591246
"category": "Message",
12601247
"code": 6029
@@ -1270,7 +1257,7 @@
12701257
"File change detected. Compiling...": {
12711258
"category": "Message",
12721259
"code": 6032
1273-
},
1260+
},
12741261
"STRING": {
12751262
"category": "Message",
12761263
"code": 6033
@@ -1306,8 +1293,8 @@
13061293
"Additional locations:": {
13071294
"category": "Message",
13081295
"code": 6041
1309-
},
1310-
"Compilation complete. Watching for file changes.": {
1296+
},
1297+
"Compilation complete. Watching for file changes.": {
13111298
"category": "Message",
13121299
"code": 6042
13131300
},
@@ -1351,6 +1338,18 @@
13511338
"category": "Error",
13521339
"code": 6051
13531340
},
1341+
"Unknown compiler option '{0}'.": {
1342+
"category": "Error",
1343+
"code": 6052
1344+
},
1345+
"File '{0}' not found.": {
1346+
"category": "Error",
1347+
"code": 6053
1348+
},
1349+
"File '{0}' must have extension '.ts' or '.d.ts'.": {
1350+
"category": "Error",
1351+
"code": 6054
1352+
},
13541353
"Warn on expressions and declarations with an implied 'any' type.": {
13551354
"category": "Message",
13561355
"code": 7004
@@ -1411,6 +1410,14 @@
14111410
"category": "Error",
14121411
"code": 7020
14131412
},
1413+
"You must rename an identifier.": {
1414+
"category": "Error",
1415+
"code": 8000
1416+
},
1417+
"You cannot rename this element.": {
1418+
"category": "Error",
1419+
"code": 8001
1420+
},
14141421
"Variable declaration list cannot be empty.": {
14151422
"category": "Error",
14161423
"code": -9999999

src/compiler/parser.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ module ts {
99
export function getNodeConstructor(kind: SyntaxKind): new () => Node {
1010
return nodeConstructors[kind] || (nodeConstructors[kind] = objectAllocator.getNodeConstructor(kind));
1111
}
12-
12+
1313
function createRootNode(kind: SyntaxKind, pos: number, end: number, flags: NodeFlags): Node {
1414
var node = new (getNodeConstructor(kind))();
1515
node.pos = pos;

src/services/services.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2462,7 +2462,7 @@ module ts {
24622462
getNameOrDottedNameSpan: getNameOrDottedNameSpan,
24632463
getBreakpointStatementAtPosition: getBreakpointStatementAtPosition,
24642464
getNavigateToItems: (searchValue) => [],
2465-
getRenameInfo: (fileName, position): RenameInfo => null,
2465+
getRenameInfo: (fileName, position): RenameInfo => RenameInfo.CreateError(getLocaleSpecificMessage(Diagnostics.You_cannot_rename_this_element.key)),
24662466
getNavigationBarItems: getNavigationBarItems,
24672467
getOutliningSpans: getOutliningSpans,
24682468
getTodoComments: getTodoComments,

0 commit comments

Comments
 (0)