当前位置: 首页>>代码示例>>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;未经允许,请勿转载。