Skip to content

Commit b87a7fa

Browse files
mhegazyDanielRosenwasser
authored andcommitted
move formatting.ts and smartIndernter.ts into formatting folder to match thier namespace
1 parent 791ba33 commit b87a7fa

4 files changed

Lines changed: 60 additions & 9 deletions

File tree

Lines changed: 55 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
1-
///<reference path='services.ts' />
2-
///<reference path='formatting\indentation.ts' />
3-
///<reference path='formatting\formattingScanner.ts' />
4-
///<reference path='formatting\rulesProvider.ts' />
1+
///<reference path='..\services.ts' />
2+
///<reference path='formattingScanner.ts' />
3+
///<reference path='references.ts' />
54

65
module ts.formatting {
76

@@ -991,4 +990,56 @@ module ts.formatting {
991990

992991
return SyntaxKind.Unknown;
993992
}
993+
994+
var internedTabsIndentation: string[];
995+
var internedSpacesIndentation: string[];
996+
997+
export function getIndentationString(indentation: number, options: FormatCodeOptions): string {
998+
if (!options.ConvertTabsToSpaces) {
999+
var tabs = Math.floor(indentation / options.TabSize);
1000+
var spaces = indentation - tabs * options.TabSize;
1001+
1002+
var tabString: string;
1003+
if (!internedTabsIndentation) {
1004+
internedTabsIndentation = [];
1005+
}
1006+
1007+
if (internedTabsIndentation[tabs] === undefined) {
1008+
internedTabsIndentation[tabs] = tabString = repeat('\t', tabs);
1009+
}
1010+
else {
1011+
tabString = internedTabsIndentation[tabs];
1012+
}
1013+
1014+
return spaces ? tabString + repeat(" ", spaces) : tabString;
1015+
}
1016+
else {
1017+
var spacesString: string;
1018+
var quotient = Math.floor(indentation / options.IndentSize);
1019+
var remainder = indentation % options.IndentSize;
1020+
if (!internedSpacesIndentation) {
1021+
internedSpacesIndentation = [];
1022+
}
1023+
1024+
if (internedSpacesIndentation[quotient] === undefined) {
1025+
spacesString = repeat(" ", options.IndentSize * quotient);
1026+
internedSpacesIndentation[quotient] = spacesString;
1027+
}
1028+
else {
1029+
spacesString = internedSpacesIndentation[quotient];
1030+
}
1031+
1032+
1033+
return remainder ? spacesString + repeat(" ", remainder) : spacesString;
1034+
}
1035+
1036+
function repeat(value: string, count: number): string {
1037+
var s = "";
1038+
for (var i = 0; i < count; ++i) {
1039+
s += value;
1040+
}
1041+
1042+
return s;
1043+
}
1044+
}
9941045
}

src/services/formatting/formattingScanner.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/// <reference path="..\formatting.ts"/>
1+
/// <reference path="formatting.ts"/>
22
/// <reference path="..\..\compiler\scanner.ts"/>
33

44
module ts.formatting {
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
///<reference path='services.ts' />
1+
///<reference path='..\services.ts' />
22

33
module ts.formatting {
44
export module SmartIndenter {

src/services/services.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@
44
/// <reference path="..\compiler\parser.ts"/>
55
/// <reference path="..\compiler\checker.ts"/>
66

7+
/// <reference path='breakpoints.ts' />
78
/// <reference path='outliningElementsCollector.ts' />
89
/// <reference path='navigationBar.ts' />
9-
/// <reference path='breakpoints.ts' />
1010
/// <reference path='signatureHelp.ts' />
1111
/// <reference path='utilities.ts' />
12-
/// <reference path='smartIndenter.ts' />
13-
/// <reference path='formatting.ts' />
12+
/// <reference path='formatting\formatting.ts' />
13+
/// <reference path='formatting\smartIndenter.ts' />
1414

1515
module ts {
1616

0 commit comments

Comments
 (0)