Skip to content

Commit add5417

Browse files
committed
Move pluralize method into "pure" helpers file (since we don't require vscode)
1 parent 31ef6ae commit add5417

6 files changed

Lines changed: 13 additions & 18 deletions

File tree

extensions/ql-vscode/src/helpers.ts

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -584,11 +584,3 @@ export async function* walkDirectory(dir: string): AsyncIterableIterator<string>
584584
}
585585
}
586586
}
587-
588-
/**
589-
* Pluralizes a word.
590-
* Example: Returns "N repository" if N is one, "N repositories" otherwise.
591-
*/
592-
export function pluralize(numItems: number | undefined, singular: string, plural: string): string {
593-
return numItems !== undefined ? `${numItems} ${numItems === 1 ? singular : plural}` : '';
594-
}

extensions/ql-vscode/src/history-item-label-provider.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,8 @@ import { QueryHistoryConfig } from './config';
44
import { LocalQueryInfo } from './query-results';
55
import { buildRepoLabel, getRawQueryName, QueryHistoryInfo } from './query-history-info';
66
import { RemoteQueryHistoryItem } from './remote-queries/remote-query-history-item';
7-
import { pluralize } from './helpers';
87
import { VariantAnalysisHistoryItem } from './remote-queries/variant-analysis-history-item';
9-
import { assertNever } from './pure/helpers-pure';
8+
import { assertNever, pluralize } from './pure/helpers-pure';
109

1110
interface InterpolateReplacements {
1211
t: string; // Start time

extensions/ql-vscode/src/pure/helpers-pure.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,3 +55,11 @@ export function getErrorStack(e: any) {
5555
export function asError(e: any): Error {
5656
return e instanceof Error ? e : new Error(String(e));
5757
}
58+
59+
/**
60+
* Pluralizes a word.
61+
* Example: Returns "N repository" if N is one, "N repositories" otherwise.
62+
*/
63+
export function pluralize(numItems: number | undefined, singular: string, plural: string): string {
64+
return numItems !== undefined ? `${numItems} ${numItems === 1 ? singular : plural}` : '';
65+
}

extensions/ql-vscode/src/query-history-info.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
import { RemoteQueryHistoryItem } from './remote-queries/remote-query-history-item';
22
import { VariantAnalysisHistoryItem } from './remote-queries/variant-analysis-history-item';
33
import { LocalQueryInfo } from './query-results';
4-
import { assertNever } from './pure/helpers-pure';
5-
import { pluralize } from './helpers';
4+
import { assertNever, pluralize } from './pure/helpers-pure';
65
import { hasRepoScanCompleted } from './remote-queries/shared/variant-analysis';
76

87
export type QueryHistoryInfo = LocalQueryInfo | RemoteQueryHistoryItem | VariantAnalysisHistoryItem;

extensions/ql-vscode/src/remote-queries/export-results.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,7 @@ import * as fs from 'fs-extra';
44
import { window, commands, Uri, ExtensionContext, QuickPickItem, workspace, ViewColumn } from 'vscode';
55
import { Credentials } from '../authentication';
66
import { UserCancellationException } from '../commandRunner';
7-
import {
8-
showInformationMessageWithAction,
9-
pluralize
10-
} from '../helpers';
7+
import { showInformationMessageWithAction } from '../helpers';
118
import { logger } from '../logging';
129
import { QueryHistoryManager } from '../query-history';
1310
import { createGist } from './gh-api/gh-actions-api-client';
@@ -16,6 +13,7 @@ import { generateMarkdown } from './remote-queries-markdown-generation';
1613
import { RemoteQuery } from './remote-query';
1714
import { AnalysisResults, sumAnalysesResults } from './shared/analysis-result';
1815
import { RemoteQueryHistoryItem } from './remote-query-history-item';
16+
import { pluralize } from '../pure/helpers-pure';
1917

2018
/**
2119
* Exports the results of the given or currently-selected remote query.

extensions/ql-vscode/src/remote-queries/run-remote-query.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ import {
1111
showAndLogErrorMessage,
1212
showAndLogInformationMessage,
1313
tryGetQueryMetadata,
14-
pluralize,
1514
tmpDir,
1615
} from '../helpers';
1716
import { Credentials } from '../authentication';
@@ -23,7 +22,7 @@ import { OctokitResponse, RequestError } from '@octokit/types/dist-types';
2322
import { RemoteQuery } from './remote-query';
2423
import { RemoteQuerySubmissionResult } from './remote-query-submission-result';
2524
import { QueryMetadata } from '../pure/interface-types';
26-
import { getErrorMessage, REPO_REGEX } from '../pure/helpers-pure';
25+
import { getErrorMessage, REPO_REGEX, pluralize } from '../pure/helpers-pure';
2726
import * as ghApiClient from './gh-api/gh-api-client';
2827
import { getRepositorySelection, isValidSelection, RepositorySelection } from './repository-selection';
2928
import { parseVariantAnalysisQueryLanguage, VariantAnalysisSubmission } from './shared/variant-analysis';

0 commit comments

Comments
 (0)