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


TypeScript LanguageClient.onDidChangeState方法代碼示例

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


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

示例1: startLanguageClient

export async function startLanguageClient(context: ExtensionContext) {
  const module = context.asAbsolutePath(join("server", "server.js"))
  const transport = TransportKind.ipc
  const options = { execArgv: ["--nolazy", "--inspect=6009"] }
  log("creating language client...")

  client = new LanguageClient(
    "ABAPFS_LC",
    "Abap FS Language client",
    {
      run: { module, transport },
      debug: { module, transport, options }
    },
    {
      documentSelector: [{ language: "abap", scheme: ADTSCHEME }],
      outputChannel: channel
    }
  )
  log("starting language client...")

  client.start()

  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,代碼行數:32,代碼來源:langClient.ts

示例2: subscribeOnStateChanging

 private subscribeOnStateChanging(): void {
     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,代碼行數:12,代碼來源:manager.ts

示例3: activate


//.........這裏部分代碼省略.........
						'Failed to load the TSLint library.',
						'Ignoring the failure since there is no \'tslint.json\' file at the root of this workspace.',
					].join('\n'));
				} else if (responseError.code === 101) {
					if (workspace.rootPath) {
						client.error([
							'The extension requires at least version 4.0.0 of tslint.',
							'Please install the latest version of tslint using \'npm install tslint\' or globally using \'npm install -g tslint\'.',
							'You need to reopen the workspace after installing tslint.',
						].join('\n'));
					} else {
						client.error([
							'The extension requires at least version 4.0.0 of tslint.',
							'Please install the latest version of tslint globally using \'npm install -g tslint\'.',
							'You need to reopen VS Code after installing tslint.',
						].join('\n'));
					}
					// actively inform the user in the output channel
					client.outputChannel.show(true);
				}
			} else {
				client.error('Server initialization failed.', error);
				client.outputChannel.show(true);
			}
			return false;
		},
	};

	let client = new LanguageClient('tslint', serverOptions, clientOptions);

	const running = 'Linter is running.';
	const stopped = 'Linter has stopped.';

	client.onDidChangeState((event) => {
		if (event.newState === ClientState.Running) {
			client.info(running);
			statusBarItem.tooltip = running;
			serverRunning = true;
		} else {
			client.info(stopped);
			statusBarItem.tooltip = stopped;
			serverRunning = false;
		}
		udpateStatusBarVisibility(window.activeTextEditor);
	});

	client.onNotification(StatusNotification.type, (params) => {
		updateStatus(params.state);
	});

	function applyTextEdits(uri: string, documentVersion: number, edits: TextEdit[]) {
		let textEditor = window.activeTextEditor;
		if (textEditor && textEditor.document.uri.toString() === uri) {
			if (textEditor.document.version !== documentVersion) {
				window.showInformationMessage(`TSLint fixes are outdated and can't be applied to the document.`);
			}
			textEditor.edit(mutator => {
				for (let edit of edits) {
					mutator.replace(Protocol2Code.asRange(edit.range), edit.newText);
				}
			}).then((success) => {
				if (!success) {
					window.showErrorMessage('Failed to apply TSLint fixes to the document. Please consider opening an issue with steps to reproduce.');
				}
			});
		}
開發者ID:ericanderson,項目名稱:vscode-tslint,代碼行數:67,代碼來源:extension.ts

示例4: activate

export async function activate(context: ExtensionContext) {
  // Create a status bar item that displays the current status of the language server.
  const statusBarItem = window.createStatusBarItem(StatusBarAlignment.Left, 0);
  statusBarItem.text = "torque-ls: <unknown>";
  statusBarItem.show();

  const torqueConfiguration = workspace.getConfiguration("torque.ls");
  let serverExecutable: string | null = torqueConfiguration.get("executable");
  if (serverExecutable == null) {
    serverExecutable = path.join(workspace.rootPath, "out", "x64.release", "torque-language-server");
  }

  let serverArguments = [];
  const loggingEnabled: boolean = torqueConfiguration.get("logging");
  if (loggingEnabled) {
    const logfile = torqueConfiguration.get("logfile");
    serverArguments = ["-l", logfile];
  }

  const serverOptions: ServerOptions = { command: serverExecutable, args: serverArguments };

  outputChannel = window.createOutputChannel("Torque Language Server");

  const clientOptions: LanguageClientOptions = {
    diagnosticCollectionName: "torque",
    documentSelector: [{ scheme: "file", language: "torque" }],
    errorHandler: new TorqueErrorHandler(workspace.getConfiguration("torque")),
    initializationFailedHandler: (e) => {
      outputChannel.appendLine(e);
      return false;
    },
    outputChannel,
    revealOutputChannelOn: RevealOutputChannelOn.Info,
  };

  // Create the language client and start the client.
  client = new LanguageClient("torque", "Torque Language Server", serverOptions, clientOptions);
  client.trace = Trace.Verbose;

  // Update the status bar according to the client state.
  client.onDidChangeState((event) => {
    if (event.newState === State.Running) {
      statusBarItem.text = "torque-ls: Running";
    } else if (event.newState === State.Starting) {
      statusBarItem.text = "torque-ls: Starting";
    } else {
      statusBarItem.text = "torque-ls: Stopped";
    }
  });

  // This will start client and server.
  client.start();

  await client.onReady();

  // The server needs an initial list of all the Torque files
  // in the workspace, send them over.
  workspace.findFiles("**/*.tq").then((urls) => {
    client.sendNotification("torque/fileList",
      { files: urls.map((url) => url.toString())});
  });
}
開發者ID:dnalborczyk,項目名稱:node,代碼行數:62,代碼來源:extension.ts

示例5: realActivate


//.........這裏部分代碼省略.........
											directory = path.join(workspaceFolderPath, directory);
										}
										else {
											directory = undefined;
										}
										let filePath = document.uri.scheme === 'file' ? document.uri.fsPath : undefined;
										if (filePath && directory && filePath.startsWith(directory)) {
											if (workingDirectory) {
												if (workingDirectory.directory.length < directory.length) {
													workingDirectory.directory = directory;
													workingDirectory.changeProcessCWD = changeProcessCWD;
												}
											}
											else {
												workingDirectory = { directory, changeProcessCWD };
											}
										}
									}
								}
								settings.workingDirectory = workingDirectory;
							}
							result.push(settings);
						}
						return result;
					}
				} as WorkspaceMiddleware
			}
		};
		let client = new LanguageClient(linterName, serverOptions, clientOptions);
		client.registerProposedFeatures();
		defaultErrorHandler = client.createDefaultErrorHandler();
		const running = `${linterName} server is running.`;
		const stopped = `${linterName} server stopped.`;
		client.onDidChangeState((event) => {
			if (event.newState === ClientState.Running) {
				client.info(running);
				statusBarItem.tooltip = running;
				serverRunning = true;
			} else {
				client.info(stopped);
				statusBarItem.tooltip = stopped;
				serverRunning = false;
			}
			updateStatusBarVisibility(Window.activeTextEditor);
		});
		client.onReady().then(() => {
			client.onNotification(StatusNotification.type, (params) => {
				updateStatus(params.state);
			});

			client.onNotification(exitCalled, (params) => {
				serverCalledProcessExit = true;
				client.error(`Server process exited with code ${params[0]}. This usually indicates a misconfigured ${linterName} setup.`, params[1]);
				Window.showErrorMessage(`${linterName} server shut down itself. See '${linterName}' output channel for details.`);
			});

			client.onRequest(NoStandardLibraryRequest.type, (params) => {
				const key = 'noStandardMessageShown';
				let state = context.globalState.get<NoStandardState>(key, {});
				let uri: Uri = Uri.parse(params.source.uri);
				let workspaceFolder = Workspace.getWorkspaceFolder(uri);
				let config = Workspace.getConfiguration('standard');
				let linter = config.get('semistandard', false) ? 'semistandard' : 'standard';
				if (workspaceFolder) {
					client.info([
						'',
開發者ID:chenxsan,項目名稱:vscode-standardjs,代碼行數:67,代碼來源:extension.ts


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