Skip to content

Commit 5df9dfc

Browse files
committed
Rename source to origin
1 parent bca7ecb commit 5df9dfc

File tree

19 files changed

+98
-98
lines changed

19 files changed

+98
-98
lines changed

extensions/ql-vscode/src/databases/config/db-config.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// Contains models and consts for the data we want to store in the database config.
22
// Changes to these models should be done carefully and account for backwards compatibility of data.
33

4-
import { DatabaseSource } from "../local-databases/database-source";
4+
import { DatabaseOrigin } from "../local-databases/database-origin";
55

66
export const DB_CONFIG_VERSION = 1;
77

@@ -90,7 +90,7 @@ export interface LocalDatabase {
9090
name: string;
9191
dateAdded: number;
9292
language: string;
93-
source: DatabaseSource;
93+
origin: DatabaseOrigin;
9494
storagePath: string;
9595
}
9696

extensions/ql-vscode/src/databases/database-fetcher.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ import { allowHttp } from "../config";
3333
import { showAndLogInformationMessage } from "../common/logging";
3434
import { AppOctokit } from "../common/octokit";
3535
import { getLanguageDisplayName } from "../common/query-language";
36-
import { DatabaseSource } from "./local-databases/database-source";
36+
import { DatabaseOrigin } from "./local-databases/database-origin";
3737

3838
/**
3939
* Prompts a user to fetch a database from a remote location. Database is assumed to be an archive file.
@@ -296,7 +296,7 @@ export async function importArchiveDatabase(
296296
* @param databaseManager the DatabaseManager
297297
* @param storagePath where to store the unzipped database.
298298
* @param nameOverride a name for the database that overrides the default
299-
* @param source the source of the database
299+
* @param origin the origin of the database
300300
* @param progress callback to send progress messages to
301301
* @param makeSelected make the new database selected in the databases panel (default: true)
302302
* @param addSourceArchiveFolder whether to add a workspace folder containing the source archive to the workspace
@@ -307,7 +307,7 @@ async function databaseArchiveFetcher(
307307
databaseManager: DatabaseManager,
308308
storagePath: string,
309309
nameOverride: string | undefined,
310-
source: DatabaseSource,
310+
origin: DatabaseOrigin,
311311
progress: ProgressCallback,
312312
cli?: CodeQLCliServer,
313313
makeSelected = true,
@@ -352,7 +352,7 @@ async function databaseArchiveFetcher(
352352

353353
const item = await databaseManager.openDatabase(
354354
Uri.file(dbPath),
355-
source,
355+
origin,
356356
makeSelected,
357357
nameOverride,
358358
{

extensions/ql-vscode/src/databases/db-item.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// This file contains models that are used to represent the databases.
22

3-
import { DatabaseSource } from "./local-databases/database-source";
3+
import { DatabaseOrigin } from "./local-databases/database-origin";
44

55
export enum DbItemKind {
66
RootLocal = "RootLocal",
@@ -40,7 +40,7 @@ export interface LocalDatabaseDbItem {
4040
databaseName: string;
4141
dateAdded: number;
4242
language: string;
43-
source: DatabaseSource;
43+
origin: DatabaseOrigin;
4444
storagePath: string;
4545
parentListName?: string;
4646
}

extensions/ql-vscode/src/databases/db-tree-creator.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ function createLocalDb(
197197
databaseName: db.name,
198198
dateAdded: db.dateAdded,
199199
language: db.language,
200-
source: db.source,
200+
origin: db.origin,
201201
storagePath: db.storagePath,
202202
selected: !!selected,
203203
parentListName: listName,

extensions/ql-vscode/src/databases/local-databases/database-item-impl.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import { isLikelyDatabaseRoot } from "./db-contents-heuristics";
1414
import { stat } from "fs-extra";
1515
import { containsPath, pathsEqual } from "../../common/files";
1616
import { DatabaseContents } from "./database-contents";
17-
import { DatabaseSource } from "./database-source";
17+
import { DatabaseOrigin } from "./database-origin";
1818

1919
export class DatabaseItemImpl implements DatabaseItem {
2020
// These are only public in the implementation, they are readonly in the interface
@@ -62,8 +62,8 @@ export class DatabaseItemImpl implements DatabaseItem {
6262
return this.options.dateAdded;
6363
}
6464

65-
public get source(): DatabaseSource | undefined {
66-
return this.options.source;
65+
public get origin(): DatabaseOrigin | undefined {
66+
return this.options.origin;
6767
}
6868

6969
public resolveSourceFile(uriStr: string | undefined): vscode.Uri {

extensions/ql-vscode/src/databases/local-databases/database-item.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import vscode from "vscode";
22
import * as cli from "../../codeql-cli/cli";
33
import { DatabaseContents } from "./database-contents";
44
import { DatabaseOptions } from "./database-options";
5-
import { DatabaseSource } from "./database-source";
5+
import { DatabaseOrigin } from "./database-origin";
66

77
/** An item in the list of available databases */
88
export interface DatabaseItem {
@@ -27,9 +27,9 @@ export interface DatabaseItem {
2727
readonly dateAdded: number | undefined;
2828

2929
/**
30-
* The source this database item was added from or undefined if unknown.
30+
* The origin this database item was retrieved from or undefined if unknown.
3131
*/
32-
readonly source: DatabaseSource | undefined;
32+
readonly origin: DatabaseOrigin | undefined;
3333

3434
/** If the database is invalid, describes why. */
3535
readonly error: Error | undefined;

extensions/ql-vscode/src/databases/local-databases/database-manager.ts

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ import { DatabaseChangedEvent, DatabaseEventKind } from "./database-events";
3434
import { DatabaseResolver } from "./database-resolver";
3535
import { telemetryListener } from "../../common/vscode/telemetry";
3636
import { LanguageContextStore } from "../../language-context-store";
37-
import { DatabaseSource } from "./database-source";
37+
import { DatabaseOrigin } from "./database-origin";
3838

3939
/**
4040
* The name of the key in the workspaceState dictionary in which we
@@ -132,7 +132,7 @@ export class DatabaseManager extends DisposableObject {
132132
*/
133133
public async openDatabase(
134134
uri: vscode.Uri,
135-
source: DatabaseSource | undefined,
135+
origin: DatabaseOrigin | undefined,
136136
makeSelected = true,
137137
displayName?: string,
138138
{
@@ -142,7 +142,7 @@ export class DatabaseManager extends DisposableObject {
142142
): Promise<DatabaseItem> {
143143
const databaseItem = await this.createDatabaseItem(
144144
uri,
145-
source,
145+
origin,
146146
displayName,
147147
);
148148

@@ -195,7 +195,7 @@ export class DatabaseManager extends DisposableObject {
195195
*/
196196
private async createDatabaseItem(
197197
uri: vscode.Uri,
198-
source: DatabaseSource | undefined,
198+
origin: DatabaseOrigin | undefined,
199199
displayName: string | undefined,
200200
): Promise<DatabaseItemImpl> {
201201
const contents = await DatabaseResolver.resolveDatabaseContents(uri);
@@ -204,7 +204,7 @@ export class DatabaseManager extends DisposableObject {
204204
displayName,
205205
dateAdded: Date.now(),
206206
language: await this.getPrimaryLanguage(uri.fsPath),
207-
source,
207+
origin,
208208
};
209209
const databaseItem = new DatabaseItemImpl(uri, contents, fullOptions);
210210

@@ -220,7 +220,7 @@ export class DatabaseManager extends DisposableObject {
220220
*/
221221
public async createOrOpenDatabaseItem(
222222
uri: vscode.Uri,
223-
source: DatabaseSource | undefined,
223+
origin: DatabaseOrigin | undefined,
224224
): Promise<DatabaseItem> {
225225
const existingItem = this.findDatabaseItem(uri);
226226
if (existingItem !== undefined) {
@@ -229,7 +229,7 @@ export class DatabaseManager extends DisposableObject {
229229
}
230230

231231
// We don't add this to the list automatically, but the user can add it later.
232-
return this.createDatabaseItem(uri, source, undefined);
232+
return this.createDatabaseItem(uri, origin, undefined);
233233
}
234234

235235
public async createSkeletonPacks(databaseItem: DatabaseItem) {
@@ -364,7 +364,7 @@ export class DatabaseManager extends DisposableObject {
364364
let displayName: string | undefined = undefined;
365365
let dateAdded = undefined;
366366
let language = undefined;
367-
let source = undefined;
367+
let origin = undefined;
368368
if (state.options) {
369369
if (typeof state.options.displayName === "string") {
370370
displayName = state.options.displayName;
@@ -373,7 +373,7 @@ export class DatabaseManager extends DisposableObject {
373373
dateAdded = state.options.dateAdded;
374374
}
375375
language = state.options.language;
376-
source = state.options.source;
376+
origin = state.options.origin;
377377
}
378378

379379
const dbBaseUri = vscode.Uri.parse(state.uri, true);
@@ -386,7 +386,7 @@ export class DatabaseManager extends DisposableObject {
386386
displayName,
387387
dateAdded,
388388
language,
389-
source,
389+
origin,
390390
};
391391
const item = new DatabaseItemImpl(dbBaseUri, undefined, fullOptions);
392392

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
1-
import { DatabaseSource } from "./database-source";
1+
import { DatabaseOrigin } from "./database-origin";
22

33
export interface DatabaseOptions {
44
displayName?: string;
55
dateAdded?: number | undefined;
66
language?: string;
7-
source?: DatabaseSource;
7+
origin?: DatabaseOrigin;
88
}
99

1010
export interface FullDatabaseOptions extends DatabaseOptions {
1111
dateAdded: number | undefined;
1212
language: string | undefined;
13-
source: DatabaseSource | undefined;
13+
origin: DatabaseOrigin | undefined;
1414
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
interface DatabaseOriginFolder {
2+
type: "folder";
3+
}
4+
5+
interface DatabaseOriginArchive {
6+
type: "archive";
7+
path: string;
8+
}
9+
10+
interface DatabaseOriginGitHub {
11+
type: "github";
12+
repository: string;
13+
commitOid: string | null;
14+
}
15+
16+
interface DatabaseOriginInternet {
17+
type: "url";
18+
url: string;
19+
}
20+
21+
interface DatabaseOriginDebugger {
22+
type: "debugger";
23+
}
24+
25+
export type DatabaseOrigin =
26+
| DatabaseOriginFolder
27+
| DatabaseOriginArchive
28+
| DatabaseOriginGitHub
29+
| DatabaseOriginInternet
30+
| DatabaseOriginDebugger;

extensions/ql-vscode/src/databases/local-databases/database-source.ts

Lines changed: 0 additions & 30 deletions
This file was deleted.

0 commit comments

Comments
 (0)