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


TypeScript LanguageClient.onRequest方法代码示例

本文整理汇总了TypeScript中vscode-languageclient.LanguageClient.onRequest方法的典型用法代码示例。如果您正苦于以下问题:TypeScript LanguageClient.onRequest方法的具体用法?TypeScript LanguageClient.onRequest怎么用?TypeScript LanguageClient.onRequest使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在vscode-languageclient.LanguageClient的用法示例。


在下文中一共展示了LanguageClient.onRequest方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: setLanguageClient

    public setLanguageClient(languageClient: LanguageClient) {
        this.languageClient = languageClient;

        this.languageClient.onRequest(
            ShowChoicePromptRequestType,
            (promptDetails) => showChoicePrompt(promptDetails, this.languageClient));

        this.languageClient.onRequest(
            ShowInputPromptRequestType,
            (promptDetails) => showInputPrompt(promptDetails, this.languageClient));

        // Set up status bar alerts for when PowerShell is executing a script
        this.languageClient.onNotification(
            ExecutionStatusChangedNotificationType,
            (executionStatusDetails) => {
                switch (executionStatusDetails.executionStatus) {
                    // If execution has changed to running, make a notification
                    case ExecutionStatus.Running:
                        this.showExecutionStatus("PowerShell");
                        break;

                    // If the execution has stopped, destroy the previous notification
                    case ExecutionStatus.Completed:
                    case ExecutionStatus.Aborted:
                    case ExecutionStatus.Failed:
                        this.clearStatusBar();
                        break;
                }
            });

    }
开发者ID:dfinke,项目名称:vscode-powershell,代码行数:31,代码来源:Console.ts

示例2: registerExtensionCommands

export function registerExtensionCommands(client: LanguageClient): void {

    vscode.commands.registerCommand('PowerShell.ShowAdditionalCommands', () => {
        var editor = vscode.window.activeTextEditor;
        var start = editor.selection.start;
        var end = editor.selection.end;
        if (editor.selection.isEmpty) {
            start = new vscode.Position(start.line, 0)
        }

        showExtensionCommands(client);
    });

    client.onNotification(
        ExtensionCommandAddedNotification.type,
        command => addExtensionCommand(command));

    client.onRequest(
        GetEditorContextRequest.type,
        details => getEditorContext());

    client.onRequest(
        InsertTextRequest.type,
        details => insertText(details));

    client.onRequest(
        SetSelectionRequest.type,
        details => setSelection(details));

    client.onRequest(
        OpenFileRequest.type,
        filePath => openFile(filePath));
}
开发者ID:Chiliyago,项目名称:vscode-powershell,代码行数:33,代码来源:ExtensionCommands.ts

示例3:

 client.onDidChangeState(e => {
   if (e.newState === State.Running) {
     client.onRequest(Methods.readConfiguration, configFromUrl)
     client.onRequest(Methods.objectDetails, objectDetailFromUrl)
     client.onRequest(Methods.readEditorObjectSource, readEditorObjectSource)
     client.onRequest(Methods.readObjectSourceOrMain, readObjectSource)
     client.onRequest(Methods.vsUri, getVSCodeUri)
   }
 })
开发者ID:valdirmendesgt,项目名称:vscode_abap_remote_fs,代码行数:9,代码来源:langClient.ts

示例4: activate

export function activate(context: ExtensionContext)
{
    let qol: QualityOfLife = new QualityOfLife();

    let serverModule = context.asAbsolutePath(path.join("server", "server.js"));
    let debugOptions = { execArgv: ["--nolazy", "--debug=6004"] };

    let serverOptions: ServerOptions = {
        run : { module: serverModule, transport: TransportKind.ipc },
        debug: { module: serverModule, transport: TransportKind.ipc, options: debugOptions }
    }

    let clientOptions: LanguageClientOptions = {
        documentSelector: ["php"],
        synchronize: {
            configurationSection: "languageServerExample",
            fileEvents: workspace.createFileSystemWatcher("**/.clientrc")
        }
    }

    // Create the language client and start the client.
    var langClient: LanguageClient = new LanguageClient("Crane Language Server", serverOptions, clientOptions);

    // Use this to handle a request sent from the server
    // https://github.com/Microsoft/vscode/blob/80bd73b5132268f68f624a86a7c3e56d2bbac662/extensions/json/client/src/jsonMain.ts
    // https://github.com/Microsoft/vscode/blob/580d19ab2e1fd6488c3e515e27fe03dceaefb819/extensions/json/server/src/server.ts
    //langClient.onRequest()

    let disposable = langClient.start();

    let crane: Crane = new Crane(langClient);

    var requestType: RequestType<any, any, any> = { method: "workDone" };
    langClient.onRequest(requestType, () => {
        // Load settings
        let craneSettings = workspace.getConfiguration("crane");
        if (craneSettings) {
            var showStatusBarItem = craneSettings.get<boolean>("showStatusBarBugReportLink", true);
            if (showStatusBarItem) {
                setTimeout(() => {
                    crane.statusBarItem.text = "$(bug) Report PHP Intellisense Bug";
                    crane.statusBarItem.tooltip = "Found a problem with the PHP Intellisense provided by Crane? Click here to file a bug report on Github";
                    crane.statusBarItem.command = "crane.reportBug";
                    crane.statusBarItem.show();
                }, 5000);
            } else {
                crane.statusBarItem.hide();
            }
        } else {
            crane.statusBarItem.hide();
        }
    });

    // Register commands for QoL improvements
    let duplicateLineCommand = commands.registerCommand("crane.duplicateLine", qol.duplicateLineOrSelection);
    let reportBugCommand = commands.registerCommand("crane.reportBug", crane.reportBug);

    context.subscriptions.push(disposable);
    context.subscriptions.push(duplicateLineCommand);
}
开发者ID:TheColorRed,项目名称:crane,代码行数:60,代码来源:extension.ts

示例5: 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{}\[\],:]+/
		});
	});
开发者ID:elemongw,项目名称:vscode,代码行数:59,代码来源:jsonMain.ts

示例6: activate

export function activate(context: ExtensionContext) {
	workspace.getConfiguration()

	let serverModule = context.asAbsolutePath(path.join('server', 'server.js'));
	let debugOptions = {execArgv: ["--nolazy", "--debug=6004"]};

	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 = {
		//documentSelector: ['raml'],
		documentSelector: ['raml'],
		synchronize: {
			configurationSection: 'languageServerExample'
			//fileEvents: workspace.createFileSystemWatcher('**/*.*')
		}
	}

	let client = new LanguageClient('Language Server Example', serverOptions, clientOptions);

	client.onRequest({method: "content"}, (request:any) => {
		var content = fs.existsSync(request.uri) ? fs.readFileSync(request.uri).toString() : null;

		return {content: content};
	})

	client.onRequest({method: "list"}, (request:any) => {
		var content = fs.existsSync(request.uri) ? fs.readdirSync(request.uri).toString() : [];

		return {list: content};
	})

	client.onRequest({method: "savecontent"}, (request:any) => {
		fs.writeFileSync(request.uri, request.content);

		return {};
	})

	let disposable = client.start();

	context.subscriptions.push(disposable);
}
开发者ID:dreamflyer,项目名称:vscode-raml-prototype,代码行数:45,代码来源:extension.ts

示例7: registerConsoleCommands

export function registerConsoleCommands(client: LanguageClient): void {

    vscode.commands.registerCommand('PowerShell.RunSelection', () => {
        var editor = vscode.window.activeTextEditor;
        var selectionRange: vscode.Range = undefined;

        if (!editor.selection.isEmpty) {
            selectionRange =
                new vscode.Range(
                    editor.selection.start,
                    editor.selection.end);
        }
        else {
            selectionRange = editor.document.lineAt(editor.selection.start.line).range;
        }

        client.sendRequest(EvaluateRequest.type, {
            expression: editor.document.getText(selectionRange)
        });
    });

    var consoleChannel = vscode.window.createOutputChannel("PowerShell Output");
    client.onNotification(OutputNotification.type, (output) => {
        var outputEditorExist = vscode.window.visibleTextEditors.some((editor) => {
	           return editor.document.languageId == 'Log'
        });
        if (!outputEditorExist)
            consoleChannel.show(vscode.ViewColumn.Three);
        consoleChannel.append(output.output);
    });

    var t: Thenable<ShowChoicePromptResponseBody>;

    client.onRequest(
        ShowChoicePromptRequest.type,
        promptDetails => showChoicePrompt(promptDetails, client));

    client.onRequest(
        ShowInputPromptRequest.type,
        promptDetails => showInputPrompt(promptDetails, client));
}
开发者ID:Chiliyago,项目名称:vscode-powershell,代码行数:41,代码来源:Console.ts

示例8: activate

export function activate(context: ExtensionContext) {

	// The server is implemented in node
	let serverModule = context.asAbsolutePath(path.join('server', 'out', 'server.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')
		}
	};

	// Create the language client and start the client.
	let client = new LanguageClient('JSON Server', serverOptions, clientOptions);
	client.onNotification(TelemetryNotification.type, (e) => {
		// to be done
	});

	// 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
	});
}
开发者ID:ErickWendel,项目名称:vscode,代码行数:53,代码来源:jsonMain.ts

示例9: activate

export function activate(context: ExtensionContext): void {
    setLogLevel();
    workspace.onDidChangeConfiguration(setLogLevel);

    // The server is implemented in node
    let serverModule = context.asAbsolutePath(path.join('server', 'src', 'server.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 plain text documents
        documentSelector: ['haskell'],
        synchronize: {
            // Synchronize the setting section 'ghcMod' to the server
            configurationSection: 'haskell'
        }
    };

    // Create the language client and start the client.
    let languageClient = new LanguageClient('ghc-mod server', serverOptions, clientOptions);
    let disposable = languageClient.start();

    // Push the disposable to the context's subscriptions so that the
    // client can be deactivated on extension deactivation
    context.subscriptions.push(disposable);
    Commands.register(context, languageClient);

    languageClient.onRequest<string, string, void>(OpenSettingsRequest.type, (action): Promise<string> => {
        switch (action) {
            case 'Workspace':
                commands.executeCommand('workbench.action.openWorkspaceSettings');
                break;
            case 'User':
                commands.executeCommand('workbench.action.openGlobalSettings');
                break;
            default:
                break;
        }
        return null;
    });
}
开发者ID:gdziadkiewicz,项目名称:vscode-ghc-mod,代码行数:49,代码来源:extension.ts

示例10: initialize

	public initialize(): void {
		this.client.onRequest(
			WorkspaceRubyEnvironmentRequest.type,
			async (params: WorkspaceRubyEnvironmentParams): Promise<WorkspaceRubyEnvironmentResult> => {
				const environments: WorkspaceRubyEnvironmentResult = {};

				for (const uri of params.folders) {
					const workspaceFolder: WorkspaceFolder = workspace.getWorkspaceFolder(Uri.parse(uri));

					if (workspaceFolder && workspaceFolder.uri.fsPath) {
						environments[uri] = await loadEnv(workspaceFolder.uri.fsPath);
					}
				}

				return environments;
			}
		);
	}
开发者ID:rubyide,项目名称:vscode-ruby,代码行数:18,代码来源:WorkspaceRubyEnvironment.ts

示例11: 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));
		});
开发者ID:pk-codebox-evo,项目名称:ide-microsoft-vscode,代码行数:19,代码来源:jsonMain.ts

示例12: 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'] }
				]
			}
		});
	});
开发者ID:ArtsyLee,项目名称:vscode,代码行数:68,代码来源:jsonMain.ts

示例13: LanguageClient

	languages.getLanguages().then(languageIds => {

		// The server is implemented in node
		let serverModule = context.asAbsolutePath(path.join('server', 'server.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 yaml documents
			documentSelector: ['yaml'],
			synchronize: {
				configurationSection: ['json.schemas', 'http.proxy', 'http.proxyStrictSSL', 'languageServerYamlSchema'],
				fileEvents: workspace.createFileSystemWatcher('**/.clientrc')
				// fileEvents: workspace.createFileSystemWatcher('**/.yaml')
			},
			initializationOptions: {
				languageIds
			}
		};

		// Create the language client and start the client.
  	let client = new LanguageClient('Language Server YAML Schema', serverOptions, clientOptions);
		client.onNotification(TelemetryNotification.type, 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('yaml', {
			comments: {
				"lineComment": "#"
			},
			"brackets": [
				["{", "}"],
				["[", "]"],
				["(", ")"]
			]
		});
	});
开发者ID:djabraham,项目名称:vscode-yaml-validation,代码行数:65,代码来源:extension.ts


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