Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
7e516deb
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,体验更适合开发者的 AI 搜索 >>
提交
7e516deb
编写于
2月 17, 2017
作者:
A
Alex Dima
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Extract TokenizationRegistry to its own file
上级
f8f17091
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
68 addition
and
41 deletion
+68
-41
src/vs/editor/common/modes.ts
src/vs/editor/common/modes.ts
+9
-41
src/vs/editor/common/modes/tokenizationRegistry.ts
src/vs/editor/common/modes/tokenizationRegistry.ts
+59
-0
未找到文件。
src/vs/editor/common/modes.ts
浏览文件 @
7e516deb
...
...
@@ -13,7 +13,8 @@ import LanguageFeatureRegistry from 'vs/editor/common/modes/languageFeatureRegis
import
{
CancellationToken
}
from
'
vs/base/common/cancellation
'
;
import
{
Position
}
from
'
vs/editor/common/core/position
'
;
import
{
Range
}
from
'
vs/editor/common/core/range
'
;
import
Event
,
{
Emitter
}
from
'
vs/base/common/event
'
;
import
Event
from
'
vs/base/common/event
'
;
import
{
TokenizationRegistryImpl
}
from
'
vs/editor/common/modes/tokenizationRegistry
'
;
/**
* Open ended enum at runtime
...
...
@@ -807,54 +808,21 @@ export interface ITokenizationSupportChangedEvent {
/**
* @internal
*/
export
class
TokenizationRegistryImpl
{
private
_map
:
{
[
language
:
string
]:
ITokenizationSupport
};
private
_onDidChange
:
Emitter
<
ITokenizationSupportChangedEvent
>
=
new
Emitter
<
ITokenizationSupportChangedEvent
>
();
public
onDidChange
:
Event
<
ITokenizationSupportChangedEvent
>
=
this
.
_onDidChange
.
event
;
private
_colorMap
:
string
[];
constructor
()
{
this
.
_map
=
Object
.
create
(
null
);
this
.
_colorMap
=
null
;
}
export
interface
ITokenizationRegistry
{
onDidChange
:
Event
<
ITokenizationSupportChangedEvent
>
;
/**
* Fire a change event for a language.
* This is useful for languages that embed other languages.
*/
public
fire
(
languages
:
string
[]):
void
{
this
.
_onDidChange
.
fire
({
languages
:
languages
});
}
fire
(
languages
:
string
[]):
void
;
public
register
(
language
:
string
,
support
:
ITokenizationSupport
):
IDisposable
{
this
.
_map
[
language
]
=
support
;
this
.
fire
([
language
]);
return
{
dispose
:
()
=>
{
if
(
this
.
_map
[
language
]
!==
support
)
{
return
;
}
delete
this
.
_map
[
language
];
this
.
fire
([
language
]);
}
};
}
register
(
language
:
string
,
support
:
ITokenizationSupport
):
IDisposable
;
public
get
(
language
:
string
):
ITokenizationSupport
{
return
(
this
.
_map
[
language
]
||
null
);
}
get
(
language
:
string
):
ITokenizationSupport
;
public
setColorMap
(
colorMap
:
string
[]):
void
{
this
.
_colorMap
=
colorMap
;
this
.
fire
(
Object
.
keys
(
this
.
_map
));
}
setColorMap
(
colorMap
:
string
[]):
void
;
public
getColorMap
():
string
[]
{
return
this
.
_colorMap
;
}
getColorMap
():
string
[];
}
/**
...
...
src/vs/editor/common/modes/tokenizationRegistry.ts
0 → 100644
浏览文件 @
7e516deb
/*---------------------------------------------------------------------------------------------
* 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
{
IDisposable
}
from
'
vs/base/common/lifecycle
'
;
import
Event
,
{
Emitter
}
from
'
vs/base/common/event
'
;
import
{
ITokenizationRegistry
,
ITokenizationSupport
,
ITokenizationSupportChangedEvent
}
from
'
vs/editor/common/modes
'
;
export
class
TokenizationRegistryImpl
implements
ITokenizationRegistry
{
private
_map
:
{
[
language
:
string
]:
ITokenizationSupport
};
private
_onDidChange
:
Emitter
<
ITokenizationSupportChangedEvent
>
=
new
Emitter
<
ITokenizationSupportChangedEvent
>
();
public
onDidChange
:
Event
<
ITokenizationSupportChangedEvent
>
=
this
.
_onDidChange
.
event
;
private
_colorMap
:
string
[];
constructor
()
{
this
.
_map
=
Object
.
create
(
null
);
this
.
_colorMap
=
null
;
}
/**
* Fire a change event for a language.
* This is useful for languages that embed other languages.
*/
public
fire
(
languages
:
string
[]):
void
{
this
.
_onDidChange
.
fire
({
languages
:
languages
});
}
public
register
(
language
:
string
,
support
:
ITokenizationSupport
):
IDisposable
{
this
.
_map
[
language
]
=
support
;
this
.
fire
([
language
]);
return
{
dispose
:
()
=>
{
if
(
this
.
_map
[
language
]
!==
support
)
{
return
;
}
delete
this
.
_map
[
language
];
this
.
fire
([
language
]);
}
};
}
public
get
(
language
:
string
):
ITokenizationSupport
{
return
(
this
.
_map
[
language
]
||
null
);
}
public
setColorMap
(
colorMap
:
string
[]):
void
{
this
.
_colorMap
=
colorMap
;
this
.
fire
(
Object
.
keys
(
this
.
_map
));
}
public
getColorMap
():
string
[]
{
return
this
.
_colorMap
;
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录