Skip to content

Commit fdc9b9d

Browse files
committed
Merge pull request #671 from Microsoft/new_smart_indentation
LS: smart indentation
2 parents f89804e + 08f446d commit fdc9b9d

21 files changed

+698
-108
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/parser.ts

Lines changed: 28 additions & 2 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 {
@@ -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) {

src/compiler/types.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,8 @@ module ts {
223223
LastTypeNode = TupleType,
224224
FirstPunctuation = OpenBraceToken,
225225
LastPunctuation = CaretEqualsToken,
226+
FirstToken = EndOfFileToken,
227+
LastToken = StringKeyword
226228
}
227229

228230
export enum NodeFlags {
@@ -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/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)