Skip to content

Commit d8b4377

Browse files
committed
Merge branch 'master' into completionFixes
Conflicts: src/services/services.ts
2 parents a164e6a + fdc9b9d commit d8b4377

40 files changed

+1806
-212
lines changed

Jakefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -318,7 +318,7 @@ function exec(cmd, completeHandler) {
318318
complete();
319319
})
320320
try{
321-
ex.run();
321+
ex.run();
322322
} catch(e) {
323323
console.log('Exception: ' + e)
324324
}
@@ -385,7 +385,7 @@ desc("Generates code coverage data via instanbul")
385385
task("generate-code-coverage", ["tests", builtLocalDirectory], function () {
386386
var cmd = 'istanbul cover node_modules/mocha/bin/_mocha -- -R min -t ' + testTimeout + ' ' + run;
387387
console.log(cmd);
388-
exec(cmd);
388+
exec(cmd);
389389
}, { async: true });
390390

391391
// Browser tests

src/compiler/checker.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5947,7 +5947,7 @@ module ts {
59475947
});
59485948
}
59495949

5950-
function checkLabelledStatement(node: LabelledStatement) {
5950+
function checkLabeledStatement(node: LabeledStatement) {
59515951
checkSourceElement(node.statement);
59525952
}
59535953

@@ -6517,8 +6517,8 @@ module ts {
65176517
return checkWithStatement(<WithStatement>node);
65186518
case SyntaxKind.SwitchStatement:
65196519
return checkSwitchStatement(<SwitchStatement>node);
6520-
case SyntaxKind.LabelledStatement:
6521-
return checkLabelledStatement(<LabelledStatement>node);
6520+
case SyntaxKind.LabeledStatement:
6521+
return checkLabeledStatement(<LabeledStatement>node);
65226522
case SyntaxKind.ThrowStatement:
65236523
return checkThrowStatement(<ThrowStatement>node);
65246524
case SyntaxKind.TryStatement:
@@ -6597,7 +6597,7 @@ module ts {
65976597
case SyntaxKind.SwitchStatement:
65986598
case SyntaxKind.CaseClause:
65996599
case SyntaxKind.DefaultClause:
6600-
case SyntaxKind.LabelledStatement:
6600+
case SyntaxKind.LabeledStatement:
66016601
case SyntaxKind.ThrowStatement:
66026602
case SyntaxKind.TryStatement:
66036603
case SyntaxKind.TryBlock:

src/compiler/emitter.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -781,8 +781,8 @@ module ts {
781781
case SyntaxKind.ContinueStatement:
782782
case SyntaxKind.ExportAssignment:
783783
return false;
784-
case SyntaxKind.LabelledStatement:
785-
return (<LabelledStatement>node.parent).label === node;
784+
case SyntaxKind.LabeledStatement:
785+
return (<LabeledStatement>node.parent).label === node;
786786
case SyntaxKind.CatchBlock:
787787
return (<CatchBlock>node.parent).variable === node;
788788
}
@@ -1200,7 +1200,7 @@ module ts {
12001200
write(";");
12011201
}
12021202

1203-
function emitLabelledStatement(node: LabelledStatement) {
1203+
function emitLabelledStatement(node: LabeledStatement) {
12041204
emit(node.label);
12051205
write(": ");
12061206
emit(node.statement);
@@ -2071,8 +2071,8 @@ module ts {
20712071
case SyntaxKind.CaseClause:
20722072
case SyntaxKind.DefaultClause:
20732073
return emitCaseOrDefaultClause(<CaseOrDefaultClause>node);
2074-
case SyntaxKind.LabelledStatement:
2075-
return emitLabelledStatement(<LabelledStatement>node);
2074+
case SyntaxKind.LabeledStatement:
2075+
return emitLabelledStatement(<LabeledStatement>node);
20762076
case SyntaxKind.ThrowStatement:
20772077
return emitThrowStatement(<ThrowStatement>node);
20782078
case SyntaxKind.TryStatement:

src/compiler/parser.ts

Lines changed: 34 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,8 @@ module ts {
5050
return node.pos;
5151
}
5252

53-
export function getTokenPosOfNode(node: Node): number {
54-
return skipTrivia(getSourceFileOfNode(node).text, node.pos);
53+
export function getTokenPosOfNode(node: Node, sourceFile?: SourceFile): number {
54+
return skipTrivia((sourceFile || getSourceFileOfNode(node)).text, node.pos);
5555
}
5656

5757
export function getSourceTextOfNodeFromSourceText(sourceText: string, node: Node): string {
@@ -307,9 +307,9 @@ module ts {
307307
case SyntaxKind.DefaultClause:
308308
return child((<CaseOrDefaultClause>node).expression) ||
309309
children((<CaseOrDefaultClause>node).statements);
310-
case SyntaxKind.LabelledStatement:
311-
return child((<LabelledStatement>node).label) ||
312-
child((<LabelledStatement>node).statement);
310+
case SyntaxKind.LabeledStatement:
311+
return child((<LabeledStatement>node).label) ||
312+
child((<LabeledStatement>node).statement);
313313
case SyntaxKind.ThrowStatement:
314314
return child((<ThrowStatement>node).expression);
315315
case SyntaxKind.TryStatement:
@@ -373,7 +373,7 @@ module ts {
373373
case SyntaxKind.SwitchStatement:
374374
case SyntaxKind.CaseClause:
375375
case SyntaxKind.DefaultClause:
376-
case SyntaxKind.LabelledStatement:
376+
case SyntaxKind.LabeledStatement:
377377
case SyntaxKind.TryStatement:
378378
case SyntaxKind.TryBlock:
379379
case SyntaxKind.CatchBlock:
@@ -487,6 +487,32 @@ module ts {
487487
return false;
488488
}
489489

490+
export function isStatement(n: Node): boolean {
491+
switch(n.kind) {
492+
case SyntaxKind.BreakStatement:
493+
case SyntaxKind.ContinueStatement:
494+
case SyntaxKind.DebuggerStatement:
495+
case SyntaxKind.DoStatement:
496+
case SyntaxKind.ExpressionStatement:
497+
case SyntaxKind.EmptyStatement:
498+
case SyntaxKind.ForInStatement:
499+
case SyntaxKind.ForStatement:
500+
case SyntaxKind.IfStatement:
501+
case SyntaxKind.LabeledStatement:
502+
case SyntaxKind.ReturnStatement:
503+
case SyntaxKind.SwitchStatement:
504+
case SyntaxKind.ThrowKeyword:
505+
case SyntaxKind.TryStatement:
506+
case SyntaxKind.VariableStatement:
507+
case SyntaxKind.WhileStatement:
508+
case SyntaxKind.WithStatement:
509+
case SyntaxKind.ExportAssignment:
510+
return true;
511+
default:
512+
return false;
513+
}
514+
}
515+
490516
// True if the given identifier, string literal, or number literal is the name of a declaration node
491517
export function isDeclarationOrFunctionExpressionOrCatchVariableName(name: Node): boolean {
492518
if (name.kind !== SyntaxKind.Identifier && name.kind !== SyntaxKind.StringLiteral && name.kind !== SyntaxKind.NumericLiteral) {
@@ -2882,8 +2908,8 @@ module ts {
28822908
return isIdentifier() && lookAhead(() => nextToken() === SyntaxKind.ColonToken);
28832909
}
28842910

2885-
function parseLabelledStatement(): LabelledStatement {
2886-
var node = <LabelledStatement>createNode(SyntaxKind.LabelledStatement);
2911+
function parseLabelledStatement(): LabeledStatement {
2912+
var node = <LabeledStatement>createNode(SyntaxKind.LabeledStatement);
28872913
node.label = parseIdentifier();
28882914
parseExpected(SyntaxKind.ColonToken);
28892915

src/compiler/types.ts

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ module ts {
184184
SwitchStatement,
185185
CaseClause,
186186
DefaultClause,
187-
LabelledStatement,
187+
LabeledStatement,
188188
ThrowStatement,
189189
TryStatement,
190190
TryBlock,
@@ -222,7 +222,9 @@ module ts {
222222
FirstTypeNode = TypeReference,
223223
LastTypeNode = TupleType,
224224
FirstPunctuation = OpenBraceToken,
225-
LastPunctuation = CaretEqualsToken
225+
LastPunctuation = CaretEqualsToken,
226+
FirstToken = EndOfFileToken,
227+
LastToken = StringKeyword
226228
}
227229

228230
export enum NodeFlags {
@@ -464,7 +466,7 @@ module ts {
464466
statements: NodeArray<Statement>;
465467
}
466468

467-
export interface LabelledStatement extends Statement {
469+
export interface LabeledStatement extends Statement {
468470
label: Identifier;
469471
statement: Statement;
470472
}
@@ -988,6 +990,15 @@ module ts {
988990
AMD,
989991
}
990992

993+
export interface LineAndCharacter {
994+
line: number;
995+
/*
996+
* This value denotes the character position in line and is different from the 'column' because of tab characters.
997+
*/
998+
character: number;
999+
}
1000+
1001+
9911002
export enum ScriptTarget {
9921003
ES3,
9931004
ES5,

src/harness/fourslash.ts

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1428,6 +1428,46 @@ module FourSlash {
14281428
Harness.IO.log(this.getNameOrDottedNameSpan(pos));
14291429
}
14301430

1431+
private verifyClassifications(expected: { classificationType: string; text: string }[], actual: ts.ClassifiedSpan[]) {
1432+
if (actual.length !== expected.length) {
1433+
throw new Error('verifySyntacticClassification failed - expected total classifications to be ' + expected.length + ', but was ' + actual.length);
1434+
}
1435+
1436+
for (var i = 0; i < expected.length; i++) {
1437+
var expectedClassification = expected[i];
1438+
var actualClassification = actual[i];
1439+
1440+
var expectedType: string = (<any>ts.ClassificationTypeNames)[expectedClassification.classificationType];
1441+
if (expectedType !== actualClassification.classificationType) {
1442+
throw new Error('verifySyntacticClassification failed - expected classifications type to be ' +
1443+
expectedType + ', but was ' +
1444+
actualClassification.classificationType);
1445+
}
1446+
1447+
var actualSpan = actualClassification.textSpan;
1448+
var actualText = this.activeFile.content.substr(actualSpan.start(), actualSpan.length());
1449+
if (expectedClassification.text !== actualText) {
1450+
throw new Error('verifySyntacticClassification failed - expected classificatied text to be ' +
1451+
expectedClassification.text + ', but was ' +
1452+
actualText);
1453+
}
1454+
}
1455+
}
1456+
1457+
public verifySemanticClassifications(expected: { classificationType: string; text: string }[]) {
1458+
var actual = this.languageService.getSemanticClassifications(this.activeFile.fileName,
1459+
new TypeScript.TextSpan(0, this.activeFile.content.length));
1460+
1461+
this.verifyClassifications(expected, actual);
1462+
}
1463+
1464+
public verifySyntacticClassifications(expected: { classificationType: string; text: string }[]) {
1465+
var actual = this.languageService.getSyntacticClassifications(this.activeFile.fileName,
1466+
new TypeScript.TextSpan(0, this.activeFile.content.length));
1467+
1468+
this.verifyClassifications(expected, actual);
1469+
}
1470+
14311471
public verifyOutliningSpans(spans: TextSpan[]) {
14321472
this.taoInvalidReason = 'verifyOutliningSpans NYI';
14331473

src/harness/typeWriter.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,8 @@ class TypeWriterWalker {
6767
case ts.SyntaxKind.ContinueStatement:
6868
case ts.SyntaxKind.BreakStatement:
6969
return (<ts.BreakOrContinueStatement>parent).label === identifier;
70-
case ts.SyntaxKind.LabelledStatement:
71-
return (<ts.LabelledStatement>parent).label === identifier;
70+
case ts.SyntaxKind.LabeledStatement:
71+
return (<ts.LabeledStatement>parent).label === identifier;
7272
}
7373
return false;
7474
}

src/services/formatting/formatting.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,5 +36,4 @@
3636
///<reference path='indentationNodeContextPool.ts' />
3737
///<reference path='indentationTrackingWalker.ts' />
3838
///<reference path='multipleTokenIndenter.ts' />
39-
///<reference path='singleTokenIndenter.ts' />
4039
///<reference path='formatter.ts' />

src/services/formatting/singleTokenIndenter.ts

Lines changed: 0 additions & 46 deletions
This file was deleted.

0 commit comments

Comments
 (0)