當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。