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);
|
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);
|
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));
|
error(errorNode, Diagnostics.Excessive_stack_depth_comparing_types_0_and_1, typeToString(source), typeToString(target));
|
||||||
}
|
}
|
||||||
else if (errorInfo) {
|
else if (errorInfo) {
|
||||||
addDiagnostic(createDiagnosticForNodeFromMessageChain(errorNode, errorInfo));
|
addDiagnostic(createDiagnosticForNodeFromMessageChain(errorNode, errorInfo, program.getCompilerHost().getNewLine()));
|
||||||
}
|
}
|
||||||
return result;
|
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 code = diagnosticChain.code;
|
||||||
var category = diagnosticChain.category;
|
var category = diagnosticChain.category;
|
||||||
var messageText = "";
|
var messageText = "";
|
||||||
|
@ -222,7 +222,7 @@ module ts {
|
||||||
var indent = 0;
|
var indent = 0;
|
||||||
while (diagnosticChain) {
|
while (diagnosticChain) {
|
||||||
if (indent) {
|
if (indent) {
|
||||||
messageText += sys.newLine;
|
messageText += newLine;
|
||||||
|
|
||||||
for (var i = 0; i < indent; i++) {
|
for (var i = 0; i < indent; i++) {
|
||||||
messageText += " ";
|
messageText += " ";
|
||||||
|
|
|
@ -22,6 +22,7 @@ module ts {
|
||||||
var compilerOptions = program.getCompilerOptions();
|
var compilerOptions = program.getCompilerOptions();
|
||||||
var sourceMapDataList: SourceMapData[] = compilerOptions.sourceMap ? [] : undefined;
|
var sourceMapDataList: SourceMapData[] = compilerOptions.sourceMap ? [] : undefined;
|
||||||
var diagnostics: Diagnostic[] = [];
|
var diagnostics: Diagnostic[] = [];
|
||||||
|
var newLine = program.getCompilerHost().getNewLine();
|
||||||
|
|
||||||
function getSourceFilePathInNewDir(newDirPath: string, sourceFile: SourceFile) {
|
function getSourceFilePathInNewDir(newDirPath: string, sourceFile: SourceFile) {
|
||||||
var sourceFilePath = getNormalizedPathFromPathCompoments(getNormalizedPathComponents(sourceFile.filename, compilerHost.getCurrentDirectory()));
|
var sourceFilePath = getNormalizedPathFromPathCompoments(getNormalizedPathComponents(sourceFile.filename, compilerHost.getCurrentDirectory()));
|
||||||
|
@ -126,7 +127,7 @@ module ts {
|
||||||
|
|
||||||
function writeLine() {
|
function writeLine() {
|
||||||
if (!lineStart) {
|
if (!lineStart) {
|
||||||
output += sys.newLine;
|
output += newLine;
|
||||||
lineCount++;
|
lineCount++;
|
||||||
linePos = output.length;
|
linePos = output.length;
|
||||||
lineStart = true;
|
lineStart = true;
|
||||||
|
@ -2252,7 +2253,7 @@ module ts {
|
||||||
compilerHost.getCurrentDirectory(),
|
compilerHost.getCurrentDirectory(),
|
||||||
/*isAbsolutePathAnUrl*/ false);
|
/*isAbsolutePathAnUrl*/ false);
|
||||||
|
|
||||||
referencePathsOutput += "/// <reference path='" + declFileName + "' />" + sys.newLine;
|
referencePathsOutput += "/// <reference path='" + declFileName + "' />" + newLine;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (root) {
|
if (root) {
|
||||||
|
|
|
@ -88,12 +88,12 @@ module ts {
|
||||||
return createFileDiagnostic(file, start, length, message, arg0, arg1, arg2);
|
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);
|
node = getErrorSpanForNode(node);
|
||||||
var file = getSourceFileOfNode(node);
|
var file = getSourceFileOfNode(node);
|
||||||
var start = skipTrivia(file.text, node.pos);
|
var start = skipTrivia(file.text, node.pos);
|
||||||
var length = node.end - start;
|
var length = node.end - start;
|
||||||
return flattenDiagnosticChain(file, start, length, messageChain);
|
return flattenDiagnosticChain(file, start, length, messageChain, newLine);
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getErrorSpanForNode(node: Node): Node {
|
export function getErrorSpanForNode(node: Node): Node {
|
||||||
|
|
|
@ -162,7 +162,8 @@ module ts {
|
||||||
writeFile: writeFile,
|
writeFile: writeFile,
|
||||||
getCurrentDirectory: () => currentDirectory || (currentDirectory = sys.getCurrentDirectory()),
|
getCurrentDirectory: () => currentDirectory || (currentDirectory = sys.getCurrentDirectory()),
|
||||||
useCaseSensitiveFileNames: () => sys.useCaseSensitiveFileNames,
|
useCaseSensitiveFileNames: () => sys.useCaseSensitiveFileNames,
|
||||||
getCanonicalFileName: getCanonicalFileName
|
getCanonicalFileName: getCanonicalFileName,
|
||||||
|
getNewLine: () => sys.newLine
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1104,5 +1104,6 @@ module ts {
|
||||||
getCurrentDirectory(): string;
|
getCurrentDirectory(): string;
|
||||||
getCanonicalFileName(fileName: string): string;
|
getCanonicalFileName(fileName: string): string;
|
||||||
useCaseSensitiveFileNames(): boolean;
|
useCaseSensitiveFileNames(): boolean;
|
||||||
|
getNewLine(): string;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue