當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript LanguageClient.onNotification方法代碼示例

本文整理匯總了TypeScript中vscode-languageclient.LanguageClient.onNotification方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript LanguageClient.onNotification方法的具體用法?TypeScript LanguageClient.onNotification怎麽用?TypeScript LanguageClient.onNotification使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在vscode-languageclient.LanguageClient的用法示例。


在下文中一共展示了LanguageClient.onNotification方法的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: activate

export function activate(context: ExtensionContext) {

	// 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 },
		debug: { module: serverModule, options: debugOptions }
	};

	// Options to control the language client
	let clientOptions: LanguageClientOptions = {
		// Register the server for php documents
		documentSelector: ['php'],
		synchronize: {
			// Synchronize the setting section 'phpcs' to the server
			configurationSection: 'phpcs',
			// Notify the server about file changes to 'phpcs.xml' files contain in the workspace
			fileEvents: workspace.createFileSystemWatcher('**/phpcs.xml')
		}
	};

	// Create the language client the client.
	let client = new LanguageClient('PHP CodeSniffer Linter', serverOptions, clientOptions);

	// Create the save handler.
	let saveHandler = workspace.onDidSaveTextDocument(document => {
		if (document.languageId != `php`) {
			return;
		}
		let params: proto.TextDocumentIdentifier = { uri: document.uri.toString() };
		client.sendNotification<proto.TextDocumentIdentifier>(proto.DidSaveTextDocumentNotification.type, params);
	});

	let status = new PhpcsStatus();
	client.onNotification( proto.DidStartValidateTextDocumentNotification.type, (document) => {
		status.startProcessing(document.uri);
	});
	client.onNotification( proto.DidEndValidateTextDocumentNotification.type, (document) => {
		status.endProcessing(document.uri);
	});

	context.subscriptions.push(saveHandler);

	// Create the settings monitor and start the monitor for the client.
	let monitor = new SettingMonitor(client, 'phpcs.enable').start();

	// Push the monitor to the context's subscriptions so that the
	// client can be deactivated on extension deactivation
	context.subscriptions.push(monitor);
	context.subscriptions.push(status);
}
開發者ID:mizunashi-mana,項目名稱:vscode-phpcs,代碼行數:57,代碼來源:extension.ts

示例2:

 this.languageClient.onDidChangeState(event => {
     if (event.newState === State.Running) {
         this.languageClient.onNotification('rustDocument/diagnosticsBegin', () => {
             this.statusBarItem.setText('Analysis started');
         });
         this.languageClient.onNotification('rustDocument/diagnosticsEnd', () => {
             this.statusBarItem.setText('Analysis finished');
         });
     }
 });
開發者ID:KalitaAlexey,項目名稱:RustyCode,代碼行數:10,代碼來源:manager.ts

示例3: processAllFilesInWorkspace

    private processAllFilesInWorkspace()
    {
        if (workspace.rootPath == undefined) return;
        var fileProcessCount = 0;
        // Find all the php files to process
        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 });
        });

        // Update the UI so the user knows the processing status
        var fileProcessed: NotificationType<any> = { method: "fileProcessed" };
        this.langClient.onNotification(fileProcessed, data => {
            // Get the percent complete
            var percent:string = ((data.total / fileProcessCount) * 100).toFixed(2);
            this.statusBarItem.text = `$(zap) Processing source files (${data.total} of ${fileProcessCount} / ${percent}%)`;
            // Once all files have been processed, update the statusBarItem
            if(data.total == fileProcessCount){
                this.statusBarItem.text = 'File Processing Complete';
            }
        });
    }
開發者ID:TheColorRed,項目名稱:crane,代碼行數:27,代碼來源:crane.ts

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

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

示例6: createProgressListeners

function createProgressListeners(client: LanguageClient) {
	// Create a "checking files" progress indicator
	let progressListener = new class {
		progress: Progress<{message: string, increment?: number}>
		resolve: (nothing: {}) => void
		
		startProgress(message: string) {
            if (this.progress != null)
                this.endProgress();

            window.withProgress({title: message, location: ProgressLocation.Notification}, progress => new Promise((resolve, _reject) => {
                this.progress = progress;
                this.resolve = resolve;
            }));
		}
		
		reportProgress(message: string, increment: number) {
            if (increment == -1)
                this.progress.report({message});
            else 
                this.progress.report({message, increment})
		}

		endProgress() {
            if (this.progress != null) {
                this.resolve({});
                this.progress = null;
                this.resolve = null;
            }
		}
	}
	// Use custom notifications to drive progressListener
	client.onNotification(new NotificationType('java/startProgress'), (event: ProgressMessage) => {
		progressListener.startProgress(event.message);
	});
	client.onNotification(new NotificationType('java/reportProgress'), (event: ProgressMessage) => {
		progressListener.reportProgress(event.message, event.increment);
	});
	client.onNotification(new NotificationType('java/endProgress'), () => {
		progressListener.endProgress();
	});
}
開發者ID:georgewfraser,項目名稱:vscode-javac,代碼行數:42,代碼來源:extension.ts

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

示例8: processAllFilesInWorkspace

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

        var fileProcessCount = 0;

        let craneSettings = workspace.getConfiguration("crane");
        let debugMode = false;
        if (craneSettings) {
            debugMode = craneSettings.get<boolean>("debugMode", false);
        }

        // Find all the php files to process
        workspace.findFiles('**/*.php', '').then(files => {
            console.log(`Files to parse: ${files.length}`);

            Debug.info(`Preparing to parse ${files.length} PHP source files...`);

            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 });
        });

        // Update the UI so the user knows the processing status
        var fileProcessed: NotificationType<any> = { method: "fileProcessed" };
        this.langClient.onNotification(fileProcessed, data => {
            // Get the percent complete
            var percent: string = ((data.total / fileProcessCount) * 100).toFixed(2);
            this.statusBarItem.text = `$(zap) Processing source files (${data.total} of ${fileProcessCount} / ${percent}%)`;

            if (data.error) {
                Debug.error("There was a problem parsing PHP file: " + data.filename);
                Debug.error(data.error);
            } else {
                Debug.info(`Parsed file ${data.total} of ${fileProcessCount} : ${data.filename}`);
            }

            // Once all files have been processed, update the statusBarItem
            if (data.total == fileProcessCount){
                Debug.info("Processing complete!");
                this.statusBarItem.text = '$(check) Processing of PHP source files complete';
            }
        });
    }
開發者ID:ciruz,項目名稱:crane,代碼行數:51,代碼來源:crane.ts

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

示例10: setup

export function setup(context: ExtensionContext, client: LanguageClient)
{
  context.subscriptions.push(content_provider.register())

  language_client = client
  language_client.onNotification(protocol.preview_response_type, params =>
    {
      const preview_uri = encode_preview(Uri.parse(params.uri))
      if (preview_uri) {
        content_provider.set_content(preview_uri, params.content)
        content_provider.update(preview_uri)

        const existing_document =
          workspace.textDocuments.find(document =>
            document.uri.scheme === preview_uri.scheme &&
            document.uri.query === preview_uri.query)
        if (!existing_document && params.column != 0) {
          commands.executeCommand("vscode.previewHtml", preview_uri, params.column, params.label)
        }
      }
    })
}
開發者ID:seL4,項目名稱:isabelle,代碼行數:22,代碼來源:preview.ts


注:本文中的vscode-languageclient.LanguageClient.onNotification方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。