diff --git a/.github/workflows/nodejs.yml b/.github/workflows/nodejs.yml index 0ac592f..01ac9f5 100644 --- a/.github/workflows/nodejs.yml +++ b/.github/workflows/nodejs.yml @@ -170,4 +170,3 @@ jobs: -Dsonar.organization=aditosoftware -Dsonar.eslint.reportPaths=eslint-results.json -Dsonar.javascript.lcov.reportPaths=coverage/lcov.info - -Dsonar.tests=src/test diff --git a/src/cache/CacheHandler.ts b/src/cache/CacheHandler.ts index f488625..5f32d7f 100644 --- a/src/cache/CacheHandler.ts +++ b/src/cache/CacheHandler.ts @@ -268,7 +268,7 @@ export class CacheHandler { readContexts(connectionLocation: string, changelogLocation: string): ContextSelection { const existingChangelog = this.getChangelog(connectionLocation, changelogLocation).existingChangelog; - if (existingChangelog && existingChangelog.contexts) { + if (existingChangelog?.contexts) { // sort any loaded contexts existingChangelog.contexts.loadedContexts?.sort((a, b) => a.localeCompare(b)); @@ -287,7 +287,7 @@ export class CacheHandler { readChangelogs(connectionLocation: string): string[] { const cache = this.readCache(); - if (cache[connectionLocation] && cache[connectionLocation].changelogs) { + if (cache[connectionLocation]?.changelogs) { return cache[connectionLocation].changelogs .toSorted((a, b) => b.lastUsed - a.lastUsed) .map((pChangelog) => pChangelog.path); diff --git a/src/cache/CacheRemover.ts b/src/cache/CacheRemover.ts index af1d6d6..07eb38e 100644 --- a/src/cache/CacheRemover.ts +++ b/src/cache/CacheRemover.ts @@ -84,7 +84,7 @@ export class CacheRemover { const toRemove = result.inputValues.get(CacheRemover.removeOption); - if (toRemove && toRemove[0]) { + if (toRemove?.[0]) { this.handleRemoval(toRemove[0], result); } } @@ -170,9 +170,9 @@ export class CacheRemover { // Build the details let detail = ""; - if (toRemove && toRemove[0]) { + if (toRemove?.[0]) { // add information about the remove option - detail = CacheRemover.removeOptions.get(toRemove[0]) || ""; + detail = CacheRemover.removeOptions.get(toRemove[0]) ?? ""; } if (propertyFiles) { @@ -193,7 +193,7 @@ export class CacheRemover { private shouldShowPropertyFileSelection(currentResults: DialogValues): boolean { const toRemove = currentResults.inputValues.get(CacheRemover.removeOption); - if (toRemove && toRemove[0]) { + if (toRemove?.[0]) { return toRemove[0] !== RemoveCacheOptions.WHOLE_CACHE; } else { return false; diff --git a/src/configuration/data/DatabaseConnection.ts b/src/configuration/data/DatabaseConnection.ts index 0b12d41..9158f18 100644 --- a/src/configuration/data/DatabaseConnection.ts +++ b/src/configuration/data/DatabaseConnection.ts @@ -74,7 +74,7 @@ export class DatabaseConnection { if (driver) { // and extract the url parts return driver.extractUrlParts(this.url); - } else if (customDriver && customDriver[this.databaseType]) { + } else if (customDriver?.[this.databaseType]) { return new CustomDriver(customDriver[this.databaseType]).extractUrlParts(this.url); } @@ -89,7 +89,7 @@ export class DatabaseConnection { */ getValue(pName: keyof DatabaseConnection): string | undefined { if (typeof this[pName] === "string") { - return this[pName] as string; + return this[pName]; } } @@ -100,7 +100,7 @@ export class DatabaseConnection { * @param pValue - the value that should be set * @returns the updated element */ - setValue(pName: keyof DatabaseConnection, pValue: string): DatabaseConnection { + setValue(pName: keyof DatabaseConnection, pValue: string): this { if (typeof this[pName] === "string") { (this[pName] as string) = pValue; } diff --git a/src/configuration/data/LiquibaseConfigurationData.ts b/src/configuration/data/LiquibaseConfigurationData.ts index 0072287..513901b 100644 --- a/src/configuration/data/LiquibaseConfigurationData.ts +++ b/src/configuration/data/LiquibaseConfigurationData.ts @@ -188,7 +188,7 @@ export class LiquibaseConfigurationData { } // and write the reference properties - if (this.referenceDatabaseConnection && this.referenceDatabaseConnection.hasData()) { + if (this.referenceDatabaseConnection?.hasData()) { this.referenceDatabaseConnection.writeDataForConnection(properties, true, pDisguisePassword); } diff --git a/src/configuration/handleChangelogSelection.ts b/src/configuration/handleChangelogSelection.ts index a98cb6e..39fc0ac 100644 --- a/src/configuration/handleChangelogSelection.ts +++ b/src/configuration/handleChangelogSelection.ts @@ -21,7 +21,7 @@ export async function chooseFileForChangelog(data: LiquibaseConfigurationData): }, }); - if (result && result[0]) { + if (result?.[0]) { const chosenFile = result[0].fsPath; // find out relative path diff --git a/src/executeJar.ts b/src/executeJar.ts index 59bf487..a58418f 100644 --- a/src/executeJar.ts +++ b/src/executeJar.ts @@ -135,7 +135,7 @@ export function executeJarAsync( } }); - childProcess.on("error", (error) => { + childProcess.on("error", (error: Error) => { Logger.getLogger().error({ message: "Child process encountered an error", error }); reject(error); }); @@ -233,11 +233,11 @@ export async function loadContextsFromChangelogFile( error: { stack: result.stderr }, notifyUser: true, }); - reject(`Error ${result.status}, ${result.error?.message}\n ${result.stderr}`); + reject(new Error(`Error ${result.status}, ${result.error?.message}\n ${result.stderr}`)); } } catch (error) { Logger.getLogger().error({ message: "Error loading contexts", error, notifyUser: true }); - reject(error); + reject(error as Error); } }); } diff --git a/src/handleChangelogFileInput.ts b/src/handleChangelogFileInput.ts index 4a0c101..bc462a6 100644 --- a/src/handleChangelogFileInput.ts +++ b/src/handleChangelogFileInput.ts @@ -105,7 +105,7 @@ export class HandleChangelogFileInput { */ private static getChangelogFileFromProperties(dialogValues: DialogValues): string | undefined { const propertyFile = dialogValues.inputValues.get(PROPERTY_FILE); - if (propertyFile && propertyFile[0]) { + if (propertyFile?.[0]) { const changelog = readChangelog(propertyFile[0]); if (changelog) { // if there is a changelog in in property-file, return it, so we can show it in the dialog @@ -114,24 +114,6 @@ export class HandleChangelogFileInput { } } - /** - * Checks if the changelog needs to be put into by an extra open dialog. - * - * @param dialogValues - the current dialog values - * @returns `true` if an OpenDialog is needed for selecting the changelog - */ - private static isChangelogFromOpenDialogNeeded(dialogValues: DialogValues): boolean { - if (this.isExtraQueryForChangelogNeeded(dialogValues)) { - const changelogPreSelection = dialogValues.inputValues.get(this.CHANGELOG_QUICK_PICK_NAME); - if (changelogPreSelection && changelogPreSelection[0]) { - // check, if the correct option was selected - return changelogPreSelection[0] === CHOOSE_CHANGELOG_OPTION; - } - } - - return false; - } - /** * Sets the changelog file from the current dialog correctly as uri (exactly as context menu). * This will mimic the behavior from a context menu, which is correct in this case. @@ -145,7 +127,7 @@ export class HandleChangelogFileInput { let changelogPath: string | undefined; - if (fileSelection && fileSelection[0]) { + if (fileSelection?.[0]) { if (fileSelection[0] === CHOOSE_CHANGELOG_OPTION) { // we are not having a correct values selected, but instead a dialog progression value // => we do not need to save anything diff --git a/src/handleContexts.ts b/src/handleContexts.ts index c69c09e..32490e5 100644 --- a/src/handleContexts.ts +++ b/src/handleContexts.ts @@ -74,11 +74,7 @@ export function generateContextInputs(): PickPanelConfig[] { export function generateItemsForContextPreDialog(contextCacheInfo?: ContextCacheInformation): vscode.QuickPickItem[] { const items: vscode.QuickPickItem[] = []; - if ( - contextCacheInfo && - contextCacheInfo.contexts.loadedContexts && - contextCacheInfo.contexts.loadedContexts.length !== 0 - ) { + if (contextCacheInfo?.contexts.loadedContexts && contextCacheInfo?.contexts.loadedContexts.length !== 0) { const cachedContexts = contextCacheInfo.contexts.loadedContexts.join(", "); items.push({ label: ContextOptions.USE_RECENTLY_LOADED, @@ -132,10 +128,8 @@ export function saveSelectedContexts(dialogValues: DialogValues, contextCacheInf */ function generateCmdArgsForPreContextSelection(dialogValues: DialogValues): string[] | undefined { const selected = dialogValues.inputValues.get(contextPreDialog); - if (selected && selected[0]) { - if (selected[0] === ContextOptions.NO_CONTEXT) { - return [`--contexts=${NO_CONTEXT_USED}`]; - } + if (selected?.[0] === ContextOptions.NO_CONTEXT) { + return [`--contexts=${NO_CONTEXT_USED}`]; } } @@ -189,7 +183,7 @@ export function loadCacheForPropertyFile(currentResults: DialogValues): ContextC function showContextSelection(dialogValues: DialogValues): boolean { const result = dialogValues.inputValues.get(contextPreDialog); - if (result && result[0]) { + if (result?.[0]) { return result[0] !== ContextOptions.NO_CONTEXT; } diff --git a/src/handleLiquibaseSettings.ts b/src/handleLiquibaseSettings.ts index 2758e3f..a5fd660 100644 --- a/src/handleLiquibaseSettings.ts +++ b/src/handleLiquibaseSettings.ts @@ -87,7 +87,7 @@ export function getDefaultDatabaseForConfiguration(): string { NO_PRE_CONFIGURED_DRIVER ); - return defaultDatabaseForConfiguration ? defaultDatabaseForConfiguration : NO_PRE_CONFIGURED_DRIVER; + return defaultDatabaseForConfiguration || NO_PRE_CONFIGURED_DRIVER; } /** diff --git a/src/liquibaseCommandsUtilities.ts b/src/liquibaseCommandsUtilities.ts index e37a91e..bac6ca7 100644 --- a/src/liquibaseCommandsUtilities.ts +++ b/src/liquibaseCommandsUtilities.ts @@ -109,7 +109,7 @@ export async function openIndexHtmlAfterCommandExecution(dialogValues: DialogVal export async function changeAndEmptyOutputDirectory(dialogValues: DialogValues): Promise { const folder = dialogValues.inputValues.get(folderSelectionName)?.[0]; - if (folder && folder.includes(os.tmpdir())) { + if (folder?.includes(os.tmpdir())) { const propertyFile = dialogValues.inputValues.get(PROPERTY_FILE)?.[0]; let configurationName = "db-doc"; diff --git a/src/panels/LiquibaseConfigurationPanel.ts b/src/panels/LiquibaseConfigurationPanel.ts index bd72038..c6d4724 100644 --- a/src/panels/LiquibaseConfigurationPanel.ts +++ b/src/panels/LiquibaseConfigurationPanel.ts @@ -21,9 +21,9 @@ import path from "path"; * - Setting message listeners so data can be passed between the webview and extension */ export class LiquibaseConfigurationPanel { - public static currentPanel: LiquibaseConfigurationPanel | undefined; + private static currentPanel: LiquibaseConfigurationPanel | undefined; private readonly _panel: WebviewPanel; - private _disposables: Disposable[] = []; + private readonly _disposables: Disposable[] = []; /** * The LiquibaseConfigurationPanel class private constructor (called only from the render method). @@ -84,16 +84,15 @@ export class LiquibaseConfigurationPanel { // In all cases, transfer a message with the current data this.transferMessage( MessageType.INIT, - data - ? data - : LiquibaseConfigurationData.createDefaultData( - { - defaultDatabaseForConfiguration: getDefaultDatabaseForConfiguration(), - liquibaseDirectoryInProject: getLiquibaseFolder(), - customDrivers: getCustomDrivers(), - }, - ConfigurationStatus.NEW - ) + data || + LiquibaseConfigurationData.createDefaultData( + { + defaultDatabaseForConfiguration: getDefaultDatabaseForConfiguration(), + liquibaseDirectoryInProject: getLiquibaseFolder(), + customDrivers: getCustomDrivers(), + }, + ConfigurationStatus.NEW + ) ); } @@ -212,12 +211,10 @@ export class LiquibaseConfigurationPanel { default: throw new Error(`Handling for command ${messageType} not found.`); } + } else if (messageData.messageType === MessageType.LOG_MESSAGE) { + Logger.getLogger().log(data); } else { - if (messageData.messageType === MessageType.LOG_MESSAGE) { - Logger.getLogger().log(data); - } else { - throw new Error(`Handling for command ${messageType} not found.`); - } + throw new Error(`Handling for command ${messageType} not found.`); } }, undefined, diff --git a/src/prerequisites.ts b/src/prerequisites.ts index 83a80ca..b7b12a7 100644 --- a/src/prerequisites.ts +++ b/src/prerequisites.ts @@ -76,7 +76,7 @@ async function downloadLiquibaseFiles(pathToResources: string, downloadUrls: str return new Promise((resolve, reject) => { Promise.all(downloadUrls.map((url) => download(url, path.join(pathToResources)))) .then(() => resolve()) - .catch((error) => { + .catch((error: Error) => { Logger.getLogger().error({ message: "downloadLiquibaseFiles threw an error", error }); reject(error); }); diff --git a/src/settings/removeConfiguration.ts b/src/settings/removeConfiguration.ts index 13ea2d6..d82f456 100644 --- a/src/settings/removeConfiguration.ts +++ b/src/settings/removeConfiguration.ts @@ -149,7 +149,7 @@ export function generateDetailMessageForDeleteConfiguration(dialogValues: Dialog whatDeleted .get(deletionMode) ?.map((pElement) => "- " + pElement) - .join("\n") || ""; + .join("\n") ?? ""; } return `This will remove the configuration from the following:\n${deletedDetail}`; diff --git a/src/test/e2e/commands/update.test.ts b/src/test/e2e/commands/update.test.ts index c36d658..80f6a30 100644 --- a/src/test/e2e/commands/update.test.ts +++ b/src/test/e2e/commands/update.test.ts @@ -42,25 +42,20 @@ suite("Update", function () { "SELECT * FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 'person'" ); - if (option === ContextOptions.NO_CONTEXT) { + if ( + option !== ContextOptions.NO_CONTEXT && + (key === "all available contexts" || key === "the first available context") + ) { + assert.ok( + databaseInformation?.length >= 1, + `Table 'person' DOES NOT exist, while it should: ${databaseInformation}` + ); + } else { assert.strictEqual( databaseInformation.length, 0, `Table 'person' DOES exist, while it shouldn't: ${databaseInformation}` ); - } else { - if (key === "all available contexts" || key === "the first available context") { - assert.ok( - databaseInformation?.length >= 1, - `Table 'person' DOES NOT exist, while it should: ${databaseInformation}` - ); - } else { - assert.strictEqual( - databaseInformation.length, - 0, - `Table 'person' DOES exist, while it shouldn't: ${databaseInformation}` - ); - } } }); }); diff --git a/src/test/suite/DockerTestUtils.ts b/src/test/suite/DockerTestUtils.ts index 3d0ba69..a29c039 100644 --- a/src/test/suite/DockerTestUtils.ts +++ b/src/test/suite/DockerTestUtils.ts @@ -1,4 +1,4 @@ -import { exec } from "child_process"; +import { exec, ExecException } from "child_process"; import { isWindows } from "../../utilities/osUtilities"; import mariadb from "mariadb"; @@ -186,7 +186,7 @@ export class DockerTestUtils { */ private static async executeCommand(command: string): Promise { return new Promise((resolve, reject) => { - exec(command, (error, stdout, stderr) => { + exec(command, (error: ExecException | null, stdout, stderr) => { if (error) { reject(error); return; diff --git a/src/test/suite/configuration/settings/configurationCommands.test.ts b/src/test/suite/configuration/settings/configurationCommands.test.ts index 2535dde..82dbaff 100644 --- a/src/test/suite/configuration/settings/configurationCommands.test.ts +++ b/src/test/suite/configuration/settings/configurationCommands.test.ts @@ -99,12 +99,12 @@ suite("configurationCommands", () => { Sinon.stub(handleLiquibaseFolder, "getLiquibaseConfigurationPath").resolves("myFolder"); Sinon.stub(ConnectionType, "suggestCreationOfConfiguration").resolves(); - assert.ok(!LiquibaseConfigurationPanel.currentPanel, "no current panel created"); + assert.ok(!LiquibaseConfigurationPanel["currentPanel"], "no current panel created"); configurationCommand .editExistingLiquibaseConfiguration(undefined, extensionContext) .then(() => { - const currentPanel = LiquibaseConfigurationPanel.currentPanel; + const currentPanel = LiquibaseConfigurationPanel["currentPanel"]; assert.ok(!currentPanel, "panel is not created"); done(); @@ -112,7 +112,7 @@ suite("configurationCommands", () => { .catch(done) .finally(() => { // dispose manually after the tests - LiquibaseConfigurationPanel.currentPanel?.dispose(); + LiquibaseConfigurationPanel["currentPanel"]?.dispose(); }); }); }); @@ -448,12 +448,12 @@ function assertEditExistingLiquibaseConfiguration( ): void { Sinon.stub(handleLiquibaseFolder, "getLiquibaseFolder").returns("myFolder"); - assert.ok(!LiquibaseConfigurationPanel.currentPanel, "no current panel created"); + assert.ok(!LiquibaseConfigurationPanel["currentPanel"], "no current panel created"); configurationCommand .editExistingLiquibaseConfiguration(uri, extensionContext) .then(() => { - const currentPanel = LiquibaseConfigurationPanel.currentPanel; + const currentPanel = LiquibaseConfigurationPanel["currentPanel"]; assert.ok(currentPanel, "panel was created"); const webviewPanel = currentPanel["_panel"]; assert.ok(webviewPanel.visible, "panel is visible"); @@ -462,7 +462,7 @@ function assertEditExistingLiquibaseConfiguration( if (uri) { LiquibaseConfigurationPanel.render(uri); - assert.ok(LiquibaseConfigurationPanel.currentPanel?.["_panel"], "panel is still visible"); + assert.ok(LiquibaseConfigurationPanel["currentPanel"]?.["_panel"], "panel is still visible"); } done(); @@ -470,7 +470,7 @@ function assertEditExistingLiquibaseConfiguration( .catch(done) .finally(() => { // dispose manually after the tests - LiquibaseConfigurationPanel.currentPanel?.dispose(); + LiquibaseConfigurationPanel["currentPanel"]?.dispose(); }); } diff --git a/src/test/suite/handleChangelogFileInput.test.ts b/src/test/suite/handleChangelogFileInput.test.ts index 41b1055..e7ef94c 100644 --- a/src/test/suite/handleChangelogFileInput.test.ts +++ b/src/test/suite/handleChangelogFileInput.test.ts @@ -118,47 +118,6 @@ suite("handleChangelogInput", () => { }); }); - /** - * Tests the method `isChangelogFromOpenDialogNeeded`. - */ - suite("isChangelogFromOpenDialogNeeded", () => { - /** - * Tests that no changelog is needed when uri is present - */ - test("should not need changelog when uri is present", () => { - const dialogValues = new DialogValues(); - dialogValues.uri = vscode.Uri.file(""); - - assert.strictEqual(HandleChangelogFileInput["isChangelogFromOpenDialogNeeded"](dialogValues), false); - }); - - [ - { - description: "the changelog should be selected", - content: CHOOSE_CHANGELOG_OPTION, - expected: true, - }, - { - description: "no changelog should be selected", - content: "foo", - expected: false, - }, - ].forEach((pArgument) => { - /** - * Tests that the desired result will be returned, when the changelog selection was or was not selected - */ - test(`should return ${pArgument.expected} when ${pArgument.description}`, () => { - const dialogValues = new DialogValues(); - dialogValues.addValue(HandleChangelogFileInput.CHANGELOG_QUICK_PICK_NAME, pArgument.content); - - assert.strictEqual( - HandleChangelogFileInput["isChangelogFromOpenDialogNeeded"](dialogValues), - pArgument.expected - ); - }); - }); - }); - /** * Tests the method `setExtraChangelogCorrectly`. */ diff --git a/src/test/suite/utilities/vscodeUtilities.test.ts b/src/test/suite/utilities/vscodeUtilities.test.ts index e467f39..2fa3fb5 100644 --- a/src/test/suite/utilities/vscodeUtilities.test.ts +++ b/src/test/suite/utilities/vscodeUtilities.test.ts @@ -114,7 +114,7 @@ suite("vscodeUtilities", () => { const errorMessage = Sinon.spy(vscode.window, "showErrorMessage"); const openExternalStub = Sinon.stub(vscode.env, "openExternal"); - openExternalStub.returns(Promise.reject(false)); + openExternalStub.returns(Promise.reject(new Error())); openLiquibaseDocumentation("foo"); diff --git a/webview-ui/src/App.tsx b/webview-ui/src/App.tsx index 0610a5b..204bb0b 100644 --- a/webview-ui/src/App.tsx +++ b/webview-ui/src/App.tsx @@ -179,8 +179,7 @@ function App(): React.JSX.Element { onClick={handleChooseChangelog} id="changelogSelection" style={{ flexShrink: 0 }}> - Choose changelog - + Choose changelog @@ -202,8 +201,7 @@ function App(): React.JSX.Element { disabled={referenceConnection} onClick={() => handleAddRemoveReferenceConnection(true)} appearance="secondary"> - Add reference connection - + Add reference connection handleAddRemoveReferenceConnection(false)} appearance="secondary"> - - Remove reference connection + Remove reference connection @@ -250,8 +247,7 @@ function App(): React.JSX.Element { - Save configuration - + Save configuration - Test configuration - + Test configuration diff --git a/webview-ui/src/components/AdditionalElements.tsx b/webview-ui/src/components/AdditionalElements.tsx index 4f44286..699fb0d 100644 --- a/webview-ui/src/components/AdditionalElements.tsx +++ b/webview-ui/src/components/AdditionalElements.tsx @@ -35,7 +35,7 @@ const valueIndicator = "value"; * @param pProperties - the properties that are needed for the additional elements * @returns the created component */ -export function AdditionalElements(pProperties: AdditionalElementProps): React.JSX.Element { +export function AdditionalElements(pProperties: Readonly): React.JSX.Element { const [additionalElementValues, setAdditionalElementValues] = useState>(new Map()); const [key, setKey] = useState(""); diff --git a/webview-ui/src/components/DatabaseConfiguration.tsx b/webview-ui/src/components/DatabaseConfiguration.tsx index df6f36b..2f72113 100644 --- a/webview-ui/src/components/DatabaseConfiguration.tsx +++ b/webview-ui/src/components/DatabaseConfiguration.tsx @@ -59,7 +59,7 @@ interface NewUrlValues extends UrlParts { * @param pProperties - the properties for creating the element * @returns the created element */ -export function DatabaseConfiguration(pProperties: DatabaseConfigurationProps): React.JSX.Element { +export function DatabaseConfiguration(pProperties: Readonly): React.JSX.Element { const [serverAddress, setServerAddress] = useState("localhost"); const [port, setPort] = useState(-1); const [databaseName, setDatabaseName] = useState("data"); diff --git a/webview-ui/src/utilities/vscodeApiWrapper.ts b/webview-ui/src/utilities/vscodeApiWrapper.ts index 4552a24..a1442ee 100644 --- a/webview-ui/src/utilities/vscodeApiWrapper.ts +++ b/webview-ui/src/utilities/vscodeApiWrapper.ts @@ -57,39 +57,39 @@ class VSCodeAPIWrapper { }); } - /** - * Get the persistent state stored for this webview. - * - * @remarks When running webview source code inside a web browser, getState will retrieve state - * from local storage (https://developer.mozilla.org/en-US/docs/Web/API/Window/localStorage). - * @returns The current state or `undefined` if no state has been set. - */ - public getState(): unknown | undefined { - if (this.vsCodeApi) { - return this.vsCodeApi.getState(); - } else { - const state = localStorage.getItem("vscodeState"); - return state ? JSON.parse(state) : undefined; - } - } + // /** + // * Get the persistent state stored for this webview. + // * + // * @remarks When running webview source code inside a web browser, getState will retrieve state + // * from local storage (https://developer.mozilla.org/en-US/docs/Web/API/Window/localStorage). + // * @returns The current state or `undefined` if no state has been set. + // */ + // public getState(): unknown | undefined { + // if (this.vsCodeApi) { + // return this.vsCodeApi.getState(); + // } else { + // const state = localStorage.getItem("vscodeState"); + // return state ? JSON.parse(state) : undefined; + // } + // } - /** - * Set the persistent state stored for this webview. - * - * @remarks When running webview source code inside a web browser, setState will set the given - * state using local storage (https://developer.mozilla.org/en-US/docs/Web/API/Window/localStorage). - * @param newState - New persisted state. This must be a JSON serializable object. Can be retrieved - * using {@link getState}. - * @returns The new state. - */ - public setState(newState: T): T { - if (this.vsCodeApi) { - return this.vsCodeApi.setState(newState); - } else { - localStorage.setItem("vscodeState", JSON.stringify(newState)); - return newState; - } - } + // /** + // * Set the persistent state stored for this webview. + // * + // * @remarks When running webview source code inside a web browser, setState will set the given + // * state using local storage (https://developer.mozilla.org/en-US/docs/Web/API/Window/localStorage). + // * @param newState - New persisted state. This must be a JSON serializable object. Can be retrieved + // * using {@link getState}. + // * @returns The new state. + // */ + // public setState(newState: T): T { + // if (this.vsCodeApi) { + // return this.vsCodeApi.setState(newState); + // } else { + // localStorage.setItem("vscodeState", JSON.stringify(newState)); + // return newState; + // } + // } } // Exports class singleton to prevent multiple invocations of acquireVsCodeApi.