Skip to content

Commit

Permalink
fix #71992
Browse files Browse the repository at this point in the history
  • Loading branch information
jrieken committed Apr 12, 2019
1 parent 39012b2 commit 261fa9f
Show file tree
Hide file tree
Showing 15 changed files with 27 additions and 24 deletions.
6 changes: 4 additions & 2 deletions src/vs/base/common/uri.ts
Original file line number Diff line number Diff line change
Expand Up @@ -373,9 +373,11 @@ export class URI implements UriComponents {
return this;
}

static revive(data: UriComponents | any): URI {
static revive(data: UriComponents | URI): URI;
static revive(data: UriComponents | URI | undefined | null): URI | undefined;
static revive(data: UriComponents | URI | undefined | null): URI | undefined {
if (!data) {
return data;
return undefined;
} else if (data instanceof URI) {
return data;
} else {
Expand Down
4 changes: 2 additions & 2 deletions src/vs/base/test/common/uri.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import * as assert from 'assert';
import { URI } from 'vs/base/common/uri';
import { URI, UriComponents } from 'vs/base/common/uri';
import { isWindows } from 'vs/base/common/platform';


Expand Down Expand Up @@ -441,7 +441,7 @@ suite('URI', () => {
// let c = 100000;
// while (c-- > 0) {
for (let value of values) {
let data = value.toJSON();
let data = value.toJSON() as UriComponents;
let clone = URI.revive(data);

assert.equal(clone.scheme, value.scheme);
Expand Down
3 changes: 2 additions & 1 deletion src/vs/monaco.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,8 @@ declare namespace monaco {
*/
toString(skipEncoding?: boolean): string;
toJSON(): object;
static revive(data: UriComponents | any): Uri;
static revive(data: UriComponents | Uri): Uri;
static revive(data: UriComponents | Uri | undefined | null): Uri | undefined;
}

export interface UriComponents {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ export class ExtensionManagementChannelClient implements IExtensionManagementSer
get onDidUninstallExtension(): Event<DidUninstallExtensionEvent> { return this.channel.listen('onDidUninstallExtension'); }

zip(extension: ILocalExtension): Promise<URI> {
return Promise.resolve(this.channel.call('zip', [extension]).then(result => URI.revive(result)));
return Promise.resolve(this.channel.call('zip', [extension]).then(result => URI.revive(<UriComponents>result)));
}

unzip(zipLocation: URI, type: ExtensionType): Promise<IExtensionIdentifier> {
Expand Down Expand Up @@ -122,4 +122,4 @@ export class ExtensionManagementChannelClient implements IExtensionManagementSer
getExtensionsReport(): Promise<IReportedExtension[]> {
return Promise.resolve(this.channel.call('getExtensionsReport'));
}
}
}
2 changes: 1 addition & 1 deletion src/vs/platform/history/electron-main/historyStorage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ export function restoreRecentlyOpened(data: RecentlyOpenedStorageData | undefine
result.workspaces.push({ workspace: { id: workspace['id'], configPath: URI.file(workspace['configPath']) } });
} else if (workspace && typeof workspace['path'] === 'string' && typeof workspace['scheme'] === 'string') {
// added by 1.26-insiders
result.workspaces.push({ folderUri: URI.revive(workspace) });
result.workspaces.push({ folderUri: URI.revive(<UriComponents>workspace) });
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/vs/workbench/api/browser/mainThreadDecorations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ export class MainThreadDecorations implements MainThreadDecorationsShape {
const provider = this._provider.get(handle);
if (provider) {
const [emitter] = provider;
emitter.fire(resources && resources.map(URI.revive));
emitter.fire(resources && resources.map(r => URI.revive(r)));
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/vs/workbench/api/browser/mainThreadSearch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ class RemoteSearchProvider implements ISearchResultProvider, IDisposable {
});
} else {
searchOp.addMatch({
resource: URI.revive(result)
resource: URI.revive(<UriComponents>result)
});
}
});
Expand Down
2 changes: 1 addition & 1 deletion src/vs/workbench/api/common/extHostDialogs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export class ExtHostDialogs {

showOpenDialog(options: vscode.OpenDialogOptions): Promise<URI[] | undefined> {
return this._proxy.$showOpenDialog(options).then(filepaths => {
return filepaths ? filepaths.map(URI.revive) : undefined;
return filepaths ? filepaths.map(p => URI.revive(p)) : undefined;
});
}

Expand Down
4 changes: 2 additions & 2 deletions src/vs/workbench/api/common/extHostTypeConverters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -478,8 +478,8 @@ export namespace WorkspaceEdit {
);
} else {
result.renameFile(
URI.revive((<ResourceFileEditDto>edit).oldUri),
URI.revive((<ResourceFileEditDto>edit).newUri),
URI.revive((<ResourceFileEditDto>edit).oldUri!),
URI.revive((<ResourceFileEditDto>edit).newUri!),
(<ResourceFileEditDto>edit).options
);
}
Expand Down
2 changes: 1 addition & 1 deletion src/vs/workbench/api/common/extHostWorkspace.ts
Original file line number Diff line number Diff line change
Expand Up @@ -420,7 +420,7 @@ export class ExtHostWorkspace implements ExtHostWorkspaceShape, IExtHostWorkspac
}

return this._proxy.$startFileSearch(includePattern, includeFolder, excludePatternOrDisregardExcludes, maxResults, token)
.then(data => Array.isArray(data) ? data.map(URI.revive) : []);
.then(data => Array.isArray(data) ? data.map(d => URI.revive(d)) : []);
}

findTextInFiles(query: vscode.TextSearchQuery, options: vscode.FindTextInFilesOptions, callback: (result: vscode.TextSearchResult) => void, extensionId: ExtensionIdentifier, token: vscode.CancellationToken = CancellationToken.None): Promise<vscode.TextSearchComplete | undefined> {
Expand Down
2 changes: 1 addition & 1 deletion src/vs/workbench/api/electron-browser/mainThreadWebview.ts
Original file line number Diff line number Diff line change
Expand Up @@ -414,7 +414,7 @@ export class MainThreadWebviews extends Disposable implements MainThreadWebviews
function reviveWebviewOptions(options: WebviewInputOptions): WebviewInputOptions {
return {
...options,
localResourceRoots: Array.isArray(options.localResourceRoots) ? options.localResourceRoots.map(URI.revive) : undefined,
localResourceRoots: Array.isArray(options.localResourceRoots) ? options.localResourceRoots.map(r => URI.revive(r)) : undefined,
};
}

Expand Down
6 changes: 3 additions & 3 deletions src/vs/workbench/browser/parts/editor/editor.contribution.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

import { Registry } from 'vs/platform/registry/common/platform';
import * as nls from 'vs/nls';
import { URI } from 'vs/base/common/uri';
import { URI, UriComponents } from 'vs/base/common/uri';
import { Action, IAction } from 'vs/base/common/actions';
import { IEditorQuickOpenEntry, IQuickOpenRegistry, Extensions as QuickOpenExtensions, QuickOpenHandlerDescriptor } from 'vs/workbench/browser/quickopen';
import { StatusbarItemDescriptor, IStatusbarRegistry, Extensions as StatusExtensions } from 'vs/workbench/browser/parts/statusbar/statusbar';
Expand Down Expand Up @@ -142,7 +142,7 @@ class UntitledEditorInputFactory implements IEditorInputFactory {
deserialize(instantiationService: IInstantiationService, serializedEditorInput: string): UntitledEditorInput {
return instantiationService.invokeFunction<UntitledEditorInput>(accessor => {
const deserialized: ISerializedUntitledEditorInput = JSON.parse(serializedEditorInput);
const resource = !!deserialized.resourceJSON ? URI.revive(deserialized.resourceJSON) : URI.parse(deserialized.resource);
const resource = !!deserialized.resourceJSON ? URI.revive(<UriComponents>deserialized.resourceJSON) : URI.parse(deserialized.resource);
const filePath = resource.scheme === Schemas.untitled ? undefined : resource.scheme === Schemas.file ? resource.fsPath : resource.path;
const language = deserialized.modeId;
const encoding = deserialized.encoding;
Expand Down Expand Up @@ -925,4 +925,4 @@ MenuRegistry.appendMenuItem(MenuId.MenubarGoMenu, {
title: nls.localize({ key: 'miSwitchGroup', comment: ['&& denotes a mnemonic'] }, "Switch &&Group"),
submenu: MenuId.MenubarSwitchGroupMenu,
order: 2
});
});
4 changes: 2 additions & 2 deletions src/vs/workbench/contrib/files/browser/files.contribution.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/

import { URI } from 'vs/base/common/uri';
import { URI, UriComponents } from 'vs/base/common/uri';
import { ViewletRegistry, Extensions as ViewletExtensions, ViewletDescriptor, ShowViewletAction } from 'vs/workbench/browser/viewlet';
import * as nls from 'vs/nls';
import { sep } from 'vs/base/common/path';
Expand Down Expand Up @@ -157,7 +157,7 @@ class FileEditorInputFactory implements IEditorInputFactory {
public deserialize(instantiationService: IInstantiationService, serializedEditorInput: string): FileEditorInput {
return instantiationService.invokeFunction<FileEditorInput>(accessor => {
const fileInput: ISerializedFileInput = JSON.parse(serializedEditorInput);
const resource = !!fileInput.resourceJSON ? URI.revive(fileInput.resourceJSON) : URI.parse(fileInput.resource);
const resource = !!fileInput.resourceJSON ? URI.revive(<UriComponents>fileInput.resourceJSON) : URI.parse(fileInput.resource);
const encoding = fileInput.encoding;

return accessor.get(IEditorService).createInput({ resource, encoding, forceFile: true }) as FileEditorInput;
Expand Down
2 changes: 1 addition & 1 deletion src/vs/workbench/electron-browser/window.ts
Original file line number Diff line number Diff line change
Expand Up @@ -526,7 +526,7 @@ export class ElectronWindow extends Disposable {
const resource = URI.revive(p.fileUri);
let input: IResourceInput | IUntitledResourceInput;
if (isNew) {
input = { filePath: resource.fsPath, options: { pinned: true } };
input = { filePath: resource!.fsPath, options: { pinned: true } };
} else {
input = { resource, options: { pinned: true } };
}
Expand Down
6 changes: 3 additions & 3 deletions src/vs/workbench/services/history/browser/history.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
*--------------------------------------------------------------------------------------------*/

import { onUnexpectedError } from 'vs/base/common/errors';
import { URI } from 'vs/base/common/uri';
import { URI, UriComponents } from 'vs/base/common/uri';
import { IEditor } from 'vs/editor/common/editorCommon';
import { ITextEditorOptions, IResourceInput, ITextEditorSelection } from 'vs/platform/editor/common/editor';
import { IEditorInput, IEditor as IBaseEditor, Extensions as EditorExtensions, EditorInput, IEditorCloseEvent, IEditorInputFactoryRegistry, toResource, Extensions as EditorInputExtensions, IFileInputFactory, IEditorIdentifier } from 'vs/workbench/common/editor';
Expand Down Expand Up @@ -888,7 +888,7 @@ export class HistoryService extends Disposable implements IHistoryService {

// File resource: via URI.revive()
if (serializedEditorHistoryEntry.resourceJSON) {
return { resource: URI.revive(serializedEditorHistoryEntry.resourceJSON) };
return { resource: URI.revive(<UriComponents>serializedEditorHistoryEntry.resourceJSON) };
}

// Editor input: via factory
Expand Down Expand Up @@ -974,4 +974,4 @@ export class HistoryService extends Disposable implements IHistoryService {
}
}

registerSingleton(IHistoryService, HistoryService);
registerSingleton(IHistoryService, HistoryService);

0 comments on commit 261fa9f

Please sign in to comment.