當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript Files.uriToFilePath方法代碼示例

本文整理匯總了TypeScript中vscode-languageserver.Files.uriToFilePath方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript Files.uriToFilePath方法的具體用法?TypeScript Files.uriToFilePath怎麽用?TypeScript Files.uriToFilePath使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在vscode-languageserver.Files的用法示例。


在下文中一共展示了Files.uriToFilePath方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: if

		return new Promise<Diagnostic[]>((resolve, reject) => {

			let filename = Files.uriToFilePath(document.uri)
			let args = [ '--report=json', filename ];
			if (settings.standard ) {
				args.push( `--standard=${settings.standard}`)
			}
			args.push( filename );

			let options = {
				cwd: rootPath ? rootPath: path.dirname(filename),
				env: process.env
			};

			let result = "";
			let phpcs = cp.spawn( this.phpcsPath, args, options );

			phpcs.stderr.on("data", (buffer: Buffer) => {
				result += buffer.toString();
			});

			phpcs.stdout.on("data", (buffer: Buffer) => {
				result += buffer.toString();
			});

			phpcs.on("close", (code: string) => {
				try {
					result = result.trim();
					let match = null;

					// Determine whether we have an error and report it otherwise send back the diagnostics.
					if (match = result.match(/^ERROR:\s?(.*)/i)) {
						let error = match[1].trim();
						if (match = error.match(/^the \"(.*)\" coding standard is not installed\./)) {
							throw { message: `The "${match[1]}" coding standard set in your configuration is not installed. Please review your configuration an try again.` };
						}
						throw { message: error };
					} else if ( match = result.match(/^FATAL\s?ERROR:\s?(.*)/i)) {
						let error = match[1].trim();
						if (match = error.match(/^Uncaught exception '.*' with message '(.*)'/)) {
							throw { message: match[1] };
						}
						throw { message: error };
					}

					let diagnostics: Diagnostic[] = [];
					let report = JSON.parse(result);
					for (var filename in report.files) {
						let file: PhpcsReportFile = report.files[filename];
						file.messages.forEach(message => {
							diagnostics.push(makeDiagnostic(document, message));
						});
					}
					resolve(diagnostics);
				}
				catch (e) {
					reject(e);
				}
			});
		});
開發者ID:mizunashi-mana,項目名稱:vscode-phpcs,代碼行數:60,代碼來源:linter.ts

示例2:

Client.connection.onFoldingRanges((params: lsp.FoldingRangeRequestParam): lsp.FoldingRange[] =>
    {
        Client.log('Client.connection.onFoldingRanges');

        let filePath = lsp.Files.uriToFilePath(params.textDocument.uri);
        Client.log('   path: ' + filePath);

        return undefined;
    });
開發者ID:legatoproject,項目名稱:legato-af,代碼行數:9,代碼來源:languageServer.ts

示例3: getMessage

function getMessage(err, document) {
	let result = null;
	if (typeof err.message === 'string') {
		result = err.message.replace(/\r?\n/g, ' ');
	} else {
		result = `An unknown error occured while validating file: ${Files.uriToFilePath(document.uri)}`;
	}

	return result;
}
開發者ID:mrmlnc,項目名稱:vscode-puglint,代碼行數:10,代碼來源:server.ts

示例4: validate

function validate(document) {
	const content = document.getText();
	const uri = document.uri;
	const url = Files.uriToFilePath(uri);

	if (Object.keys(editorSettings.config).length === 0) {
		// Update settings from a configuration file only if their updates
		if (configWatcherStatus) {
			linterSettings = configResolver.load(null, path.dirname(url));
			configWatcherStatus = false;
		}
	} else {
		linterSettings = editorSettings.config;
	}

	if (!linterSettings) {
		linterSettings = {};
	}

	// ---> Maybe there's another way?
	const extendPath = linterSettings.extends;
	if (extendPath && path.basename(extendPath) === extendPath) {
		linterSettings.extends = `./node_modules/pug-lint-config-${linterSettings.extends}/index.js`;
	}
	// <---

	linter.configure(linterSettings);

	const diagnostics = [];
	const report = linter.checkString(content, url);
	if (report.length > 0) {
		report.forEach((problem) => {
			diagnostics.push(makeDiagnostic(problem));
		});
	}

	connection.sendDiagnostics({ uri, diagnostics });
}
開發者ID:mrmlnc,項目名稱:vscode-puglint,代碼行數:38,代碼來源:server.ts

示例5:

 (rootFolder: lsp.WorkspaceFolder): string =>
 {
     return lsp.Files.uriToFilePath(rootFolder.uri);
 }),
開發者ID:legatoproject,項目名稱:legato-af,代碼行數:4,代碼來源:lspClient.ts


注:本文中的vscode-languageserver.Files.uriToFilePath方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。