* Minor update to watchForCrashes.
* Add preinitialize message.
This commit is contained in:
Sean McManus 2024-04-16 15:36:28 -07:00 коммит произвёл GitHub
Родитель f06f689488
Коммит 3e6b99925b
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: B5690EEEBB952194
2 изменённых файлов: 13 добавлений и 4 удалений

Просмотреть файл

@ -53,7 +53,7 @@ import {
import { Location, TextEdit, WorkspaceEdit } from './commonTypes';
import * as configs from './configurations';
import { DataBinding } from './dataBinding';
import { CppSourceStr, clients, configPrefix, updateLanguageConfigurations, watchForCrashes } from './extension';
import { CppSourceStr, clients, configPrefix, updateLanguageConfigurations, usesCrashHandler, watchForCrashes } from './extension';
import { LocalizeStringParams, getLocaleId, getLocalizedString } from './localization';
import { PersistentFolderState, PersistentWorkspaceState } from './persistentState';
import { createProtocolFilter } from './protocolFilter';
@ -544,7 +544,8 @@ interface GetIncludesResult
}
// Requests
const InitializationRequest: RequestType<CppInitializationParams, string, void> = new RequestType<CppInitializationParams, string, void>('cpptools/initialize');
const PreInitializationRequest: RequestType<void, string, void> = new RequestType<void, string, void>('cpptools/preinitialize');
const InitializationRequest: RequestType<CppInitializationParams, void, void> = new RequestType<CppInitializationParams, void, void>('cpptools/initialize');
const QueryCompilerDefaultsRequest: RequestType<QueryDefaultCompilerParams, configs.CompilerDefaults, void> = new RequestType<QueryDefaultCompilerParams, configs.CompilerDefaults, void>('cpptools/queryCompilerDefaults');
const QueryTranslationUnitSourceRequest: RequestType<QueryTranslationUnitSourceParams, QueryTranslationUnitSourceResult, void> = new RequestType<QueryTranslationUnitSourceParams, QueryTranslationUnitSourceResult, void>('cpptools/queryTranslationUnitSource');
const SwitchHeaderSourceRequest: RequestType<SwitchHeaderSourceParams, string, void> = new RequestType<SwitchHeaderSourceParams, string, void>('cpptools/didSwitchHeaderSource');
@ -1592,10 +1593,14 @@ export class DefaultClient implements Client {
languageClient.registerProposedFeatures();
await languageClient.start();
if (usesCrashHandler()) {
watchForCrashes(await languageClient.sendRequest(PreInitializationRequest, null));
}
// Move initialization to a separate message, so we can see log output from it.
// A request is used in order to wait for completion and ensure that no subsequent
// higher priority message may be processed before the Initialization request.
watchForCrashes(await languageClient.sendRequest(InitializationRequest, cppInitializationParams));
await languageClient.sendRequest(InitializationRequest, cppInitializationParams);
}
public async sendDidChangeSettings(): Promise<void> {

Просмотреть файл

@ -958,8 +958,12 @@ function reportMacCrashes(): void {
}
}
export function usesCrashHandler(): boolean {
return process.platform !== "win32" && (process.platform === "darwin" || os.arch() === "x64");
}
export function watchForCrashes(crashDirectory: string): void {
if (process.platform !== "win32" && (process.platform === "darwin" || os.arch() === "x64")) {
if (crashDirectory !== "") {
prevCrashFile = "";
fs.stat(crashDirectory, (err) => {
const crashObject: Record<string, string> = {};