Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
ec8a02a3
V
vscode
项目概览
xxadev
/
vscode
与 Fork 源项目一致
从无法访问的项目Fork
通知
2
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
V
vscode
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
ec8a02a3
编写于
4月 05, 2017
作者:
J
Johannes Rieken
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
debt - remove rename/common
上级
7a4d2a16
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
65 addition
and
75 deletion
+65
-75
src/vs/editor/contrib/rename/browser/rename.ts
src/vs/editor/contrib/rename/browser/rename.ts
+64
-3
src/vs/editor/contrib/rename/common/rename.ts
src/vs/editor/contrib/rename/common/rename.ts
+0
-71
src/vs/workbench/test/electron-browser/api/extHostLanguageFeatures.test.ts
...test/electron-browser/api/extHostLanguageFeatures.test.ts
+1
-1
未找到文件。
src/vs/editor/contrib/rename/browser/rename.ts
浏览文件 @
ec8a02a3
...
...
@@ -6,7 +6,7 @@
'
use strict
'
;
import
*
as
nls
from
'
vs/nls
'
;
import
{
isPromiseCanceledError
}
from
'
vs/base/common/errors
'
;
import
{
isPromiseCanceledError
,
onUnexpectedExternalError
,
illegalArgument
}
from
'
vs/base/common/errors
'
;
import
{
KeyMod
,
KeyCode
}
from
'
vs/base/common/keyCodes
'
;
import
Severity
from
'
vs/base/common/severity
'
;
import
{
TPromise
}
from
'
vs/base/common/winjs.base
'
;
...
...
@@ -16,14 +16,65 @@ import { IMessageService } from 'vs/platform/message/common/message';
import
{
IProgressService
}
from
'
vs/platform/progress/common/progress
'
;
import
{
editorAction
,
ServicesAccessor
,
EditorAction
,
EditorCommand
,
CommonEditorRegistry
}
from
'
vs/editor/common/editorCommonExtensions
'
;
import
{
editorContribution
}
from
'
vs/editor/browser/editorBrowserExtensions
'
;
import
{
IRange
,
ICommonCodeEditor
,
EditorContextKeys
,
ModeContextKeys
,
IEditorContribution
}
from
'
vs/editor/common/editorCommon
'
;
import
{
IRange
,
ICommonCodeEditor
,
EditorContextKeys
,
ModeContextKeys
,
IEditorContribution
,
IReadOnlyModel
}
from
'
vs/editor/common/editorCommon
'
;
import
{
BulkEdit
,
createBulkEdit
}
from
'
vs/editor/common/services/bulkEdit
'
;
import
{
ICodeEditor
}
from
'
vs/editor/browser/editorBrowser
'
;
import
{
rename
}
from
'
../common/rename
'
;
import
RenameInputField
from
'
./renameInputField
'
;
import
{
ITextModelResolverService
}
from
'
vs/editor/common/services/resolverService
'
;
import
{
optional
}
from
'
vs/platform/instantiation/common/instantiation
'
;
import
{
IThemeService
}
from
"
vs/platform/theme/common/themeService
"
;
import
{
sequence
,
asWinJsPromise
}
from
'
vs/base/common/async
'
;
import
{
WorkspaceEdit
,
RenameProviderRegistry
}
from
'
vs/editor/common/modes
'
;
import
{
Position
}
from
'
vs/editor/common/core/position
'
;
export
function
rename
(
model
:
IReadOnlyModel
,
position
:
Position
,
newName
:
string
):
TPromise
<
WorkspaceEdit
>
{
const
supports
=
RenameProviderRegistry
.
ordered
(
model
);
const
rejects
:
string
[]
=
[];
let
hasResult
=
false
;
const
factory
=
supports
.
map
(
support
=>
{
return
()
=>
{
if
(
!
hasResult
)
{
return
asWinJsPromise
((
token
)
=>
{
return
support
.
provideRenameEdits
(
model
,
position
,
newName
,
token
);
}).
then
(
result
=>
{
if
(
!
result
)
{
// ignore
}
else
if
(
!
result
.
rejectReason
)
{
hasResult
=
true
;
return
result
;
}
else
{
rejects
.
push
(
result
.
rejectReason
);
}
return
undefined
;
},
err
=>
{
onUnexpectedExternalError
(
err
);
return
TPromise
.
wrapError
<
WorkspaceEdit
>
(
'
provider failed
'
);
});
}
return
undefined
;
};
});
return
sequence
(
factory
).
then
((
values
):
WorkspaceEdit
=>
{
let
result
=
values
[
0
];
if
(
rejects
.
length
>
0
)
{
return
{
edits
:
undefined
,
rejectReason
:
rejects
.
join
(
'
\n
'
)
};
}
else
if
(
!
result
)
{
return
{
edits
:
undefined
,
rejectReason
:
nls
.
localize
(
'
no result
'
,
"
No result.
"
)
};
}
else
{
return
result
;
}
});
}
// --- register actions and commands
...
...
@@ -204,3 +255,13 @@ CommonEditorRegistry.registerEditorCommand(new RenameCommand({
secondary
:
[
KeyMod
.
Shift
|
KeyCode
.
Escape
]
}
}));
// ---- api bridge command
CommonEditorRegistry
.
registerDefaultLanguageCommand
(
'
_executeDocumentRenameProvider
'
,
function
(
model
,
position
,
args
)
{
let
{
newName
}
=
args
;
if
(
typeof
newName
!==
'
string
'
)
{
throw
illegalArgument
(
'
newName
'
);
}
return
rename
(
model
,
position
,
newName
);
});
src/vs/editor/contrib/rename/common/rename.ts
已删除
100644 → 0
浏览文件 @
7a4d2a16
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
'
use strict
'
;
import
{
localize
}
from
'
vs/nls
'
;
import
{
sequence
,
asWinJsPromise
}
from
'
vs/base/common/async
'
;
import
{
illegalArgument
,
onUnexpectedExternalError
}
from
'
vs/base/common/errors
'
;
import
{
TPromise
}
from
'
vs/base/common/winjs.base
'
;
import
{
IReadOnlyModel
}
from
'
vs/editor/common/editorCommon
'
;
import
{
CommonEditorRegistry
}
from
'
vs/editor/common/editorCommonExtensions
'
;
import
{
WorkspaceEdit
,
RenameProviderRegistry
}
from
'
vs/editor/common/modes
'
;
import
{
Position
}
from
'
vs/editor/common/core/position
'
;
export
function
rename
(
model
:
IReadOnlyModel
,
position
:
Position
,
newName
:
string
):
TPromise
<
WorkspaceEdit
>
{
const
supports
=
RenameProviderRegistry
.
ordered
(
model
);
const
rejects
:
string
[]
=
[];
let
hasResult
=
false
;
const
factory
=
supports
.
map
(
support
=>
{
return
()
=>
{
if
(
!
hasResult
)
{
return
asWinJsPromise
((
token
)
=>
{
return
support
.
provideRenameEdits
(
model
,
position
,
newName
,
token
);
}).
then
(
result
=>
{
if
(
!
result
)
{
// ignore
}
else
if
(
!
result
.
rejectReason
)
{
hasResult
=
true
;
return
result
;
}
else
{
rejects
.
push
(
result
.
rejectReason
);
}
return
undefined
;
},
err
=>
{
onUnexpectedExternalError
(
err
);
return
TPromise
.
wrapError
<
WorkspaceEdit
>
(
'
provider failed
'
);
});
}
return
undefined
;
};
});
return
sequence
(
factory
).
then
((
values
):
WorkspaceEdit
=>
{
let
result
=
values
[
0
];
if
(
rejects
.
length
>
0
)
{
return
{
edits
:
undefined
,
rejectReason
:
rejects
.
join
(
'
\n
'
)
};
}
else
if
(
!
result
)
{
return
{
edits
:
undefined
,
rejectReason
:
localize
(
'
no result
'
,
"
No result.
"
)
};
}
else
{
return
result
;
}
});
}
CommonEditorRegistry
.
registerDefaultLanguageCommand
(
'
_executeDocumentRenameProvider
'
,
function
(
model
,
position
,
args
)
{
let
{
newName
}
=
args
;
if
(
typeof
newName
!==
'
string
'
)
{
throw
illegalArgument
(
'
newName
'
);
}
return
rename
(
model
,
position
,
newName
);
});
src/vs/workbench/test/electron-browser/api/extHostLanguageFeatures.test.ts
浏览文件 @
ec8a02a3
...
...
@@ -34,7 +34,7 @@ import { getOccurrencesAtPosition } from 'vs/editor/contrib/wordHighlighter/comm
import
{
provideReferences
}
from
'
vs/editor/contrib/referenceSearch/common/referenceSearch
'
;
import
{
getCodeActions
}
from
'
vs/editor/contrib/quickFix/common/quickFix
'
;
import
{
getWorkspaceSymbols
}
from
'
vs/workbench/parts/search/common/search
'
;
import
{
rename
}
from
'
vs/editor/contrib/rename/
common
/rename
'
;
import
{
rename
}
from
'
vs/editor/contrib/rename/
browser
/rename
'
;
import
{
provideSignatureHelp
}
from
'
vs/editor/contrib/parameterHints/common/parameterHints
'
;
import
{
provideSuggestionItems
}
from
'
vs/editor/contrib/suggest/common/suggest
'
;
import
{
getDocumentFormattingEdits
,
getDocumentRangeFormattingEdits
,
getOnTypeFormattingEdits
}
from
'
vs/editor/contrib/format/common/format
'
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录