11/// <reference path='..\services\services.ts' />
22/// <reference path='..\services\shims.ts' />
3+ /// <reference path='harness.ts' />
34
45module Harness . LanguageService {
56 export class ScriptInfo {
@@ -54,15 +55,10 @@ module Harness.LanguageService {
5455 }
5556 }
5657
57- class ScriptSnapshotShim implements ts . ScriptSnapshotShim {
58- private lineMap : number [ ] = null ;
59- private textSnapshot : string ;
60- private version : number ;
61-
62- constructor ( private scriptInfo : ScriptInfo ) {
63- this . textSnapshot = scriptInfo . content ;
64- this . version = scriptInfo . version ;
65- }
58+ class ScriptSnapshot implements ts . IScriptSnapshot {
59+ public textSnapshot : string ; public version : number ;
60+ constructor ( public scriptInfo : ScriptInfo ) {
61+ this . textSnapshot = scriptInfo . content ; this . version = scriptInfo . version ; }
6662
6763 public getText ( start : number , end : number ) : string {
6864 return this . textSnapshot . substring ( start , end ) ;
@@ -72,9 +68,28 @@ module Harness.LanguageService {
7268 return this . textSnapshot . length ;
7369 }
7470
71+ public getChangeRange ( oldScript : ts . IScriptSnapshot ) : ts . TextChangeRange {
72+ var oldShim = < ScriptSnapshot > oldScript ;
73+ return this . scriptInfo . getTextChangeRangeBetweenVersions ( oldShim . version , this . version ) ;
74+ }
75+ }
76+
77+ class ScriptSnapshotShim implements ts . ScriptSnapshotShim {
78+ constructor ( public scriptSnapshot : ScriptSnapshot ) {
79+ }
80+
81+ public getText ( start : number , end : number ) : string {
82+ return this . scriptSnapshot . getText ( start , end ) ;
83+ }
84+
85+ public getLength ( ) : number {
86+ return this . scriptSnapshot . getLength ( ) ;
87+ }
88+
7589 public getChangeRange ( oldScript : ts . ScriptSnapshotShim ) : string {
7690 var oldShim = < ScriptSnapshotShim > oldScript ;
77- var range = this . scriptInfo . getTextChangeRangeBetweenVersions ( oldShim . version , this . version ) ;
91+
92+ var range = this . scriptSnapshot . getChangeRange ( oldShim . scriptSnapshot ) ;
7893 if ( range === null ) {
7994 return null ;
8095 }
@@ -194,7 +209,7 @@ module Harness.LanguageService {
194209
195210 public getScriptSnapshot ( fileName : string ) : ts . ScriptSnapshotShim {
196211 if ( this . contains ( fileName ) ) {
197- return new ScriptSnapshotShim ( this . getScriptInfo ( fileName ) ) ;
212+ return new ScriptSnapshotShim ( new ScriptSnapshot ( this . getScriptInfo ( fileName ) ) ) ;
198213 }
199214 return undefined ;
200215 }
0 commit comments