Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
掘金者说
vscode
提交
6c0bb9ba
V
vscode
项目概览
掘金者说
/
vscode
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
V
vscode
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
6c0bb9ba
编写于
9月 04, 2019
作者:
J
Johannes Rieken
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
make DecorationData a class and rename it to Decoration, #54938
上级
07d19b90
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
40 addition
and
20 deletion
+40
-20
extensions/git/src/decorationProvider.ts
extensions/git/src/decorationProvider.ts
+9
-9
extensions/git/src/repository.ts
extensions/git/src/repository.ts
+2
-2
src/vs/vscode.proposed.d.ts
src/vs/vscode.proposed.d.ts
+2
-3
src/vs/workbench/api/common/extHost.api.impl.ts
src/vs/workbench/api/common/extHost.api.impl.ts
+2
-1
src/vs/workbench/api/common/extHostDecorations.ts
src/vs/workbench/api/common/extHostDecorations.ts
+7
-5
src/vs/workbench/api/common/extHostTypes.ts
src/vs/workbench/api/common/extHostTypes.ts
+18
-0
未找到文件。
extensions/git/src/decorationProvider.ts
浏览文件 @
6c0bb9ba
...
...
@@ -3,7 +3,7 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import
{
window
,
workspace
,
Uri
,
Disposable
,
Event
,
EventEmitter
,
Decoration
Data
,
DecorationProvider
,
ThemeColor
}
from
'
vscode
'
;
import
{
window
,
workspace
,
Uri
,
Disposable
,
Event
,
EventEmitter
,
Decoration
,
DecorationProvider
,
ThemeColor
}
from
'
vscode
'
;
import
*
as
path
from
'
path
'
;
import
{
Repository
,
GitResourceGroup
}
from
'
./repository
'
;
import
{
Model
}
from
'
./model
'
;
...
...
@@ -29,7 +29,7 @@ class GitIgnoreDecorationProvider implements DecorationProvider {
this
.
disposables
.
push
(
window
.
registerDecorationProvider
(
this
));
}
provideDecoration
(
uri
:
Uri
):
Promise
<
Decoration
Data
|
undefined
>
{
provideDecoration
(
uri
:
Uri
):
Promise
<
Decoration
|
undefined
>
{
const
repository
=
this
.
model
.
getRepository
(
uri
);
if
(
!
repository
)
{
...
...
@@ -48,7 +48,7 @@ class GitIgnoreDecorationProvider implements DecorationProvider {
this
.
checkIgnoreSoon
();
}).
then
(
ignored
=>
{
if
(
ignored
)
{
return
<
Decoration
Data
>
{
return
<
Decoration
>
{
priority
:
3
,
color
:
new
ThemeColor
(
'
gitDecoration.ignoredResourceForeground
'
)
};
...
...
@@ -89,7 +89,7 @@ class GitIgnoreDecorationProvider implements DecorationProvider {
class
GitDecorationProvider
implements
DecorationProvider
{
private
static
SubmoduleDecorationData
:
Decoration
Data
=
{
private
static
SubmoduleDecorationData
:
Decoration
=
{
title
:
'
Submodule
'
,
letter
:
'
S
'
,
color
:
new
ThemeColor
(
'
gitDecoration.submoduleResourceForeground
'
)
...
...
@@ -99,7 +99,7 @@ class GitDecorationProvider implements DecorationProvider {
readonly
onDidChangeDecorations
:
Event
<
Uri
[]
>
=
this
.
_onDidChangeDecorations
.
event
;
private
disposables
:
Disposable
[]
=
[];
private
decorations
=
new
Map
<
string
,
Decoration
Data
>
();
private
decorations
=
new
Map
<
string
,
Decoration
>
();
constructor
(
private
repository
:
Repository
)
{
this
.
disposables
.
push
(
...
...
@@ -109,7 +109,7 @@ class GitDecorationProvider implements DecorationProvider {
}
private
onDidRunGitStatus
():
void
{
let
newDecorations
=
new
Map
<
string
,
Decoration
Data
>
();
let
newDecorations
=
new
Map
<
string
,
Decoration
>
();
this
.
collectSubmoduleDecorationData
(
newDecorations
);
this
.
collectDecorationData
(
this
.
repository
.
indexGroup
,
newDecorations
);
...
...
@@ -121,7 +121,7 @@ class GitDecorationProvider implements DecorationProvider {
this
.
_onDidChangeDecorations
.
fire
([...
uris
.
values
()].
map
(
value
=>
Uri
.
parse
(
value
,
true
)));
}
private
collectDecorationData
(
group
:
GitResourceGroup
,
bucket
:
Map
<
string
,
Decoration
Data
>
):
void
{
private
collectDecorationData
(
group
:
GitResourceGroup
,
bucket
:
Map
<
string
,
Decoration
>
):
void
{
group
.
resourceStates
.
forEach
(
r
=>
{
if
(
r
.
resourceDecoration
)
{
// not deleted and has a decoration
...
...
@@ -130,13 +130,13 @@ class GitDecorationProvider implements DecorationProvider {
});
}
private
collectSubmoduleDecorationData
(
bucket
:
Map
<
string
,
Decoration
Data
>
):
void
{
private
collectSubmoduleDecorationData
(
bucket
:
Map
<
string
,
Decoration
>
):
void
{
for
(
const
submodule
of
this
.
repository
.
submodules
)
{
bucket
.
set
(
Uri
.
file
(
path
.
join
(
this
.
repository
.
root
,
submodule
.
path
)).
toString
(),
GitDecorationProvider
.
SubmoduleDecorationData
);
}
}
provideDecoration
(
uri
:
Uri
):
Decoration
Data
|
undefined
{
provideDecoration
(
uri
:
Uri
):
Decoration
|
undefined
{
return
this
.
decorations
.
get
(
uri
.
toString
());
}
...
...
extensions/git/src/repository.ts
浏览文件 @
6c0bb9ba
...
...
@@ -3,7 +3,7 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import
{
commands
,
Uri
,
Command
,
EventEmitter
,
Event
,
scm
,
SourceControl
,
SourceControlInputBox
,
SourceControlResourceGroup
,
SourceControlResourceState
,
SourceControlResourceDecorations
,
SourceControlInputBoxValidation
,
Disposable
,
ProgressLocation
,
window
,
workspace
,
WorkspaceEdit
,
ThemeColor
,
Decoration
Data
,
Memento
,
SourceControlInputBoxValidationType
,
OutputChannel
,
LogLevel
,
env
,
ProgressOptions
,
CancellationToken
}
from
'
vscode
'
;
import
{
commands
,
Uri
,
Command
,
EventEmitter
,
Event
,
scm
,
SourceControl
,
SourceControlInputBox
,
SourceControlResourceGroup
,
SourceControlResourceState
,
SourceControlResourceDecorations
,
SourceControlInputBoxValidation
,
Disposable
,
ProgressLocation
,
window
,
workspace
,
WorkspaceEdit
,
ThemeColor
,
Decoration
,
Memento
,
SourceControlInputBoxValidationType
,
OutputChannel
,
LogLevel
,
env
,
ProgressOptions
,
CancellationToken
}
from
'
vscode
'
;
import
{
Repository
as
BaseRepository
,
Commit
,
Stash
,
GitError
,
Submodule
,
CommitOptions
,
ForcePushMode
}
from
'
./git
'
;
import
{
anyEvent
,
filterEvent
,
eventToPromise
,
dispose
,
find
,
isDescendant
,
IDisposable
,
onceEvent
,
EmptyDisposable
,
debounceEvent
,
combinedDisposable
}
from
'
./util
'
;
import
{
memoize
,
throttle
,
debounce
}
from
'
./decorators
'
;
...
...
@@ -244,7 +244,7 @@ export class Resource implements SourceControlResourceState {
}
}
get
resourceDecoration
():
Decoration
Data
{
get
resourceDecoration
():
Decoration
{
const
title
=
this
.
tooltip
;
const
letter
=
this
.
letter
;
const
color
=
this
.
color
;
...
...
src/vs/vscode.proposed.d.ts
浏览文件 @
6c0bb9ba
...
...
@@ -556,8 +556,7 @@ declare module 'vscode' {
//#region Joh: decorations
//todo@joh -> make class
export
interface
DecorationData
{
export
class
Decoration
{
letter
?:
string
;
title
?:
string
;
color
?:
ThemeColor
;
...
...
@@ -567,7 +566,7 @@ declare module 'vscode' {
export
interface
DecorationProvider
{
onDidChangeDecorations
:
Event
<
undefined
|
Uri
|
Uri
[]
>
;
provideDecoration
(
uri
:
Uri
,
token
:
CancellationToken
):
ProviderResult
<
Decoration
Data
>
;
provideDecoration
(
uri
:
Uri
,
token
:
CancellationToken
):
ProviderResult
<
Decoration
>
;
}
export
namespace
window
{
...
...
src/vs/workbench/api/common/extHost.api.impl.ts
浏览文件 @
6c0bb9ba
...
...
@@ -890,7 +890,8 @@ export function createApiFactoryAndRegisterActors(accessor: ServicesAccessor): I
WorkspaceEdit
:
extHostTypes
.
WorkspaceEdit
,
// proposed
CallHierarchyDirection
:
extHostTypes
.
CallHierarchyDirection
,
CallHierarchyItem
:
extHostTypes
.
CallHierarchyItem
CallHierarchyItem
:
extHostTypes
.
CallHierarchyItem
,
Decoration
:
extHostTypes
.
Decoration
};
};
}
...
...
src/vs/workbench/api/common/extHostDecorations.ts
浏览文件 @
6c0bb9ba
...
...
@@ -6,7 +6,7 @@
import
*
as
vscode
from
'
vscode
'
;
import
{
URI
}
from
'
vs/base/common/uri
'
;
import
{
MainContext
,
ExtHostDecorationsShape
,
MainThreadDecorationsShape
,
DecorationData
,
DecorationRequest
,
DecorationReply
}
from
'
vs/workbench/api/common/extHost.protocol
'
;
import
{
Disposable
}
from
'
vs/workbench/api/common/extHostTypes
'
;
import
{
Disposable
,
Decoration
}
from
'
vs/workbench/api/common/extHostTypes
'
;
import
{
CancellationToken
}
from
'
vs/base/common/cancellation
'
;
import
{
ExtensionIdentifier
}
from
'
vs/platform/extensions/common/extensions
'
;
import
{
asArray
}
from
'
vs/base/common/arrays
'
;
...
...
@@ -59,12 +59,14 @@ export class ExtHostDecorations implements IExtHostDecorations {
}
const
{
provider
,
extensionId
}
=
entry
;
return
Promise
.
resolve
(
provider
.
provideDecoration
(
URI
.
revive
(
uri
),
token
)).
then
(
data
=>
{
if
(
data
&&
data
.
letter
&&
data
.
letter
.
length
!==
1
)
{
console
.
warn
(
`INVALID decoration from extension '
${
extensionId
.
value
}
'. The 'letter' must be set and be one character, not '
${
data
.
letter
}
'.`
)
;
if
(
!
data
)
{
return
;
}
if
(
data
)
{
try
{
Decoration
.
validate
(
data
);
result
[
id
]
=
<
DecorationData
>
[
data
.
priority
,
data
.
bubble
,
data
.
title
,
data
.
letter
,
data
.
color
];
}
catch
(
e
)
{
console
.
warn
(
`INVALID decoration from extension '
${
extensionId
.
value
}
':
${
e
}
`
);
}
},
err
=>
{
console
.
error
(
err
);
...
...
src/vs/workbench/api/common/extHostTypes.ts
浏览文件 @
6c0bb9ba
...
...
@@ -2349,3 +2349,21 @@ export enum ExtensionKind {
UI
=
1
,
Workspace
=
2
}
export
class
Decoration
{
static
validate
(
d
:
Decoration
):
void
{
if
(
d
.
letter
&&
d
.
letter
.
length
!==
1
)
{
throw
new
Error
(
`The 'letter'-property must be undefined or a single character`
);
}
if
(
!
d
.
bubble
&&
!
d
.
color
&&
!
d
.
letter
&&
!
d
.
priority
&&
!
d
.
title
)
{
throw
new
Error
(
`The decoration is empty`
);
}
}
letter
?:
string
;
title
?:
string
;
color
?:
vscode
.
ThemeColor
;
priority
?:
number
;
bubble
?:
boolean
;
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录