@@ -27,20 +27,6 @@ namespace ts {
27
27
return undefined ;
28
28
}
29
29
30
- export function findDeclaration < T extends Declaration > ( symbol : Symbol , predicate : ( node : Declaration ) => node is T ) : T | undefined ;
31
- export function findDeclaration ( symbol : Symbol , predicate : ( node : Declaration ) => boolean ) : Declaration | undefined ;
32
- export function findDeclaration ( symbol : Symbol , predicate : ( node : Declaration ) => boolean ) : Declaration | undefined {
33
- const declarations = symbol . declarations ;
34
- if ( declarations ) {
35
- for ( const declaration of declarations ) {
36
- if ( predicate ( declaration ) ) {
37
- return declaration ;
38
- }
39
- }
40
- }
41
- return undefined ;
42
- }
43
-
44
30
export interface StringSymbolWriter extends SymbolWriter {
45
31
string ( ) : string ;
46
32
}
@@ -112,19 +98,16 @@ namespace ts {
112
98
sourceFile . resolvedTypeReferenceDirectiveNames . set ( typeReferenceDirectiveName , resolvedTypeReferenceDirective ) ;
113
99
}
114
100
115
- /* @internal */
116
101
export function moduleResolutionIsEqualTo ( oldResolution : ResolvedModuleFull , newResolution : ResolvedModuleFull ) : boolean {
117
102
return oldResolution . isExternalLibraryImport === newResolution . isExternalLibraryImport &&
118
103
oldResolution . extension === newResolution . extension &&
119
104
oldResolution . resolvedFileName === newResolution . resolvedFileName ;
120
105
}
121
106
122
- /* @internal */
123
107
export function typeDirectiveIsEqualTo ( oldResolution : ResolvedTypeReferenceDirective , newResolution : ResolvedTypeReferenceDirective ) : boolean {
124
108
return oldResolution . resolvedFileName === newResolution . resolvedFileName && oldResolution . primary === newResolution . primary ;
125
109
}
126
110
127
- /* @internal */
128
111
export function hasChangesInResolutions < T > (
129
112
names : ReadonlyArray < string > ,
130
113
newResolutions : ReadonlyArray < T > ,
@@ -203,14 +186,6 @@ namespace ts {
203
186
return `${ file . fileName } (${ loc . line + 1 } ,${ loc . character + 1 } )` ;
204
187
}
205
188
206
- export function getStartPosOfNode ( node : Node ) : number {
207
- return node . pos ;
208
- }
209
-
210
- export function isDefined ( value : any ) : boolean {
211
- return value !== undefined ;
212
- }
213
-
214
189
export function getEndLinePosition ( line : number , sourceFile : SourceFileLike ) : number {
215
190
Debug . assert ( line >= 0 ) ;
216
191
const lineStarts = getLineStarts ( sourceFile ) ;
@@ -463,7 +438,7 @@ namespace ts {
463
438
return isExternalModule ( node ) || compilerOptions . isolatedModules ;
464
439
}
465
440
466
- export function isBlockScope ( node : Node , parentNode : Node ) {
441
+ function isBlockScope ( node : Node , parentNode : Node ) {
467
442
switch ( node . kind ) {
468
443
case SyntaxKind . SourceFile :
469
444
case SyntaxKind . CaseBlock :
@@ -664,29 +639,25 @@ namespace ts {
664
639
return getLeadingCommentRanges ( sourceFileOfNode . text , node . pos ) ;
665
640
}
666
641
667
- export function getLeadingCommentRangesOfNodeFromText ( node : Node , text : string ) {
668
- return getLeadingCommentRanges ( text , node . pos ) ;
669
- }
670
-
671
642
export function getJSDocCommentRanges ( node : Node , text : string ) {
672
643
const commentRanges = ( node . kind === SyntaxKind . Parameter ||
673
644
node . kind === SyntaxKind . TypeParameter ||
674
645
node . kind === SyntaxKind . FunctionExpression ||
675
646
node . kind === SyntaxKind . ArrowFunction ||
676
647
node . kind === SyntaxKind . ParenthesizedExpression ) ?
677
648
concatenate ( getTrailingCommentRanges ( text , node . pos ) , getLeadingCommentRanges ( text , node . pos ) ) :
678
- getLeadingCommentRangesOfNodeFromText ( node , text ) ;
649
+ getLeadingCommentRanges ( text , node . pos ) ;
679
650
// True if the comment starts with '/**' but not if it is '/**/'
680
651
return filter ( commentRanges , comment =>
681
652
text . charCodeAt ( comment . pos + 1 ) === CharacterCodes . asterisk &&
682
653
text . charCodeAt ( comment . pos + 2 ) === CharacterCodes . asterisk &&
683
654
text . charCodeAt ( comment . pos + 3 ) !== CharacterCodes . slash ) ;
684
655
}
685
656
686
- export let fullTripleSlashReferencePathRegEx = / ^ ( \/ \/ \/ \s * < r e f e r e n c e \s + p a t h \s * = \s * ) ( ' | " ) ( .+ ?) \2.* ?\/ > / ;
687
- export let fullTripleSlashReferenceTypeReferenceDirectiveRegEx = / ^ ( \/ \/ \/ \s * < r e f e r e n c e \s + t y p e s \s * = \s * ) ( ' | " ) ( .+ ?) \2.* ?\/ > / ;
688
- export let fullTripleSlashAMDReferencePathRegEx = / ^ ( \/ \/ \/ \s * < a m d - d e p e n d e n c y \s + p a t h \s * = \s * ) ( ' | " ) ( .+ ?) \2.* ?\/ > / ;
689
- export let defaultLibReferenceRegEx = / ^ ( \/ \/ \/ \s * < r e f e r e n c e \s + n o - d e f a u l t - l i b \s * = \s * ) ( ' | " ) ( .+ ?) \2\s * \/ > / ;
657
+ export const fullTripleSlashReferencePathRegEx = / ^ ( \/ \/ \/ \s * < r e f e r e n c e \s + p a t h \s * = \s * ) ( ' | " ) ( .+ ?) \2.* ?\/ > / ;
658
+ const fullTripleSlashReferenceTypeReferenceDirectiveRegEx = / ^ ( \/ \/ \/ \s * < r e f e r e n c e \s + t y p e s \s * = \s * ) ( ' | " ) ( .+ ?) \2.* ?\/ > / ;
659
+ export const fullTripleSlashAMDReferencePathRegEx = / ^ ( \/ \/ \/ \s * < a m d - d e p e n d e n c y \s + p a t h \s * = \s * ) ( ' | " ) ( .+ ?) \2.* ?\/ > / ;
660
+ const defaultLibReferenceRegEx = / ^ ( \/ \/ \/ \s * < r e f e r e n c e \s + n o - d e f a u l t - l i b \s * = \s * ) ( ' | " ) ( .+ ?) \2\s * \/ > / ;
690
661
691
662
export function isPartOfTypeNode ( node : Node ) : boolean {
692
663
if ( SyntaxKind . FirstTypeNode <= node . kind && node . kind <= SyntaxKind . LastTypeNode ) {
@@ -2095,10 +2066,6 @@ namespace ts {
2095
2066
return getParseTreeNode ( sourceFile , isSourceFile ) || sourceFile ;
2096
2067
}
2097
2068
2098
- export function getOriginalSourceFiles ( sourceFiles : ReadonlyArray < SourceFile > ) {
2099
- return sameMap ( sourceFiles , getOriginalSourceFile ) ;
2100
- }
2101
-
2102
2069
export const enum Associativity {
2103
2070
Left ,
2104
2071
Right
@@ -3090,24 +3057,6 @@ namespace ts {
3090
3057
return false ;
3091
3058
}
3092
3059
3093
- // Returns false if this heritage clause element's expression contains something unsupported
3094
- // (i.e. not a name or dotted name).
3095
- export function isSupportedExpressionWithTypeArguments ( node : ExpressionWithTypeArguments ) : boolean {
3096
- return isSupportedExpressionWithTypeArgumentsRest ( node . expression ) ;
3097
- }
3098
-
3099
- function isSupportedExpressionWithTypeArgumentsRest ( node : Expression ) : boolean {
3100
- if ( node . kind === SyntaxKind . Identifier ) {
3101
- return true ;
3102
- }
3103
- else if ( isPropertyAccessExpression ( node ) ) {
3104
- return isSupportedExpressionWithTypeArgumentsRest ( node . expression ) ;
3105
- }
3106
- else {
3107
- return false ;
3108
- }
3109
- }
3110
-
3111
3060
export function isExpressionWithTypeArgumentsInClassExtendsClause ( node : Node ) : boolean {
3112
3061
return tryGetClassExtendingExpressionWithTypeArguments ( node ) !== undefined ;
3113
3062
}
@@ -3244,81 +3193,6 @@ namespace ts {
3244
3193
return carriageReturnLineFeed ;
3245
3194
}
3246
3195
3247
- /**
3248
- * Tests whether a node and its subtree is simple enough to have its position
3249
- * information ignored when emitting source maps in a destructuring assignment.
3250
- *
3251
- * @param node The expression to test.
3252
- */
3253
- export function isSimpleExpression ( node : Expression ) : boolean {
3254
- return isSimpleExpressionWorker ( node , 0 ) ;
3255
- }
3256
-
3257
- function isSimpleExpressionWorker ( node : Expression , depth : number ) : boolean {
3258
- if ( depth <= 5 ) {
3259
- const kind = node . kind ;
3260
- if ( kind === SyntaxKind . StringLiteral
3261
- || kind === SyntaxKind . NumericLiteral
3262
- || kind === SyntaxKind . RegularExpressionLiteral
3263
- || kind === SyntaxKind . NoSubstitutionTemplateLiteral
3264
- || kind === SyntaxKind . Identifier
3265
- || kind === SyntaxKind . ThisKeyword
3266
- || kind === SyntaxKind . SuperKeyword
3267
- || kind === SyntaxKind . TrueKeyword
3268
- || kind === SyntaxKind . FalseKeyword
3269
- || kind === SyntaxKind . NullKeyword ) {
3270
- return true ;
3271
- }
3272
- else if ( kind === SyntaxKind . PropertyAccessExpression ) {
3273
- return isSimpleExpressionWorker ( ( < PropertyAccessExpression > node ) . expression , depth + 1 ) ;
3274
- }
3275
- else if ( kind === SyntaxKind . ElementAccessExpression ) {
3276
- return isSimpleExpressionWorker ( ( < ElementAccessExpression > node ) . expression , depth + 1 )
3277
- && isSimpleExpressionWorker ( ( < ElementAccessExpression > node ) . argumentExpression , depth + 1 ) ;
3278
- }
3279
- else if ( kind === SyntaxKind . PrefixUnaryExpression
3280
- || kind === SyntaxKind . PostfixUnaryExpression ) {
3281
- return isSimpleExpressionWorker ( ( < PrefixUnaryExpression | PostfixUnaryExpression > node ) . operand , depth + 1 ) ;
3282
- }
3283
- else if ( kind === SyntaxKind . BinaryExpression ) {
3284
- return ( < BinaryExpression > node ) . operatorToken . kind !== SyntaxKind . AsteriskAsteriskToken
3285
- && isSimpleExpressionWorker ( ( < BinaryExpression > node ) . left , depth + 1 )
3286
- && isSimpleExpressionWorker ( ( < BinaryExpression > node ) . right , depth + 1 ) ;
3287
- }
3288
- else if ( kind === SyntaxKind . ConditionalExpression ) {
3289
- return isSimpleExpressionWorker ( ( < ConditionalExpression > node ) . condition , depth + 1 )
3290
- && isSimpleExpressionWorker ( ( < ConditionalExpression > node ) . whenTrue , depth + 1 )
3291
- && isSimpleExpressionWorker ( ( < ConditionalExpression > node ) . whenFalse , depth + 1 ) ;
3292
- }
3293
- else if ( kind === SyntaxKind . VoidExpression
3294
- || kind === SyntaxKind . TypeOfExpression
3295
- || kind === SyntaxKind . DeleteExpression ) {
3296
- return isSimpleExpressionWorker ( ( < VoidExpression | TypeOfExpression | DeleteExpression > node ) . expression , depth + 1 ) ;
3297
- }
3298
- else if ( kind === SyntaxKind . ArrayLiteralExpression ) {
3299
- return ( < ArrayLiteralExpression > node ) . elements . length === 0 ;
3300
- }
3301
- else if ( kind === SyntaxKind . ObjectLiteralExpression ) {
3302
- return ( < ObjectLiteralExpression > node ) . properties . length === 0 ;
3303
- }
3304
- else if ( kind === SyntaxKind . CallExpression ) {
3305
- if ( ! isSimpleExpressionWorker ( ( < CallExpression > node ) . expression , depth + 1 ) ) {
3306
- return false ;
3307
- }
3308
-
3309
- for ( const argument of ( < CallExpression > node ) . arguments ) {
3310
- if ( ! isSimpleExpressionWorker ( argument , depth + 1 ) ) {
3311
- return false ;
3312
- }
3313
- }
3314
-
3315
- return true ;
3316
- }
3317
- }
3318
-
3319
- return false ;
3320
- }
3321
-
3322
3196
/**
3323
3197
* Formats an enum value as a string for debugging and debug assertions.
3324
3198
*/
@@ -3391,24 +3265,6 @@ namespace ts {
3391
3265
return formatEnum ( flags , ( < any > ts ) . ObjectFlags , /*isFlags*/ true ) ;
3392
3266
}
3393
3267
3394
- export function getRangePos ( range : TextRange | undefined ) {
3395
- return range ? range . pos : - 1 ;
3396
- }
3397
-
3398
- export function getRangeEnd ( range : TextRange | undefined ) {
3399
- return range ? range . end : - 1 ;
3400
- }
3401
-
3402
- /**
3403
- * Increases (or decreases) a position by the provided amount.
3404
- *
3405
- * @param pos The position.
3406
- * @param value The delta.
3407
- */
3408
- export function movePos ( pos : number , value : number ) {
3409
- return positionIsSynthesized ( pos ) ? - 1 : pos + value ;
3410
- }
3411
-
3412
3268
/**
3413
3269
* Creates a new TextRange from the provided pos and end.
3414
3270
*
@@ -3466,26 +3322,6 @@ namespace ts {
3466
3322
return range . pos === range . end ;
3467
3323
}
3468
3324
3469
- /**
3470
- * Creates a new TextRange from a provided range with its end position collapsed to its
3471
- * start position.
3472
- *
3473
- * @param range A TextRange.
3474
- */
3475
- export function collapseRangeToStart ( range : TextRange ) : TextRange {
3476
- return isCollapsedRange ( range ) ? range : moveRangeEnd ( range , range . pos ) ;
3477
- }
3478
-
3479
- /**
3480
- * Creates a new TextRange from a provided range with its start position collapsed to its
3481
- * end position.
3482
- *
3483
- * @param range A TextRange.
3484
- */
3485
- export function collapseRangeToEnd ( range : TextRange ) : TextRange {
3486
- return isCollapsedRange ( range ) ? range : moveRangePos ( range , range . end ) ;
3487
- }
3488
-
3489
3325
/**
3490
3326
* Creates a new TextRange for a token at the provides start position.
3491
3327
*
@@ -3549,31 +3385,6 @@ namespace ts {
3549
3385
return node . initializer !== undefined ;
3550
3386
}
3551
3387
3552
- /**
3553
- * Gets a value indicating whether a node is merged with a class declaration in the same scope.
3554
- */
3555
- export function isMergedWithClass ( node : Node ) {
3556
- if ( node . symbol ) {
3557
- for ( const declaration of node . symbol . declarations ) {
3558
- if ( declaration . kind === SyntaxKind . ClassDeclaration && declaration !== node ) {
3559
- return true ;
3560
- }
3561
- }
3562
- }
3563
-
3564
- return false ;
3565
- }
3566
-
3567
- /**
3568
- * Gets a value indicating whether a node is the first declaration of its kind.
3569
- *
3570
- * @param node A Declaration node.
3571
- * @param kind The SyntaxKind to find among related declarations.
3572
- */
3573
- export function isFirstDeclarationOfKind ( node : Node , kind : SyntaxKind ) {
3574
- return node . symbol && getDeclarationOfKind ( node . symbol , kind ) === node ;
3575
- }
3576
-
3577
3388
export function isWatchSet ( options : CompilerOptions ) {
3578
3389
// Firefox has Object.prototype.watch
3579
3390
return options . watch && options . hasOwnProperty ( "watch" ) ;
0 commit comments