@@ -445,9 +445,9 @@ namespace ts {
445
445
}
446
446
}
447
447
448
- export function createSourceFile ( fileName : string , sourceText : string , languageVersion : ScriptTarget , setParentNodes = false , scriptKind ?: ScriptKind , range ?: TextRange ) : SourceFile {
448
+ export function createSourceFile ( fileName : string , sourceText : string , languageVersion : ScriptTarget , setParentNodes = false , scriptKind ?: ScriptKind ) : SourceFile {
449
449
performance . mark ( "beforeParse" ) ;
450
- const result = Parser . parseSourceFile ( fileName , sourceText , languageVersion , /*syntaxCursor*/ undefined , setParentNodes , scriptKind , range ) ;
450
+ const result = Parser . parseSourceFile ( fileName , sourceText , languageVersion , /*syntaxCursor*/ undefined , setParentNodes , scriptKind ) ;
451
451
performance . mark ( "afterParse" ) ;
452
452
performance . measure ( "Parse" , "beforeParse" , "afterParse" ) ;
453
453
return result ;
@@ -470,8 +470,8 @@ namespace ts {
470
470
// from this SourceFile that are being held onto may change as a result (including
471
471
// becoming detached from any SourceFile). It is recommended that this SourceFile not
472
472
// be used once 'update' is called on it.
473
- export function updateSourceFile ( sourceFile : SourceFile , newText : string , textChangeRange : TextChangeRange , aggressiveChecks ?: boolean , range ?: TextRange ) : SourceFile {
474
- return IncrementalParser . updateSourceFile ( sourceFile , newText , textChangeRange , aggressiveChecks , range ) ;
473
+ export function updateSourceFile ( sourceFile : SourceFile , newText : string , textChangeRange : TextChangeRange , aggressiveChecks ?: boolean ) : SourceFile {
474
+ return IncrementalParser . updateSourceFile ( sourceFile , newText , textChangeRange , aggressiveChecks ) ;
475
475
}
476
476
477
477
/* @internal */
@@ -596,10 +596,10 @@ namespace ts {
596
596
// attached to the EOF token.
597
597
let parseErrorBeforeNextFinishedNode = false ;
598
598
599
- export function parseSourceFile ( fileName : string , sourceText : string , languageVersion : ScriptTarget , syntaxCursor : IncrementalParser . SyntaxCursor , setParentNodes ?: boolean , scriptKind ?: ScriptKind , range ?: TextRange ) : SourceFile {
599
+ export function parseSourceFile ( fileName : string , sourceText : string , languageVersion : ScriptTarget , syntaxCursor : IncrementalParser . SyntaxCursor , setParentNodes ?: boolean , scriptKind ?: ScriptKind ) : SourceFile {
600
600
scriptKind = ensureScriptKind ( fileName , scriptKind ) ;
601
601
602
- initializeState ( sourceText , languageVersion , syntaxCursor , scriptKind , range ) ;
602
+ initializeState ( sourceText , languageVersion , syntaxCursor , scriptKind ) ;
603
603
604
604
const result = parseSourceFileWorker ( fileName , languageVersion , setParentNodes , scriptKind ) ;
605
605
@@ -623,7 +623,7 @@ namespace ts {
623
623
return scriptKind === ScriptKind . TSX || scriptKind === ScriptKind . JSX || scriptKind === ScriptKind . JS ? LanguageVariant . JSX : LanguageVariant . Standard ;
624
624
}
625
625
626
- function initializeState ( _sourceText : string , languageVersion : ScriptTarget , _syntaxCursor : IncrementalParser . SyntaxCursor , scriptKind : ScriptKind , range ?: TextRange ) {
626
+ function initializeState ( _sourceText : string , languageVersion : ScriptTarget , _syntaxCursor : IncrementalParser . SyntaxCursor , scriptKind : ScriptKind ) {
627
627
NodeConstructor = objectAllocator . getNodeConstructor ( ) ;
628
628
TokenConstructor = objectAllocator . getTokenConstructor ( ) ;
629
629
IdentifierConstructor = objectAllocator . getIdentifierConstructor ( ) ;
@@ -642,13 +642,7 @@ namespace ts {
642
642
parseErrorBeforeNextFinishedNode = false ;
643
643
644
644
// Initialize and prime the scanner before parsing the source elements.
645
- if ( range ) {
646
- // create a scanner with different start and stop values
647
- scanner . setText ( sourceText , range . pos , range . end - range . pos ) ;
648
- }
649
- else {
650
- scanner . setText ( sourceText ) ;
651
- }
645
+ scanner . setText ( sourceText ) ;
652
646
scanner . setOnError ( scanError ) ;
653
647
scanner . setScriptTarget ( languageVersion ) ;
654
648
scanner . setLanguageVariant ( getLanguageVariant ( scriptKind ) ) ;
@@ -6908,7 +6902,7 @@ namespace ts {
6908
6902
}
6909
6903
6910
6904
namespace IncrementalParser {
6911
- export function updateSourceFile ( sourceFile : SourceFile , newText : string , textChangeRange : TextChangeRange , aggressiveChecks : boolean , range ?: TextRange ) : SourceFile {
6905
+ export function updateSourceFile ( sourceFile : SourceFile , newText : string , textChangeRange : TextChangeRange , aggressiveChecks : boolean ) : SourceFile {
6912
6906
aggressiveChecks = aggressiveChecks || Debug . shouldAssert ( AssertionLevel . Aggressive ) ;
6913
6907
6914
6908
checkChangeRange ( sourceFile , newText , textChangeRange , aggressiveChecks ) ;
@@ -6920,7 +6914,7 @@ namespace ts {
6920
6914
if ( sourceFile . statements . length === 0 ) {
6921
6915
// If we don't have any statements in the current source file, then there's no real
6922
6916
// way to incrementally parse. So just do a full parse instead.
6923
- return Parser . parseSourceFile ( sourceFile . fileName , newText , sourceFile . languageVersion , /*syntaxCursor*/ undefined , /*setParentNodes*/ true , sourceFile . scriptKind , range ) ;
6917
+ return Parser . parseSourceFile ( sourceFile . fileName , newText , sourceFile . languageVersion , /*syntaxCursor*/ undefined , /*setParentNodes*/ true , sourceFile . scriptKind ) ;
6924
6918
}
6925
6919
6926
6920
// Make sure we're not trying to incrementally update a source file more than once. Once
@@ -6984,7 +6978,7 @@ namespace ts {
6984
6978
// inconsistent tree. Setting the parents on the new tree should be very fast. We
6985
6979
// will immediately bail out of walking any subtrees when we can see that their parents
6986
6980
// are already correct.
6987
- return Parser . parseSourceFile ( sourceFile . fileName , newText , sourceFile . languageVersion , syntaxCursor , /*setParentNodes*/ true , sourceFile . scriptKind , range ) ;
6981
+ return Parser . parseSourceFile ( sourceFile . fileName , newText , sourceFile . languageVersion , syntaxCursor , /*setParentNodes*/ true , sourceFile . scriptKind ) ;
6988
6982
}
6989
6983
6990
6984
function moveElementEntirelyPastChangeRange ( element : IncrementalElement , isArray : boolean , delta : number , oldText : string , newText : string , aggressiveChecks : boolean ) {
0 commit comments