Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
be836877
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,发现更多精彩内容 >>
提交
be836877
编写于
7月 27, 2017
作者:
M
Michel Kaporin
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Simplified extHost <-> mainThread communication by having color formatters map on both sides.
上级
6629ed86
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
78 addition
and
51 deletion
+78
-51
src/vs/editor/contrib/colorPicker/common/colorFormatter.ts
src/vs/editor/contrib/colorPicker/common/colorFormatter.ts
+1
-4
src/vs/workbench/api/electron-browser/mainThreadLanguageFeatures.ts
...kbench/api/electron-browser/mainThreadLanguageFeatures.ts
+25
-16
src/vs/workbench/api/node/extHost.protocol.ts
src/vs/workbench/api/node/extHost.protocol.ts
+8
-4
src/vs/workbench/api/node/extHostLanguageFeatures.ts
src/vs/workbench/api/node/extHostLanguageFeatures.ts
+37
-6
src/vs/workbench/api/node/extHostTypeConverters.ts
src/vs/workbench/api/node/extHostTypeConverters.ts
+7
-21
未找到文件。
src/vs/editor/contrib/colorPicker/common/colorFormatter.ts
浏览文件 @
be836877
...
...
@@ -146,9 +146,6 @@ export class ColorFormatter {
constructor
(
format
:
string
)
{
this
.
parse
(
format
);
// this.tree.push(createLiteralNode('new Color('));
// this.tree.push(createPropertyNode('red', 'd', 0, 255));
// this.tree.push(createLiteralNode(')'));
}
private
parse
(
format
:
string
):
void
{
...
...
@@ -166,7 +163,7 @@ export class ColorFormatter {
// add more parser catches
const
variable
=
match
[
1
];
if
(
!
variable
)
{
throw
new
Error
(
`
${
variable
}
is not defined`
);
throw
new
Error
(
`
${
variable
}
is not defined
.
`
);
}
const
decimals
=
parseInt
(
match
[
2
]);
const
type
=
match
[
3
];
...
...
src/vs/workbench/api/electron-browser/mainThreadLanguageFeatures.ts
浏览文件 @
be836877
...
...
@@ -16,7 +16,7 @@ import { wireCancellationToken } from 'vs/base/common/async';
import
{
CancellationToken
}
from
'
vs/base/common/cancellation
'
;
import
{
Position
as
EditorPosition
}
from
'
vs/editor/common/core/position
'
;
import
{
Range
as
EditorRange
}
from
'
vs/editor/common/core/range
'
;
import
{
ExtHostContext
,
MainThreadLanguageFeaturesShape
,
ExtHostLanguageFeaturesShape
}
from
'
../node/extHost.protocol
'
;
import
{
ExtHostContext
,
MainThreadLanguageFeaturesShape
,
ExtHostLanguageFeaturesShape
,
IRawColorInfo
,
IColorFormatMap
}
from
'
../node/extHost.protocol
'
;
import
{
LanguageConfigurationRegistry
}
from
'
vs/editor/common/modes/languageConfigurationRegistry
'
;
import
{
LanguageConfiguration
}
from
'
vs/editor/common/modes/languageConfiguration
'
;
import
{
IHeapService
}
from
'
./mainThreadHeapService
'
;
...
...
@@ -28,6 +28,7 @@ export class MainThreadLanguageFeatures extends MainThreadLanguageFeaturesShape
private
_heapService
:
IHeapService
;
private
_modeService
:
IModeService
;
private
_registrations
:
{
[
handle
:
number
]:
IDisposable
;
}
=
Object
.
create
(
null
);
private
_colorFormatsMap
:
Map
<
number
,
modes
.
IColorFormat
>
;
constructor
(
@
IThreadService
threadService
:
IThreadService
,
...
...
@@ -38,6 +39,7 @@ export class MainThreadLanguageFeatures extends MainThreadLanguageFeaturesShape
this
.
_proxy
=
threadService
.
get
(
ExtHostContext
.
ExtHostLanguageFeatures
);
this
.
_heapService
=
heapService
;
this
.
_modeService
=
modeService
;
this
.
_colorFormatsMap
=
new
Map
<
number
,
modes
.
IColorFormat
>
();
}
$unregister
(
handle
:
number
):
TPromise
<
any
>
{
...
...
@@ -269,27 +271,17 @@ export class MainThreadLanguageFeatures extends MainThreadLanguageFeaturesShape
$registerDocumentColorProvider
(
handle
:
number
,
selector
:
vscode
.
DocumentSelector
):
TPromise
<
any
>
{
const
proxy
=
this
.
_proxy
;
const
colorFormatsMap
=
this
.
_colorFormatsMap
;
this
.
_registrations
[
handle
]
=
modes
.
ColorProviderRegistry
.
register
(
selector
,
<
modes
.
ColorRangeProvider
>
{
provideColorRanges
:
function
(
model
,
token
)
{
return
wireCancellationToken
(
token
,
proxy
.
$provideDocumentColors
(
handle
,
model
.
uri
))
.
then
((
colorInfos
)
=>
{
return
colorInfos
.
map
(
c
=>
{
let
format
:
modes
.
IColorFormat
;
if
(
typeof
c
.
format
===
'
string
'
)
{
format
=
c
.
format
;
}
else
{
format
=
{
opaque
:
c
.
format
[
0
],
transparent
:
c
.
format
[
1
]
};
}
const
format
=
colorFormatsMap
.
get
(
c
.
format
);
let
availableFormats
:
modes
.
IColorFormat
[]
=
[];
c
.
availableFormats
.
forEach
(
format
=>
{
if
(
typeof
format
===
'
string
'
)
{
availableFormats
.
push
(
format
);
}
else
{
availableFormats
.
push
({
opaque
:
format
[
0
],
transparent
:
format
[
1
]
});
}
c
.
availableFormats
.
forEach
(
f
=>
{
availableFormats
.
push
(
colorFormatsMap
.
get
(
c
.
format
));
});
const
[
red
,
green
,
blue
,
alpha
]
=
c
.
color
;
...
...
@@ -313,6 +305,23 @@ export class MainThreadLanguageFeatures extends MainThreadLanguageFeaturesShape
return
undefined
;
}
$registerColorFormats
(
formats
:
IColorFormatMap
):
TPromise
<
any
>
{
formats
.
forEach
(
f
=>
{
const
raw
=
f
[
1
];
let
format
:
modes
.
IColorFormat
;
if
(
typeof
raw
===
'
string
'
)
{
format
=
raw
;
}
else
{
format
=
{
opaque
:
raw
[
1
][
0
],
transparent
:
raw
[
1
][
0
]
};
}
this
.
_colorFormatsMap
.
set
(
f
[
0
],
format
);
});
return
undefined
;
}
// --- configuration
$setLanguageConfiguration
(
handle
:
number
,
languageId
:
string
,
_configuration
:
vscode
.
LanguageConfiguration
):
TPromise
<
any
>
{
...
...
src/vs/workbench/api/node/extHost.protocol.ts
浏览文件 @
be836877
...
...
@@ -230,6 +230,7 @@ export abstract class MainThreadLanguageFeaturesShape {
$registerSuggestSupport
(
handle
:
number
,
selector
:
vscode
.
DocumentSelector
,
triggerCharacters
:
string
[]):
TPromise
<
any
>
{
throw
ni
();
}
$registerSignatureHelpProvider
(
handle
:
number
,
selector
:
vscode
.
DocumentSelector
,
triggerCharacter
:
string
[]):
TPromise
<
any
>
{
throw
ni
();
}
$registerDocumentLinkProvider
(
handle
:
number
,
selector
:
vscode
.
DocumentSelector
):
TPromise
<
any
>
{
throw
ni
();
}
$registerColorFormats
(
formats
:
IColorFormatMap
):
TPromise
<
any
>
{
throw
ni
();
}
$registerDocumentColorProvider
(
handle
:
number
,
selector
:
vscode
.
DocumentSelector
):
TPromise
<
any
>
{
throw
ni
();
}
$setLanguageConfiguration
(
handle
:
number
,
languageId
:
string
,
configuration
:
vscode
.
LanguageConfiguration
):
TPromise
<
any
>
{
throw
ni
();
}
}
...
...
@@ -464,13 +465,16 @@ export namespace ObjectIdentifier {
export
abstract
class
ExtHostHeapServiceShape
{
$onGarbageCollection
(
ids
:
number
[]):
void
{
throw
ni
();
}
}
export
interface
IColorInfo
{
export
interface
I
Raw
ColorInfo
{
color
:
[
number
,
number
,
number
,
number
|
undefined
];
format
:
string
|
[
string
,
string
]
;
availableFormats
:
(
string
|
[
string
,
string
])
[];
format
:
number
;
availableFormats
:
number
[];
range
:
IRange
;
}
export
type
IRawColorFormat
=
string
|
[
string
,
string
];
export
type
IColorFormatMap
=
[
number
,
IRawColorFormat
][];
export
abstract
class
ExtHostLanguageFeaturesShape
{
$provideDocumentSymbols
(
handle
:
number
,
resource
:
URI
):
TPromise
<
modes
.
SymbolInformation
[]
>
{
throw
ni
();
}
$provideCodeLenses
(
handle
:
number
,
resource
:
URI
):
TPromise
<
modes
.
ICodeLensSymbol
[]
>
{
throw
ni
();
}
...
...
@@ -492,7 +496,7 @@ export abstract class ExtHostLanguageFeaturesShape {
$resolveCompletionItem
(
handle
:
number
,
resource
:
URI
,
position
:
IPosition
,
suggestion
:
modes
.
ISuggestion
):
TPromise
<
modes
.
ISuggestion
>
{
throw
ni
();
}
$provideSignatureHelp
(
handle
:
number
,
resource
:
URI
,
position
:
IPosition
):
TPromise
<
modes
.
SignatureHelp
>
{
throw
ni
();
}
$provideDocumentLinks
(
handle
:
number
,
resource
:
URI
):
TPromise
<
modes
.
ILink
[]
>
{
throw
ni
();
}
$provideDocumentColors
(
handle
:
number
,
resource
:
URI
):
TPromise
<
IColorInfo
[]
>
{
throw
ni
();
}
$provideDocumentColors
(
handle
:
number
,
resource
:
URI
):
TPromise
<
I
Raw
ColorInfo
[]
>
{
throw
ni
();
}
$resolveDocumentLink
(
handle
:
number
,
link
:
modes
.
ILink
):
TPromise
<
modes
.
ILink
>
{
throw
ni
();
}
}
...
...
src/vs/workbench/api/node/extHostLanguageFeatures.ts
浏览文件 @
be836877
...
...
@@ -19,7 +19,7 @@ import { ExtHostCommands, CommandsConverter } from 'vs/workbench/api/node/extHos
import
{
ExtHostDiagnostics
}
from
'
vs/workbench/api/node/extHostDiagnostics
'
;
import
{
IWorkspaceSymbolProvider
}
from
'
vs/workbench/parts/search/common/search
'
;
import
{
asWinJsPromise
}
from
'
vs/base/common/async
'
;
import
{
MainContext
,
MainThreadLanguageFeaturesShape
,
ExtHostLanguageFeaturesShape
,
ObjectIdentifier
,
I
ColorInfo
}
from
'
./extHost.protocol
'
;
import
{
MainContext
,
MainThreadLanguageFeaturesShape
,
ExtHostLanguageFeaturesShape
,
ObjectIdentifier
,
I
RawColorInfo
,
IRawColorFormat
,
IColorFormatMap
}
from
'
./extHost.protocol
'
;
import
{
regExpLeadsToEndlessLoop
}
from
'
vs/base/common/strings
'
;
import
{
IPosition
}
from
'
vs/editor/common/core/position
'
;
import
{
IRange
}
from
'
vs/editor/common/core/range
'
;
...
...
@@ -668,20 +668,51 @@ class LinkProviderAdapter {
class
ColorProviderAdapter
{
private
_proxy
:
MainThreadLanguageFeaturesShape
;
private
_documents
:
ExtHostDocuments
;
private
_provider
:
vscode
.
DocumentColorProvider
;
private
_formatStorageMap
:
Map
<
vscode
.
IColorFormat
,
number
>
;
private
_formatStorageIndex
;
constructor
(
documents
:
ExtHostDocuments
,
provider
:
vscode
.
DocumentColorProvider
)
{
constructor
(
proxy
:
MainThreadLanguageFeaturesShape
,
documents
:
ExtHostDocuments
,
provider
:
vscode
.
DocumentColorProvider
)
{
this
.
_proxy
=
proxy
;
this
.
_documents
=
documents
;
this
.
_provider
=
provider
;
this
.
_formatStorageMap
=
new
Map
<
vscode
.
IColorFormat
,
number
>
();
this
.
_formatStorageIndex
=
0
;
}
provideColors
(
resource
:
URI
):
TPromise
<
IColorInfo
[]
>
{
provideColors
(
resource
:
URI
):
TPromise
<
I
Raw
ColorInfo
[]
>
{
const
doc
=
this
.
_documents
.
getDocumentData
(
resource
).
document
;
return
asWinJsPromise
(
token
=>
this
.
_provider
.
provideDocumentColors
(
doc
,
token
)).
then
(
colors
=>
{
if
(
Array
.
isArray
(
colors
))
{
return
colors
.
map
(
TypeConverters
.
DocumentColor
.
from
);
const
colorFormats
:
IColorFormatMap
=
[];
const
colorInfos
:
IRawColorInfo
[]
=
[];
colors
.
forEach
(
ci
=>
{
let
cachedId
=
this
.
_formatStorageMap
.
get
(
ci
.
format
);
if
(
cachedId
===
undefined
)
{
cachedId
=
this
.
_formatStorageIndex
;
this
.
_formatStorageMap
.
set
(
ci
.
format
,
cachedId
);
this
.
_formatStorageIndex
+=
1
;
if
(
typeof
ci
.
format
===
'
string
'
)
{
// Append to format list for registration
colorFormats
.
push
([
cachedId
,
ci
.
format
]);
}
else
{
colorFormats
.
push
([
cachedId
,
[
ci
.
format
.
opaque
,
ci
.
format
.
transparent
]]);
}
}
colorInfos
.
push
({
color
:
[
ci
.
color
.
red
,
ci
.
color
.
green
,
ci
.
color
.
blue
,
ci
.
color
.
alpha
],
format
:
cachedId
,
availableFormats
:
[],
range
:
TypeConverters
.
fromRange
(
ci
.
range
)
});
});
this
.
_proxy
.
$registerColorFormats
(
colorFormats
);
return
colorInfos
;
}
return
undefined
;
});
...
...
@@ -978,12 +1009,12 @@ export class ExtHostLanguageFeatures extends ExtHostLanguageFeaturesShape {
registerColorProvider
(
selector
:
vscode
.
DocumentSelector
,
provider
:
vscode
.
DocumentColorProvider
):
vscode
.
Disposable
{
const
handle
=
this
.
_nextHandle
();
this
.
_adapter
.
set
(
handle
,
new
ColorProviderAdapter
(
this
.
_documents
,
provider
));
this
.
_adapter
.
set
(
handle
,
new
ColorProviderAdapter
(
this
.
_
proxy
,
this
.
_
documents
,
provider
));
this
.
_proxy
.
$registerDocumentColorProvider
(
handle
,
selector
);
return
this
.
_createDisposable
(
handle
);
}
$provideDocumentColors
(
handle
:
number
,
resource
:
URI
):
TPromise
<
IColorInfo
[]
>
{
$provideDocumentColors
(
handle
:
number
,
resource
:
URI
):
TPromise
<
I
Raw
ColorInfo
[]
>
{
return
this
.
_withAdapter
(
handle
,
ColorProviderAdapter
,
adapter
=>
adapter
.
provideColors
(
resource
));
}
...
...
src/vs/workbench/api/node/extHostTypeConverters.ts
浏览文件 @
be836877
...
...
@@ -16,7 +16,7 @@ import { SaveReason } from 'vs/workbench/services/textfile/common/textfiles';
import
{
IPosition
}
from
'
vs/editor/common/core/position
'
;
import
{
IRange
}
from
'
vs/editor/common/core/range
'
;
import
{
ISelection
}
from
'
vs/editor/common/core/selection
'
;
import
{
I
ColorInfo
}
from
'
vs/workbench/api/node/extHost.protocol
'
;
import
{
I
RawColorFormat
}
from
"
vs/workbench/api/node/extHost.protocol
"
;
export
interface
PositionLike
{
line
:
number
;
...
...
@@ -370,30 +370,16 @@ export namespace DocumentLink {
}
}
export
namespace
DocumentColor
{
export
function
from
(
color
Info
:
vscode
.
ColorInfo
):
IColorInfo
{
export
namespace
DocumentColor
Format
{
export
function
from
(
color
Format
:
vscode
.
IColorFormat
):
IRawColorFormat
{
let
format
:
string
|
[
string
,
string
];
if
(
typeof
color
Info
.
f
ormat
===
'
string
'
)
{
format
=
color
Info
.
f
ormat
;
if
(
typeof
color
F
ormat
===
'
string
'
)
{
format
=
color
F
ormat
;
}
else
{
format
=
[
color
Info
.
format
.
opaque
,
colorInfo
.
f
ormat
.
transparent
];
format
=
[
color
Format
.
opaque
,
colorF
ormat
.
transparent
];
}
let
availableFormats
:
(
string
|
[
string
,
string
])[]
=
[];
colorInfo
.
availableFormats
.
forEach
(
format
=>
{
if
(
typeof
format
===
'
string
'
)
{
availableFormats
.
push
(
format
);
}
else
{
availableFormats
.
push
([
format
.
opaque
,
format
.
transparent
]);
}
});
return
{
color
:
[
colorInfo
.
color
.
red
,
colorInfo
.
color
.
green
,
colorInfo
.
color
.
blue
,
colorInfo
.
color
.
alpha
],
format
:
format
,
availableFormats
:
availableFormats
,
range
:
fromRange
(
colorInfo
.
range
)
};
return
format
;
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录