本文整理匯總了TypeScript中vscode.workspace.findFiles方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript workspace.findFiles方法的具體用法?TypeScript workspace.findFiles怎麽用?TypeScript workspace.findFiles使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類vscode.workspace
的用法示例。
在下文中一共展示了workspace.findFiles方法的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: computeWorkspaceType
export async function computeWorkspaceType(): Promise<HaskellWorkspaceType> {
const configType =
vscode.workspace.getConfiguration('ghcSimple').workspaceType as
HaskellWorkspaceType | 'detect';
if (configType !== 'detect') return configType;
const isStack = await vscode.workspace.findFiles('stack.yaml');
if (isStack.length > 0)
return 'stack';
const isCabal = await vscode.workspace.findFiles('**/*.cabal');
if (isCabal.length > 0)
return 'cabal';
const hasStack = await new Promise<boolean>((resolve, reject) => {
const cp = child_process.exec(
'stack --help',
{
cwd: vscode.workspace.rootPath,
timeout: 5000
}, (err, stdout, stderr) => {
if (err) resolve(false);
else resolve(true);
}
)
});
if (hasStack)
return 'bare-stack'
else
return 'bare';
}
示例2: selectDotEnsime
function selectDotEnsime(callback, filterMethod = (dotEnsime) => true) {
let dirs = [vscode.workspace.rootPath]
let dotEnsimeUris = vscode.workspace.findFiles("**/.ensime", "node_modules", 10)
let toString = (uris: vscode.Uri[]) => uris.map((uri) => uri.fsPath)
dotEnsimeUris.then((uris) => {
if(!uris) {
vscode.window.showErrorMessage("You are not in a workspace. Please open a project before using ENSIME.")
return
}
let dotEnsimes = toString(uris)
let filteredDotEnsime = dotEnsimes.filter(filterMethod)
if(filteredDotEnsime.length == 0)
{
vscode.window.showErrorMessage("No .ensime file found. Please generate with `sbt gen-ensime` or similar")
}
else if (filteredDotEnsime.length == 1)
{
callback(filteredDotEnsime[0])
}
else
{
vscode.window.showQuickPick(filteredDotEnsime).then((item) => callback(item))
}
})
}
示例3: detectNpmScripts
async function detectNpmScripts(): Promise<Task[]> {
let emptyTasks: Task[] = [];
let allTasks: Task[] = [];
let visitedPackageJsonFiles: Set<string> = new Set();
let folders = workspace.workspaceFolders;
if (!folders) {
return emptyTasks;
}
try {
for (const folder of folders) {
if (isAutoDetectionEnabled(folder)) {
let relativePattern = new RelativePattern(folder, '**/package.json');
let paths = await workspace.findFiles(relativePattern, '**/node_modules/**');
for (const path of paths) {
if (!isExcluded(folder, path) && !visitedPackageJsonFiles.has(path.fsPath)) {
let tasks = await provideNpmScriptsForFolder(path);
visitedPackageJsonFiles.add(path.fsPath);
allTasks.push(...tasks);
}
}
}
}
return allTasks;
} catch (error) {
return Promise.reject(error);
}
}
示例4: processAllFilesInWorkspace
private processAllFilesInWorkspace()
{
if (workspace.rootPath == undefined) return;
var fileProcessCount = 0;
// Find all the php files to process
workspace.findFiles('**/*.php', '').then(files => {
console.log(`Files to parse: ${files.length}`);
fileProcessCount = files.length;
var filePaths: string[] = [];
// Get the objects path value for the current file system
files.forEach(file => { filePaths.push(file.fsPath); });
// Send the array of paths to the language server
this.langClient.sendRequest({ method: "buildFromFiles" }, { files: filePaths });
});
// Update the UI so the user knows the processing status
var fileProcessed: NotificationType<any> = { method: "fileProcessed" };
this.langClient.onNotification(fileProcessed, data => {
// Get the percent complete
var percent:string = ((data.total / fileProcessCount) * 100).toFixed(2);
this.statusBarItem.text = `$(zap) Processing source files (${data.total} of ${fileProcessCount} / ${percent}%)`;
// Once all files have been processed, update the statusBarItem
if(data.total == fileProcessCount){
this.statusBarItem.text = 'File Processing Complete';
}
});
}
示例5: async
let buildMap = async (args: any[]) => {
let config = vscode.workspace.getConfiguration("wurst");
let mapPromise: Thenable<string>;
if (args && args.length > 0) {
mapPromise = Promise.resolve(args[0]);
} else {
let items = workspace.findFiles('*.w3x', null, 10)
.then(uris => uris.sort(function(a, b) {
return fs.statSync(b.fsPath).mtime.getTime() -
fs.statSync(a.fsPath).mtime.getTime();
}))
.then(uris => uris.map(uri => uri.path))
mapPromise = window.showQuickPick(items)
}
let mappath = await mapPromise;
if (!mappath) {
return Promise.reject("No map selected.");
}
let request: ExecuteCommandParams = {
command: "wurst.buildmap",
arguments: [{
'mappath': mappath
}]
};
return client.sendRequest(ExecuteCommandRequest.type, request)
};
示例6: provideNpmScripts
export async function provideNpmScripts(): Promise<Task[]> {
let emptyTasks: Task[] = [];
let allTasks: Task[] = [];
let folders = workspace.workspaceFolders;
if (!folders) {
return emptyTasks;
}
try {
for (let i = 0; i < folders.length; i++) {
let folder = folders[i];
if (isAutoDetectionEnabled(folder)) {
let relativePattern = new RelativePattern(folder, '**/package.json');
let paths = await workspace.findFiles(relativePattern, '**/node_modules/**');
for (let j = 0; j < paths.length; j++) {
if (!isExcluded(folder, paths[j])) {
let tasks = await provideNpmScriptsForFolder(paths[j]);
allTasks.push(...tasks);
}
}
}
}
return allTasks;
} catch (error) {
return Promise.reject(error);
}
}
示例7: getYoForceConfig
function getYoForceConfig() {
return vscode.workspace.findFiles('force.json', '').then(function (files) {
var buffer: NodeBuffer = undefined;
var data: any = {};
if (files.length && files[0].path) {
buffer = fs.readFileSync(files[0].path);
try {
data = JSON.parse(buffer.toString());
} catch (error) {
vscode.window.forceCode.outputChannel.appendLine(error);
}
return new Promise((resolve, reject) => {
try {
keychain.getPassword({
account: data.username,
service: constants.FORCECODE_KEYCHAIN,
}, function (err, pass) {
data.password = pass;
resolve(data);
});
} catch (error) {
console.error(error);
data.password = (vscode.window.forceCode.config.password || '') + (vscode.window.forceCode.config.token || '');
resolve(data);
}
});
}
return data;
});
}
示例8: forceApexTestRun
export function forceApexTestRun(testClass?: string) {
if (testClass) {
runTestClass(testClass);
} else {
vscode.workspace.findFiles('**/*.testSuite-meta.xml', '').then(files => {
const fileItems: vscode.QuickPickItem[] = files.map(file => {
return {
label: path
.basename(file.toString())
.replace('.testSuite-meta.xml', ''),
description: file.fsPath
};
});
fileItems.push({
label: 'All tests',
description: 'Runs all tests in the current workspace'
});
vscode.window.showQuickPick(fileItems).then(selection => {
if (selection) {
if (selection.label === 'All tests') {
runAllTests();
} else {
runTestSuite(selection.label);
}
}
});
});
}
}
示例9: registerTaskProvider
export async function registerTaskProvider(ctx: vscode.ExtensionContext) {
let rakePromise: Thenable<vscode.Task[]> | undefined = undefined;
let files = await vscode.workspace.findFiles("**/[rR]akefile{,.rb}");
for (let i = 0; i < files.length; i++) {
rakeFiles.add(files[i]);
}
let fileWatcher = vscode.workspace.createFileSystemWatcher("**/[rR]akefile{,.rb}");
fileWatcher.onDidChange(() => rakePromise = undefined);
fileWatcher.onDidCreate((uri) => {
rakeFiles.add(uri);
rakePromise = undefined
});
fileWatcher.onDidDelete((uri) => {
rakeFiles.delete(uri);
rakePromise = undefined
});
let taskProvider = vscode.workspace.registerTaskProvider('rake', {
provideTasks: () => {
if (!rakePromise) {
rakePromise = getRakeTasks();
}
return rakePromise;
},
resolveTask(_task: vscode.Task): vscode.Task | undefined {
return undefined;
}
});
}