move formatting.ts and smartIndernter.ts into formatting folder to match thier namespace

This commit is contained in:
Mohamed Hegazy 2014-12-07 16:26:08 -08:00 committed by Daniel Rosenwasser
parent 791ba336cc
commit b87a7fafaf
4 changed files with 60 additions and 9 deletions

View File

@ -1,7 +1,6 @@
///<reference path='services.ts' />
///<reference path='formatting\indentation.ts' />
///<reference path='formatting\formattingScanner.ts' />
///<reference path='formatting\rulesProvider.ts' />
///<reference path='..\services.ts' />
///<reference path='formattingScanner.ts' />
///<reference path='references.ts' />
module ts.formatting {
@ -991,4 +990,56 @@ module ts.formatting {
return SyntaxKind.Unknown;
}
var internedTabsIndentation: string[];
var internedSpacesIndentation: string[];
export function getIndentationString(indentation: number, options: FormatCodeOptions): string {
if (!options.ConvertTabsToSpaces) {
var tabs = Math.floor(indentation / options.TabSize);
var spaces = indentation - tabs * options.TabSize;
var tabString: string;
if (!internedTabsIndentation) {
internedTabsIndentation = [];
}
if (internedTabsIndentation[tabs] === undefined) {
internedTabsIndentation[tabs] = tabString = repeat('\t', tabs);
}
else {
tabString = internedTabsIndentation[tabs];
}
return spaces ? tabString + repeat(" ", spaces) : tabString;
}
else {
var spacesString: string;
var quotient = Math.floor(indentation / options.IndentSize);
var remainder = indentation % options.IndentSize;
if (!internedSpacesIndentation) {
internedSpacesIndentation = [];
}
if (internedSpacesIndentation[quotient] === undefined) {
spacesString = repeat(" ", options.IndentSize * quotient);
internedSpacesIndentation[quotient] = spacesString;
}
else {
spacesString = internedSpacesIndentation[quotient];
}
return remainder ? spacesString + repeat(" ", remainder) : spacesString;
}
function repeat(value: string, count: number): string {
var s = "";
for (var i = 0; i < count; ++i) {
s += value;
}
return s;
}
}
}

View File

@ -1,4 +1,4 @@
/// <reference path="..\formatting.ts"/>
/// <reference path="formatting.ts"/>
/// <reference path="..\..\compiler\scanner.ts"/>
module ts.formatting {

View File

@ -1,4 +1,4 @@
///<reference path='services.ts' />
///<reference path='..\services.ts' />
module ts.formatting {
export module SmartIndenter {

View File

@ -4,13 +4,13 @@
/// <reference path="..\compiler\parser.ts"/>
/// <reference path="..\compiler\checker.ts"/>
/// <reference path='breakpoints.ts' />
/// <reference path='outliningElementsCollector.ts' />
/// <reference path='navigationBar.ts' />
/// <reference path='breakpoints.ts' />
/// <reference path='signatureHelp.ts' />
/// <reference path='utilities.ts' />
/// <reference path='smartIndenter.ts' />
/// <reference path='formatting.ts' />
/// <reference path='formatting\formatting.ts' />
/// <reference path='formatting\smartIndenter.ts' />
module ts {