Skip to content

Commit aef859f

Browse files
Merge branch 'master' into getReferences
Conflicts: src/services/services.ts
2 parents 5c1b245 + b73558d commit aef859f

File tree

105 files changed

+1813
-1259
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

105 files changed

+1813
-1259
lines changed

Jakefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ var harnessSources = [
7171
"fourslashRunner.ts",
7272
"projectsRunner.ts",
7373
"unittestrunner.ts",
74+
"loggedIO.ts",
7475
"rwcRunner.ts",
7576
"runner.ts"
7677
].map(function (f) {

src/compiler/checker.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1472,7 +1472,7 @@ module ts {
14721472
function getTypeOfFuncClassEnumModule(symbol: Symbol): Type {
14731473
var links = getSymbolLinks(symbol);
14741474
if (!links.type) {
1475-
var type = links.type = createObjectType(TypeFlags.Anonymous, symbol);
1475+
links.type = createObjectType(TypeFlags.Anonymous, symbol);
14761476
}
14771477
return links.type;
14781478
}

src/compiler/core.ts

Lines changed: 2 additions & 5 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

@@ -567,7 +564,7 @@ module ts {
567564
var currentAssertionLevel = AssertionLevel.None;
568565

569566
export function shouldAssert(level: AssertionLevel): boolean {
570-
return this.currentAssertionLevel >= level;
567+
return currentAssertionLevel >= level;
571568
}
572569

573570
export function assert(expression: any, message?: string, verboseDebugInfo?: () => string): void {

src/compiler/diagnosticInformationMap.generated.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ module ts {
111111
Import_declarations_in_an_internal_module_cannot_reference_an_external_module: { code: 1147, category: DiagnosticCategory.Error, key: "Import declarations in an internal module cannot reference an external module." },
112112
Cannot_compile_external_modules_unless_the_module_flag_is_provided: { code: 1148, category: DiagnosticCategory.Error, key: "Cannot compile external modules unless the '--module' flag is provided." },
113113
Filename_0_differs_from_already_included_filename_1_only_in_casing: { code: 1149, category: DiagnosticCategory.Error, key: "Filename '{0}' differs from already included filename '{1}' only in casing" },
114-
new_T_cannot_be_used_to_create_an_array_Use_new_Array_T_instead: { code: 2068, category: DiagnosticCategory.Error, key: "'new T[]' cannot be used to create an array. Use 'new Array<T>()' instead." },
114+
new_T_cannot_be_used_to_create_an_array_Use_new_Array_T_instead: { code: 1150, category: DiagnosticCategory.Error, key: "'new T[]' cannot be used to create an array. Use 'new Array<T>()' instead." },
115115
Duplicate_identifier_0: { code: 2300, category: DiagnosticCategory.Error, key: "Duplicate identifier '{0}'." },
116116
Initializer_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor: { code: 2301, category: DiagnosticCategory.Error, key: "Initializer of instance member variable '{0}' cannot reference identifier '{1}' declared in the constructor." },
117117
Static_members_cannot_reference_class_type_parameters: { code: 2302, category: DiagnosticCategory.Error, key: "Static members cannot reference class type parameters." },
@@ -389,5 +389,6 @@ module ts {
389389
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." },
390390
Rest_parameter_0_implicitly_has_an_any_type: { code: 7019, category: DiagnosticCategory.Error, key: "Rest parameter '{0}' implicitly has an 'any[]' type." },
391391
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." },
392+
You_cannot_rename_this_element: { code: 8000, category: DiagnosticCategory.Error, key: "You cannot rename this element." },
392393
};
393394
}

src/compiler/diagnosticMessages.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1355,7 +1355,6 @@
13551355
"category": "Error",
13561356
"code": 5039
13571357
},
1358-
13591358
"Concatenate and emit output to single file.": {
13601359
"category": "Message",
13611360
"code": 6001
@@ -1552,5 +1551,9 @@
15521551
"Call signature, which lacks return-type annotation, implicitly has an 'any' return type.": {
15531552
"category": "Error",
15541553
"code": 7020
1554+
},
1555+
"You cannot rename this element.": {
1556+
"category": "Error",
1557+
"code": 8000
15551558
}
15561559
}

src/compiler/emitter.ts

Lines changed: 48 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -330,6 +330,8 @@ module ts {
330330
/** Emit Trailing comments of the node */
331331
var emitTrailingComments = compilerOptions.removeComments ? (node: Node) => { } : emitTrailingDeclarationComments;
332332

333+
var emitLeadingCommentsOfPosition = compilerOptions.removeComments ? (pos: number) => { } : emitLeadingCommentsOfLocalPosition;
334+
333335
var detachedCommentsInfo: { nodePos: number; detachedCommentEndPos: number }[];
334336
/** Emit detached comments of the node */
335337
var emitDetachedComments = compilerOptions.removeComments ? (node: TextRange) => { } : emitDetachedCommentsAtPosition;
@@ -1390,12 +1392,14 @@ module ts {
13901392
write(";");
13911393
emitTrailingComments(node.body);
13921394
}
1393-
decreaseIndent();
13941395
writeLine();
13951396
if (node.body.kind === SyntaxKind.FunctionBlock) {
1397+
emitLeadingCommentsOfPosition((<Block>node.body).statements.end);
1398+
decreaseIndent();
13961399
emitToken(SyntaxKind.CloseBraceToken, (<Block>node.body).statements.end);
13971400
}
13981401
else {
1402+
decreaseIndent();
13991403
emitStart(node.body);
14001404
write("}");
14011405
emitEnd(node.body);
@@ -1648,8 +1652,11 @@ module ts {
16481652
if (superCall) statements = statements.slice(1);
16491653
emitLines(statements);
16501654
}
1651-
decreaseIndent();
16521655
writeLine();
1656+
if (ctor) {
1657+
emitLeadingCommentsOfPosition((<Block>ctor.body).statements.end);
1658+
}
1659+
decreaseIndent();
16531660
emitToken(SyntaxKind.CloseBraceToken, ctor ? (<Block>ctor.body).statements.end : node.members.end);
16541661
scopeEmitEnd();
16551662
emitEnd(<Node>ctor || node);
@@ -1925,6 +1932,8 @@ module ts {
19251932

19261933
function emitSourceFile(node: SourceFile) {
19271934
currentSourceFile = node;
1935+
// Start new file on new line
1936+
writeLine();
19281937
emitDetachedComments(node);
19291938
// emit prologue directives prior to __extends
19301939
var startIndex = emitDirectivePrologues(node.statements, /*startWithNewLine*/ false);
@@ -2075,23 +2084,34 @@ module ts {
20752084
}
20762085
}
20772086

2087+
function hasDetachedComments(pos: number) {
2088+
return detachedCommentsInfo !== undefined && detachedCommentsInfo[detachedCommentsInfo.length - 1].nodePos === pos;
2089+
}
2090+
2091+
function getLeadingCommentsWithoutDetachedComments() {
2092+
// get the leading comments from detachedPos
2093+
var leadingComments = getLeadingComments(currentSourceFile.text, detachedCommentsInfo[detachedCommentsInfo.length - 1].detachedCommentEndPos);
2094+
if (detachedCommentsInfo.length - 1) {
2095+
detachedCommentsInfo.pop();
2096+
}
2097+
else {
2098+
detachedCommentsInfo = undefined;
2099+
}
2100+
2101+
return leadingComments;
2102+
}
2103+
20782104
function emitLeadingDeclarationComments(node: Node) {
20792105
// Emit the leading comments only if the parent's pos doesnt match because parent should take care of emitting these comments
20802106
if (node.parent.kind === SyntaxKind.SourceFile || node.pos !== node.parent.pos) {
20812107
var leadingComments: Comment[];
2082-
if (detachedCommentsInfo === undefined || detachedCommentsInfo[detachedCommentsInfo.length - 1].nodePos !== node.pos) {
2083-
// get the leading comments from the node
2084-
leadingComments = getLeadingCommentsOfNode(node, currentSourceFile);
2108+
if (hasDetachedComments(node.pos)) {
2109+
// get comments without detached comments
2110+
leadingComments = getLeadingCommentsWithoutDetachedComments();
20852111
}
20862112
else {
2087-
// get the leading comments from detachedPos
2088-
leadingComments = getLeadingComments(currentSourceFile.text, detachedCommentsInfo[detachedCommentsInfo.length - 1].detachedCommentEndPos);
2089-
if (detachedCommentsInfo.length - 1) {
2090-
detachedCommentsInfo.pop();
2091-
}
2092-
else {
2093-
detachedCommentsInfo = undefined;
2094-
}
2113+
// get the leading comments from the node
2114+
leadingComments = getLeadingCommentsOfNode(node, currentSourceFile);
20952115
}
20962116
emitNewLineBeforeLeadingComments(node, leadingComments, writer);
20972117
// Leading comments are emitted at /*leading comment1 */space/*leading comment*/space
@@ -2108,6 +2128,21 @@ module ts {
21082128
}
21092129
}
21102130

2131+
function emitLeadingCommentsOfLocalPosition(pos: number) {
2132+
var leadingComments: Comment[];
2133+
if (hasDetachedComments(pos)) {
2134+
// get comments without detached comments
2135+
leadingComments = getLeadingCommentsWithoutDetachedComments();
2136+
}
2137+
else {
2138+
// get the leading comments from the node
2139+
leadingComments = getLeadingComments(currentSourceFile.text, pos);
2140+
}
2141+
emitNewLineBeforeLeadingComments({ pos: pos, end: pos }, leadingComments, writer);
2142+
// Leading comments are emitted at /*leading comment1 */space/*leading comment*/space
2143+
emitComments(leadingComments, /*trailingSeparator*/ true, writer, writeComment);
2144+
}
2145+
21112146
function emitDetachedCommentsAtPosition(node: TextRange) {
21122147
var leadingComments = getLeadingComments(currentSourceFile.text, node.pos);
21132148
if (leadingComments) {

src/compiler/parser.ts

Lines changed: 2 additions & 4 deletions
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;
@@ -483,7 +483,7 @@ module ts {
483483
nodeIsNestedInLabel(label: Identifier, requireIterationStatement: boolean, stopAtFunctionBoundary: boolean): ControlBlockContext;
484484
}
485485

486-
export function createSourceFile(filename: string, sourceText: string, languageVersion: ScriptTarget, version: number = 0, isOpen: boolean = false): SourceFile {
486+
export function createSourceFile(filename: string, sourceText: string, languageVersion: ScriptTarget, version: string, isOpen: boolean = false): SourceFile {
487487
var file: SourceFile;
488488
var scanner: Scanner;
489489
var token: SyntaxKind;
@@ -2455,8 +2455,6 @@ module ts {
24552455
function parseBreakOrContinueStatement(kind: SyntaxKind): BreakOrContinueStatement {
24562456
var node = <BreakOrContinueStatement>createNode(kind);
24572457
var errorCountBeforeStatement = file.syntacticErrors.length;
2458-
var keywordStart = scanner.getTokenPos();
2459-
var keywordLength = scanner.getTextPos() - keywordStart;
24602458
parseExpected(kind === SyntaxKind.BreakStatement ? SyntaxKind.BreakKeyword : SyntaxKind.ContinueKeyword);
24612459
if (!canParseSemicolon()) node.label = parseIdentifier();
24622460
parseSemicolon();

src/compiler/tsc.ts

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -86,13 +86,18 @@ module ts {
8686
}
8787

8888
function reportDiagnostic(diagnostic: Diagnostic) {
89+
var output = "";
90+
8991
if (diagnostic.file) {
9092
var loc = diagnostic.file.getLineAndCharacterFromPosition(diagnostic.start);
91-
sys.write(diagnostic.file.filename + "(" + loc.line + "," + loc.character + "): " + diagnostic.messageText + sys.newLine);
92-
}
93-
else {
94-
sys.write(diagnostic.messageText + sys.newLine);
93+
94+
output += diagnostic.file.filename + "(" + loc.line + "," + loc.character + "): ";
9595
}
96+
97+
var category = DiagnosticCategory[diagnostic.category].toLowerCase();
98+
output += category + " TS" + diagnostic.code + ": " + diagnostic.messageText + sys.newLine;
99+
100+
sys.write(output);
96101
}
97102

98103
function reportDiagnostics(diagnostics: Diagnostic[]) {
@@ -142,7 +147,7 @@ module ts {
142147
}
143148
text = "";
144149
}
145-
return text !== undefined ? createSourceFile(filename, text, languageVersion) : undefined;
150+
return text !== undefined ? createSourceFile(filename, text, languageVersion, /*version:*/ "0") : undefined;
146151
}
147152

148153
function writeFile(fileName: string, data: string, writeByteOrderMark: boolean, onError?: (message: string) => void) {

src/compiler/types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -535,7 +535,7 @@ module ts {
535535
identifierCount: number;
536536
symbolCount: number;
537537
isOpen: boolean;
538-
version: number;
538+
version: string;
539539
languageVersion: ScriptTarget;
540540
identifiers: Map<string>;
541541
}

src/harness/compilerRunner.ts

Lines changed: 29 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -183,19 +183,40 @@ class CompilerBaselineRunner extends RunnerBase {
183183

184184
// if the .d.ts is non-empty, confirm it compiles correctly as well
185185
if (options.declaration && result.errors.length === 0 && result.declFilesCode.length > 0) {
186-
function getDtsFile(file: { unitName: string; content: string }) {
186+
function addDtsFile(file: { unitName: string; content: string }, dtsFiles: { unitName: string; content: string }[]) {
187187
if (Harness.Compiler.isDTS(file.unitName)) {
188-
return file;
189-
} else {
190-
var declFile = ts.forEach(result.declFilesCode,
191-
declFile => declFile.fileName === (file.unitName.substr(0, file.unitName.length - ".ts".length) + ".d.ts")
188+
dtsFiles.push(file);
189+
}
190+
else {
191+
var declFile = findResultCodeFile(file.unitName);
192+
// Look if there is --out file corresponding to this ts file
193+
if (!declFile && options.out) {
194+
declFile = findResultCodeFile(options.out);
195+
if (!declFile || findUnit(declFile.fileName, declToBeCompiled) ||
196+
findUnit(declFile.fileName, declOtherFiles)) {
197+
return;
198+
}
199+
}
200+
201+
if (declFile) {
202+
dtsFiles.push({ unitName: declFile.fileName, content: declFile.code });
203+
return;
204+
}
205+
}
206+
207+
function findResultCodeFile(fileName: string) {
208+
return ts.forEach(result.declFilesCode,
209+
declFile => declFile.fileName === (fileName.substr(0, fileName.length - ".ts".length) + ".d.ts")
192210
? declFile : undefined);
193-
return { unitName: declFile.fileName, content: declFile.code };
211+
}
212+
213+
function findUnit(fileName: string, units: { unitName: string; content: string }[]) {
214+
return ts.forEach(units, unit => unit.unitName === fileName ? unit : undefined);
194215
}
195216
}
196217

197-
ts.forEach(toBeCompiled, file => { declToBeCompiled.push(getDtsFile(file)); });
198-
ts.forEach(otherFiles, file => { declOtherFiles.push(getDtsFile(file)); });
218+
ts.forEach(toBeCompiled, file => addDtsFile(file, declToBeCompiled));
219+
ts.forEach(otherFiles, file => addDtsFile(file, declOtherFiles));
199220
harnessCompiler.compileFiles(declToBeCompiled, declOtherFiles, function (compileResult) {
200221
declResult = compileResult;
201222
}, function (settings) {

0 commit comments

Comments
 (0)