本文整理汇总了TypeScript中vscode-languageserver.Files类的典型用法代码示例。如果您正苦于以下问题:TypeScript Files类的具体用法?TypeScript Files怎么用?TypeScript Files使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Files类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。
示例1: loadLibrary
async function loadLibrary(docUri: string) {
trace(`loadLibrary for: ${docUri}`);
const uri = URI.parse(docUri);
let promise: Thenable<string>;
const settings = await settingsCache.get(docUri);
const getGlobalPath = () => getGlobalPackageManagerPath(settings.packageManager);
if (uri.scheme === "file") {
const file = uri.fsPath;
const directory = path.dirname(file);
let nodePath: string | undefined;
if (settings && settings.nodePath) {
// TODO: https://github.com/Microsoft/vscode-languageserver-node/issues/475
const exists = fs.existsSync(settings.nodePath);
if (exists) {
nodePath = settings.nodePath;
} else {
connection.window.showErrorMessage(
`The setting 'sasslint.nodePath' refers to '${settings.nodePath}', but this path does not exist. ` +
"The setting will be ignored."
);
}
}
if (nodePath) {
promise = Files.resolve("sass-lint", nodePath, nodePath, trace).then<string, string>(
undefined,
() => Files.resolve("sass-lint", getGlobalPath(), directory, trace)
);
} else {
promise = Files.resolve("sass-lint", getGlobalPath(), directory, trace);
}
} else {
promise = Files.resolve("sass-lint", getGlobalPath(), undefined, trace);
}
document2Library.set(docUri, promise.then(
(libraryPath) => {
let library;
if (!path2Library.has(libraryPath)) {
library = require(libraryPath);
trace(`sass-lint library loaded from: ${libraryPath}`);
path2Library.set(libraryPath, library);
}
return path2Library.get(libraryPath);
},
() => {
connection.sendRequest(NoSassLintLibraryRequest.type, {source: {uri: docUri}});
}
));
}
开发者ID:glen-84,项目名称:vscode-sass-lint,代码行数:56,代码来源:sass-lint-server.ts
示例2: 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
示例3:
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
示例4: setParser
}, (error) => {
return Files.resolveModule(workspaceRoot, 'protagonist').then((value) => {
setParser(value, 'Protagonist');
return { capabilities: capabilities };
}, (error) => {
setParser(require('drafter.js'), 'Ext Drafter.js');
return { capabilities: capabilities };
});
});
开发者ID:smizell,项目名称:vscode-apielements,代码行数:9,代码来源:server.ts
示例5: getGlobalPackageManagerPath
function getGlobalPackageManagerPath(packageManager: string): string | undefined {
trace(`Begin - resolve global package manager path for: ${packageManager}`);
if (!globalPackageManagerPath.has(packageManager)) {
let packageManagerPath: string | undefined;
if (packageManager === "npm") {
packageManagerPath = Files.resolveGlobalNodePath(trace);
} else if (packageManager === "yarn") {
packageManagerPath = Files.resolveGlobalYarnPath(trace);
}
// tslint:disable-next-line:no-non-null-assertion
globalPackageManagerPath.set(packageManager, packageManagerPath!);
}
trace(`Done - resolve global package manager path for: ${packageManager}`);
return globalPackageManagerPath.get(packageManager);
}
开发者ID:glen-84,项目名称:vscode-sass-lint,代码行数:19,代码来源:sass-lint-server.ts
示例6: 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
示例7: 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
示例8: getGlobalPath
() => Files.resolve("sass-lint", getGlobalPath(), directory, trace)
开发者ID:glen-84,项目名称:vscode-sass-lint,代码行数:1,代码来源:sass-lint-server.ts
示例9:
(rootFolder: lsp.WorkspaceFolder): string =>
{
return lsp.Files.uriToFilePath(rootFolder.uri);
}),
开发者ID:legatoproject,项目名称:legato-af,代码行数:4,代码来源:lspClient.ts
注:本文中的vscode-languageserver.Files类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论