( params: ReadonlyArray<ExtendedTcbTypeParameter> | undefined | null, env: TcbEnvironment, defaultModuleSpecifier?: string | null, )
| 351 | } |
| 352 | |
| 353 | export function qualifyTypeParameters( |
| 354 | params: ReadonlyArray<ExtendedTcbTypeParameter> | undefined | null, |
| 355 | env: TcbEnvironment, |
| 356 | defaultModuleSpecifier?: string | null, |
| 357 | ): ExtendedTcbTypeParameter[] | undefined { |
| 358 | if (!params || params.length === 0) { |
| 359 | return params ? [] : undefined; |
| 360 | } |
| 361 | |
| 362 | return params.map((param) => { |
| 363 | const typeRefs = param.typeRefs; |
| 364 | if (!typeRefs || typeRefs.length === 0) { |
| 365 | return param; |
| 366 | } |
| 367 | |
| 368 | // Sort descending by start offset so replacing back-to-front preserves earlier offsets |
| 369 | const sortedRefs = [...typeRefs].sort((a, b) => (b.span?.start ?? 0) - (a.span?.start ?? 0)); |
| 370 | |
| 371 | let representation = param.representation; |
| 372 | let representationWithDefault = param.representationWithDefault; |
| 373 | |
| 374 | for (const ref of sortedRefs) { |
| 375 | const mod = ref.moduleSpecifier || defaultModuleSpecifier; |
| 376 | if (!mod || !ref.span) continue; |
| 377 | |
| 378 | const qualified = env.referenceExternalSymbol(mod, ref.symbol).print(); |
| 379 | const {start, end} = ref.span; |
| 380 | |
| 381 | if (start <= representation.length && end <= representation.length) { |
| 382 | representation = representation.slice(0, start) + qualified + representation.slice(end); |
| 383 | } |
| 384 | if (start <= representationWithDefault.length && end <= representationWithDefault.length) { |
| 385 | representationWithDefault = |
| 386 | representationWithDefault.slice(0, start) + |
| 387 | qualified + |
| 388 | representationWithDefault.slice(end); |
| 389 | } |
| 390 | } |
| 391 | |
| 392 | return { |
| 393 | ...param, |
| 394 | representation, |
| 395 | representationWithDefault, |
| 396 | }; |
| 397 | }); |
| 398 | } |
| 399 | |
| 400 | function generateGenericArgs(typeParameters: ReadonlyArray<TcbTypeParameter> | undefined): string { |
| 401 | if (typeParameters === undefined || typeParameters.length === 0) { |
no test coverage detected