@@ -67,7 +67,11 @@ namespace ts.formatting {
6767 delta : number ;
6868 }
6969
70- export function formatOnEnter ( position : number , sourceFile : SourceFile , rulesProvider : RulesProvider , options : FormatCodeSettings ) : TextChange [ ] {
70+ export function formatOnEnter ( position : number , sourceFile : SourceFile , rulesProvider : RulesProvider , options : FormatCodeSettings | FormatCodeOptions ) : TextChange [ ] {
71+ return formatOnEnterWorker ( position , sourceFile , rulesProvider , toEditorSettings ( options ) ) ;
72+ }
73+
74+ export function formatOnEnterWorker ( position : number , sourceFile : SourceFile , rulesProvider : RulesProvider , options : FormatCodeSettings ) : TextChange [ ] {
7175 const line = sourceFile . getLineAndCharacterOfPosition ( position ) . line ;
7276 if ( line === 0 ) {
7377 return [ ] ;
@@ -96,23 +100,39 @@ namespace ts.formatting {
96100 return formatSpan ( span , sourceFile , options , rulesProvider , FormattingRequestKind . FormatOnEnter ) ;
97101 }
98102
99- export function formatOnSemicolon ( position : number , sourceFile : SourceFile , rulesProvider : RulesProvider , options : FormatCodeSettings ) : TextChange [ ] {
103+ export function formatOnSemicolon ( position : number , sourceFile : SourceFile , rulesProvider : RulesProvider , options : FormatCodeSettings | FormatCodeOptions ) : TextChange [ ] {
104+ return formatOnSemicolonWorker ( position , sourceFile , rulesProvider , toEditorSettings ( options ) ) ;
105+ }
106+
107+ export function formatOnSemicolonWorker ( position : number , sourceFile : SourceFile , rulesProvider : RulesProvider , options : FormatCodeSettings ) : TextChange [ ] {
100108 return formatOutermostParent ( position , SyntaxKind . SemicolonToken , sourceFile , options , rulesProvider , FormattingRequestKind . FormatOnSemicolon ) ;
101109 }
102110
103- export function formatOnClosingCurly ( position : number , sourceFile : SourceFile , rulesProvider : RulesProvider , options : FormatCodeSettings ) : TextChange [ ] {
111+ export function formatOnClosingCurly ( position : number , sourceFile : SourceFile , rulesProvider : RulesProvider , options : FormatCodeSettings | FormatCodeOptions ) : TextChange [ ] {
112+ return formatOnClosingCurlyWorker ( position , sourceFile , rulesProvider , toEditorSettings ( options ) ) ;
113+ }
114+
115+ export function formatOnClosingCurlyWorker ( position : number , sourceFile : SourceFile , rulesProvider : RulesProvider , options : FormatCodeSettings ) : TextChange [ ] {
104116 return formatOutermostParent ( position , SyntaxKind . CloseBraceToken , sourceFile , options , rulesProvider , FormattingRequestKind . FormatOnClosingCurlyBrace ) ;
105117 }
106118
107- export function formatDocument ( sourceFile : SourceFile , rulesProvider : RulesProvider , options : FormatCodeSettings ) : TextChange [ ] {
119+ export function formatDocument ( sourceFile : SourceFile , rulesProvider : RulesProvider , options : FormatCodeSettings | FormatCodeOptions ) : TextChange [ ] {
120+ return formatDocumentWorker ( sourceFile , rulesProvider , toEditorSettings ( options ) ) ;
121+ }
122+
123+ export function formatDocumentWorker ( sourceFile : SourceFile , rulesProvider : RulesProvider , options : FormatCodeSettings ) : TextChange [ ] {
108124 const span = {
109125 pos : 0 ,
110126 end : sourceFile . text . length
111127 } ;
112128 return formatSpan ( span , sourceFile , options , rulesProvider , FormattingRequestKind . FormatDocument ) ;
113129 }
114130
115- export function formatSelection ( start : number , end : number , sourceFile : SourceFile , rulesProvider : RulesProvider , options : FormatCodeSettings ) : TextChange [ ] {
131+ export function formatSelection ( start : number , end : number , sourceFile : SourceFile , rulesProvider : RulesProvider , options : FormatCodeSettings | FormatCodeOptions ) : TextChange [ ] {
132+ return formatSelectionWorker ( start , end , sourceFile , rulesProvider , toEditorSettings ( options ) ) ;
133+ }
134+
135+ export function formatSelectionWorker ( start : number , end : number , sourceFile : SourceFile , rulesProvider : RulesProvider , options : FormatCodeSettings ) : TextChange [ ] {
116136 // format from the beginning of the line
117137 const span = {
118138 pos : getLineStartPositionForPosition ( start , sourceFile ) ,
0 commit comments