Fixed a few of the code review suggestions

This commit is contained in:
ChrisBubernak 2014-09-25 13:02:37 -07:00
parent 16a8b3c59f
commit e11ee0f6cf
5 changed files with 25 additions and 22 deletions

View File

@ -6,6 +6,7 @@ module ts {
Identifier_expected: { code: 1003, category: DiagnosticCategory.Error, key: "Identifier expected." },
_0_expected: { code: 1005, category: DiagnosticCategory.Error, key: "'{0}' expected." },
Trailing_comma_not_allowed: { code: 1009, category: DiagnosticCategory.Error, key: "Trailing comma not allowed." },
A_file_cannot_have_a_reference_to_itself: { code: 1006, category: DiagnosticCategory.Error, key: "A file cannot have a reference to itself." },
Asterisk_Slash_expected: { code: 1010, category: DiagnosticCategory.Error, key: "'*/' expected." },
Unexpected_token: { code: 1012, category: DiagnosticCategory.Error, key: "Unexpected token." },
Catch_clause_parameter_cannot_have_a_type_annotation: { code: 1013, category: DiagnosticCategory.Error, key: "Catch clause parameter cannot have a type annotation." },
@ -340,7 +341,6 @@ module ts {
Parameter_0_of_exported_function_has_or_is_using_name_1_from_private_module_2: { code: 4077, category: DiagnosticCategory.Error, key: "Parameter '{0}' of exported function has or is using name '{1}' from private module '{2}'." },
Parameter_0_of_exported_function_has_or_is_using_private_name_1: { code: 4078, category: DiagnosticCategory.Error, key: "Parameter '{0}' of exported function has or is using private name '{1}'." },
The_current_host_does_not_support_the_0_option: { code: 5001, category: DiagnosticCategory.Error, key: "The current host does not support the '{0}' option." },
A_file_cannot_have_a_reference_to_itself: { code: 5006, category: DiagnosticCategory.Error, key: "A file cannot have a reference to itself." },
Cannot_find_the_common_subdirectory_path_for_the_input_files: { code: 5009, category: DiagnosticCategory.Error, key: "Cannot find the common subdirectory path for the input files." },
Cannot_read_file_0_Colon_1: { code: 5012, category: DiagnosticCategory.Error, key: "Cannot read file '{0}': {1}" },
Unsupported_file_encoding: { code: 5013, category: DiagnosticCategory.Error, key: "Unsupported file encoding." },

View File

@ -14,6 +14,10 @@
"Trailing comma not allowed.": {
"category": "Error",
"code": 1009
},
"A file cannot have a reference to itself.": {
"category": "Error",
"code": 1006
},
"'*/' expected.": {
"category": "Error",
@ -1355,10 +1359,7 @@
"category": "Error",
"code": 5001
},
"A file cannot have a reference to itself.": {
"category": "Error",
"code": 5006
},
"Cannot find the common subdirectory path for the input files.": {
"category": "Error",
"code": 5009

View File

@ -3822,24 +3822,26 @@ module ts {
}
else {
var matchResult = fullTripleSlashReferencePathRegEx.exec(comment);
var start = range.pos;
var end = range.end;
var length = end - start;
if (!matchResult) {
var start = range.pos;
var length = range.end - start;
errorAtPos(start, length, Diagnostics.Invalid_reference_directive_syntax);
}
else {
var referenceFilename = matchResult[3];
var basePath = getDirectoryPath(file.filename);
var referenceFilename = normalizePath(combinePaths(basePath, matchResult[3]));
if (file.filename === referenceFilename) {
errorAtPos(range.pos, range.end - range.pos, Diagnostics.A_file_cannot_have_a_reference_to_itself);
}
else {
referencedFiles.push({
pos: range.pos,
end: range.end,
filename: matchResult[3]
});
}
var referenceFullPath = normalizePath(combinePaths(basePath, referenceFilename));
if (file.filename === referenceFullPath) {
errorAtPos(start, length, Diagnostics.A_file_cannot_have_a_reference_to_itself);
}
else {
referencedFiles.push({
pos: start,
end: end,
filename: referenceFilename
});
}
}
}
}

View File

@ -1,10 +1,10 @@
tests/cases/compiler/selfReferencingFile.ts(1,1): error TS5006: A file cannot have a reference to itself.
tests/cases/compiler/selfReferencingFile.ts(1,1): error TS1006: A file cannot have a reference to itself.
==== tests/cases/compiler/selfReferencingFile.ts (1 errors) ====
///<reference path='selfReferencingFile.ts'/>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
!!! error TS5006: A file cannot have a reference to itself.
!!! error TS1006: A file cannot have a reference to itself.
class selfReferencingFile {

View File

@ -1,10 +1,10 @@
tests/cases/compiler/selfReferencingFile3.ts(1,1): error TS5006: A file cannot have a reference to itself.
tests/cases/compiler/selfReferencingFile3.ts(1,1): error TS1006: A file cannot have a reference to itself.
==== tests/cases/compiler/selfReferencingFile3.ts (1 errors) ====
///<reference path='./selfReferencingFile3.ts'/>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
!!! error TS5006: A file cannot have a reference to itself.
!!! error TS1006: A file cannot have a reference to itself.
class selfReferencingFile3 {