push newline to compilerhost instead of using sys directelly. This allows the language service to set it, as sys is not defined in language service scenarios
This commit is contained in:
parent
253273820d
commit
2ed3de1c28
|
@ -2387,7 +2387,7 @@ module ts {
|
|||
|
||||
var errorInfo = chainDiagnosticMessages(undefined, Diagnostics.Named_properties_0_of_types_1_and_2_are_not_identical, prop.name, typeName1, typeName2);
|
||||
errorInfo = chainDiagnosticMessages(errorInfo, Diagnostics.Interface_0_cannot_simultaneously_extend_types_1_and_2_Colon, typeToString(type), typeName1, typeName2);
|
||||
addDiagnostic(createDiagnosticForNodeFromMessageChain(typeNode, errorInfo));
|
||||
addDiagnostic(createDiagnosticForNodeFromMessageChain(typeNode, errorInfo, program.getCompilerHost().getNewLine()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2434,7 +2434,7 @@ module ts {
|
|||
error(errorNode, Diagnostics.Excessive_stack_depth_comparing_types_0_and_1, typeToString(source), typeToString(target));
|
||||
}
|
||||
else if (errorInfo) {
|
||||
addDiagnostic(createDiagnosticForNodeFromMessageChain(errorNode, errorInfo));
|
||||
addDiagnostic(createDiagnosticForNodeFromMessageChain(errorNode, errorInfo, program.getCompilerHost().getNewLine()));
|
||||
}
|
||||
return result;
|
||||
|
||||
|
|
|
@ -214,7 +214,7 @@ module ts {
|
|||
}
|
||||
}
|
||||
|
||||
export function flattenDiagnosticChain(file: SourceFile, start: number, length: number, diagnosticChain: DiagnosticMessageChain): Diagnostic {
|
||||
export function flattenDiagnosticChain(file: SourceFile, start: number, length: number, diagnosticChain: DiagnosticMessageChain, newLine: string): Diagnostic {
|
||||
var code = diagnosticChain.code;
|
||||
var category = diagnosticChain.category;
|
||||
var messageText = "";
|
||||
|
@ -222,7 +222,7 @@ module ts {
|
|||
var indent = 0;
|
||||
while (diagnosticChain) {
|
||||
if (indent) {
|
||||
messageText += sys.newLine;
|
||||
messageText += newLine;
|
||||
|
||||
for (var i = 0; i < indent; i++) {
|
||||
messageText += " ";
|
||||
|
|
|
@ -22,6 +22,7 @@ module ts {
|
|||
var compilerOptions = program.getCompilerOptions();
|
||||
var sourceMapDataList: SourceMapData[] = compilerOptions.sourceMap ? [] : undefined;
|
||||
var diagnostics: Diagnostic[] = [];
|
||||
var newLine = program.getCompilerHost().getNewLine();
|
||||
|
||||
function getSourceFilePathInNewDir(newDirPath: string, sourceFile: SourceFile) {
|
||||
var sourceFilePath = getNormalizedPathFromPathCompoments(getNormalizedPathComponents(sourceFile.filename, compilerHost.getCurrentDirectory()));
|
||||
|
@ -126,7 +127,7 @@ module ts {
|
|||
|
||||
function writeLine() {
|
||||
if (!lineStart) {
|
||||
output += sys.newLine;
|
||||
output += newLine;
|
||||
lineCount++;
|
||||
linePos = output.length;
|
||||
lineStart = true;
|
||||
|
@ -2252,7 +2253,7 @@ module ts {
|
|||
compilerHost.getCurrentDirectory(),
|
||||
/*isAbsolutePathAnUrl*/ false);
|
||||
|
||||
referencePathsOutput += "/// <reference path='" + declFileName + "' />" + sys.newLine;
|
||||
referencePathsOutput += "/// <reference path='" + declFileName + "' />" + newLine;
|
||||
}
|
||||
|
||||
if (root) {
|
||||
|
|
|
@ -88,12 +88,12 @@ module ts {
|
|||
return createFileDiagnostic(file, start, length, message, arg0, arg1, arg2);
|
||||
}
|
||||
|
||||
export function createDiagnosticForNodeFromMessageChain(node: Node, messageChain: DiagnosticMessageChain): Diagnostic {
|
||||
export function createDiagnosticForNodeFromMessageChain(node: Node, messageChain: DiagnosticMessageChain, newLine: string): Diagnostic {
|
||||
node = getErrorSpanForNode(node);
|
||||
var file = getSourceFileOfNode(node);
|
||||
var start = skipTrivia(file.text, node.pos);
|
||||
var length = node.end - start;
|
||||
return flattenDiagnosticChain(file, start, length, messageChain);
|
||||
return flattenDiagnosticChain(file, start, length, messageChain, newLine);
|
||||
}
|
||||
|
||||
export function getErrorSpanForNode(node: Node): Node {
|
||||
|
|
|
@ -162,7 +162,8 @@ module ts {
|
|||
writeFile: writeFile,
|
||||
getCurrentDirectory: () => currentDirectory || (currentDirectory = sys.getCurrentDirectory()),
|
||||
useCaseSensitiveFileNames: () => sys.useCaseSensitiveFileNames,
|
||||
getCanonicalFileName: getCanonicalFileName
|
||||
getCanonicalFileName: getCanonicalFileName,
|
||||
getNewLine: () => sys.newLine
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -1104,5 +1104,6 @@ module ts {
|
|||
getCurrentDirectory(): string;
|
||||
getCanonicalFileName(fileName: string): string;
|
||||
useCaseSensitiveFileNames(): boolean;
|
||||
getNewLine(): string;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue