提交 79fbea36 编写于 作者: I isidor

explorer: TPromise.wrap -> Promise.resolve, TPromise.wrapError -> Promise.reject

上级 f9d63a1e
......@@ -4,7 +4,6 @@
*--------------------------------------------------------------------------------------------*/
'use strict';
import { TPromise } from 'vs/base/common/winjs.base';
import * as nls from 'vs/nls';
import * as errors from 'vs/base/common/errors';
import { toErrorMessage } from 'vs/base/common/errorMessage';
......@@ -176,12 +175,12 @@ export class TextFileEditor extends BaseTextEditor {
if ((<FileOperationError>error).fileOperationResult === FileOperationResult.FILE_IS_DIRECTORY) {
this.openAsFolder(input);
return TPromise.wrapError(new Error(nls.localize('openFolderError', "File is a directory")));
return Promise.reject(new Error(nls.localize('openFolderError', "File is a directory")));
}
// Offer to create a file from the error if we have a file not found and the name is valid
if ((<FileOperationError>error).fileOperationResult === FileOperationResult.FILE_NOT_FOUND && paths.isValidBasename(paths.basename(input.getResource().fsPath))) {
return TPromise.wrapError<void>(errors.create(toErrorMessage(error), {
return Promise.reject(errors.create(toErrorMessage(error), {
actions: [
new Action('workbench.files.action.createMissingFile', nls.localize('createFile', "Create File"), null, true, () => {
return this.fileService.updateContent(input.getResource(), '').then(() => this.editorService.openEditor({
......@@ -198,7 +197,7 @@ export class TextFileEditor extends BaseTextEditor {
if ((<FileOperationError>error).fileOperationResult === FileOperationResult.FILE_EXCEED_MEMORY_LIMIT) {
const memoryLimit = Math.max(MIN_MAX_MEMORY_SIZE_MB, +this.configurationService.getValue<number>(null, 'files.maxMemoryForLargeFilesMB') || FALLBACK_MAX_MEMORY_SIZE_MB);
return TPromise.wrapError<void>(errors.create(toErrorMessage(error), {
return Promise.reject(errors.create(toErrorMessage(error), {
actions: [
new Action('workbench.window.action.relaunchWithIncreasedMemoryLimit', nls.localize('relaunchWithIncreasedMemoryLimit', "Restart with {0} MB", memoryLimit), null, true, () => {
return this.windowsService.relaunch({
......@@ -215,7 +214,7 @@ export class TextFileEditor extends BaseTextEditor {
}
// Otherwise make sure the error bubbles up
return TPromise.wrapError<void>(error);
return Promise.reject(error);
});
});
}
......
......@@ -278,7 +278,7 @@ export class FileEditorInput extends EditorInput implements IFileEditorInput {
}
// Bubble any other error up
return TPromise.wrapError(error);
return Promise.reject(error);
});
}
......
......@@ -21,7 +21,7 @@ import { MessageType, IInputValidator } from 'vs/base/browser/ui/inputbox/inputB
import { ITree, IHighlightEvent } from 'vs/base/parts/tree/browser/tree';
import { dispose, IDisposable } from 'vs/base/common/lifecycle';
import { VIEWLET_ID } from 'vs/workbench/parts/files/common/files';
import { ITextFileService } from 'vs/workbench/services/textfile/common/textfiles';
import { ITextFileService, ITextFileOperationResult } from 'vs/workbench/services/textfile/common/textfiles';
import { IFileService, IFileStat, AutoSaveConfiguration } from 'vs/platform/files/common/files';
import { toResource, IUntitledResourceInput } from 'vs/workbench/common/editor';
import { ExplorerItem, Model, NewStatPlaceholder } from 'vs/workbench/parts/files/common/explorerModel';
......@@ -171,17 +171,17 @@ class TriggerRenameFileAction extends BaseFileAction {
public run(context?: any): TPromise<any> {
if (!context) {
return TPromise.wrapError(new Error('No context provided to BaseEnableFileRenameAction.'));
return Promise.reject(new Error('No context provided to BaseEnableFileRenameAction.'));
}
const viewletState = <IFileViewletState>context.viewletState;
if (!viewletState) {
return TPromise.wrapError(new Error('Invalid viewlet state provided to BaseEnableFileRenameAction.'));
return Promise.reject(new Error('Invalid viewlet state provided to BaseEnableFileRenameAction.'));
}
const stat = <ExplorerItem>context.stat;
if (!stat) {
return TPromise.wrapError(new Error('Invalid stat provided to BaseEnableFileRenameAction.'));
return Promise.reject(new Error('Invalid stat provided to BaseEnableFileRenameAction.'));
}
viewletState.setEditable(stat, {
......@@ -238,12 +238,12 @@ export abstract class BaseRenameAction extends BaseFileAction {
public run(context?: any): TPromise<any> {
if (!context) {
return TPromise.wrapError(new Error('No context provided to BaseRenameFileAction.'));
return Promise.reject(new Error('No context provided to BaseRenameFileAction.'));
}
let name = <string>context.value;
if (!name) {
return TPromise.wrapError(new Error('No new name provided to BaseRenameFileAction.'));
return Promise.reject(new Error('No new name provided to BaseRenameFileAction.'));
}
// Automatically trim whitespaces and trailing dots to produce nice file names
......@@ -336,12 +336,12 @@ export class BaseNewAction extends BaseFileAction {
public run(context?: any): TPromise<any> {
if (!context) {
return TPromise.wrapError(new Error('No context provided to BaseNewAction.'));
return Promise.reject(new Error('No context provided to BaseNewAction.'));
}
const viewletState = <IFileViewletState>context.viewletState;
if (!viewletState) {
return TPromise.wrapError(new Error('Invalid viewlet state provided to BaseNewAction.'));
return Promise.reject(new Error('Invalid viewlet state provided to BaseNewAction.'));
}
let folder = this.presetFolder;
......@@ -356,10 +356,10 @@ export class BaseNewAction extends BaseFileAction {
}
if (!folder) {
return TPromise.wrapError(new Error('Invalid parent folder to create.'));
return Promise.reject(new Error('Invalid parent folder to create.'));
}
if (folder.isReadonly) {
return TPromise.wrapError(new Error('Parent folder is readonly.'));
return Promise.reject(new Error('Parent folder is readonly.'));
}
if (!!folder.getChild(NewStatPlaceholder.NAME)) {
// Do not allow to creatae a new file/folder while in the process of creating a new file/folder #47606
......@@ -838,7 +838,7 @@ export class AddFilesAction extends BaseFileAction {
// if the target exists and is dirty, make sure to revert it. otherwise the dirty contents
// of the target file would replace the contents of the added file. since we already
// confirmed the overwrite before, this is OK.
let revertPromise = TPromise.wrap(null);
let revertPromise: Thenable<ITextFileOperationResult> = Promise.resolve(null);
if (this.textFileService.isDirty(targetFile)) {
revertPromise = this.textFileService.revertAll([targetFile], { soft: true });
}
......
......@@ -351,7 +351,7 @@ export class ExplorerView extends TreeViewsViewletPanel implements IExplorerView
// Return now if the workbench has not yet been created - in this case the workbench takes care of restoring last used editors
if (!this.partService.isCreated()) {
return TPromise.wrap(null);
return Promise.resolve(null);
}
// Otherwise restore last used file: By lastActiveFileResource
......
......@@ -946,7 +946,7 @@ export class FileDragAndDrop extends SimpleFileResourceDragAndDrop {
if (folders.length > 0) {
// If we are in no-workspace context, ask for confirmation to create a workspace
let confirmedPromise: TPromise<IConfirmationResult> = TPromise.wrap({ confirmed: true });
let confirmedPromise: TPromise<IConfirmationResult> = Promise.resolve({ confirmed: true });
if (this.contextService.getWorkbenchState() !== WorkbenchState.WORKSPACE) {
confirmedPromise = this.dialogService.confirm({
message: folders.length > 1 ? nls.localize('dropFolders', "Do you want to add the folders to the workspace?") : nls.localize('dropFolder', "Do you want to add the folder to the workspace?"),
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册