Skip to content

Commit ba61c63

Browse files
committed
Moved logic to another location where host was in scope so we could call
getCanonicalFileName
1 parent 36b4629 commit ba61c63

File tree

1 file changed

+10
-15
lines changed

1 file changed

+10
-15
lines changed

src/compiler/parser.ts

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3825,24 +3825,16 @@ module ts {
38253825
var start = range.pos;
38263826
var end = range.end;
38273827
var length = end - start;
3828-
3828+
38293829
if (!matchResult) {
38303830
errorAtPos(start, length, Diagnostics.Invalid_reference_directive_syntax);
38313831
}
38323832
else {
3833-
var referenceFilename = matchResult[3];
3834-
var basePath = getDirectoryPath(file.filename);
3835-
var referenceFullPath = normalizePath(combinePaths(basePath, referenceFilename));
3836-
if (file.filename.toLocaleLowerCase() === referenceFullPath.toLocaleLowerCase()) {
3837-
errorAtPos(start, length, Diagnostics.A_file_cannot_have_a_reference_to_itself);
3838-
}
3839-
else {
3840-
referencedFiles.push({
3841-
pos: start,
3842-
end: end,
3843-
filename: referenceFilename
3844-
});
3845-
}
3833+
referencedFiles.push({
3834+
pos: start,
3835+
end: end,
3836+
filename: matchResult[3]
3837+
});
38463838
}
38473839
}
38483840
}
@@ -3957,6 +3949,9 @@ module ts {
39573949
else if (!findSourceFile(filename, isDefaultLib, refFile, refPos, refEnd)) {
39583950
diagnostic = Diagnostics.File_0_not_found;
39593951
}
3952+
else if (refFile && host.getCanonicalFileName(filename) === host.getCanonicalFileName(refFile.filename)) {
3953+
diagnostic = Diagnostics.A_file_cannot_have_a_reference_to_itself;
3954+
}
39603955
}
39613956
else {
39623957
if (!(findSourceFile(filename + ".ts", isDefaultLib, refFile, refPos, refEnd) || findSourceFile(filename + ".d.ts", isDefaultLib, refFile, refPos, refEnd))) {
@@ -4015,7 +4010,7 @@ module ts {
40154010

40164011
function processReferencedFiles(file: SourceFile, basePath: string) {
40174012
forEach(file.referencedFiles, ref => {
4018-
processSourceFile(normalizePath(combinePaths(basePath, ref.filename)), /* isDefaultLib */ false, file, ref.pos, ref.end);
4013+
processSourceFile(normalizePath(combinePaths(basePath, ref.filename)), /* isDefaultLib */ false, file, ref.pos, ref.end);
40194014
});
40204015
}
40214016

0 commit comments

Comments
 (0)