Merge pull request #2806 from github/robertbrignull/rename_externalApiUsages

Renames remaining references to "external API usage" in the code
This commit is contained in:
Robert
2023-09-12 16:45:51 +01:00
committed by GitHub
4 changed files with 14 additions and 18 deletions

View File

@@ -3,9 +3,7 @@ import { Call, CallClassification, Method } from "./method";
import { ModeledMethodType } from "./modeled-method";
import { parseLibraryFilename } from "./library";
export function decodeBqrsToExternalApiUsages(
chunk: DecodedBqrsChunk,
): Method[] {
export function decodeBqrsToMethods(chunk: DecodedBqrsChunk): Method[] {
const methodsByApiName = new Map<string, Method>();
chunk?.tuples.forEach((tuple) => {

View File

@@ -15,7 +15,7 @@ import { QueryLanguage } from "../common/query-language";
import { fetchExternalApiQueries } from "./queries";
import { Method } from "./method";
import { runQuery } from "../local-queries/run-query";
import { decodeBqrsToExternalApiUsages } from "./bqrs";
import { decodeBqrsToMethods } from "./bqrs";
type RunQueryOptions = {
cliServer: CodeQLCliServer;
@@ -132,7 +132,7 @@ export async function runExternalApiQueries(
maxStep: externalApiQueriesProgressMaxStep,
});
return decodeBqrsToExternalApiUsages(bqrsChunk);
return decodeBqrsToMethods(bqrsChunk);
}
type GetResultsOptions = {

View File

@@ -193,7 +193,7 @@ export class ModelEditorView extends AbstractWebview<
break;
case "refreshMethods":
await withProgress((progress) => this.loadExternalApiUsages(progress), {
await withProgress((progress) => this.loadMethods(progress), {
cancellable: false,
});
@@ -227,7 +227,7 @@ export class ModelEditorView extends AbstractWebview<
await Promise.all([
this.setViewState(),
this.loadExternalApiUsages((update) =>
this.loadMethods((update) =>
progress({
...update,
step: update.step + 500,
@@ -283,7 +283,7 @@ export class ModelEditorView extends AbstractWebview<
methods: this.methods,
}),
this.setViewState(),
withProgress((progress) => this.loadExternalApiUsages(progress), {
withProgress((progress) => this.loadMethods(progress), {
cancellable: false,
}),
]);
@@ -311,7 +311,7 @@ export class ModelEditorView extends AbstractWebview<
await Promise.all([
this.setViewState(),
withProgress((progress) => this.loadExternalApiUsages(progress), {
withProgress((progress) => this.loadMethods(progress), {
cancellable: false,
}),
this.loadExistingModeledMethods(),
@@ -357,9 +357,7 @@ export class ModelEditorView extends AbstractWebview<
}
}
protected async loadExternalApiUsages(
progress: ProgressCallback,
): Promise<void> {
protected async loadMethods(progress: ProgressCallback): Promise<void> {
try {
const cancellationTokenSource = new CancellationTokenSource();
const queryResult = await runExternalApiQueries(this.mode, {

View File

@@ -1,8 +1,8 @@
import { decodeBqrsToExternalApiUsages } from "../../../src/model-editor/bqrs";
import { decodeBqrsToMethods } from "../../../src/model-editor/bqrs";
import { DecodedBqrsChunk } from "../../../src/common/bqrs-cli-types";
import { CallClassification } from "../../../src/model-editor/method";
describe("decodeBqrsToExternalApiUsages", () => {
describe("decodeBqrsToMethods", () => {
const chunk: DecodedBqrsChunk = {
columns: [
{ name: "usage", kind: "Entity" },
@@ -230,11 +230,11 @@ describe("decodeBqrsToExternalApiUsages", () => {
],
};
it("extracts api usages", () => {
// Even though there are a number of usages with the same number of usages, the order returned should be stable:
it("extracts methods", () => {
// Even though there are a number of methods with the same number of usages, the order returned should be stable:
// - Iterating over a map (as done by .values()) is guaranteed to be in insertion order
// - Sorting the array of usages is guaranteed to be a stable sort
expect(decodeBqrsToExternalApiUsages(chunk)).toEqual([
// - Sorting the array of methods is guaranteed to be a stable sort
expect(decodeBqrsToMethods(chunk)).toEqual([
{
library: "rt",
libraryVersion: undefined,