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


TypeScript LanguageClient.sendRequest方法代码示例

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


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

示例1:

	let performCodeAction = (args: any[]) => {
		let request: ExecuteCommandParams = {
			command: "wurst.perform_code_action",
			arguments: args
		};
		return client.sendRequest(ExecuteCommandRequest.type, request)
	}
开发者ID:peq,项目名称:wurst4vscode,代码行数:7,代码来源:commands.ts

示例2:

        this.command = vscode.commands.registerCommand("PowerShell.ExpandAlias", () => {
            if (this.languageClient === undefined) {
                this.log.writeAndShowError(`<${ExpandAliasFeature.name}>: ` +
                    "Unable to instantiate; language client undefined.");
                return;
            }

            const editor = Window.activeTextEditor;
            const document = editor.document;
            const selection = editor.selection;
            const sls = selection.start;
            const sle = selection.end;

            let text;
            let range;

            if ((sls.character === sle.character) && (sls.line === sle.line)) {
                text = document.getText();
                range = new vscode.Range(0, 0, document.lineCount, text.length);
            } else {
                text = document.getText(selection);
                range = new vscode.Range(sls.line, sls.character, sle.line, sle.character);
            }

            this.languageClient.sendRequest(ExpandAliasRequestType, text).then((result) => {
                editor.edit((editBuilder) => {
                    editBuilder.replace(range, result);
                });
            });
        });
开发者ID:dfinke,项目名称:vscode-powershell,代码行数:30,代码来源:ExpandAlias.ts

示例3: 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

示例4:

 provideHover: (document, position, token, next) => {
   // This code is adapted from HoverFeature#registerLanguageProvider in
   // https://github.com/Microsoft/vscode-languageserver-node/blob/master/client/src/client.ts
   return client
     .sendRequest(HoverRequest.type,
                  client.code2ProtocolConverter.asTextDocumentPositionParams(document, position), token)
     .then(
       hover => {
         if (!hover) {
           return undefined
         }
         // The server is supposed to return string or { language: string,
         // value: string } or an array of those things, but instead it returns
         // an array of { value: string }. This used to work but with a recent
         // vscode-languageclient the user ends up seeing "[object Object]" as
         // the hover information.
         // We work around this by manually parsing the array of { value: string }
         // into a Hover.
         const contents = hover.contents as { value: string }[]
         let result: vscode.MarkdownString[] = []
         for (let element of contents) {
           let item = new vscode.MarkdownString()
           item.appendCodeblock(element.value, "scala")
           result.push(item)
         }
         return new vscode.Hover(result)
       },
       error => {
         client.logFailedRequest(HoverRequest.type, error)
         return Promise.resolve(null)
       }
     )
 }
开发者ID:dotty-staging,项目名称:dotty,代码行数:33,代码来源:compat.ts

示例5: processAllFilesInWorkspace

    private processAllFilesInWorkspace()
    {
        if (workspace.rootPath == undefined) return;

        var requestType: RequestType<any, any, any> = { method: "buildObjectTreeForWorkspace" };
        this.langClient.sendRequest(requestType);
    }
开发者ID:gitter-badger,项目名称:crane-1,代码行数:7,代码来源:crane.ts

示例6: pickPowerShellModule

    private pickPowerShellModule(): Thenable<string> {
        return this.languageClient.sendRequest(FindModuleRequestType, null).then((modules) => {
            const items: QuickPickItem[] = [];

            // We've got the modules info, let's cancel the timeout unless it's already been cancelled
            if (this.cancelFindToken) {
                this.clearCancelFindToken();
            } else {
                // Already timed out, would be weird to dislay modules after we said it timed out.
                return Promise.resolve("");
            }

            for (const item in modules) {
                if (modules.hasOwnProperty(item)) {
                    items.push({ label: modules[item].name, description: modules[item].description });
                }
            }

            if (items.length === 0) {
                return Promise.reject("No PowerShell modules were found.");
            }

            const options: vscode.QuickPickOptions = {
                placeHolder: "Select a PowerShell module to install",
                matchOnDescription: true,
                matchOnDetail: true,
            };

            return vscode.window.showQuickPick(items, options).then((item) => {
                return item ? item.label : "";
            });
        });
    }
开发者ID:dfinke,项目名称:vscode-powershell,代码行数:33,代码来源:FindModule.ts

示例7: complete

    public async complete(): Promise<void> {
        if (this.langClient === undefined) {
            return;
        }

        const triggerStartPos = this.lastChangeRange.start;
        const doc = this.lastDocument;

        const result = await this.langClient.sendRequest(CommentHelpRequestType, {
            documentUri: doc.uri.toString(),
            triggerPosition: triggerStartPos,
            blockComment: this.settings.helpCompletion === Settings.HelpCompletion.BlockComment,
        });

        if (!(result && result.content)) {
            return;
        }

        const replaceRange = new Range(triggerStartPos.translate(0, -1), triggerStartPos.translate(0, 1));

        // TODO add indentation level to the help content
        // Trim leading whitespace (used by the rule for indentation) as VSCode takes care of the indentation.
        // Trim the last empty line and join the strings.
        const lines: string[] = result.content;
        const text = lines
            .map((x) => (x as any).trimLeft())
            .join(this.getEOL(doc.eol));

        const snippetString = new SnippetString(text);

        window.activeTextEditor.insertSnippet(snippetString, replaceRange);
    }
开发者ID:dfinke,项目名称:vscode-powershell,代码行数:32,代码来源:HelpCompletion.ts

示例8:

    var disposable = vscode.commands.registerCommand('PowerShell.ExpandAlias', () => {

        var editor = Window.activeTextEditor;
        var document = editor.document;
        var selection = editor.selection;
        var text, range;

        var sls = selection.start;
        var sle = selection.end;

        if (
            (sls.character === sle.character) &&
            (sls.line === sle.line)
        ) {
            text = document.getText();
            range = new vscode.Range(0, 0, document.lineCount, text.length);
        } else {
            text = document.getText(selection);
            range = new vscode.Range(sls.line, sls.character, sle.line, sle.character);
        }

        client.sendRequest(ExpandAliasRequest.type, text).then((result) => {
            editor.edit((editBuilder) => {
                editBuilder.replace(range, result);
            });
        });
    });
开发者ID:Chiliyago,项目名称:vscode-powershell,代码行数:27,代码来源:ExpandAlias.ts

示例9: resolve

        return new Promise<void>((resolve, reject) => {
            var path = document.fileName;
            var text = document.getText();

            var requestType: RequestType<any, any, any> = { method: "buildObjectTreeForDocument" };
            this.langClient.sendRequest(requestType, { path, text }).then(() => resolve() );
        });
开发者ID:ciruz,项目名称:crane,代码行数:7,代码来源:crane.ts

示例10: switch

 Window.showQuickPick(items,{placeHolder: "Results: (" + modules.length + ")"}).then((selection) => {
 	if (!selection) { return; }
 	switch (selection.label) {
 	    default :
 	        var moduleName = selection.label;
 	        //vscode.window.setStatusBarMessage("Installing PowerShell Module " + moduleName, 1500);
 	        client.sendRequest(InstallModuleRequest.type, moduleName);
 	    }
 	});
开发者ID:Chiliyago,项目名称:vscode-powershell,代码行数:9,代码来源:PowerShellFindModule.ts

示例11:

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

示例12:

    var disposable = vscode.commands.registerCommand('PowerShell.OnlineHelp', () => {

        const editor = vscode.window.activeTextEditor;

        var selection = editor.selection;
        var doc = editor.document;
        var cwr = doc.getWordRangeAtPosition(selection.active)
        var text = doc.getText(cwr);

        client.sendRequest(ShowOnlineHelpRequest.type, text);
    });
开发者ID:Chiliyago,项目名称:vscode-powershell,代码行数:11,代码来源:ShowOnlineHelp.ts

示例13:

        this.command = vscode.commands.registerCommand("PowerShell.ShowHelp", (item?) => {
            if (this.languageClient === undefined) {
                this.log.writeAndShowError(`<${ShowHelpFeature.name}>: ` +
                    "Unable to instantiate; language client undefined.");
                return;
            }
            if (!item || !item.Name) {

                const editor = vscode.window.activeTextEditor;

                const selection = editor.selection;
                const doc = editor.document;
                const cwr = doc.getWordRangeAtPosition(selection.active);
                const text = doc.getText(cwr);

                this.languageClient.sendRequest(ShowHelpRequestType, text);
            } else {
                this.languageClient.sendRequest(ShowHelpRequestType, item.Name);
            }
        });
开发者ID:dfinke,项目名称:vscode-powershell,代码行数:20,代码来源:ShowHelp.ts

示例14: onCommandSelected

function onCommandSelected(
    chosenItem: ExtensionCommandQuickPickItem,
    client: LanguageClient) {

    if (chosenItem !== undefined) {
        client.sendRequest(
            InvokeExtensionCommandRequest.type,
            { name: chosenItem.command.name,
              context: getEditorContext() });
    }
}
开发者ID:Chiliyago,项目名称:vscode-powershell,代码行数:11,代码来源:ExtensionCommands.ts

示例15:

 vscode.commands.registerCommand('PowerShell.RunSelection', () => {
     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)
     }
     client.sendRequest(EvaluateRequest.type, {
         expression:
         editor.document.getText(
             new vscode.Range(start, end))
     });
 });
开发者ID:GoFrag,项目名称:vscode-powershell,代码行数:13,代码来源:Console.ts


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