本文整理汇总了TypeScript中vscode-languageclient.LanguageClient.onTelemetry方法的典型用法代码示例。如果您正苦于以下问题:TypeScript LanguageClient.onTelemetry方法的具体用法?TypeScript LanguageClient.onTelemetry怎么用?TypeScript LanguageClient.onTelemetry使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类vscode-languageclient.LanguageClient
的用法示例。
在下文中一共展示了LanguageClient.onTelemetry方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: LanguageClient
languages.getLanguages().then(languageIds => {
// The server is implemented in node
let serverModule = context.asAbsolutePath(path.join('server', 'out', 'jsonServerMain.js'));
// The debug options for the server
let debugOptions = { execArgv: ['--nolazy', '--debug=6004'] };
// If the extension is launch in debug mode the debug server options are use
// Otherwise the run options are used
let serverOptions: ServerOptions = {
run: { module: serverModule, transport: TransportKind.ipc },
debug: { module: serverModule, transport: TransportKind.ipc, options: debugOptions }
};
// Options to control the language client
let clientOptions: LanguageClientOptions = {
// Register the server for json documents
documentSelector: ['json'],
synchronize: {
// Synchronize the setting section 'json' to the server
configurationSection: ['json.schemas', 'http.proxy', 'http.proxyStrictSSL'],
fileEvents: workspace.createFileSystemWatcher('**/*.json')
},
initializationOptions: {
languageIds,
['format.enable']: workspace.getConfiguration('json').get('format.enable')
}
};
// Create the language client and start the client.
let client = new LanguageClient('json', localize('jsonserver.name', 'JSON Language Server'), serverOptions, clientOptions);
client.onTelemetry(e => {
if (telemetryReporter) {
telemetryReporter.sendTelemetryEvent(e.key, e.data);
}
});
// handle content request
client.onRequest(VSCodeContentRequest.type, (uriPath: string) => {
let uri = Uri.parse(uriPath);
return workspace.openTextDocument(uri).then(doc => {
return doc.getText();
}, error => {
return Promise.reject(error);
});
});
let disposable = client.start();
client.sendNotification(SchemaAssociationNotification.type, getSchemaAssociation(context));
// Push the disposable to the context's subscriptions so that the
// client can be deactivated on extension deactivation
context.subscriptions.push(disposable);
languages.setLanguageConfiguration('json', {
wordPattern: /("(?:[^\\\"]*(?:\\.)?)*"?)|[^\s{}\[\],:]+/
});
});
示例2: getSchemaAssociation
client.onReady().then(() => {
client.onTelemetry(e => {
if (telemetryReporter) {
telemetryReporter.sendTelemetryEvent(e.key, e.data);
}
});
// handle content request
client.onRequest(VSCodeContentRequest.type, (uriPath: string) => {
let uri = Uri.parse(uriPath);
return workspace.openTextDocument(uri).then(doc => {
return doc.getText();
}, error => {
return Promise.reject(error);
});
});
client.sendNotification(SchemaAssociationNotification.type, getSchemaAssociation(context));
});
示例3: LanguageClient
languages.getLanguages().then(languageIds => {
// The server is implemented in node
let serverModule = context.asAbsolutePath(path.join('server', 'out', 'jsonServerMain.js'));
// The debug options for the server
let debugOptions = { execArgv: ['--nolazy', '--debug=6004'] };
// If the extension is launch in debug mode the debug server options are use
// Otherwise the run options are used
let serverOptions: ServerOptions = {
run: { module: serverModule, transport: TransportKind.ipc },
debug: { module: serverModule, transport: TransportKind.ipc, options: debugOptions }
};
// Options to control the language client
let clientOptions: LanguageClientOptions = {
// Register the server for json documents
documentSelector: ['json'],
synchronize: {
// Synchronize the setting section 'json' to the server
configurationSection: ['json.schemas', 'http.proxy', 'http.proxyStrictSSL'],
fileEvents: workspace.createFileSystemWatcher('**/*.json')
},
initializationOptions: {
languageIds
}
};
// Create the language client and start the client.
let client = new LanguageClient('JSON Server', serverOptions, clientOptions);
client.onTelemetry(e => {
if (telemetryReporter) {
telemetryReporter.sendTelemetryEvent(e.key, e.data);
}
});
// handle content request
client.onRequest(VSCodeContentRequest.type, (uriPath: string) => {
let uri = Uri.parse(uriPath);
return workspace.openTextDocument(uri).then(doc => {
return doc.getText();
}, error => {
return Promise.reject(error);
});
});
let disposable = client.start();
client.sendNotification(SchemaAssociationNotification.type, getSchemaAssociation(context));
// Push the disposable to the context's subscriptions so that the
// client can be deactivated on extension deactivation
context.subscriptions.push(disposable);
languages.setLanguageConfiguration('json', {
wordPattern: /(-?\d*\.\d\w*)|([^\[\{\]\}\:\"\,\s]+)/g,
__characterPairSupport: {
autoClosingPairs: [
{ open: '{', close: '}' },
{ open: '[', close: ']' },
{ open: '(', close: ')' },
{ open: '"', close: '"', notIn: ['string'] },
{ open: '\'', close: '\'', notIn: ['string', 'comment'] },
{ open: '`', close: '`', notIn: ['string', 'comment'] }
]
}
});
});