@@ -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
}
@@ -115,19 +101,16 @@ namespace ts {
115
101
sourceFile . resolvedTypeReferenceDirectiveNames . set ( typeReferenceDirectiveName , resolvedTypeReferenceDirective ) ;
116
102
}
117
103
118
- /* @internal */
119
104
export function moduleResolutionIsEqualTo ( oldResolution : ResolvedModuleFull , newResolution : ResolvedModuleFull ) : boolean {
120
105
return oldResolution . isExternalLibraryImport === newResolution . isExternalLibraryImport &&
121
106
oldResolution . extension === newResolution . extension &&
122
107
oldResolution . resolvedFileName === newResolution . resolvedFileName ;
123
108
}
124
109
125
- /* @internal */
126
110
export function typeDirectiveIsEqualTo ( oldResolution : ResolvedTypeReferenceDirective , newResolution : ResolvedTypeReferenceDirective ) : boolean {
127
111
return oldResolution . resolvedFileName === newResolution . resolvedFileName && oldResolution . primary === newResolution . primary ;
128
112
}
129
113
130
- /* @internal */
131
114
export function hasChangesInResolutions < T > ( names : string [ ] , newResolutions : T [ ] , oldResolutions : Map < T > , comparer : ( oldResolution : T , newResolution : T ) => boolean ) : boolean {
132
115
Debug . assert ( names . length === newResolutions . length ) ;
133
116
@@ -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 ) ;
@@ -431,7 +406,7 @@ namespace ts {
431
406
return isExternalModule ( node ) || compilerOptions . isolatedModules ;
432
407
}
433
408
434
- export function isBlockScope ( node : Node , parentNode : Node ) {
409
+ function isBlockScope ( node : Node , parentNode : Node ) {
435
410
switch ( node . kind ) {
436
411
case SyntaxKind . SourceFile :
437
412
case SyntaxKind . CaseBlock :
@@ -632,28 +607,24 @@ namespace ts {
632
607
return getLeadingCommentRanges ( sourceFileOfNode . text , node . pos ) ;
633
608
}
634
609
635
- export function getLeadingCommentRangesOfNodeFromText ( node : Node , text : string ) {
636
- return getLeadingCommentRanges ( text , node . pos ) ;
637
- }
638
-
639
610
export function getJSDocCommentRanges ( node : Node , text : string ) {
640
611
const commentRanges = ( node . kind === SyntaxKind . Parameter ||
641
612
node . kind === SyntaxKind . TypeParameter ||
642
613
node . kind === SyntaxKind . FunctionExpression ||
643
614
node . kind === SyntaxKind . ArrowFunction ||
644
615
node . kind === SyntaxKind . ParenthesizedExpression ) ?
645
616
concatenate ( getTrailingCommentRanges ( text , node . pos ) , getLeadingCommentRanges ( text , node . pos ) ) :
646
- getLeadingCommentRangesOfNodeFromText ( node , text ) ;
617
+ getLeadingCommentRanges ( text , node . pos ) ;
647
618
// True if the comment starts with '/**' but not if it is '/**/'
648
619
return filter ( commentRanges , comment =>
649
620
text . charCodeAt ( comment . pos + 1 ) === CharacterCodes . asterisk &&
650
621
text . charCodeAt ( comment . pos + 2 ) === CharacterCodes . asterisk &&
651
622
text . charCodeAt ( comment . pos + 3 ) !== CharacterCodes . slash ) ;
652
623
}
653
624
654
- export let fullTripleSlashReferencePathRegEx = / ^ ( \/ \/ \/ \s * < r e f e r e n c e \s + p a t h \s * = \s * ) ( ' | " ) ( .+ ?) \2.* ?\/ > / ;
655
- export let fullTripleSlashReferenceTypeReferenceDirectiveRegEx = / ^ ( \/ \/ \/ \s * < r e f e r e n c e \s + t y p e s \s * = \s * ) ( ' | " ) ( .+ ?) \2.* ?\/ > / ;
656
- 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.* ?\/ > / ;
625
+ export const fullTripleSlashReferencePathRegEx = / ^ ( \/ \/ \/ \s * < r e f e r e n c e \s + p a t h \s * = \s * ) ( ' | " ) ( .+ ?) \2.* ?\/ > / ;
626
+ export const fullTripleSlashReferenceTypeReferenceDirectiveRegEx = / ^ ( \/ \/ \/ \s * < r e f e r e n c e \s + t y p e s \s * = \s * ) ( ' | " ) ( .+ ?) \2.* ?\/ > / ;
627
+ 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.* ?\/ > / ;
657
628
658
629
export function isPartOfTypeNode ( node : Node ) : boolean {
659
630
if ( SyntaxKind . FirstTypeNode <= node . kind && node . kind <= SyntaxKind . LastTypeNode ) {
@@ -2067,10 +2038,6 @@ namespace ts {
2067
2038
return getParseTreeNode ( sourceFile , isSourceFile ) || sourceFile ;
2068
2039
}
2069
2040
2070
- export function getOriginalSourceFiles ( sourceFiles : SourceFile [ ] ) {
2071
- return sameMap ( sourceFiles , getOriginalSourceFile ) ;
2072
- }
2073
-
2074
2041
export const enum Associativity {
2075
2042
Left ,
2076
2043
Right
@@ -3056,24 +3023,6 @@ namespace ts {
3056
3023
return false ;
3057
3024
}
3058
3025
3059
- // Returns false if this heritage clause element's expression contains something unsupported
3060
- // (i.e. not a name or dotted name).
3061
- export function isSupportedExpressionWithTypeArguments ( node : ExpressionWithTypeArguments ) : boolean {
3062
- return isSupportedExpressionWithTypeArgumentsRest ( node . expression ) ;
3063
- }
3064
-
3065
- function isSupportedExpressionWithTypeArgumentsRest ( node : Expression ) : boolean {
3066
- if ( node . kind === SyntaxKind . Identifier ) {
3067
- return true ;
3068
- }
3069
- else if ( isPropertyAccessExpression ( node ) ) {
3070
- return isSupportedExpressionWithTypeArgumentsRest ( node . expression ) ;
3071
- }
3072
- else {
3073
- return false ;
3074
- }
3075
- }
3076
-
3077
3026
export function isExpressionWithTypeArgumentsInClassExtendsClause ( node : Node ) : boolean {
3078
3027
return tryGetClassExtendingExpressionWithTypeArguments ( node ) !== undefined ;
3079
3028
}
@@ -3210,81 +3159,6 @@ namespace ts {
3210
3159
return carriageReturnLineFeed ;
3211
3160
}
3212
3161
3213
- /**
3214
- * Tests whether a node and its subtree is simple enough to have its position
3215
- * information ignored when emitting source maps in a destructuring assignment.
3216
- *
3217
- * @param node The expression to test.
3218
- */
3219
- export function isSimpleExpression ( node : Expression ) : boolean {
3220
- return isSimpleExpressionWorker ( node , 0 ) ;
3221
- }
3222
-
3223
- function isSimpleExpressionWorker ( node : Expression , depth : number ) : boolean {
3224
- if ( depth <= 5 ) {
3225
- const kind = node . kind ;
3226
- if ( kind === SyntaxKind . StringLiteral
3227
- || kind === SyntaxKind . NumericLiteral
3228
- || kind === SyntaxKind . RegularExpressionLiteral
3229
- || kind === SyntaxKind . NoSubstitutionTemplateLiteral
3230
- || kind === SyntaxKind . Identifier
3231
- || kind === SyntaxKind . ThisKeyword
3232
- || kind === SyntaxKind . SuperKeyword
3233
- || kind === SyntaxKind . TrueKeyword
3234
- || kind === SyntaxKind . FalseKeyword
3235
- || kind === SyntaxKind . NullKeyword ) {
3236
- return true ;
3237
- }
3238
- else if ( kind === SyntaxKind . PropertyAccessExpression ) {
3239
- return isSimpleExpressionWorker ( ( < PropertyAccessExpression > node ) . expression , depth + 1 ) ;
3240
- }
3241
- else if ( kind === SyntaxKind . ElementAccessExpression ) {
3242
- return isSimpleExpressionWorker ( ( < ElementAccessExpression > node ) . expression , depth + 1 )
3243
- && isSimpleExpressionWorker ( ( < ElementAccessExpression > node ) . argumentExpression , depth + 1 ) ;
3244
- }
3245
- else if ( kind === SyntaxKind . PrefixUnaryExpression
3246
- || kind === SyntaxKind . PostfixUnaryExpression ) {
3247
- return isSimpleExpressionWorker ( ( < PrefixUnaryExpression | PostfixUnaryExpression > node ) . operand , depth + 1 ) ;
3248
- }
3249
- else if ( kind === SyntaxKind . BinaryExpression ) {
3250
- return ( < BinaryExpression > node ) . operatorToken . kind !== SyntaxKind . AsteriskAsteriskToken
3251
- && isSimpleExpressionWorker ( ( < BinaryExpression > node ) . left , depth + 1 )
3252
- && isSimpleExpressionWorker ( ( < BinaryExpression > node ) . right , depth + 1 ) ;
3253
- }
3254
- else if ( kind === SyntaxKind . ConditionalExpression ) {
3255
- return isSimpleExpressionWorker ( ( < ConditionalExpression > node ) . condition , depth + 1 )
3256
- && isSimpleExpressionWorker ( ( < ConditionalExpression > node ) . whenTrue , depth + 1 )
3257
- && isSimpleExpressionWorker ( ( < ConditionalExpression > node ) . whenFalse , depth + 1 ) ;
3258
- }
3259
- else if ( kind === SyntaxKind . VoidExpression
3260
- || kind === SyntaxKind . TypeOfExpression
3261
- || kind === SyntaxKind . DeleteExpression ) {
3262
- return isSimpleExpressionWorker ( ( < VoidExpression | TypeOfExpression | DeleteExpression > node ) . expression , depth + 1 ) ;
3263
- }
3264
- else if ( kind === SyntaxKind . ArrayLiteralExpression ) {
3265
- return ( < ArrayLiteralExpression > node ) . elements . length === 0 ;
3266
- }
3267
- else if ( kind === SyntaxKind . ObjectLiteralExpression ) {
3268
- return ( < ObjectLiteralExpression > node ) . properties . length === 0 ;
3269
- }
3270
- else if ( kind === SyntaxKind . CallExpression ) {
3271
- if ( ! isSimpleExpressionWorker ( ( < CallExpression > node ) . expression , depth + 1 ) ) {
3272
- return false ;
3273
- }
3274
-
3275
- for ( const argument of ( < CallExpression > node ) . arguments ) {
3276
- if ( ! isSimpleExpressionWorker ( argument , depth + 1 ) ) {
3277
- return false ;
3278
- }
3279
- }
3280
-
3281
- return true ;
3282
- }
3283
- }
3284
-
3285
- return false ;
3286
- }
3287
-
3288
3162
/**
3289
3163
* Formats an enum value as a string for debugging and debug assertions.
3290
3164
*/
@@ -3357,24 +3231,6 @@ namespace ts {
3357
3231
return formatEnum ( flags , ( < any > ts ) . ObjectFlags , /*isFlags*/ true ) ;
3358
3232
}
3359
3233
3360
- export function getRangePos ( range : TextRange | undefined ) {
3361
- return range ? range . pos : - 1 ;
3362
- }
3363
-
3364
- export function getRangeEnd ( range : TextRange | undefined ) {
3365
- return range ? range . end : - 1 ;
3366
- }
3367
-
3368
- /**
3369
- * Increases (or decreases) a position by the provided amount.
3370
- *
3371
- * @param pos The position.
3372
- * @param value The delta.
3373
- */
3374
- export function movePos ( pos : number , value : number ) {
3375
- return positionIsSynthesized ( pos ) ? - 1 : pos + value ;
3376
- }
3377
-
3378
3234
/**
3379
3235
* Creates a new TextRange from the provided pos and end.
3380
3236
*
@@ -3432,26 +3288,6 @@ namespace ts {
3432
3288
return range . pos === range . end ;
3433
3289
}
3434
3290
3435
- /**
3436
- * Creates a new TextRange from a provided range with its end position collapsed to its
3437
- * start position.
3438
- *
3439
- * @param range A TextRange.
3440
- */
3441
- export function collapseRangeToStart ( range : TextRange ) : TextRange {
3442
- return isCollapsedRange ( range ) ? range : moveRangeEnd ( range , range . pos ) ;
3443
- }
3444
-
3445
- /**
3446
- * Creates a new TextRange from a provided range with its start position collapsed to its
3447
- * end position.
3448
- *
3449
- * @param range A TextRange.
3450
- */
3451
- export function collapseRangeToEnd ( range : TextRange ) : TextRange {
3452
- return isCollapsedRange ( range ) ? range : moveRangePos ( range , range . end ) ;
3453
- }
3454
-
3455
3291
/**
3456
3292
* Creates a new TextRange for a token at the provides start position.
3457
3293
*
@@ -3515,31 +3351,6 @@ namespace ts {
3515
3351
return node . initializer !== undefined ;
3516
3352
}
3517
3353
3518
- /**
3519
- * Gets a value indicating whether a node is merged with a class declaration in the same scope.
3520
- */
3521
- export function isMergedWithClass ( node : Node ) {
3522
- if ( node . symbol ) {
3523
- for ( const declaration of node . symbol . declarations ) {
3524
- if ( declaration . kind === SyntaxKind . ClassDeclaration && declaration !== node ) {
3525
- return true ;
3526
- }
3527
- }
3528
- }
3529
-
3530
- return false ;
3531
- }
3532
-
3533
- /**
3534
- * Gets a value indicating whether a node is the first declaration of its kind.
3535
- *
3536
- * @param node A Declaration node.
3537
- * @param kind The SyntaxKind to find among related declarations.
3538
- */
3539
- export function isFirstDeclarationOfKind ( node : Node , kind : SyntaxKind ) {
3540
- return node . symbol && getDeclarationOfKind ( node . symbol , kind ) === node ;
3541
- }
3542
-
3543
3354
export function isWatchSet ( options : CompilerOptions ) {
3544
3355
// Firefox has Object.prototype.watch
3545
3356
return options . watch && options . hasOwnProperty ( "watch" ) ;
0 commit comments