Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
30073321
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,发现更多精彩内容 >>
提交
30073321
编写于
8月 14, 2017
作者:
J
Joao Moreno
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fixes #32379
上级
062a9183
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
57 addition
and
82 deletion
+57
-82
src/vs/workbench/api/electron-browser/mainThreadLanguageFeatures.ts
...kbench/api/electron-browser/mainThreadLanguageFeatures.ts
+12
-19
src/vs/workbench/api/node/extHost.protocol.ts
src/vs/workbench/api/node/extHost.protocol.ts
+4
-5
src/vs/workbench/api/node/extHostLanguageFeatures.ts
src/vs/workbench/api/node/extHostLanguageFeatures.ts
+41
-44
src/vs/workbench/api/node/extHostTypeConverters.ts
src/vs/workbench/api/node/extHostTypeConverters.ts
+0
-14
未找到文件。
src/vs/workbench/api/electron-browser/mainThreadLanguageFeatures.ts
浏览文件 @
30073321
...
...
@@ -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
,
IColorFormatMap
}
from
'
../node/extHost.protocol
'
;
import
{
ExtHostContext
,
MainThreadLanguageFeaturesShape
,
ExtHostLanguageFeaturesShape
,
I
Raw
ColorFormatMap
}
from
'
../node/extHost.protocol
'
;
import
{
LanguageConfigurationRegistry
}
from
'
vs/editor/common/modes/languageConfigurationRegistry
'
;
import
{
LanguageConfiguration
}
from
'
vs/editor/common/modes/languageConfiguration
'
;
import
{
IHeapService
}
from
'
./mainThreadHeapService
'
;
...
...
@@ -29,7 +29,7 @@ export class MainThreadLanguageFeatures extends MainThreadLanguageFeaturesShape
private
_heapService
:
IHeapService
;
private
_modeService
:
IModeService
;
private
_registrations
:
{
[
handle
:
number
]:
IDisposable
;
}
=
Object
.
create
(
null
);
private
_formatters
:
Map
<
number
,
modes
.
I
ColorFormatter
>
;
private
_formatters
:
Map
<
number
,
ColorFormatter
>
;
constructor
(
@
IThreadService
threadService
:
IThreadService
,
...
...
@@ -40,7 +40,7 @@ export class MainThreadLanguageFeatures extends MainThreadLanguageFeaturesShape
this
.
_proxy
=
threadService
.
get
(
ExtHostContext
.
ExtHostLanguageFeatures
);
this
.
_heapService
=
heapService
;
this
.
_modeService
=
modeService
;
this
.
_formatters
=
new
Map
<
number
,
modes
.
I
ColorFormatter
>
();
this
.
_formatters
=
new
Map
<
number
,
ColorFormatter
>
();
}
$unregister
(
handle
:
number
):
TPromise
<
any
>
{
...
...
@@ -278,8 +278,13 @@ export class MainThreadLanguageFeatures extends MainThreadLanguageFeaturesShape
return
wireCancellationToken
(
token
,
proxy
.
$provideDocumentColors
(
handle
,
model
.
uri
))
.
then
(
documentColors
=>
{
return
documentColors
.
map
(
documentColor
=>
{
const
formatters
=
documentColor
.
availableFormats
.
map
(
f
=>
this
.
_formatters
.
get
(
f
));
const
formatters
=
documentColor
.
availableFormats
.
map
(
f
=>
{
if
(
typeof
f
===
'
number
'
)
{
return
this
.
_formatters
.
get
(
f
);
}
else
{
return
new
CombinedColorFormatter
(
this
.
_formatters
.
get
(
f
[
0
]),
this
.
_formatters
.
get
(
f
[
1
]));
}
});
const
[
red
,
green
,
blue
,
alpha
]
=
documentColor
.
color
;
const
color
=
{
...
...
@@ -302,20 +307,8 @@ export class MainThreadLanguageFeatures extends MainThreadLanguageFeaturesShape
return
TPromise
.
as
(
null
);
}
$registerColorFormats
(
formats
:
IColorFormatMap
):
TPromise
<
any
>
{
formats
.
forEach
(
f
=>
{
const
raw
=
f
[
1
];
let
formatter
:
modes
.
IColorFormatter
;
if
(
typeof
raw
===
'
string
'
)
{
formatter
=
new
ColorFormatter
(
raw
);
}
else
{
formatter
=
new
CombinedColorFormatter
(
new
ColorFormatter
(
raw
[
0
]),
new
ColorFormatter
(
raw
[
1
]));
}
this
.
_formatters
.
set
(
f
[
0
],
formatter
);
});
$registerColorFormats
(
formats
:
IRawColorFormatMap
):
TPromise
<
any
>
{
formats
.
forEach
(
f
=>
this
.
_formatters
.
set
(
f
[
0
],
new
ColorFormatter
(
f
[
1
])));
return
TPromise
.
as
(
null
);
}
...
...
src/vs/workbench/api/node/extHost.protocol.ts
浏览文件 @
30073321
...
...
@@ -230,7 +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
();
}
$registerColorFormats
(
formats
:
I
Raw
ColorFormatMap
):
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
();
}
}
...
...
@@ -466,13 +466,12 @@ export abstract class ExtHostHeapServiceShape {
$onGarbageCollection
(
ids
:
number
[]):
void
{
throw
ni
();
}
}
export
interface
IRawColorInfo
{
color
:
[
number
,
number
,
number
,
number
|
undefined
];
availableFormats
:
number
[];
color
:
[
number
,
number
,
number
,
number
];
availableFormats
:
(
number
|
[
number
,
number
])
[];
range
:
IRange
;
}
export
type
IRawColorFormat
=
string
|
[
string
,
string
];
export
type
IColorFormatMap
=
[
number
,
IRawColorFormat
][];
export
type
IRawColorFormatMap
=
[
number
,
string
][];
export
abstract
class
ExtHostLanguageFeaturesShape
{
$provideDocumentSymbols
(
handle
:
number
,
resource
:
URI
):
TPromise
<
modes
.
SymbolInformation
[]
>
{
throw
ni
();
}
...
...
src/vs/workbench/api/node/extHostLanguageFeatures.ts
浏览文件 @
30073321
...
...
@@ -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
,
IRawColorInfo
,
IColorFormatMap
}
from
'
./extHost.protocol
'
;
import
{
MainContext
,
MainThreadLanguageFeaturesShape
,
ExtHostLanguageFeaturesShape
,
ObjectIdentifier
,
IRawColorInfo
,
I
Raw
ColorFormatMap
}
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,57 +668,53 @@ class LinkProviderAdapter {
class
ColorProviderAdapter
{
private
_proxy
:
MainThreadLanguageFeaturesShape
;
private
_documents
:
ExtHostDocuments
;
private
_provider
:
vscode
.
DocumentColorProvider
;
private
_formatStorageMap
:
Map
<
vscode
.
ColorFormat
,
number
>
;
private
_formatStorageIndex
;
private
static
_colorFormatHandlePool
:
number
=
0
;
constructor
(
proxy
:
MainThreadLanguageFeaturesShape
,
documents
:
ExtHostDocuments
,
provider
:
vscode
.
DocumentColorProvider
)
{
this
.
_proxy
=
proxy
;
this
.
_documents
=
documents
;
this
.
_provider
=
provider
;
this
.
_formatStorageMap
=
new
Map
<
vscode
.
ColorFormat
,
number
>
();
this
.
_formatStorageIndex
=
0
;
}
constructor
(
private
_proxy
:
MainThreadLanguageFeaturesShape
,
private
_documents
:
ExtHostDocuments
,
private
_colorFormatCache
:
Map
<
string
,
number
>
,
private
_provider
:
vscode
.
DocumentColorProvider
)
{
}
provideColors
(
resource
:
URI
):
TPromise
<
IRawColorInfo
[]
>
{
const
doc
=
this
.
_documents
.
getDocumentData
(
resource
).
document
;
const
colorFormats
:
IColorFormatMap
=
[];
const
getCachedId
=
(
format
:
vscode
.
ColorFormat
)
=>
{
let
cachedId
=
this
.
_formatStorageMap
.
get
(
format
);
if
(
cachedId
===
undefined
)
{
cachedId
=
this
.
_formatStorageIndex
;
this
.
_formatStorageMap
.
set
(
format
,
cachedId
);
this
.
_formatStorageIndex
+=
1
;
if
(
typeof
format
===
'
string
'
)
{
// Append to format list for registration
colorFormats
.
push
([
cachedId
,
format
]);
}
else
{
colorFormats
.
push
([
cachedId
,
[
format
.
opaque
,
format
.
transparent
]]);
}
return
asWinJsPromise
(
token
=>
this
.
_provider
.
provideDocumentColors
(
doc
,
token
)).
then
(
colors
=>
{
if
(
!
Array
.
isArray
(
colors
))
{
return
[];
}
return
cachedId
;
};
const
newRawColorFormats
:
IRawColorFormatMap
=
[];
const
getFormatId
=
(
format
:
string
)
=>
{
let
id
=
this
.
_colorFormatCache
.
get
(
format
);
return
asWinJsPromise
(
token
=>
this
.
_provider
.
provideDocumentColors
(
doc
,
token
)).
then
(
colors
=>
{
if
(
Array
.
isArray
(
colors
))
{
const
colorInfos
:
IRawColorInfo
[]
=
[];
colors
.
forEach
(
ci
=>
{
const
availableFormats
=
ci
.
availableFormats
.
map
(
f
=>
getCachedId
(
f
));
colorInfos
.
push
({
color
:
[
ci
.
color
.
red
,
ci
.
color
.
green
,
ci
.
color
.
blue
,
ci
.
color
.
alpha
],
availableFormats
:
availableFormats
,
range
:
TypeConverters
.
fromRange
(
ci
.
range
)
});
if
(
typeof
id
!==
'
number
'
)
{
id
=
ColorProviderAdapter
.
_colorFormatHandlePool
++
;
this
.
_colorFormatCache
.
set
(
format
,
id
);
newRawColorFormats
.
push
([
id
,
format
]);
}
return
id
;
};
const
colorInfos
:
IRawColorInfo
[]
=
colors
.
map
(
ci
=>
{
const
availableFormats
=
ci
.
availableFormats
.
map
(
format
=>
{
if
(
typeof
format
===
'
string
'
)
{
return
getFormatId
(
format
);
}
else
{
return
[
getFormatId
(
format
.
opaque
),
getFormatId
(
format
.
transparent
)]
as
[
number
,
number
];
}
});
this
.
_proxy
.
$registerColorFormats
(
colorFormats
);
return
colorInfos
;
}
return
undefined
;
return
{
color
:
[
ci
.
color
.
red
,
ci
.
color
.
green
,
ci
.
color
.
blue
,
ci
.
color
.
alpha
]
as
[
number
,
number
,
number
,
number
],
availableFormats
:
availableFormats
,
range
:
TypeConverters
.
fromRange
(
ci
.
range
)
};
});
this
.
_proxy
.
$registerColorFormats
(
newRawColorFormats
);
return
colorInfos
;
});
}
}
...
...
@@ -738,6 +734,7 @@ export class ExtHostLanguageFeatures extends ExtHostLanguageFeaturesShape {
private
_heapService
:
ExtHostHeapService
;
private
_diagnostics
:
ExtHostDiagnostics
;
private
_adapter
=
new
Map
<
number
,
Adapter
>
();
private
_colorFormatCache
=
new
Map
<
string
,
number
>
();
constructor
(
threadService
:
IThreadService
,
...
...
@@ -1013,7 +1010,7 @@ 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
.
_proxy
,
this
.
_documents
,
provider
));
this
.
_adapter
.
set
(
handle
,
new
ColorProviderAdapter
(
this
.
_proxy
,
this
.
_documents
,
this
.
_colorFormatCache
,
provider
));
this
.
_proxy
.
$registerDocumentColorProvider
(
handle
,
selector
);
return
this
.
_createDisposable
(
handle
);
}
...
...
src/vs/workbench/api/node/extHostTypeConverters.ts
浏览文件 @
30073321
...
...
@@ -16,7 +16,6 @@ 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
{
IRawColorFormat
}
from
"
vs/workbench/api/node/extHost.protocol
"
;
export
interface
PositionLike
{
line
:
number
;
...
...
@@ -370,19 +369,6 @@ export namespace DocumentLink {
}
}
export
namespace
DocumentColorFormat
{
export
function
from
(
colorFormat
:
vscode
.
ColorFormat
):
IRawColorFormat
{
let
format
:
string
|
[
string
,
string
];
if
(
typeof
colorFormat
===
'
string
'
)
{
format
=
colorFormat
;
}
else
{
format
=
[
colorFormat
.
opaque
,
colorFormat
.
transparent
];
}
return
format
;
}
}
export
namespace
TextDocumentSaveReason
{
export
function
to
(
reason
:
SaveReason
):
vscode
.
TextDocumentSaveReason
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录