Invert condition to reduce nesting

This commit is contained in:
Robert
2023-06-16 12:31:12 +01:00
parent ce6a21c65a
commit 6504e46011

View File

@@ -62,26 +62,27 @@ export class QueryDiscovery
const queriesInRoot = this.paths.filter((query) =>
containsPath(workspaceFolder.uri.fsPath, query.path),
);
if (queriesInRoot.length > 0) {
const root = new FileTreeDirectory<string>(
workspaceFolder.uri.fsPath,
workspaceFolder.name,
this.env,
);
for (const query of queriesInRoot) {
const dirName = dirname(normalize(relative(root.path, query.path)));
const parentDirectory = root.createDirectory(dirName);
parentDirectory.addChild(
new FileTreeLeaf<string>(
query.path,
basename(query.path),
query.language,
),
);
}
root.finish();
roots.push(root);
if (queriesInRoot.length === 0) {
continue;
}
const root = new FileTreeDirectory<string>(
workspaceFolder.uri.fsPath,
workspaceFolder.name,
this.env,
);
for (const query of queriesInRoot) {
const dirName = dirname(normalize(relative(root.path, query.path)));
const parentDirectory = root.createDirectory(dirName);
parentDirectory.addChild(
new FileTreeLeaf<string>(
query.path,
basename(query.path),
query.language,
),
);
}
root.finish();
roots.push(root);
}
return roots;
}