Make pathData private to FilePathDiscovery

This commit is contained in:
Robert
2023-06-16 16:40:11 +01:00
parent da92a67834
commit af62a92c5b
4 changed files with 9 additions and 5 deletions

View File

@@ -33,7 +33,7 @@ interface PathData {
*/
export abstract class FilePathDiscovery<T extends PathData> extends Discovery {
/** The set of known paths and associated data that we are tracking */
protected pathData: T[] = [];
private pathData: T[] = [];
/** Event that fires whenever the contents of `pathData` changes */
protected readonly onDidChangePathDataEmitter: AppEventEmitter<void>;
@@ -71,6 +71,10 @@ export abstract class FilePathDiscovery<T extends PathData> extends Discovery {
this.push(this.watcher.onDidChange(this.fileChanged.bind(this)));
}
protected getPathData(): readonly T[] {
return this.pathData;
}
/**
* Compute any extra data to be stored regarding the given path.
*/

View File

@@ -59,7 +59,7 @@ export class QueryDiscovery
public buildQueryTree(): Array<FileTreeNode<string>> {
const roots = [];
for (const workspaceFolder of getOnDiskWorkspaceFoldersObjects()) {
const queriesInRoot = this.pathData.filter((query) =>
const queriesInRoot = this.getPathData().filter((query) =>
containsPath(workspaceFolder.uri.fsPath, query.path),
);
if (queriesInRoot.length === 0) {

View File

@@ -37,7 +37,7 @@ export class QueryPackDiscovery extends FilePathDiscovery<QueryPack> {
*/
public getLanguageForQueryFile(queryPath: string): QueryLanguage | undefined {
// Find all packs in a higher directory than the query
const packs = this.pathData.filter((queryPack) =>
const packs = this.getPathData().filter((queryPack) =>
containsPath(dirname(queryPack.path), queryPath),
);

View File

@@ -28,8 +28,8 @@ class TestFilePathDiscovery extends FilePathDiscovery<TestData> {
return this.onDidChangePathDataEmitter.event;
}
public getPathData(): TestData[] {
return this.pathData;
public getPathData(): readonly TestData[] {
return super.getPathData();
}
protected async getDataForPath(path: string): Promise<TestData> {