( rowConfigs: string[], fileData: ProjectEntry, resolver: ProjectMetadataResolver )
| 401 | } |
| 402 | |
| 403 | function buildProjectMetadataRows( |
| 404 | rowConfigs: string[], |
| 405 | fileData: ProjectEntry, |
| 406 | resolver: ProjectMetadataResolver |
| 407 | ): ProjectCompletionMetadata { |
| 408 | const metadataRows: ProjectCompletionMetadata = []; |
| 409 | const maxRows = Math.min(rowConfigs.length, 3); |
| 410 | |
| 411 | for (let i = 0; i < maxRows; i++) { |
| 412 | const row = rowConfigs[i]; |
| 413 | if (!row) continue; |
| 414 | |
| 415 | try { |
| 416 | const tokens = parseDisplayFieldsRow(row); |
| 417 | const parts: ProjectCompletionMetadataPart[] = []; |
| 418 | |
| 419 | for (const token of tokens) { |
| 420 | if (token.property.startsWith("literal:")) { |
| 421 | const text = token.property.slice(8); |
| 422 | if (text) { |
| 423 | parts.push({ text, searchable: false, kind: "literal" }); |
| 424 | } |
| 425 | continue; |
| 426 | } |
| 427 | |
| 428 | const value = resolver.resolve(token.property, fileData); |
| 429 | if (!value) continue; |
| 430 | |
| 431 | if (token.showName) { |
| 432 | parts.push({ |
| 433 | text: `${token.displayName ?? token.property}:`, |
| 434 | searchable: false, |
| 435 | kind: "label", |
| 436 | }); |
| 437 | } |
| 438 | |
| 439 | parts.push({ |
| 440 | text: value, |
| 441 | searchable: |
| 442 | token.searchable === true || |
| 443 | DEFAULT_SEARCHABLE_PROJECT_FIELDS.has(token.property), |
| 444 | kind: "value", |
| 445 | }); |
| 446 | } |
| 447 | |
| 448 | if (parts.some((part) => part.text.trim().length > 0)) { |
| 449 | metadataRows.push(parts); |
| 450 | } |
| 451 | } catch { |
| 452 | // Ignore invalid project metadata rows. |
| 453 | } |
| 454 | } |
| 455 | |
| 456 | return metadataRows; |
| 457 | } |
| 458 | |
| 459 | function appendHighlightedText(container: HTMLElement, text: string, query: string): void { |
| 460 | const doc = container.ownerDocument; |
no test coverage detected