当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript workspace.findFiles方法代码示例

本文整理汇总了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';
}
开发者ID:OlingCat,项目名称:vscode-ghc-simple,代码行数:33,代码来源:extension-state.ts

示例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))
      }
    })
}
开发者ID:ensime,项目名称:ensime-vscode,代码行数:30,代码来源:extension.ts

示例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);
	}
}
开发者ID:PKRoma,项目名称:vscode,代码行数:29,代码来源:tasks.ts

示例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';
            }
        });
    }
开发者ID:TheColorRed,项目名称:crane,代码行数:27,代码来源:crane.ts

示例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)
	};
开发者ID:peq,项目名称:wurst4vscode,代码行数:28,代码来源:commands.ts

示例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);
	}
}
开发者ID:AllureFer,项目名称:vscode,代码行数:27,代码来源:tasks.ts

示例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;
     });
 }
开发者ID:rebornix,项目名称:ForceCode,代码行数:30,代码来源:credentials.ts

示例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);
          }
        }
      });
    });
  }
}
开发者ID:nertofiveone,项目名称:salesforcedx-vscode,代码行数:31,代码来源:forceApexTestRun.ts

示例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;
		}
	});
}
开发者ID:rubyide,项目名称:vscode-ruby,代码行数:30,代码来源:rake.ts


注:本文中的vscode.workspace.findFiles方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。