@@ -26,20 +26,6 @@ namespace ts {
26
26
return undefined ;
27
27
}
28
28
29
- export function findDeclaration < T extends Declaration > ( symbol : Symbol , predicate : ( node : Declaration ) => node is T ) : T | undefined ;
30
- export function findDeclaration ( symbol : Symbol , predicate : ( node : Declaration ) => boolean ) : Declaration | undefined ;
31
- export function findDeclaration ( symbol : Symbol , predicate : ( node : Declaration ) => boolean ) : Declaration | undefined {
32
- const declarations = symbol . declarations ;
33
- if ( declarations ) {
34
- for ( const declaration of declarations ) {
35
- if ( predicate ( declaration ) ) {
36
- return declaration ;
37
- }
38
- }
39
- }
40
- return undefined ;
41
- }
42
-
43
29
export interface StringSymbolWriter extends SymbolWriter {
44
30
string ( ) : string ;
45
31
}
@@ -111,19 +97,16 @@ namespace ts {
111
97
sourceFile . resolvedTypeReferenceDirectiveNames . set ( typeReferenceDirectiveName , resolvedTypeReferenceDirective ) ;
112
98
}
113
99
114
- /* @internal */
115
100
export function moduleResolutionIsEqualTo ( oldResolution : ResolvedModuleFull , newResolution : ResolvedModuleFull ) : boolean {
116
101
return oldResolution . isExternalLibraryImport === newResolution . isExternalLibraryImport &&
117
102
oldResolution . extension === newResolution . extension &&
118
103
oldResolution . resolvedFileName === newResolution . resolvedFileName ;
119
104
}
120
105
121
- /* @internal */
122
106
export function typeDirectiveIsEqualTo ( oldResolution : ResolvedTypeReferenceDirective , newResolution : ResolvedTypeReferenceDirective ) : boolean {
123
107
return oldResolution . resolvedFileName === newResolution . resolvedFileName && oldResolution . primary === newResolution . primary ;
124
108
}
125
109
126
- /* @internal */
127
110
export function hasChangesInResolutions < T > (
128
111
names : ReadonlyArray < string > ,
129
112
newResolutions : ReadonlyArray < T > ,
@@ -202,14 +185,6 @@ namespace ts {
202
185
return `${ file . fileName } (${ loc . line + 1 } ,${ loc . character + 1 } )` ;
203
186
}
204
187
205
- export function getStartPosOfNode ( node : Node ) : number {
206
- return node . pos ;
207
- }
208
-
209
- export function isDefined ( value : any ) : boolean {
210
- return value !== undefined ;
211
- }
212
-
213
188
export function getEndLinePosition ( line : number , sourceFile : SourceFileLike ) : number {
214
189
Debug . assert ( line >= 0 ) ;
215
190
const lineStarts = getLineStarts ( sourceFile ) ;
@@ -436,7 +411,7 @@ namespace ts {
436
411
return isExternalModule ( node ) || compilerOptions . isolatedModules ;
437
412
}
438
413
439
- export function isBlockScope ( node : Node , parentNode : Node ) {
414
+ function isBlockScope ( node : Node , parentNode : Node ) {
440
415
switch ( node . kind ) {
441
416
case SyntaxKind . SourceFile :
442
417
case SyntaxKind . CaseBlock :
@@ -637,28 +612,24 @@ namespace ts {
637
612
return getLeadingCommentRanges ( sourceFileOfNode . text , node . pos ) ;
638
613
}
639
614
640
- export function getLeadingCommentRangesOfNodeFromText ( node : Node , text : string ) {
641
- return getLeadingCommentRanges ( text , node . pos ) ;
642
- }
643
-
644
615
export function getJSDocCommentRanges ( node : Node , text : string ) {
645
616
const commentRanges = ( node . kind === SyntaxKind . Parameter ||
646
617
node . kind === SyntaxKind . TypeParameter ||
647
618
node . kind === SyntaxKind . FunctionExpression ||
648
619
node . kind === SyntaxKind . ArrowFunction ||
649
620
node . kind === SyntaxKind . ParenthesizedExpression ) ?
650
621
concatenate ( getTrailingCommentRanges ( text , node . pos ) , getLeadingCommentRanges ( text , node . pos ) ) :
651
- getLeadingCommentRangesOfNodeFromText ( node , text ) ;
622
+ getLeadingCommentRanges ( text , node . pos ) ;
652
623
// True if the comment starts with '/**' but not if it is '/**/'
653
624
return filter ( commentRanges , comment =>
654
625
text . charCodeAt ( comment . pos + 1 ) === CharacterCodes . asterisk &&
655
626
text . charCodeAt ( comment . pos + 2 ) === CharacterCodes . asterisk &&
656
627
text . charCodeAt ( comment . pos + 3 ) !== CharacterCodes . slash ) ;
657
628
}
658
629
659
- export let fullTripleSlashReferencePathRegEx = / ^ ( \/ \/ \/ \s * < r e f e r e n c e \s + p a t h \s * = \s * ) ( ' | " ) ( .+ ?) \2.* ?\/ > / ;
660
- export let fullTripleSlashReferenceTypeReferenceDirectiveRegEx = / ^ ( \/ \/ \/ \s * < r e f e r e n c e \s + t y p e s \s * = \s * ) ( ' | " ) ( .+ ?) \2.* ?\/ > / ;
661
- 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.* ?\/ > / ;
630
+ export const fullTripleSlashReferencePathRegEx = / ^ ( \/ \/ \/ \s * < r e f e r e n c e \s + p a t h \s * = \s * ) ( ' | " ) ( .+ ?) \2.* ?\/ > / ;
631
+ export const fullTripleSlashReferenceTypeReferenceDirectiveRegEx = / ^ ( \/ \/ \/ \s * < r e f e r e n c e \s + t y p e s \s * = \s * ) ( ' | " ) ( .+ ?) \2.* ?\/ > / ;
632
+ 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.* ?\/ > / ;
662
633
663
634
export function isPartOfTypeNode ( node : Node ) : boolean {
664
635
if ( SyntaxKind . FirstTypeNode <= node . kind && node . kind <= SyntaxKind . LastTypeNode ) {
@@ -2072,10 +2043,6 @@ namespace ts {
2072
2043
return getParseTreeNode ( sourceFile , isSourceFile ) || sourceFile ;
2073
2044
}
2074
2045
2075
- export function getOriginalSourceFiles ( sourceFiles : ReadonlyArray < SourceFile > ) {
2076
- return sameMap ( sourceFiles , getOriginalSourceFile ) ;
2077
- }
2078
-
2079
2046
export const enum Associativity {
2080
2047
Left ,
2081
2048
Right
@@ -3068,24 +3035,6 @@ namespace ts {
3068
3035
return false ;
3069
3036
}
3070
3037
3071
- // Returns false if this heritage clause element's expression contains something unsupported
3072
- // (i.e. not a name or dotted name).
3073
- export function isSupportedExpressionWithTypeArguments ( node : ExpressionWithTypeArguments ) : boolean {
3074
- return isSupportedExpressionWithTypeArgumentsRest ( node . expression ) ;
3075
- }
3076
-
3077
- function isSupportedExpressionWithTypeArgumentsRest ( node : Expression ) : boolean {
3078
- if ( node . kind === SyntaxKind . Identifier ) {
3079
- return true ;
3080
- }
3081
- else if ( isPropertyAccessExpression ( node ) ) {
3082
- return isSupportedExpressionWithTypeArgumentsRest ( node . expression ) ;
3083
- }
3084
- else {
3085
- return false ;
3086
- }
3087
- }
3088
-
3089
3038
export function isExpressionWithTypeArgumentsInClassExtendsClause ( node : Node ) : boolean {
3090
3039
return tryGetClassExtendingExpressionWithTypeArguments ( node ) !== undefined ;
3091
3040
}
@@ -3222,81 +3171,6 @@ namespace ts {
3222
3171
return carriageReturnLineFeed ;
3223
3172
}
3224
3173
3225
- /**
3226
- * Tests whether a node and its subtree is simple enough to have its position
3227
- * information ignored when emitting source maps in a destructuring assignment.
3228
- *
3229
- * @param node The expression to test.
3230
- */
3231
- export function isSimpleExpression ( node : Expression ) : boolean {
3232
- return isSimpleExpressionWorker ( node , 0 ) ;
3233
- }
3234
-
3235
- function isSimpleExpressionWorker ( node : Expression , depth : number ) : boolean {
3236
- if ( depth <= 5 ) {
3237
- const kind = node . kind ;
3238
- if ( kind === SyntaxKind . StringLiteral
3239
- || kind === SyntaxKind . NumericLiteral
3240
- || kind === SyntaxKind . RegularExpressionLiteral
3241
- || kind === SyntaxKind . NoSubstitutionTemplateLiteral
3242
- || kind === SyntaxKind . Identifier
3243
- || kind === SyntaxKind . ThisKeyword
3244
- || kind === SyntaxKind . SuperKeyword
3245
- || kind === SyntaxKind . TrueKeyword
3246
- || kind === SyntaxKind . FalseKeyword
3247
- || kind === SyntaxKind . NullKeyword ) {
3248
- return true ;
3249
- }
3250
- else if ( kind === SyntaxKind . PropertyAccessExpression ) {
3251
- return isSimpleExpressionWorker ( ( < PropertyAccessExpression > node ) . expression , depth + 1 ) ;
3252
- }
3253
- else if ( kind === SyntaxKind . ElementAccessExpression ) {
3254
- return isSimpleExpressionWorker ( ( < ElementAccessExpression > node ) . expression , depth + 1 )
3255
- && isSimpleExpressionWorker ( ( < ElementAccessExpression > node ) . argumentExpression , depth + 1 ) ;
3256
- }
3257
- else if ( kind === SyntaxKind . PrefixUnaryExpression
3258
- || kind === SyntaxKind . PostfixUnaryExpression ) {
3259
- return isSimpleExpressionWorker ( ( < PrefixUnaryExpression | PostfixUnaryExpression > node ) . operand , depth + 1 ) ;
3260
- }
3261
- else if ( kind === SyntaxKind . BinaryExpression ) {
3262
- return ( < BinaryExpression > node ) . operatorToken . kind !== SyntaxKind . AsteriskAsteriskToken
3263
- && isSimpleExpressionWorker ( ( < BinaryExpression > node ) . left , depth + 1 )
3264
- && isSimpleExpressionWorker ( ( < BinaryExpression > node ) . right , depth + 1 ) ;
3265
- }
3266
- else if ( kind === SyntaxKind . ConditionalExpression ) {
3267
- return isSimpleExpressionWorker ( ( < ConditionalExpression > node ) . condition , depth + 1 )
3268
- && isSimpleExpressionWorker ( ( < ConditionalExpression > node ) . whenTrue , depth + 1 )
3269
- && isSimpleExpressionWorker ( ( < ConditionalExpression > node ) . whenFalse , depth + 1 ) ;
3270
- }
3271
- else if ( kind === SyntaxKind . VoidExpression
3272
- || kind === SyntaxKind . TypeOfExpression
3273
- || kind === SyntaxKind . DeleteExpression ) {
3274
- return isSimpleExpressionWorker ( ( < VoidExpression | TypeOfExpression | DeleteExpression > node ) . expression , depth + 1 ) ;
3275
- }
3276
- else if ( kind === SyntaxKind . ArrayLiteralExpression ) {
3277
- return ( < ArrayLiteralExpression > node ) . elements . length === 0 ;
3278
- }
3279
- else if ( kind === SyntaxKind . ObjectLiteralExpression ) {
3280
- return ( < ObjectLiteralExpression > node ) . properties . length === 0 ;
3281
- }
3282
- else if ( kind === SyntaxKind . CallExpression ) {
3283
- if ( ! isSimpleExpressionWorker ( ( < CallExpression > node ) . expression , depth + 1 ) ) {
3284
- return false ;
3285
- }
3286
-
3287
- for ( const argument of ( < CallExpression > node ) . arguments ) {
3288
- if ( ! isSimpleExpressionWorker ( argument , depth + 1 ) ) {
3289
- return false ;
3290
- }
3291
- }
3292
-
3293
- return true ;
3294
- }
3295
- }
3296
-
3297
- return false ;
3298
- }
3299
-
3300
3174
/**
3301
3175
* Formats an enum value as a string for debugging and debug assertions.
3302
3176
*/
@@ -3369,24 +3243,6 @@ namespace ts {
3369
3243
return formatEnum ( flags , ( < any > ts ) . ObjectFlags , /*isFlags*/ true ) ;
3370
3244
}
3371
3245
3372
- export function getRangePos ( range : TextRange | undefined ) {
3373
- return range ? range . pos : - 1 ;
3374
- }
3375
-
3376
- export function getRangeEnd ( range : TextRange | undefined ) {
3377
- return range ? range . end : - 1 ;
3378
- }
3379
-
3380
- /**
3381
- * Increases (or decreases) a position by the provided amount.
3382
- *
3383
- * @param pos The position.
3384
- * @param value The delta.
3385
- */
3386
- export function movePos ( pos : number , value : number ) {
3387
- return positionIsSynthesized ( pos ) ? - 1 : pos + value ;
3388
- }
3389
-
3390
3246
/**
3391
3247
* Creates a new TextRange from the provided pos and end.
3392
3248
*
@@ -3444,26 +3300,6 @@ namespace ts {
3444
3300
return range . pos === range . end ;
3445
3301
}
3446
3302
3447
- /**
3448
- * Creates a new TextRange from a provided range with its end position collapsed to its
3449
- * start position.
3450
- *
3451
- * @param range A TextRange.
3452
- */
3453
- export function collapseRangeToStart ( range : TextRange ) : TextRange {
3454
- return isCollapsedRange ( range ) ? range : moveRangeEnd ( range , range . pos ) ;
3455
- }
3456
-
3457
- /**
3458
- * Creates a new TextRange from a provided range with its start position collapsed to its
3459
- * end position.
3460
- *
3461
- * @param range A TextRange.
3462
- */
3463
- export function collapseRangeToEnd ( range : TextRange ) : TextRange {
3464
- return isCollapsedRange ( range ) ? range : moveRangePos ( range , range . end ) ;
3465
- }
3466
-
3467
3303
/**
3468
3304
* Creates a new TextRange for a token at the provides start position.
3469
3305
*
@@ -3527,31 +3363,6 @@ namespace ts {
3527
3363
return node . initializer !== undefined ;
3528
3364
}
3529
3365
3530
- /**
3531
- * Gets a value indicating whether a node is merged with a class declaration in the same scope.
3532
- */
3533
- export function isMergedWithClass ( node : Node ) {
3534
- if ( node . symbol ) {
3535
- for ( const declaration of node . symbol . declarations ) {
3536
- if ( declaration . kind === SyntaxKind . ClassDeclaration && declaration !== node ) {
3537
- return true ;
3538
- }
3539
- }
3540
- }
3541
-
3542
- return false ;
3543
- }
3544
-
3545
- /**
3546
- * Gets a value indicating whether a node is the first declaration of its kind.
3547
- *
3548
- * @param node A Declaration node.
3549
- * @param kind The SyntaxKind to find among related declarations.
3550
- */
3551
- export function isFirstDeclarationOfKind ( node : Node , kind : SyntaxKind ) {
3552
- return node . symbol && getDeclarationOfKind ( node . symbol , kind ) === node ;
3553
- }
3554
-
3555
3366
export function isWatchSet ( options : CompilerOptions ) {
3556
3367
// Firefox has Object.prototype.watch
3557
3368
return options . watch && options . hasOwnProperty ( "watch" ) ;
0 commit comments